@lerianstudio/sindarian-ui 1.4.0-beta.8 → 2.0.0-beta.10

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 (196) hide show
  1. package/dist/components/breadcrumb/index.d.ts.map +1 -1
  2. package/dist/components/breadcrumb/index.js +25 -1
  3. package/dist/components/card/account-card/index.d.ts.map +1 -1
  4. package/dist/components/card/account-card/index.js +5 -5
  5. package/dist/components/card/basic-card/index.d.ts.map +1 -1
  6. package/dist/components/card/basic-card/index.js +2 -2
  7. package/dist/components/card/entity-card/index.js +4 -4
  8. package/dist/components/dialog/confirmation-dialog/index.d.ts +36 -5
  9. package/dist/components/dialog/confirmation-dialog/index.d.ts.map +1 -1
  10. package/dist/components/dialog/confirmation-dialog/index.js +5 -2
  11. package/dist/components/entity-box/index.d.ts +18 -2
  12. package/dist/components/entity-box/index.d.ts.map +1 -1
  13. package/dist/components/entity-box/index.js +33 -5
  14. package/dist/components/entity-data-table/index.d.ts.map +1 -1
  15. package/dist/components/entity-data-table/index.js +1 -1
  16. package/dist/components/form/file-upload-field/index.d.ts +11 -2
  17. package/dist/components/form/file-upload-field/index.d.ts.map +1 -1
  18. package/dist/components/form/file-upload-field/index.js +8 -3
  19. package/dist/components/form/input-field/index.d.ts +41 -2
  20. package/dist/components/form/input-field/index.d.ts.map +1 -1
  21. package/dist/components/form/input-field/index.js +73 -15
  22. package/dist/components/form/password-field/index.d.ts +5 -1
  23. package/dist/components/form/password-field/index.d.ts.map +1 -1
  24. package/dist/components/form/password-field/index.js +2 -2
  25. package/dist/components/form/select-field/index.d.ts +9 -1
  26. package/dist/components/form/select-field/index.d.ts.map +1 -1
  27. package/dist/components/form/select-field/index.js +2 -2
  28. package/dist/components/page-header/index.d.ts.map +1 -1
  29. package/dist/components/page-header/index.js +2 -2
  30. package/dist/components/table/id-table-cell.d.ts +5 -1
  31. package/dist/components/table/id-table-cell.d.ts.map +1 -1
  32. package/dist/components/table/id-table-cell.js +48 -6
  33. package/dist/components/ui/autocomplete/index.d.ts +58 -6
  34. package/dist/components/ui/autocomplete/index.d.ts.map +1 -1
  35. package/dist/components/ui/autocomplete/index.js +96 -16
  36. package/dist/components/ui/badge/index.d.ts +11 -7
  37. package/dist/components/ui/badge/index.d.ts.map +1 -1
  38. package/dist/components/ui/badge/index.js +31 -9
  39. package/dist/components/ui/button/styles.css +31 -1
  40. package/dist/components/ui/calendar/index.d.ts.map +1 -1
  41. package/dist/components/ui/calendar/index.js +7 -1
  42. package/dist/components/ui/card/index.d.ts.map +1 -1
  43. package/dist/components/ui/card/index.js +1 -1
  44. package/dist/components/ui/copy-field/index.d.ts.map +1 -1
  45. package/dist/components/ui/copy-field/index.js +1 -1
  46. package/dist/components/ui/dropdown-menu/index.d.ts.map +1 -1
  47. package/dist/components/ui/dropdown-menu/index.js +4 -1
  48. package/dist/components/ui/field/index.d.ts.map +1 -1
  49. package/dist/components/ui/field/index.js +5 -2
  50. package/dist/components/ui/file-upload/index.d.ts +235 -9
  51. package/dist/components/ui/file-upload/index.d.ts.map +1 -1
  52. package/dist/components/ui/file-upload/index.js +354 -17
  53. package/dist/components/ui/form.d.ts +4 -0
  54. package/dist/components/ui/form.d.ts.map +1 -1
  55. package/dist/components/ui/form.js +53 -8
  56. package/dist/components/ui/input/styles.css +30 -2
  57. package/dist/components/ui/multiple-select/index.js +2 -2
  58. package/dist/components/ui/progress/index.d.ts +15 -1
  59. package/dist/components/ui/progress/index.d.ts.map +1 -1
  60. package/dist/components/ui/progress/index.js +25 -2
  61. package/dist/components/ui/sheet/index.d.ts.map +1 -1
  62. package/dist/components/ui/sheet/index.js +2 -2
  63. package/dist/components/ui/sidebar/index.d.ts +1 -0
  64. package/dist/components/ui/sidebar/index.d.ts.map +1 -1
  65. package/dist/components/ui/sidebar/index.js +1 -0
  66. package/dist/components/ui/sidebar/sidebar-expand-button.d.ts +1 -1
  67. package/dist/components/ui/sidebar/sidebar-expand-button.d.ts.map +1 -1
  68. package/dist/components/ui/sidebar/sidebar-expand-button.js +32 -2
  69. package/dist/components/ui/sidebar/sidebar-item.d.ts +1 -1
  70. package/dist/components/ui/sidebar/sidebar-item.d.ts.map +1 -1
  71. package/dist/components/ui/sidebar/sidebar-item.js +28 -4
  72. package/dist/components/ui/sidebar/sidebar-provider.d.ts +37 -0
  73. package/dist/components/ui/sidebar/sidebar-provider.d.ts.map +1 -1
  74. package/dist/components/ui/sidebar/sidebar-provider.js +125 -4
  75. package/dist/components/ui/sidebar/sidebar-root.d.ts +38 -1
  76. package/dist/components/ui/sidebar/sidebar-root.d.ts.map +1 -1
  77. package/dist/components/ui/sidebar/sidebar-root.js +100 -5
  78. package/dist/components/ui/sidebar/sidebar-trigger.d.ts +18 -0
  79. package/dist/components/ui/sidebar/sidebar-trigger.d.ts.map +1 -0
  80. package/dist/components/ui/sidebar/sidebar-trigger.js +30 -0
  81. package/dist/components/ui/toggle-group/index.d.ts +1 -1
  82. package/dist/components/ui/toggle-group/index.d.ts.map +1 -1
  83. package/dist/components/ui/toggle-group/index.js +73 -4
  84. package/dist/components/ui/tooltip/index.d.ts +15 -0
  85. package/dist/components/ui/tooltip/index.d.ts.map +1 -1
  86. package/dist/components/ui/tooltip/index.js +16 -1
  87. package/dist/domain/blotter/index.d.ts +4 -2
  88. package/dist/domain/blotter/index.d.ts.map +1 -1
  89. package/dist/domain/delinquency-aging/aging-buckets.d.ts.map +1 -1
  90. package/dist/domain/delinquency-aging/aging-buckets.js +8 -3
  91. package/dist/domain/delinquency-aging/index.d.ts.map +1 -1
  92. package/dist/domain/delinquency-aging/index.js +8 -3
  93. package/dist/domain/key-id/index.js +1 -1
  94. package/dist/domain/status-rail/index.js +1 -1
  95. package/dist/domain/threshold-gauge/index.d.ts.map +1 -1
  96. package/dist/domain/threshold-gauge/index.js +9 -5
  97. package/dist/enterprise/stat-card/index.d.ts.map +1 -1
  98. package/dist/enterprise/stat-card/index.js +12 -4
  99. package/dist/esm/components/breadcrumb/index.d.ts.map +1 -1
  100. package/dist/esm/components/breadcrumb/index.js +25 -1
  101. package/dist/esm/components/card/account-card/index.d.ts.map +1 -1
  102. package/dist/esm/components/card/account-card/index.js +5 -5
  103. package/dist/esm/components/card/basic-card/index.d.ts.map +1 -1
  104. package/dist/esm/components/card/basic-card/index.js +2 -2
  105. package/dist/esm/components/card/entity-card/index.js +4 -4
  106. package/dist/esm/components/dialog/confirmation-dialog/index.d.ts +36 -5
  107. package/dist/esm/components/dialog/confirmation-dialog/index.d.ts.map +1 -1
  108. package/dist/esm/components/dialog/confirmation-dialog/index.js +5 -2
  109. package/dist/esm/components/entity-box/index.d.ts +18 -2
  110. package/dist/esm/components/entity-box/index.d.ts.map +1 -1
  111. package/dist/esm/components/entity-box/index.js +30 -5
  112. package/dist/esm/components/entity-data-table/index.d.ts.map +1 -1
  113. package/dist/esm/components/entity-data-table/index.js +1 -1
  114. package/dist/esm/components/form/file-upload-field/index.d.ts +11 -2
  115. package/dist/esm/components/form/file-upload-field/index.d.ts.map +1 -1
  116. package/dist/esm/components/form/file-upload-field/index.js +8 -3
  117. package/dist/esm/components/form/input-field/index.d.ts +41 -2
  118. package/dist/esm/components/form/input-field/index.d.ts.map +1 -1
  119. package/dist/esm/components/form/input-field/index.js +73 -15
  120. package/dist/esm/components/form/password-field/index.d.ts +5 -1
  121. package/dist/esm/components/form/password-field/index.d.ts.map +1 -1
  122. package/dist/esm/components/form/password-field/index.js +2 -2
  123. package/dist/esm/components/form/select-field/index.d.ts +9 -1
  124. package/dist/esm/components/form/select-field/index.d.ts.map +1 -1
  125. package/dist/esm/components/form/select-field/index.js +2 -2
  126. package/dist/esm/components/page-header/index.d.ts.map +1 -1
  127. package/dist/esm/components/page-header/index.js +2 -2
  128. package/dist/esm/components/table/id-table-cell.d.ts +5 -1
  129. package/dist/esm/components/table/id-table-cell.d.ts.map +1 -1
  130. package/dist/esm/components/table/id-table-cell.js +48 -3
  131. package/dist/esm/components/ui/autocomplete/index.d.ts +58 -6
  132. package/dist/esm/components/ui/autocomplete/index.d.ts.map +1 -1
  133. package/dist/esm/components/ui/autocomplete/index.js +96 -16
  134. package/dist/esm/components/ui/badge/index.d.ts +11 -7
  135. package/dist/esm/components/ui/badge/index.d.ts.map +1 -1
  136. package/dist/esm/components/ui/badge/index.js +31 -9
  137. package/dist/esm/components/ui/calendar/index.d.ts.map +1 -1
  138. package/dist/esm/components/ui/calendar/index.js +8 -2
  139. package/dist/esm/components/ui/card/index.d.ts.map +1 -1
  140. package/dist/esm/components/ui/card/index.js +1 -1
  141. package/dist/esm/components/ui/copy-field/index.d.ts.map +1 -1
  142. package/dist/esm/components/ui/copy-field/index.js +1 -1
  143. package/dist/esm/components/ui/dropdown-menu/index.d.ts.map +1 -1
  144. package/dist/esm/components/ui/dropdown-menu/index.js +4 -1
  145. package/dist/esm/components/ui/field/index.d.ts.map +1 -1
  146. package/dist/esm/components/ui/field/index.js +5 -2
  147. package/dist/esm/components/ui/file-upload/index.d.ts +235 -9
  148. package/dist/esm/components/ui/file-upload/index.d.ts.map +1 -1
  149. package/dist/esm/components/ui/file-upload/index.js +353 -17
  150. package/dist/esm/components/ui/form.d.ts +4 -0
  151. package/dist/esm/components/ui/form.d.ts.map +1 -1
  152. package/dist/esm/components/ui/form.js +53 -8
  153. package/dist/esm/components/ui/multiple-select/index.js +2 -2
  154. package/dist/esm/components/ui/progress/index.d.ts +15 -1
  155. package/dist/esm/components/ui/progress/index.d.ts.map +1 -1
  156. package/dist/esm/components/ui/progress/index.js +25 -2
  157. package/dist/esm/components/ui/sheet/index.d.ts.map +1 -1
  158. package/dist/esm/components/ui/sheet/index.js +2 -2
  159. package/dist/esm/components/ui/sidebar/index.d.ts +1 -0
  160. package/dist/esm/components/ui/sidebar/index.d.ts.map +1 -1
  161. package/dist/esm/components/ui/sidebar/index.js +1 -0
  162. package/dist/esm/components/ui/sidebar/sidebar-expand-button.d.ts +1 -1
  163. package/dist/esm/components/ui/sidebar/sidebar-expand-button.d.ts.map +1 -1
  164. package/dist/esm/components/ui/sidebar/sidebar-expand-button.js +32 -2
  165. package/dist/esm/components/ui/sidebar/sidebar-item.d.ts +1 -1
  166. package/dist/esm/components/ui/sidebar/sidebar-item.d.ts.map +1 -1
  167. package/dist/esm/components/ui/sidebar/sidebar-item.js +28 -4
  168. package/dist/esm/components/ui/sidebar/sidebar-provider.d.ts +37 -0
  169. package/dist/esm/components/ui/sidebar/sidebar-provider.d.ts.map +1 -1
  170. package/dist/esm/components/ui/sidebar/sidebar-provider.js +122 -1
  171. package/dist/esm/components/ui/sidebar/sidebar-root.d.ts +38 -1
  172. package/dist/esm/components/ui/sidebar/sidebar-root.d.ts.map +1 -1
  173. package/dist/esm/components/ui/sidebar/sidebar-root.js +102 -7
  174. package/dist/esm/components/ui/sidebar/sidebar-trigger.d.ts +18 -0
  175. package/dist/esm/components/ui/sidebar/sidebar-trigger.d.ts.map +1 -0
  176. package/dist/esm/components/ui/sidebar/sidebar-trigger.js +26 -0
  177. package/dist/esm/components/ui/toggle-group/index.d.ts +1 -1
  178. package/dist/esm/components/ui/toggle-group/index.d.ts.map +1 -1
  179. package/dist/esm/components/ui/toggle-group/index.js +73 -4
  180. package/dist/esm/components/ui/tooltip/index.d.ts +15 -0
  181. package/dist/esm/components/ui/tooltip/index.d.ts.map +1 -1
  182. package/dist/esm/components/ui/tooltip/index.js +16 -1
  183. package/dist/esm/domain/blotter/index.d.ts +4 -2
  184. package/dist/esm/domain/blotter/index.d.ts.map +1 -1
  185. package/dist/esm/domain/delinquency-aging/aging-buckets.d.ts.map +1 -1
  186. package/dist/esm/domain/delinquency-aging/aging-buckets.js +8 -3
  187. package/dist/esm/domain/delinquency-aging/index.d.ts.map +1 -1
  188. package/dist/esm/domain/delinquency-aging/index.js +8 -3
  189. package/dist/esm/domain/key-id/index.js +1 -1
  190. package/dist/esm/domain/status-rail/index.js +1 -1
  191. package/dist/esm/domain/threshold-gauge/index.d.ts.map +1 -1
  192. package/dist/esm/domain/threshold-gauge/index.js +9 -5
  193. package/dist/esm/enterprise/stat-card/index.d.ts.map +1 -1
  194. package/dist/esm/enterprise/stat-card/index.js +12 -4
  195. package/dist/globals.css +101 -32
  196. package/package.json +5 -3
@@ -2,7 +2,30 @@
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import * as ProgressPrimitive from '@radix-ui/react-progress';
4
4
  import { cn } from '../../../lib/utils.js';
5
- function Progress({ className, value, indicatorColor = 'bg-primary', ...props }) {
6
- return (_jsx(ProgressPrimitive.Root, { "data-slot": "progress", className: cn('bg-primary/20 relative h-4 w-full overflow-hidden rounded-full', className), ...props, children: _jsx(ProgressPrimitive.Indicator, { "data-slot": "progress-indicator", className: cn('h-full w-full flex-1 transition-all', indicatorColor), style: { transform: `translateX(-${100 - (value || 0)}%)` } }) }));
5
+ /**
6
+ * `value` and `max` are Radix's own props, so the bar reports `aria-valuenow` /
7
+ * `aria-valuemax` and flips `data-state` between `loading` and `complete`.
8
+ * Omitting `value`, or passing `null`, is Radix's indeterminate state and draws
9
+ * an empty track.
10
+ *
11
+ * Both numbers are BOUNDED BEFORE THE ROOT SEES THEM, so the drawn width and
12
+ * the announced value can never disagree. Radix accepts a value only inside
13
+ * `[0, max]`: hand it one outside and the root drops `aria-valuenow`, sticks
14
+ * `data-state` on `indeterminate` and logs an error, while the indicator here
15
+ * goes on drawing the clamped bar. Substituting 100 for a non-positive max is
16
+ * Radix's own fallback, and is also what keeps a `max` of 0 from dividing by
17
+ * zero.
18
+ */
19
+ function Progress({ className, value, max, indicatorColor = 'bg-primary', ...props }) {
20
+ const scale = Number.isFinite(max) && max > 0 ? max : 100;
21
+ // Bound against `scale`, not against the rejected `max`: with `max={0}` the
22
+ // scale is already 100, and clamping to 0 would report a finished bar empty.
23
+ // Non-finite values are indeterminate, matching Radix without producing an
24
+ // invalid CSS transform.
25
+ const bounded = Number.isFinite(value)
26
+ ? Math.min(scale, Math.max(0, value))
27
+ : null;
28
+ const percent = ((bounded ?? 0) / scale) * 100;
29
+ return (_jsx(ProgressPrimitive.Root, { "data-slot": "progress", value: bounded, max: scale, className: cn('bg-primary/20 relative h-4 w-full overflow-hidden rounded-full', className), ...props, children: _jsx(ProgressPrimitive.Indicator, { "data-slot": "progress-indicator", className: cn('h-full w-full flex-1 transition-all', indicatorColor), style: { transform: `translateX(-${100 - percent}%)` } }) }));
7
30
  }
8
31
  export { Progress };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/sheet/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,cAAc,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAIjE,iBAAS,KAAK,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,IAAI,CAAC,qBAE5E;AAED,iBAAS,YAAY,CAAC,EACpB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,OAAO,CAAC,qBAErD;AAED,iBAAS,UAAU,CAAC,EAClB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,KAAK,CAAC,qBAEnD;AAED,iBAAS,WAAW,CAAC,EACnB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,MAAM,CAAC,qBAEpD;AAED,iBAAS,YAAY,CAAC,EACpB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,OAAO,CAAC,qBAWrD;AAED,QAAA,MAAM,aAAa;;8EAiBlB,CAAA;AAED,KAAK,iBAAiB,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,OAAO,CAAC,GAC1E,YAAY,CAAC,OAAO,aAAa,CAAC,CAAA;AAEpC,iBAAS,YAAY,CAAC,EACpB,IAAc,EACd,SAAS,EACT,QAAQ,EACR,iBAAiB,EACjB,GAAG,KAAK,EACT,EAAE,iBAAiB,qBAsCnB;AAED,iBAAS,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,qBAWxE;AAED,iBAAS,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,qBAWxE;AAED,iBAAS,UAAU,CAAC,EAClB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,KAAK,CAAC,qBAWnD;AAED,iBAAS,gBAAgB,CAAC,EACxB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,WAAW,CAAC,qBAQzD;AAED,OAAO,EACL,KAAK,EACL,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,gBAAgB,EACjB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/sheet/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,cAAc,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAIjE,iBAAS,KAAK,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,IAAI,CAAC,qBAE5E;AAED,iBAAS,YAAY,CAAC,EACpB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,OAAO,CAAC,qBAErD;AAED,iBAAS,UAAU,CAAC,EAClB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,KAAK,CAAC,qBAEnD;AAED,iBAAS,WAAW,CAAC,EACnB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,MAAM,CAAC,qBAEpD;AAED,iBAAS,YAAY,CAAC,EACpB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,OAAO,CAAC,qBAWrD;AAED,QAAA,MAAM,aAAa;;8EAiBlB,CAAA;AAED,KAAK,iBAAiB,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,OAAO,CAAC,GAC1E,YAAY,CAAC,OAAO,aAAa,CAAC,CAAA;AAEpC,iBAAS,YAAY,CAAC,EACpB,IAAc,EACd,SAAS,EACT,QAAQ,EACR,iBAAiB,EACjB,GAAG,KAAK,EACT,EAAE,iBAAiB,qBA6CnB;AAED,iBAAS,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,qBAWxE;AAED,iBAAS,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,qBAWxE;AAED,iBAAS,UAAU,CAAC,EAClB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,KAAK,CAAC,qBAWnD;AAED,iBAAS,gBAAgB,CAAC,EACxB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,WAAW,CAAC,qBAQzD;AAED,OAAO,EACL,KAAK,EACL,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,gBAAgB,EACjB,CAAA"}
@@ -42,7 +42,7 @@ function SheetContent({ side = 'right', className, children, onInteractOutside,
42
42
  }
43
43
  onInteractOutside?.(event);
44
44
  }, [onInteractOutside]);
45
- return (_jsxs(SheetPortal, { children: [_jsx(SheetOverlay, {}), _jsxs(SheetPrimitive.Content, { "data-slot": "sheet-content", className: cn('flex max-h-screen flex-col overflow-x-auto px-8 pb-0', sheetVariants({ side }), className), onInteractOutside: handleInteractOutside, ...props, children: [children, _jsxs(SheetPrimitive.Close, { className: "data-[state=open]:bg-secondary absolute top-7 right-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-hidden disabled:pointer-events-none", children: [_jsx(X, { className: "h-6 w-6" }), _jsx("span", { className: "sr-only", children: "Close" })] })] })] }));
45
+ return (_jsxs(SheetPortal, { children: [_jsx(SheetOverlay, {}), _jsxs(SheetPrimitive.Content, { "data-slot": "sheet-content", className: cn('flex max-h-screen flex-col overflow-x-auto px-8 pb-0', sheetVariants({ side }), className), onInteractOutside: handleInteractOutside, ...props, children: [children, _jsxs(SheetPrimitive.Close, { className: "data-[state=open]:bg-secondary ring-offset-background focus-visible:ring-ring absolute top-7 right-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:pointer-events-none", children: [_jsx(X, { className: "h-6 w-6" }), _jsx("span", { className: "sr-only", children: "Close" })] })] })] }));
46
46
  }
47
47
  function SheetHeader({ className, ...props }) {
48
48
  return (_jsx("div", { "data-slot": "sheet-header", className: cn('mb-4 flex flex-col space-y-2 text-center sm:text-left', className), ...props }));
@@ -54,6 +54,6 @@ function SheetTitle({ className, ...props }) {
54
54
  return (_jsx(SheetPrimitive.Title, { "data-slot": "sheet-title", className: cn('text-muted-foreground mb-2 flex text-xl font-bold', className), ...props }));
55
55
  }
56
56
  function SheetDescription({ className, ...props }) {
57
- return (_jsx(SheetPrimitive.Description, { "data-slot": "sheet-description", className: cn('text-shadcn-500 text-sm font-medium', className), ...props }));
57
+ return (_jsx(SheetPrimitive.Description, { "data-slot": "sheet-description", className: cn('text-muted-foreground text-sm font-medium', className), ...props }));
58
58
  }
59
59
  export { Sheet, SheetPortal, SheetOverlay, SheetTrigger, SheetClose, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription };
@@ -4,6 +4,7 @@ export * from './sidebar-item-icon-button.js';
4
4
  export * from './sidebar-item-button.js';
5
5
  export * from './sidebar-item.js';
6
6
  export * from './sidebar-expand-button.js';
7
+ export * from './sidebar-trigger.js';
7
8
  export * from './sidebar-back-button.js';
8
9
  export * from './sidebar-provider.js';
9
10
  export * from './sidebar-item-collapsible.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/sidebar/index.tsx"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,uBAAuB,CAAA;AACrC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,yBAAyB,CAAA;AACvC,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/sidebar/index.tsx"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,uBAAuB,CAAA;AACrC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,kBAAkB,CAAA"}
@@ -4,6 +4,7 @@ export * from './sidebar-item-icon-button.js';
4
4
  export * from './sidebar-item-button.js';
5
5
  export * from './sidebar-item.js';
6
6
  export * from './sidebar-expand-button.js';
7
+ export * from './sidebar-trigger.js';
7
8
  export * from './sidebar-back-button.js';
8
9
  export * from './sidebar-provider.js';
9
10
  export * from './sidebar-item-collapsible.js';
@@ -7,6 +7,6 @@ type SidebarExpandButtonProps = {
7
7
  */
8
8
  tooltip?: string;
9
9
  };
10
- export declare const SidebarExpandButton: ({ tooltip }: SidebarExpandButtonProps) => React.JSX.Element;
10
+ export declare const SidebarExpandButton: ({ tooltip }: SidebarExpandButtonProps) => React.JSX.Element | null;
11
11
  export {};
12
12
  //# sourceMappingURL=sidebar-expand-button.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sidebar-expand-button.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/sidebar/sidebar-expand-button.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAYzB,KAAK,wBAAwB,GAAG;IAC9B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,aAAa,wBAAwB,sBA6CxE,CAAA"}
1
+ {"version":3,"file":"sidebar-expand-button.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/sidebar/sidebar-expand-button.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAYzB,KAAK,wBAAwB,GAAG;IAC9B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,aAAa,wBAAwB,6BAwExE,CAAA"}
@@ -7,6 +7,36 @@ import { SidebarFooter } from './sidebar-components.js';
7
7
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../../ui/tooltip/index.js';
8
8
  import { IconButton } from '../icon-button/index.js';
9
9
  export const SidebarExpandButton = ({ tooltip }) => {
10
- const { isCollapsed, toggleSidebar } = useSidebar();
11
- return (_jsxs(React.Fragment, { children: [!isCollapsed && (_jsx("div", { "data-slot": "sidebar-expand-button", className: "border-border bg-card flex w-full", children: _jsx("div", { className: "absolute right-[-20px] bottom-4", children: _jsx(IconButton, { variant: "secondary", rounded: true, onClick: toggleSidebar, "aria-label": tooltip || 'Collapse sidebar', "aria-expanded": true, children: _jsx(PanelLeftClose, { className: "text-shadcn-400" }) }) }) })), isCollapsed && (_jsx(SidebarFooter, { children: _jsx(TooltipProvider, { children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { className: "group/expand-button text-shadcn-400 hover:bg-accent rounded-sm bg-transparent p-2", onClick: toggleSidebar, "aria-label": tooltip || 'Expand sidebar', "aria-expanded": false, children: _jsx(PanelRightClose, { className: "group-hover/expand-button:text-white dark:text-white" }) }), _jsx(TooltipContent, { side: "right", children: tooltip || 'Expand' })] }) }) }))] }));
10
+ const { isCollapsed, isDrawer, toggleSidebar } = useSidebar();
11
+ /**
12
+ * Nothing to collapse in a drawer. The expanded branch below hangs its button
13
+ * at `right-[-20px]`, twenty pixels outside the rail — off the canvas of an
14
+ * overlay that has no page beside it — and collapsing to a 72px strip inside
15
+ * a 244px sheet is not a state worth reaching. The drawer's own close control
16
+ * and the backdrop are how it is dismissed.
17
+ *
18
+ * ⚠️ `isDrawer`, NOT `isMobile`. A consumer left on the default
19
+ * `mobile="inline"` still has a real rail below 768px, and its collapse
20
+ * control has to come with it.
21
+ */
22
+ if (isDrawer) {
23
+ return null;
24
+ }
25
+ return (_jsxs(React.Fragment, { children: [!isCollapsed && (_jsx("div", { "data-slot": "sidebar-expand-button", className: "border-border bg-card flex w-full", children: _jsx("div", { className: "absolute right-[-20px] bottom-4", children: _jsx(IconButton, { variant: "secondary", rounded: true, onClick: toggleSidebar, "aria-label": tooltip || 'Collapse sidebar', "aria-expanded": true, children: _jsx(PanelLeftClose, { className: "text-muted-foreground" }) }) }) })), isCollapsed && (_jsx(SidebarFooter, { children: _jsx(TooltipProvider, { children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger
26
+ // `hover:text-accent-foreground` on the TRIGGER, not only on
27
+ // the glyph below. The base ink here used to be base/400, which
28
+ // no rule paired with anything; now that it is the muted token,
29
+ // it is the ink anything inside this trigger inherits, and the
30
+ // muted token reads 1.07:1 on sunglow in dark. The glyph
31
+ // overrides it today, so this pairs the fill for whatever the
32
+ // trigger holds next.
33
+ , {
34
+ // `hover:text-accent-foreground` on the TRIGGER, not only on
35
+ // the glyph below. The base ink here used to be base/400, which
36
+ // no rule paired with anything; now that it is the muted token,
37
+ // it is the ink anything inside this trigger inherits, and the
38
+ // muted token reads 1.07:1 on sunglow in dark. The glyph
39
+ // overrides it today, so this pairs the fill for whatever the
40
+ // trigger holds next.
41
+ className: "group/expand-button text-muted-foreground hover:bg-accent hover:text-accent-foreground rounded-sm bg-transparent p-2", onClick: toggleSidebar, "aria-label": tooltip || 'Expand sidebar', "aria-expanded": false, children: _jsx(PanelRightClose, { className: "group-hover/expand-button:text-accent-foreground dark:text-white" }) }), _jsx(TooltipContent, { side: "right", children: tooltip || 'Expand' })] }) }) }))] }));
12
42
  };
@@ -9,5 +9,5 @@ export type SidebarItemProps = React.ComponentProps<typeof SidebarItemButton> &
9
9
  disabled?: boolean;
10
10
  children?: React.ReactNode;
11
11
  };
12
- export declare const SidebarItem: ({ active, href, children: _children, ...props }: SidebarItemProps) => React.JSX.Element;
12
+ export declare const SidebarItem: ({ active, href, children: _children, onClick, ...props }: SidebarItemProps) => React.JSX.Element;
13
13
  //# sourceMappingURL=sidebar-item.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sidebar-item.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/sidebar/sidebar-item.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAIlE,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,iBAAiB,CAAC,GAC3E,KAAK,CAAC,cAAc,CAAC,OAAO,qBAAqB,CAAC,GAAG;IACnD,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,KAAK,CAAC,SAAS,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,CAAA;AAEH,eAAO,MAAM,WAAW,GAAI,iDAKzB,gBAAgB,sBA0BlB,CAAA"}
1
+ {"version":3,"file":"sidebar-item.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/sidebar/sidebar-item.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAIlE,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,iBAAiB,CAAC,GAC3E,KAAK,CAAC,cAAc,CAAC,OAAO,qBAAqB,CAAC,GAAG;IACnD,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,KAAK,CAAC,SAAS,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,CAAA;AAEH,eAAO,MAAM,WAAW,GAAI,0DAMzB,gBAAgB,sBAsDlB,CAAA"}
@@ -4,13 +4,37 @@ import { SidebarItemButton } from './sidebar-item-button.js';
4
4
  import { SidebarItemIconButton } from './sidebar-item-icon-button.js';
5
5
  import { useSidebar } from './sidebar-provider.js';
6
6
  import { useSidebarRouter } from './sidebar-router.js';
7
- export const SidebarItem = ({ active, href, children: _children, ...props }) => {
7
+ export const SidebarItem = ({ active, href, children: _children, onClick, ...props }) => {
8
8
  const { usePathname } = useSidebarRouter();
9
9
  const pathname = usePathname();
10
- const { isCollapsed } = useSidebar();
10
+ const { isCollapsed, isDrawer, setOpenMobile } = useSidebar();
11
11
  const isActive = (href) => pathname === href;
12
+ /**
13
+ * ⛔ ACTIVATING A DESTINATION CLOSES THE DRAWER. It is the whole point of the
14
+ * drawer and it was the one interaction that left it open: Escape, the
15
+ * backdrop and the X all dismissed it, a navigation link did not.
16
+ *
17
+ * The overlay is modal, so `document.body` carries `pointer-events: none`
18
+ * while it is up, and a consumer's `SidebarItem` is a client-side `Link`
19
+ * under a provider that survives the route change — so the reader landed on
20
+ * the new page rendered INERT behind a drawer they had to dismiss a second
21
+ * time, on a phone.
22
+ *
23
+ * Here rather than in `SidebarRoot`, because this is the component that knows
24
+ * an activation happened; `SidebarBackButton` and every
25
+ * `SidebarItemCollapsibleContent` leaf render through it, so they are covered
26
+ * by construction. Guarded on `isDrawer` so an inline rail — where nothing is
27
+ * covering the page — behaves exactly as before, and the consumer's own
28
+ * handler still runs either way.
29
+ */
30
+ const handleClick = (event) => {
31
+ onClick?.(event);
32
+ if (isDrawer) {
33
+ setOpenMobile(false);
34
+ }
35
+ };
12
36
  if (isCollapsed) {
13
- return (_jsx(SidebarItemIconButton, { "data-slot": "sidebar-item", href: href, active: isActive(href) || active, ...props }));
37
+ return (_jsx(SidebarItemIconButton, { "data-slot": "sidebar-item", href: href, active: isActive(href) || active, onClick: handleClick, ...props }));
14
38
  }
15
- return (_jsx(SidebarItemButton, { "data-slot": "sidebar-item", href: href, active: isActive(href) || active, ...props }));
39
+ return (_jsx(SidebarItemButton, { "data-slot": "sidebar-item", href: href, active: isActive(href) || active, onClick: handleClick, ...props }));
16
40
  };
@@ -1,12 +1,49 @@
1
1
  import React from 'react';
2
+ /**
3
+ * The viewport below which the rail stops being a layout and becomes a drawer.
4
+ *
5
+ * 767px rather than 768px: this is the upper bound of `max-width`, so it is the
6
+ * complement of Tailwind's `md` breakpoint (`min-width: 768px`) and `md:hidden`
7
+ * on `SidebarTrigger` flips at exactly the same pixel the query does.
8
+ */
9
+ export declare const SIDEBAR_MOBILE_QUERY = "(max-width: 767px)";
2
10
  export type SidebarContextProps = {
3
11
  isCollapsed: boolean;
12
+ /**
13
+ * True only inside a drawer that `SidebarRoot` is actually rendering, which
14
+ * needs `mobile="drawer"` as well as a narrow viewport. `SidebarRoot`
15
+ * re-provides the context for that subtree; nothing else sets it.
16
+ */
17
+ isDrawer: boolean;
18
+ /**
19
+ * True while the viewport is narrow enough for a drawer. Reported in BOTH
20
+ * modes, so a consumer still on `mobile="inline"` can build its own
21
+ * responsive behaviour from it.
22
+ */
23
+ isMobile: boolean;
24
+ /** Whether the mobile drawer is showing. Meaningless while `isMobile` is false. */
25
+ openMobile: boolean;
26
+ setOpenMobile: (open: boolean) => void;
27
+ /**
28
+ * Puts focus back on whatever opened the drawer. `SidebarRoot` calls it when
29
+ * the drawer closes; nothing else should need it.
30
+ */
31
+ restoreDrawerFocus: () => void;
32
+ /** The drawer's DOM id, so `SidebarTrigger` can point `aria-controls` at it. */
33
+ sidebarId: string;
4
34
  items: Record<string, boolean>;
5
35
  setItems: React.Dispatch<React.SetStateAction<Record<string, boolean>>>;
6
36
  getItemCollapsed: (key: string) => boolean;
7
37
  setItemCollapsed: (key: string, value: boolean) => void;
8
38
  toggleSidebar: () => void;
9
39
  };
40
+ /**
41
+ * Exported so `SidebarRoot` can re-provide it for the drawer's subtree. That
42
+ * subtree is the only place `isCollapsed` and `isDrawer` differ from the
43
+ * provider's own values, and scoping the override to it is what keeps a
44
+ * consumer on `mobile="inline"` seeing exactly today's rail.
45
+ */
46
+ export declare const SidebarContext: React.Context<SidebarContextProps | undefined>;
10
47
  export declare const useSidebar: () => SidebarContextProps;
11
48
  export declare const SidebarProvider: ({ children }: React.PropsWithChildren) => React.JSX.Element;
12
49
  //# sourceMappingURL=sidebar-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sidebar-provider.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/sidebar/sidebar-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,OAAO,CAAA;IACpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;IACvE,gBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAA;IAC1C,gBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACvD,aAAa,EAAE,MAAM,IAAI,CAAA;CAC1B,CAAA;AAMD,eAAO,MAAM,UAAU,2BAMtB,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,cAAc,KAAK,CAAC,iBAAiB,sBAqDpE,CAAA"}
1
+ {"version":3,"file":"sidebar-provider.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/sidebar/sidebar-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,uBAAuB,CAAA;AAUxD,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,OAAO,CAAA;IACpB;;;;OAIG;IACH,QAAQ,EAAE,OAAO,CAAA;IACjB;;;;OAIG;IACH,QAAQ,EAAE,OAAO,CAAA;IACjB,mFAAmF;IACnF,UAAU,EAAE,OAAO,CAAA;IACnB,aAAa,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACtC;;;OAGG;IACH,kBAAkB,EAAE,MAAM,IAAI,CAAA;IAC9B,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;IACvE,gBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAA;IAC1C,gBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACvD,aAAa,EAAE,MAAM,IAAI,CAAA;CAC1B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,gDAEf,CAAA;AAEZ,eAAO,MAAM,UAAU,2BAMtB,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,cAAc,KAAK,CAAC,iBAAiB,sBAkKpE,CAAA"}
@@ -2,7 +2,28 @@
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import React from 'react';
4
4
  import { getStorage, getStorageObject } from '../../../lib/storage/index.js';
5
- const SidebarContext = React.createContext(undefined);
5
+ /**
6
+ * The viewport below which the rail stops being a layout and becomes a drawer.
7
+ *
8
+ * 767px rather than 768px: this is the upper bound of `max-width`, so it is the
9
+ * complement of Tailwind's `md` breakpoint (`min-width: 768px`) and `md:hidden`
10
+ * on `SidebarTrigger` flips at exactly the same pixel the query does.
11
+ */
12
+ export const SIDEBAR_MOBILE_QUERY = '(max-width: 767px)';
13
+ /**
14
+ * Where focus goes when the rail has to receive it. The rail's own content is
15
+ * links and buttons, so this is deliberately the short list rather than the
16
+ * full tabbable grammar: a `[tabindex]` sweep would have to exclude `-1`, and
17
+ * nothing in a sidebar carries one.
18
+ */
19
+ const FOCUSABLE = 'a[href], button:not([disabled])';
20
+ /**
21
+ * Exported so `SidebarRoot` can re-provide it for the drawer's subtree. That
22
+ * subtree is the only place `isCollapsed` and `isDrawer` differ from the
23
+ * provider's own values, and scoping the override to it is what keeps a
24
+ * consumer on `mobile="inline"` seeing exactly today's rail.
25
+ */
26
+ export const SidebarContext = React.createContext(undefined);
6
27
  export const useSidebar = () => {
7
28
  const context = React.useContext(SidebarContext);
8
29
  if (!context) {
@@ -14,6 +35,61 @@ export const SidebarProvider = ({ children }) => {
14
35
  const [hydrated, setHydrated] = React.useState(false);
15
36
  const [collapsed, setCollapsed] = React.useState(false);
16
37
  const [items, _setItems] = React.useState({});
38
+ const [isMobile, setIsMobile] = React.useState(false);
39
+ const [openMobile, _setOpenMobile] = React.useState(false);
40
+ const sidebarId = React.useId();
41
+ /**
42
+ * ⛔ RADIX CANNOT RESTORE THIS FOCUS BY ITSELF. `DialogContent` preventDefaults
43
+ * the focus scope's own restore and focuses `triggerRef.current` instead —
44
+ * the ref a `SheetTrigger` would have filled. The drawer is opened from this
45
+ * state rather than from a trigger inside the dialog, so that ref is null and
46
+ * closing dropped focus onto `<body>`: a keyboard reader who opened the
47
+ * navigation and pressed Escape was returned to the top of the document.
48
+ *
49
+ * Captured here rather than in `SidebarTrigger` so that a consumer opening
50
+ * the drawer from its own control gets the same behaviour.
51
+ */
52
+ const opener = React.useRef(null);
53
+ const setOpenMobile = React.useCallback((open) => {
54
+ if (open && typeof document !== 'undefined') {
55
+ opener.current = document.activeElement;
56
+ }
57
+ _setOpenMobile(open);
58
+ }, []);
59
+ /**
60
+ * ⛔ THE VIEWPORT AT THE MOMENT FOCUS MOVES, NOT AT THE MOMENT IT OPENED.
61
+ *
62
+ * Radix calls `restoreDrawerFocus` from the focus scope's UNMOUNT handler,
63
+ * which is the last thing in the commit to touch focus — later than any
64
+ * effect in this provider, so the decision has to be made inside the handler
65
+ * rather than beside it. By then `isMobile` has already flipped.
66
+ */
67
+ const isMobileRef = React.useRef(false);
68
+ isMobileRef.current = isMobile;
69
+ const restoreDrawerFocus = React.useCallback(() => {
70
+ // `isConnected`: the control that opened the drawer may itself have been
71
+ // unmounted by whatever the reader did inside it.
72
+ //
73
+ // ⛔ AND NOT AT ALL WHEN THE VIEWPORT IS THE ONE THAT DISMISSED IT. A
74
+ // tablet rotated from portrait to landscape with the navigation open
75
+ // crosses 768px, so the drawer is replaced by the rail and the opener is
76
+ // `SidebarTrigger` — which the same breakpoint just hid with `md:hidden`.
77
+ // `.focus()` on a `display: none` element is a silent no-op, and Radix's
78
+ // own restore is already `preventDefault()`ed, so focus fell to `<body>`
79
+ // and the reader lost their place (SC 2.4.3). Measured in Chromium at
80
+ // 390 → 1280: `{"rails":1,"triggerDisplay":"none","focus":"BODY:"}`.
81
+ if (isMobileRef.current && opener.current?.isConnected) {
82
+ opener.current.focus();
83
+ return;
84
+ }
85
+ // The rail is what the drawer became, so that is where the reader goes.
86
+ // Below the breakpoint there is nothing here to find — a closed drawer
87
+ // leaves no navigation in the DOM — and focus stays where Radix left it.
88
+ document
89
+ .getElementById(sidebarId)
90
+ ?.querySelector(FOCUSABLE)
91
+ ?.focus();
92
+ }, [sidebarId]);
17
93
  const toggleSidebar = () => setCollapsed((collapsed) => !collapsed);
18
94
  const getItemCollapsed = (key) => {
19
95
  return items[key] || false;
@@ -27,6 +103,37 @@ export const SidebarProvider = ({ children }) => {
27
103
  _setItems(getStorageObject('sidebar-items', {}));
28
104
  setHydrated(true);
29
105
  }, []);
106
+ /**
107
+ * ⚠️ FALSE UNTIL THE CLIENT SAYS OTHERWISE. There is no viewport on the
108
+ * server, so the first paint is always the rail and the drawer appears on
109
+ * hydration; starting from a guess would make the markup differ between the
110
+ * two renders. The `matchMedia` guard is the one `theme-provider.tsx` next
111
+ * door already carries: jsdom and some embedded runtimes ship without it, and
112
+ * a missing media API is a desktop, not a crash.
113
+ */
114
+ React.useEffect(() => {
115
+ if (typeof window.matchMedia !== 'function') {
116
+ return;
117
+ }
118
+ const media = window.matchMedia(SIDEBAR_MOBILE_QUERY);
119
+ const sync = () => setIsMobile(media.matches);
120
+ sync();
121
+ media.addEventListener('change', sync);
122
+ return () => media.removeEventListener('change', sync);
123
+ }, []);
124
+ /**
125
+ * A drawer left open while the viewport grows back would keep an overlay and
126
+ * a focus trap over a layout that is already showing its rail, with nothing
127
+ * on screen to dismiss them.
128
+ *
129
+ * Where focus goes afterwards is `restoreDrawerFocus`'s decision, not this
130
+ * effect's: Radix's unmount handler runs later than anything here.
131
+ */
132
+ React.useEffect(() => {
133
+ if (!isMobile) {
134
+ _setOpenMobile(false);
135
+ }
136
+ }, [isMobile]);
30
137
  // Only persist to localStorage after hydration to avoid overwriting stored values
31
138
  React.useEffect(() => {
32
139
  if (!hydrated) {
@@ -41,7 +148,21 @@ export const SidebarProvider = ({ children }) => {
41
148
  localStorage.setItem('sidebar-items', JSON.stringify(items));
42
149
  }, [items, hydrated]);
43
150
  return (_jsx(SidebarContext.Provider, { value: {
151
+ /**
152
+ * ⚠️ A NARROW VIEWPORT DOES NOT TOUCH THIS. It used to be forced false
153
+ * whenever `isMobile`, which silently changed the rail for every
154
+ * consumer — including the ones that never asked for a drawer.
155
+ * `SidebarRoot` overrides it for the drawer's own subtree instead, so
156
+ * the stored preference reaches an inline rail unchanged at every
157
+ * viewport.
158
+ */
44
159
  isCollapsed: collapsed,
160
+ isDrawer: false,
161
+ isMobile,
162
+ openMobile,
163
+ setOpenMobile,
164
+ restoreDrawerFocus,
165
+ sidebarId,
45
166
  items,
46
167
  setItems: _setItems,
47
168
  getItemCollapsed,
@@ -1,3 +1,40 @@
1
1
  import React from 'react';
2
- export declare const SidebarRoot: ({ className, ...props }: React.ComponentProps<"nav">) => React.JSX.Element;
2
+ export type SidebarRootProps = React.ComponentProps<'nav'> & {
3
+ /**
4
+ * What this rail becomes below 768px.
5
+ *
6
+ * - `'inline'` (default): nothing changes. The rail renders at every
7
+ * viewport exactly as it always has, and the reader's collapsed preference
8
+ * is untouched.
9
+ * - `'drawer'`: the inline rail is not rendered below the breakpoint and the
10
+ * navigation moves into an overlay drawer that `SidebarTrigger` opens.
11
+ *
12
+ * ⛔ THE DEFAULT IS NOT A TASTE, IT IS A CONSUMER-SAFETY RULE. `SidebarTrigger`
13
+ * is the only way back into the drawer and it must render inside
14
+ * `SidebarProvider`. A consumer that has not placed one yet — which is every
15
+ * consumer at the moment this shipped — would get a phone with NO navigation
16
+ * rather than a rail that takes 63% of it, and that is strictly worse. Opt in
17
+ * once there is somewhere to put the trigger.
18
+ */
19
+ mobile?: 'inline' | 'drawer';
20
+ /**
21
+ * The drawer's accessible name. A dialog needs one, and it is read out when
22
+ * the drawer opens. Unused while `mobile` is `'inline'`.
23
+ */
24
+ mobileTitle?: string;
25
+ };
26
+ /**
27
+ * ⛔ BELOW 768px A RAIL IS NOT A LAYOUT — once a consumer opts in.
28
+ *
29
+ * The widths above are a fixed share of a flex row, so at 390px the expanded
30
+ * rail took 63% of the screen and left the page 146px, and the only affordance
31
+ * — `SidebarExpandButton` — shrinks it to 72px, which is still 18% and still
32
+ * permanently on screen. There was nothing that removed it.
33
+ *
34
+ * With `mobile="drawer"` the rail is replaced below the breakpoint by an
35
+ * overlay drawer. Escape, the backdrop click, the focus trap and returning
36
+ * focus to whatever opened it are Radix Dialog's, through the kit's own
37
+ * `Sheet`; none of that is re-implemented here.
38
+ */
39
+ export declare const SidebarRoot: ({ className, id, mobile, mobileTitle, ...props }: SidebarRootProps) => React.JSX.Element;
3
40
  //# sourceMappingURL=sidebar-root.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sidebar-root.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/sidebar/sidebar-root.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAoBzB,eAAO,MAAM,WAAW,GAAI,yBAGzB,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,sBAW7B,CAAA"}
1
+ {"version":3,"file":"sidebar-root.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/sidebar/sidebar-root.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAqEzB,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG;IAC3D;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC5B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,GAAI,kDAMzB,gBAAgB,sBA0GlB,CAAA"}
@@ -1,20 +1,115 @@
1
1
  'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { cva } from 'class-variance-authority';
4
- import { useSidebar } from './sidebar-provider.js';
4
+ import { SidebarContext, useSidebar } from './sidebar-provider.js';
5
5
  import { cn } from '../../../lib/utils.js';
6
+ import { Sheet, SheetContent, SheetTitle } from '../sheet/index.js';
7
+ /**
8
+ * ⛔ THE WIDTHS ARE TOKENS, NOT LITERALS.
9
+ *
10
+ * They were `w-[72px]` and `w-[244px]`, which a consumer could only override by
11
+ * winning a specificity argument with `cn`. `--sidebar-width` and
12
+ * `--sidebar-width-collapsed` are declared in `globals.css`, so the default
13
+ * still ships with the stylesheet, and a consumer re-points either one with
14
+ * `className="[--sidebar-width:280px]"` ON THE RAIL, which moves the rail and
15
+ * the mobile drawer together (see `liftWidthOverrides` below), or with a rule
16
+ * on `:root`/`html`.
17
+ *
18
+ * ⚠️ A DECLARATION ON A REACT-TREE ANCESTOR REACHES THE RAIL AND NOT THE
19
+ * DRAWER. Custom properties inherit down the DOM tree, and the drawer is
20
+ * portalled to `document.body`, so a layout wrapper is not an ancestor of it.
21
+ * `:root` is, which is why it is named above and a wrapper is not.
22
+ */
6
23
  const sidebarVariants = cva('group/sidebar shadow-sidebar relative flex flex-col transition-[width] duration-300 ease-in-out', {
7
24
  variants: {
8
25
  collapsed: {
9
- true: 'w-[72px]',
10
- false: 'w-[244px]'
26
+ true: 'w-[var(--sidebar-width-collapsed)]',
27
+ false: 'w-[var(--sidebar-width)]'
11
28
  }
12
29
  },
13
30
  defaultVariants: {
14
31
  collapsed: false
15
32
  }
16
33
  });
17
- export const SidebarRoot = ({ className, ...props }) => {
18
- const { isCollapsed } = useSidebar();
19
- return (_jsx("nav", { "data-slot": "sidebar-root", className: cn(sidebarVariants({ collapsed: isCollapsed }), className), "data-collapsed": isCollapsed, ...props }));
34
+ /**
35
+ * Tailwind arbitrary-property classes that re-point the sidebar geometry, e.g.
36
+ * `[--sidebar-width:320px]` or `[--sidebar-width-collapsed:88px]`.
37
+ *
38
+ * ⚠️ ANCHORED TO A CLASS BOUNDARY, WHICH IS THE WHOLE POINT OF THE LOOKBEHIND.
39
+ * Unanchored it also matched the tail of `md:[--sidebar-width:320px]` and
40
+ * lifted it with the prefix stripped — an override a consumer scoped to
41
+ * ≥768px, applied unconditionally to the drawer that only exists below it.
42
+ */
43
+ const WIDTH_OVERRIDE = /(?<=^|\s)\[--sidebar-width(?:-collapsed)?:[^\]]+\]/g;
44
+ /**
45
+ * ⛔ THE ONE PART OF THE CONSUMER'S className THAT HAS TO CROSS THE PORTAL.
46
+ *
47
+ * `SheetContent` mounts through `SheetPortal` into `document.body`, and custom
48
+ * properties inherit down the DOM tree rather than the React tree. So the
49
+ * documented override — a class on the rail — set `--sidebar-width` on an
50
+ * element the drawer is not a descendant of, and the whole className that DOES
51
+ * travel lands on the inner `<nav>`, which is BELOW the element that reads the
52
+ * variable. Measured in Chromium: rail 320px, drawer 244px. Following the
53
+ * instruction handed to product-console produced a 280px rail on desktop and a
54
+ * 244px drawer on a phone, silently.
55
+ *
56
+ * ⚠️ ONLY THE GEOMETRY TOKENS. The rest of a rail className is rail-shaped —
57
+ * `h-full`, and the `data-[collapsed=false]:min-w-70` all eight console
58
+ * sidebars pass — and putting that on the sheet would reinstate the
59
+ * 280px-inside-a-244px-sheet overflow from the other side.
60
+ */
61
+ function liftWidthOverrides(className) {
62
+ return className?.match(WIDTH_OVERRIDE)?.join(' ');
63
+ }
64
+ /**
65
+ * ⛔ BELOW 768px A RAIL IS NOT A LAYOUT — once a consumer opts in.
66
+ *
67
+ * The widths above are a fixed share of a flex row, so at 390px the expanded
68
+ * rail took 63% of the screen and left the page 146px, and the only affordance
69
+ * — `SidebarExpandButton` — shrinks it to 72px, which is still 18% and still
70
+ * permanently on screen. There was nothing that removed it.
71
+ *
72
+ * With `mobile="drawer"` the rail is replaced below the breakpoint by an
73
+ * overlay drawer. Escape, the backdrop click, the focus trap and returning
74
+ * focus to whatever opened it are Radix Dialog's, through the kit's own
75
+ * `Sheet`; none of that is re-implemented here.
76
+ */
77
+ export const SidebarRoot = ({ className, id, mobile = 'inline', mobileTitle = 'Navigation', ...props }) => {
78
+ const context = useSidebar();
79
+ const { isCollapsed, isMobile, openMobile, setOpenMobile, restoreDrawerFocus, sidebarId } = context;
80
+ if (!isMobile || mobile === 'inline') {
81
+ return (_jsx("nav", { "data-slot": "sidebar-root", className: cn(sidebarVariants({ collapsed: isCollapsed }), className), "data-collapsed": isCollapsed, ...props, id: mobile === 'drawer' ? sidebarId : id }));
82
+ }
83
+ return (_jsx(SidebarContext.Provider, { value: { ...context, isCollapsed: false, isDrawer: true }, children: _jsx(Sheet, { open: openMobile, onOpenChange: setOpenMobile, children: _jsxs(SheetContent, { side: "left",
84
+ // The Sheet's own paddings are built for a form panel; a rail brings
85
+ // its own. `max-w-full` so a consumer widening `--sidebar-width` past
86
+ // the viewport still cannot push the drawer off screen. The lifted
87
+ // override goes LAST so it re-points the variable this element reads.
88
+ className: cn('w-[var(--sidebar-width)] max-w-full gap-0 p-0', liftWidthOverrides(className)), "aria-describedby": undefined,
89
+ // ⛔ RADIX'S OWN RESTORE GOES NOWHERE HERE. `DialogContent`
90
+ // preventDefaults the focus scope's restore and focuses the ref a
91
+ // `SheetTrigger` would have filled; this drawer is opened from provider
92
+ // state, so that ref is null and closing dropped focus onto `<body>`.
93
+ // Running first means `composeEventHandlers` skips Radix's half.
94
+ onCloseAutoFocus: (event) => {
95
+ event.preventDefault();
96
+ restoreDrawerFocus();
97
+ }, children: [_jsx(SheetTitle, { className: "sr-only", children: mobileTitle }), _jsx("nav", { "data-slot": "sidebar-root", "data-mobile": "true",
98
+ /* ⛔ NO `data-collapsed` HERE. The consumer className is forwarded
99
+ verbatim, and all eight console sidebars pass
100
+ `data-[collapsed=false]:min-w-70`; stamping the attribute armed
101
+ it, giving the navigation a 280px min-width inside a 244px sheet.
102
+ `min-width` resolves after `max-width`, so the sheet could not
103
+ claw it back and the contents were 36px wider than the drawer.
104
+ `data-mobile` already names this surface and a drawer is never
105
+ collapsed, so the attribute had nothing left to say. */
106
+ className: cn(sidebarVariants({ collapsed: false }), 'h-full w-full shadow-none', className), ...props,
107
+ /* ⛔ AFTER THE SPREAD, AND NOT THE CALLER'S. This is the target of
108
+ `SidebarTrigger`'s `aria-controls` and the handle the provider
109
+ uses to put focus back into the navigation when the viewport
110
+ grows. Spread first, a caller that set `id` replaced it and left
111
+ a dangling `aria-controls` — which axe reports as a CRITICAL
112
+ `aria-valid-attr-value` — and a focus restore that lands on
113
+ `<body>`. Both silent. */
114
+ id: sidebarId })] }) }) }));
20
115
  };
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { IconButton } from '../icon-button/index.js';
3
+ export type SidebarTriggerProps = React.ComponentProps<typeof IconButton>;
4
+ /**
5
+ * The control that opens the mobile drawer.
6
+ *
7
+ * `md:hidden` by default because above 768px the rail is already on screen and
8
+ * a second way to reach it is a second thing to explain; a consumer that wants
9
+ * it everywhere passes its own display class.
10
+ *
11
+ * ⚠️ `aria-controls` IS SET ONLY WHILE THE DRAWER EXISTS. Radix unmounts the
12
+ * dialog content when closed, and a reference to an element that is not in the
13
+ * DOM is what axe-core reports as a CRITICAL `aria-valid-attr-value` — the same
14
+ * defect the Autocomplete panel was repaired for (console-sdk#150). A toggle
15
+ * with `aria-expanded="false"` and no `aria-controls` is complete on its own.
16
+ */
17
+ export declare const SidebarTrigger: ({ className, onClick, "aria-label": ariaLabel, ...props }: SidebarTriggerProps) => React.JSX.Element;
18
+ //# sourceMappingURL=sidebar-trigger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sidebar-trigger.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/sidebar/sidebar-trigger.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAG3C,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,UAAU,CAAC,CAAA;AAEzE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GAAI,2DAK5B,mBAAmB,sBAqBrB,CAAA"}