@aglyn/shared-ui-jsx 1.0.0-beta.143

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 (261) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +7 -0
  3. package/package.json +63 -0
  4. package/src/index.d.ts +48 -0
  5. package/src/index.js +179 -0
  6. package/src/index.js.map +1 -0
  7. package/src/lib/components/aglyn-text.d.ts +86 -0
  8. package/src/lib/components/aglyn-text.js +44 -0
  9. package/src/lib/components/aglyn-text.js.map +1 -0
  10. package/src/lib/components/app-link.d.ts +74 -0
  11. package/src/lib/components/app-link.js +139 -0
  12. package/src/lib/components/app-link.js.map +1 -0
  13. package/src/lib/components/aspect-ratio.d.ts +59 -0
  14. package/src/lib/components/aspect-ratio.js +153 -0
  15. package/src/lib/components/aspect-ratio.js.map +1 -0
  16. package/src/lib/components/background-image.component.d.ts +30 -0
  17. package/src/lib/components/background-image.component.js +42 -0
  18. package/src/lib/components/background-image.component.js.map +1 -0
  19. package/src/lib/components/card-columns.d.ts +86 -0
  20. package/src/lib/components/card-columns.js +148 -0
  21. package/src/lib/components/card-columns.js.map +1 -0
  22. package/src/lib/components/card-display.d.ts +36 -0
  23. package/src/lib/components/card-display.js +158 -0
  24. package/src/lib/components/card-display.js.map +1 -0
  25. package/src/lib/components/card-list-item.d.ts +35 -0
  26. package/src/lib/components/card-list-item.js +137 -0
  27. package/src/lib/components/card-list-item.js.map +1 -0
  28. package/src/lib/components/children-function-prop.d.ts +25 -0
  29. package/src/lib/components/children-function-prop.js +29 -0
  30. package/src/lib/components/children-function-prop.js.map +1 -0
  31. package/src/lib/components/confirmation-provider.component.d.ts +19 -0
  32. package/src/lib/components/confirmation-provider.component.js +83 -0
  33. package/src/lib/components/confirmation-provider.component.js.map +1 -0
  34. package/src/lib/components/container.d.ts +25 -0
  35. package/src/lib/components/container.js +62 -0
  36. package/src/lib/components/container.js.map +1 -0
  37. package/src/lib/components/data-table.component.d.ts +54 -0
  38. package/src/lib/components/data-table.component.js +211 -0
  39. package/src/lib/components/data-table.component.js.map +1 -0
  40. package/src/lib/components/dialog-confirm.d.ts +36 -0
  41. package/src/lib/components/dialog-confirm.js +74 -0
  42. package/src/lib/components/dialog-confirm.js.map +1 -0
  43. package/src/lib/components/ellipsis-pulse.component.d.ts +22 -0
  44. package/src/lib/components/ellipsis-pulse.component.js +51 -0
  45. package/src/lib/components/ellipsis-pulse.component.js.map +1 -0
  46. package/src/lib/components/emotion-cache-provider.d.ts +31 -0
  47. package/src/lib/components/emotion-cache-provider.js +40 -0
  48. package/src/lib/components/emotion-cache-provider.js.map +1 -0
  49. package/src/lib/components/empty-state.component.d.ts +63 -0
  50. package/src/lib/components/empty-state.component.js +214 -0
  51. package/src/lib/components/empty-state.component.js.map +1 -0
  52. package/src/lib/components/error-boundary.component.d.ts +28 -0
  53. package/src/lib/components/error-boundary.component.js +86 -0
  54. package/src/lib/components/error-boundary.component.js.map +1 -0
  55. package/src/lib/components/grid-buttons.d.ts +26 -0
  56. package/src/lib/components/grid-buttons.js +45 -0
  57. package/src/lib/components/grid-buttons.js.map +1 -0
  58. package/src/lib/components/grid-items.d.ts +103 -0
  59. package/src/lib/components/grid-items.js +336 -0
  60. package/src/lib/components/grid-items.js.map +1 -0
  61. package/src/lib/components/grid-list.d.ts +37 -0
  62. package/src/lib/components/grid-list.js +156 -0
  63. package/src/lib/components/grid-list.js.map +1 -0
  64. package/src/lib/components/help-tip.component.d.ts +30 -0
  65. package/src/lib/components/help-tip.component.js +139 -0
  66. package/src/lib/components/help-tip.component.js.map +1 -0
  67. package/src/lib/components/link-navigation-reporter.d.ts +24 -0
  68. package/src/lib/components/link-navigation-reporter.js +64 -0
  69. package/src/lib/components/link-navigation-reporter.js.map +1 -0
  70. package/src/lib/components/list-pagination.component.d.ts +57 -0
  71. package/src/lib/components/list-pagination.component.js +90 -0
  72. package/src/lib/components/list-pagination.component.js.map +1 -0
  73. package/src/lib/components/list-table.component.d.ts +155 -0
  74. package/src/lib/components/list-table.component.js +369 -0
  75. package/src/lib/components/list-table.component.js.map +1 -0
  76. package/src/lib/components/loading-layout-app.component.d.ts +35 -0
  77. package/src/lib/components/loading-layout-app.component.js +42 -0
  78. package/src/lib/components/loading-layout-app.component.js.map +1 -0
  79. package/src/lib/components/loading-modal-overlay.d.ts +30 -0
  80. package/src/lib/components/loading-modal-overlay.js +156 -0
  81. package/src/lib/components/loading-modal-overlay.js.map +1 -0
  82. package/src/lib/components/loading-modal.d.ts +19 -0
  83. package/src/lib/components/loading-modal.js +113 -0
  84. package/src/lib/components/loading-modal.js.map +1 -0
  85. package/src/lib/components/loading-text.component.d.ts +21 -0
  86. package/src/lib/components/loading-text.component.js +40 -0
  87. package/src/lib/components/loading-text.component.js.map +1 -0
  88. package/src/lib/components/mdi-icon/index.d.ts +2 -0
  89. package/src/lib/components/mdi-icon/index.js +4 -0
  90. package/src/lib/components/mdi-icon/index.js.map +1 -0
  91. package/src/lib/components/mdi-icon/md-icon-stack.d.ts +31 -0
  92. package/src/lib/components/mdi-icon/md-icon-stack.js +101 -0
  93. package/src/lib/components/mdi-icon/md-icon-stack.js.map +1 -0
  94. package/src/lib/components/mdi-icon/md-icon.d.ts +32 -0
  95. package/src/lib/components/mdi-icon/md-icon.js +147 -0
  96. package/src/lib/components/mdi-icon/md-icon.js.map +1 -0
  97. package/src/lib/components/mdi-icon/mdi-icon-from-id.d.ts +23 -0
  98. package/src/lib/components/mdi-icon/mdi-icon-from-id.js +35 -0
  99. package/src/lib/components/mdi-icon/mdi-icon-from-id.js.map +1 -0
  100. package/src/lib/components/mdi-icon/mdi-icon.d.ts +24 -0
  101. package/src/lib/components/mdi-icon/mdi-icon.js +46 -0
  102. package/src/lib/components/mdi-icon/mdi-icon.js.map +1 -0
  103. package/src/lib/components/measured-figures.component.d.ts +64 -0
  104. package/src/lib/components/measured-figures.component.js +161 -0
  105. package/src/lib/components/measured-figures.component.js.map +1 -0
  106. package/src/lib/components/menu.d.ts +45 -0
  107. package/src/lib/components/menu.js +229 -0
  108. package/src/lib/components/menu.js.map +1 -0
  109. package/src/lib/components/mui-shadow-dom.d.ts +38 -0
  110. package/src/lib/components/mui-shadow-dom.js +161 -0
  111. package/src/lib/components/mui-shadow-dom.js.map +1 -0
  112. package/src/lib/components/navigation-drawer.component.d.ts +31 -0
  113. package/src/lib/components/navigation-drawer.component.js +76 -0
  114. package/src/lib/components/navigation-drawer.component.js.map +1 -0
  115. package/src/lib/components/navigation-intent.d.ts +18 -0
  116. package/src/lib/components/navigation-intent.js +56 -0
  117. package/src/lib/components/navigation-intent.js.map +1 -0
  118. package/src/lib/components/navigation-view/index.d.ts +18 -0
  119. package/src/lib/components/navigation-view/index.js +19 -0
  120. package/src/lib/components/navigation-view/index.js.map +1 -0
  121. package/src/lib/components/navigation-view/navigation-view.d.ts +35 -0
  122. package/src/lib/components/navigation-view/navigation-view.js +175 -0
  123. package/src/lib/components/navigation-view/navigation-view.js.map +1 -0
  124. package/src/lib/components/next-link.d.ts +27 -0
  125. package/src/lib/components/next-link.js +88 -0
  126. package/src/lib/components/next-link.js.map +1 -0
  127. package/src/lib/components/popper-styled.component.d.ts +25 -0
  128. package/src/lib/components/popper-styled.component.js +129 -0
  129. package/src/lib/components/popper-styled.component.js.map +1 -0
  130. package/src/lib/components/quota-readout.component.d.ts +69 -0
  131. package/src/lib/components/quota-readout.component.js +52 -0
  132. package/src/lib/components/quota-readout.component.js.map +1 -0
  133. package/src/lib/components/resizeable-stack.d.ts +4 -0
  134. package/src/lib/components/resizeable-stack.js +23 -0
  135. package/src/lib/components/resizeable-stack.js.map +1 -0
  136. package/src/lib/components/row-actions-menu.component.d.ts +53 -0
  137. package/src/lib/components/row-actions-menu.component.js +132 -0
  138. package/src/lib/components/row-actions-menu.component.js.map +1 -0
  139. package/src/lib/components/ruler-guides.component.d.ts +35 -0
  140. package/src/lib/components/ruler-guides.component.js +166 -0
  141. package/src/lib/components/ruler-guides.component.js.map +1 -0
  142. package/src/lib/components/sandbox-frame.d.ts +42 -0
  143. package/src/lib/components/sandbox-frame.js +122 -0
  144. package/src/lib/components/sandbox-frame.js.map +1 -0
  145. package/src/lib/components/scroll-reaction.d.ts +59 -0
  146. package/src/lib/components/scroll-reaction.js +43 -0
  147. package/src/lib/components/scroll-reaction.js.map +1 -0
  148. package/src/lib/components/scroll-table.component.d.ts +124 -0
  149. package/src/lib/components/scroll-table.component.js +103 -0
  150. package/src/lib/components/scroll-table.component.js.map +1 -0
  151. package/src/lib/components/shadow-dom/index.d.ts +18 -0
  152. package/src/lib/components/shadow-dom/index.js +19 -0
  153. package/src/lib/components/shadow-dom/index.js.map +1 -0
  154. package/src/lib/components/shadow-dom/shadow-dom.d.ts +42 -0
  155. package/src/lib/components/shadow-dom/shadow-dom.js +123 -0
  156. package/src/lib/components/shadow-dom/shadow-dom.js.map +1 -0
  157. package/src/lib/components/splash-screen.d.ts +33 -0
  158. package/src/lib/components/splash-screen.js +105 -0
  159. package/src/lib/components/splash-screen.js.map +1 -0
  160. package/src/lib/components/sr-only.d.ts +20 -0
  161. package/src/lib/components/sr-only.js +25 -0
  162. package/src/lib/components/sr-only.js.map +1 -0
  163. package/src/lib/components/status-screen-plain.component.d.ts +27 -0
  164. package/src/lib/components/status-screen-plain.component.js +178 -0
  165. package/src/lib/components/status-screen-plain.component.js.map +1 -0
  166. package/src/lib/components/usage-meter.component.d.ts +30 -0
  167. package/src/lib/components/usage-meter.component.js +92 -0
  168. package/src/lib/components/usage-meter.component.js.map +1 -0
  169. package/src/lib/components/variable-text-field.component.d.ts +50 -0
  170. package/src/lib/components/variable-text-field.component.js +188 -0
  171. package/src/lib/components/variable-text-field.component.js.map +1 -0
  172. package/src/lib/components/zoomable-panning-component/index.d.ts +1 -0
  173. package/src/lib/components/zoomable-panning-component/index.js +3 -0
  174. package/src/lib/components/zoomable-panning-component/index.js.map +1 -0
  175. package/src/lib/components/zoomable-panning-component/util.d.ts +58 -0
  176. package/src/lib/components/zoomable-panning-component/util.js +114 -0
  177. package/src/lib/components/zoomable-panning-component/util.js.map +1 -0
  178. package/src/lib/components/zoomable-panning-component/zoomable-panning-component.d.ts +132 -0
  179. package/src/lib/components/zoomable-panning-component/zoomable-panning-component.js +728 -0
  180. package/src/lib/components/zoomable-panning-component/zoomable-panning-component.js.map +1 -0
  181. package/src/lib/const/aglyn-besigner-logo-full.d.ts +39 -0
  182. package/src/lib/const/aglyn-besigner-logo-full.js +146 -0
  183. package/src/lib/const/aglyn-besigner-logo-full.js.map +1 -0
  184. package/src/lib/const/aglyn-console-logo-full.d.ts +34 -0
  185. package/src/lib/const/aglyn-console-logo-full.js +142 -0
  186. package/src/lib/const/aglyn-console-logo-full.js.map +1 -0
  187. package/src/lib/const/aglyn-logo-class-keys.d.ts +30 -0
  188. package/src/lib/const/aglyn-logo-class-keys.js +32 -0
  189. package/src/lib/const/aglyn-logo-class-keys.js.map +1 -0
  190. package/src/lib/const/aglyn-logo-full.d.ts +29 -0
  191. package/src/lib/const/aglyn-logo-full.js +111 -0
  192. package/src/lib/const/aglyn-logo-full.js.map +1 -0
  193. package/src/lib/const/list-filter.d.ts +260 -0
  194. package/src/lib/const/list-filter.js +409 -0
  195. package/src/lib/const/list-filter.js.map +1 -0
  196. package/src/lib/const/prebuilt-components.d.ts +17 -0
  197. package/src/lib/const/prebuilt-components.js +22 -0
  198. package/src/lib/const/prebuilt-components.js.map +1 -0
  199. package/src/lib/const/svg-icons.d.ts +75 -0
  200. package/src/lib/const/svg-icons.js +313 -0
  201. package/src/lib/const/svg-icons.js.map +1 -0
  202. package/src/lib/const/table-pagination.d.ts +106 -0
  203. package/src/lib/const/table-pagination.js +106 -0
  204. package/src/lib/const/table-pagination.js.map +1 -0
  205. package/src/lib/contexts/confirmation.context.d.ts +996 -0
  206. package/src/lib/contexts/confirmation.context.js +49 -0
  207. package/src/lib/contexts/confirmation.context.js.map +1 -0
  208. package/src/lib/contexts/loading.context.d.ts +93 -0
  209. package/src/lib/contexts/loading.context.js +126 -0
  210. package/src/lib/contexts/loading.context.js.map +1 -0
  211. package/src/lib/hocs/create-hoc-with-context-consumer.d.ts +36 -0
  212. package/src/lib/hocs/create-hoc-with-context-consumer.js +44 -0
  213. package/src/lib/hocs/create-hoc-with-context-consumer.js.map +1 -0
  214. package/src/lib/hocs/with-hoc.d.ts +32 -0
  215. package/src/lib/hocs/with-hoc.js +37 -0
  216. package/src/lib/hocs/with-hoc.js.map +1 -0
  217. package/src/lib/hooks/mdi-icon/use-mdi-icon.d.ts +20 -0
  218. package/src/lib/hooks/mdi-icon/use-mdi-icon.js +48 -0
  219. package/src/lib/hooks/mdi-icon/use-mdi-icon.js.map +1 -0
  220. package/src/lib/hooks/mdi-icon/use-mdi-icons-fuzzy.d.ts +26 -0
  221. package/src/lib/hooks/mdi-icon/use-mdi-icons-fuzzy.js +73 -0
  222. package/src/lib/hooks/mdi-icon/use-mdi-icons-fuzzy.js.map +1 -0
  223. package/src/lib/hooks/mdi-icon/use-mdi-icons.d.ts +19 -0
  224. package/src/lib/hooks/mdi-icon/use-mdi-icons.js +49 -0
  225. package/src/lib/hooks/mdi-icon/use-mdi-icons.js.map +1 -0
  226. package/src/lib/hooks/router-events.d.ts +56 -0
  227. package/src/lib/hooks/router-events.js +88 -0
  228. package/src/lib/hooks/router-events.js.map +1 -0
  229. package/src/lib/hooks/use-async-effect.d.ts +24 -0
  230. package/src/lib/hooks/use-async-effect.js +44 -0
  231. package/src/lib/hooks/use-async-effect.js.map +1 -0
  232. package/src/lib/hooks/use-callback-param-ref.d.ts +19 -0
  233. package/src/lib/hooks/use-callback-param-ref.js +29 -0
  234. package/src/lib/hooks/use-callback-param-ref.js.map +1 -0
  235. package/src/lib/hooks/use-id.d.ts +21 -0
  236. package/src/lib/hooks/use-id.js +28 -0
  237. package/src/lib/hooks/use-id.js.map +1 -0
  238. package/src/lib/hooks/use-isomorphic-layout-effect.d.ts +19 -0
  239. package/src/lib/hooks/use-isomorphic-layout-effect.js +20 -0
  240. package/src/lib/hooks/use-isomorphic-layout-effect.js.map +1 -0
  241. package/src/lib/hooks/use-merge-refs.d.ts +38 -0
  242. package/src/lib/hooks/use-merge-refs.js +52 -0
  243. package/src/lib/hooks/use-merge-refs.js.map +1 -0
  244. package/src/lib/hooks/use-subscribable.d.ts +29 -0
  245. package/src/lib/hooks/use-subscribable.js +50 -0
  246. package/src/lib/hooks/use-subscribable.js.map +1 -0
  247. package/src/lib/types.d.ts +18 -0
  248. package/src/lib/types.js +18 -0
  249. package/src/lib/types.js.map +1 -0
  250. package/src/lib/utils/make-link-elements.d.ts +24 -0
  251. package/src/lib/utils/make-link-elements.js +32 -0
  252. package/src/lib/utils/make-link-elements.js.map +1 -0
  253. package/src/lib/utils/make-meta-elements.d.ts +24 -0
  254. package/src/lib/utils/make-meta-elements.js +32 -0
  255. package/src/lib/utils/make-meta-elements.js.map +1 -0
  256. package/src/lib/utils/scroll-overflow.d.ts +120 -0
  257. package/src/lib/utils/scroll-overflow.js +115 -0
  258. package/src/lib/utils/scroll-overflow.js.map +1 -0
  259. package/src/lib/utils/vendor.d.ts +17 -0
  260. package/src/lib/utils/vendor.js +18 -0
  261. package/src/lib/utils/vendor.js.map +1 -0
@@ -0,0 +1,86 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ 'use client';
17
+ import { _ as _extends } from "@swc/helpers/_/_extends";
18
+ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
19
+ import { jsx as _jsx } from "react/jsx-runtime";
20
+ import { getDisplayName } from "@aglyn/shared-util-tools";
21
+ import { hoistNonReactStatics } from "@aglyn/shared-util-vendor";
22
+ import { Component, forwardRef } from "react";
23
+ /**
24
+ * @see https://reactjs.org/docs/error-boundaries.html
25
+ */ let ErrorBoundaryComponentClass = class ErrorBoundaryComponentClass extends Component {
26
+ static getDerivedStateFromError(error) {
27
+ // Update state so the next render will show the fallback UI.
28
+ console.error(error, 'getDerivedStateFromError');
29
+ return {
30
+ hasError: true,
31
+ error
32
+ };
33
+ }
34
+ componentDidCatch(error, errorInfo) {
35
+ // You can also log the error to an error reporting service
36
+ // logErrorToMyService(error, errorInfo)
37
+ console.error(error, errorInfo, 'componentDidCatch');
38
+ if (typeof this.props.onCatch === 'function') {
39
+ this.props.onCatch(error, errorInfo);
40
+ }
41
+ }
42
+ render() {
43
+ var _this_props_fallback;
44
+ return this.state.hasError ? (_this_props_fallback = this.props.fallback) != null ? _this_props_fallback : /*#__PURE__*/ _jsx("h6", {
45
+ children: "Something went wrong..."
46
+ }) : this.props.children;
47
+ }
48
+ constructor(props){
49
+ super(props);
50
+ this.state = {
51
+ hasError: false,
52
+ error: undefined
53
+ };
54
+ }
55
+ };
56
+ ErrorBoundaryComponentClass.displayName = 'ErrorBoundaryComponentClass';
57
+ ErrorBoundaryComponentClass.aglyn = true;
58
+ const ErrorBoundaryComponent = /*#__PURE__*/ forwardRef((props, ref)=>{
59
+ const { children } = props, rest = _object_without_properties_loose(props, [
60
+ "children"
61
+ ]);
62
+ return /*#__PURE__*/ _jsx(ErrorBoundaryComponentClass, _extends({
63
+ ref: ref
64
+ }, rest, {
65
+ children: children
66
+ }));
67
+ });
68
+ ErrorBoundaryComponent.displayName = 'ErrorBoundaryComponent';
69
+ ErrorBoundaryComponent.aglyn = true;
70
+ export function withErrorBoundary(WrappedComponent, options) {
71
+ const displayName = getDisplayName(WrappedComponent);
72
+ const WithErrorBoundary = /*#__PURE__*/ forwardRef((props, ref)=>{
73
+ return /*#__PURE__*/ _jsx(ErrorBoundaryComponentClass, _extends({}, options, {
74
+ children: /*#__PURE__*/ _jsx(WrappedComponent, _extends({
75
+ ref: ref
76
+ }, props))
77
+ }));
78
+ });
79
+ WithErrorBoundary.displayName = `WithErrorBoundary(${displayName})`;
80
+ hoistNonReactStatics(WithErrorBoundary, WrappedComponent);
81
+ return WithErrorBoundary;
82
+ }
83
+ export { ErrorBoundaryComponent };
84
+ export default ErrorBoundaryComponent;
85
+
86
+ //# sourceMappingURL=error-boundary.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/shared/ui/jsx/src/lib/components/error-boundary.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2024 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { getDisplayName } from '@aglyn/shared-util-tools'\nimport { hoistNonReactStatics } from '@aglyn/shared-util-vendor'\nimport {\n Component,\n type ComponentType,\n type ErrorInfo,\n forwardRef,\n type ForwardRefExoticComponent,\n type PropsWithoutRef,\n type RefAttributes,\n} from 'react'\n\nexport interface ErrorBoundaryProps {\n children?: JSX.Children\n fallback?: JSX.Node\n onCatch?: (error: Error, errorInfo: ErrorInfo) => void\n}\n\ntype State = {\n hasError: boolean\n error: any\n}\n\n/**\n * @see https://reactjs.org/docs/error-boundaries.html\n */\nclass ErrorBoundaryComponentClass extends Component<ErrorBoundaryProps, State> {\n public static displayName = 'ErrorBoundaryComponentClass'\n public static readonly aglyn = true\n\n constructor(props: ErrorBoundaryProps) {\n super(props)\n this.state = {\n hasError: false,\n error: undefined,\n }\n }\n\n public static getDerivedStateFromError(error: Error) {\n // Update state so the next render will show the fallback UI.\n console.error(error, 'getDerivedStateFromError')\n return { hasError: true, error }\n }\n\n public override componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n // You can also log the error to an error reporting service\n // logErrorToMyService(error, errorInfo)\n console.error(error, errorInfo, 'componentDidCatch')\n\n if (typeof this.props.onCatch === 'function') {\n this.props.onCatch(error, errorInfo)\n }\n }\n\n public override render() {\n return this.state.hasError\n ? this.props.fallback ?? <h6>Something went wrong...</h6>\n : this.props.children\n }\n}\n\nconst ErrorBoundaryComponent = forwardRef<\n ErrorBoundaryComponentClass,\n ErrorBoundaryProps\n>((props, ref) => {\n const { children, ...rest } = props\n\n return (\n <ErrorBoundaryComponentClass ref={ref} {...rest}>\n {children}\n </ErrorBoundaryComponentClass>\n )\n})\nErrorBoundaryComponent.displayName = 'ErrorBoundaryComponent'\nErrorBoundaryComponent.aglyn = true\n\nexport function withErrorBoundary<P, T>(\n WrappedComponent: ComponentType<P>,\n options?: ErrorBoundaryProps,\n): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>> {\n const displayName = getDisplayName(WrappedComponent)\n const WithErrorBoundary = forwardRef<T, P>((props, ref) => {\n return (\n <ErrorBoundaryComponentClass {...options}>\n {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}\n <WrappedComponent ref={ref as any} {...(props as any)} />\n </ErrorBoundaryComponentClass>\n )\n })\n WithErrorBoundary.displayName = `WithErrorBoundary(${displayName})`\n hoistNonReactStatics(WithErrorBoundary, WrappedComponent)\n\n return WithErrorBoundary\n}\n\nexport { ErrorBoundaryComponent }\nexport default ErrorBoundaryComponent\n"],"names":["getDisplayName","hoistNonReactStatics","Component","forwardRef","ErrorBoundaryComponentClass","getDerivedStateFromError","error","console","hasError","componentDidCatch","errorInfo","props","onCatch","render","state","fallback","h6","children","undefined","displayName","aglyn","ErrorBoundaryComponent","ref","rest","withErrorBoundary","WrappedComponent","options","WithErrorBoundary"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;;AAEA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,oBAAoB,QAAQ,4BAA2B;AAChE,SACEC,SAAS,EAGTC,UAAU,QAIL,QAAO;AAad;;CAEC,GACD,IAAA,AAAMC,8BAAN,MAAMA,oCAAoCF;IAYxC,OAAcG,yBAAyBC,KAAY,EAAE;QACnD,6DAA6D;QAC7DC,QAAQD,KAAK,CAACA,OAAO;QACrB,OAAO;YAAEE,UAAU;YAAMF;QAAM;IACjC;IAEgBG,kBAAkBH,KAAY,EAAEI,SAAoB,EAAE;QACpE,2DAA2D;QAC3D,wCAAwC;QACxCH,QAAQD,KAAK,CAACA,OAAOI,WAAW;QAEhC,IAAI,OAAO,IAAI,CAACC,KAAK,CAACC,OAAO,KAAK,YAAY;YAC5C,IAAI,CAACD,KAAK,CAACC,OAAO,CAACN,OAAOI;QAC5B;IACF;IAEgBG,SAAS;YAEnB;QADJ,OAAO,IAAI,CAACC,KAAK,CAACN,QAAQ,IACtB,uBAAA,IAAI,CAACG,KAAK,CAACI,QAAQ,YAAnB,qCAAuB,KAACC;sBAAG;aAC3B,IAAI,CAACL,KAAK,CAACM,QAAQ;IACzB;IA5BA,YAAYN,KAAyB,CAAE;QACrC,KAAK,CAACA;QACN,IAAI,CAACG,KAAK,GAAG;YACXN,UAAU;YACVF,OAAOY;QACT;IACF;AAuBF;AAjCMd,4BACUe,cAAc;AADxBf,4BAEmBgB,QAAQ;AAiCjC,MAAMC,uCAAyBlB,WAG7B,CAACQ,OAAOW;IACR,MAAM,EAAEL,QAAQ,EAAW,GAAGN,OAATY,wCAASZ;;;IAE9B,qBACE,KAACP;QAA4BkB,KAAKA;OAASC;kBACxCN;;AAGP;AACAI,uBAAuBF,WAAW,GAAG;AACrCE,uBAAuBD,KAAK,GAAG;AAE/B,OAAO,SAASI,kBACdC,gBAAkC,EAClCC,OAA4B;IAE5B,MAAMP,cAAcnB,eAAeyB;IACnC,MAAME,kCAAoBxB,WAAiB,CAACQ,OAAOW;QACjD,qBACE,KAAClB,0CAAgCsB;sBAE/B,cAAA,KAACD;gBAAiBH,KAAKA;eAAiBX;;IAG9C;IACAgB,kBAAkBR,WAAW,GAAG,CAAC,kBAAkB,EAAEA,YAAY,CAAC,CAAC;IACnElB,qBAAqB0B,mBAAmBF;IAExC,OAAOE;AACT;AAEA,SAASN,sBAAsB,GAAE;AACjC,eAAeA,uBAAsB"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { type ButtonProps as MuiButtonProps, type GridProps } from '@mui/material';
18
+ import { type ElementType } from 'react';
19
+ export interface GridButtonsProps<P = MuiButtonProps> extends GridProps {
20
+ items: (P & {
21
+ GridItemProps?: GridProps;
22
+ })[];
23
+ ItemComponent?: ElementType<P>;
24
+ }
25
+ export declare const GridButtons: import("react").ForwardRefExoticComponent<Omit<GridButtonsProps<any>, "ref"> & import("react").RefAttributes<any>>;
26
+ export default GridButtons;
@@ -0,0 +1,45 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ /**
5
+ * @license
6
+ * Copyright 2024 Aglyn LLC
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */ import { Button } from "@mui/material";
20
+ import { forwardRef } from "react";
21
+ import GridItems from "./grid-items.js";
22
+ export const GridButtons = /*#__PURE__*/ forwardRef((props, ref)=>{
23
+ const { items = [], ItemComponent = Button } = props, rest = _object_without_properties_loose(props, [
24
+ "items",
25
+ "ItemComponent"
26
+ ]);
27
+ return /*#__PURE__*/ _jsx(GridItems, _extends({
28
+ // Buttons. Stacking them into columns would read as a menu, not a row.
29
+ masonry: false,
30
+ ref: ref,
31
+ items: items.map((_0)=>{
32
+ let { GridItemProps } = _0, item = _object_without_properties_loose(_0, [
33
+ "GridItemProps"
34
+ ]);
35
+ return _extends({
36
+ children: /*#__PURE__*/ _jsx(ItemComponent, _extends({}, item))
37
+ }, GridItemProps);
38
+ })
39
+ }, rest));
40
+ });
41
+ GridButtons.displayName = 'GridButtons';
42
+ GridButtons.aglyn = true;
43
+ export default GridButtons;
44
+
45
+ //# sourceMappingURL=grid-buttons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/shared/ui/jsx/src/lib/components/grid-buttons.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2024 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Button,\n type ButtonProps as MuiButtonProps,\n type GridProps,\n} from '@mui/material'\nimport { type ElementType, forwardRef } from 'react'\nimport GridItems from './grid-items'\n\n/* eslint-disable-next-line */\nexport interface GridButtonsProps<P = MuiButtonProps> extends GridProps {\n items: (P & { GridItemProps?: GridProps })[]\n ItemComponent?: ElementType<P>\n}\n\nexport const GridButtons = forwardRef<any, GridButtonsProps<any>>(\n (props, ref) => {\n const { items = [], ItemComponent = Button, ...rest } = props\n return (\n <GridItems\n // Buttons. Stacking them into columns would read as a menu, not a row.\n masonry={false}\n ref={ref}\n items={items.map(({ GridItemProps, ...item }) => ({\n children: <ItemComponent {...item} />,\n ...GridItemProps,\n }))}\n {...rest}\n />\n )\n },\n)\n\nGridButtons.displayName = 'GridButtons'\nGridButtons.aglyn = true\n\nexport default GridButtons\n"],"names":["Button","forwardRef","GridItems","GridButtons","props","ref","items","ItemComponent","rest","masonry","map","GridItemProps","item","children","displayName","aglyn"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,MAAM,QAGD,gBAAe;AACtB,SAA2BC,UAAU,QAAQ,QAAO;AACpD,OAAOC,eAAe,kBAAc;AAQpC,OAAO,MAAMC,4BAAcF,WACzB,CAACG,OAAOC;IACN,MAAM,EAAEC,QAAQ,EAAE,EAAEC,gBAAgBP,MAAM,EAAW,GAAGI,OAATI,wCAASJ;;;;IACxD,qBACE,KAACF;QACC,uEAAuE;QACvEO,SAAS;QACTJ,KAAKA;QACLC,OAAOA,MAAMI,GAAG,CAAC;gBAAC,EAAEC,aAAa,EAAW,OAANC;;;mBAAY;gBAChDC,wBAAU,KAACN,4BAAkBK;eAC1BD;;OAEDH;AAGV,GACD;AAEDL,YAAYW,WAAW,GAAG;AAC1BX,YAAYY,KAAK,GAAG;AAEpB,eAAeZ,YAAW"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { type GridProps } from '@mui/material';
18
+ export interface GridItemsProps extends GridProps, ReplaceKey<JSX.OverrideableComponentProps, 'component', 'itemComponent'> {
19
+ items: GridProps[];
20
+ /**
21
+ * Lay the items out as MASONRY instead of rigid rows.
22
+ *
23
+ * ## The bug this exists to kill
24
+ *
25
+ * A `<GridItems>` of cards is a twelve-column flex row that wraps, and every
26
+ * item in a wrapped row is as tall as the tallest one in it. Two consequences,
27
+ * both reported from real pages:
28
+ *
29
+ * 1. **Holes.** Billing puts `Current plan` (4) beside `Usage` (8). `Usage` is
30
+ * more than twice as tall, so the row is `Usage`-tall and the area under
31
+ * `Current plan` is dead — while `Metered usage estimate` (4), the card
32
+ * shaped to fill it, is pushed onto its own row far below with eight
33
+ * columns of nothing beside it.
34
+ * 2. **The stranded sidebar.** The marketplace listing detail is `body` (8),
35
+ * `changelog` (8), `sidebar` (4). Two eights cannot share a row, so the
36
+ * changelog wraps — and the sidebar, which follows it in source order,
37
+ * wraps WITH it. `Install`, the point of the page, starts a screen below
38
+ * the top of the content with blank space above it.
39
+ *
40
+ * ## What it does instead
41
+ *
42
+ * Items are bucketed into COLUMNS by their `size`, and each column stacks its
43
+ * own cards at their natural heights. `Current plan` and `Metered usage
44
+ * estimate` are both 4-wide, so they become one 4-wide column beside the
45
+ * 8-wide `Usage` column; `body` and `changelog` become one 8-wide column
46
+ * beside the 4-wide sidebar. A full-width item (span 12) interrupts the
47
+ * bucketing and takes a band of its own, so source order is preserved across
48
+ * it — without that, billing's five full-width cards would collect at the
49
+ * bottom in one column and reorder the page.
50
+ *
51
+ * ## Why bucketing rather than measured row spans
52
+ *
53
+ * The obvious implementation is a fine-grained row grid where each card's
54
+ * MEASURED height becomes a `grid-row: span n`, packed `dense`. It was built
55
+ * that way first and it is a trap: `n` is only correct until the card's
56
+ * content changes size, and a card whose `n` is too small does not merely
57
+ * leave a gap — the next card is placed UNDERNEATH IT. Overlapping cards are
58
+ * a far worse defect than the holes this mode exists to close, and they
59
+ * appear exactly when measurement is least reliable (data still arriving,
60
+ * images still decoding). Keeping the whole thing in CSS means there is no
61
+ * measurement to go stale: heights are whatever the browser computes, every
62
+ * frame, and cards cannot overlap because nothing ever claims a height on
63
+ * their behalf.
64
+ *
65
+ * It also costs nothing at hydration. A measured layout renders wrong on the
66
+ * server and corrects on mount; this renders identically in both.
67
+ *
68
+ * ## The one behaviour change
69
+ *
70
+ * At a breakpoint where every item is full width (`xs: 12`, the phone case)
71
+ * the columns stack, so cards are read column by column rather than in the
72
+ * authored order — on billing, `Current plan` then `Metered usage estimate`
73
+ * then `Usage`. Cards that share a column are the ones that share a width,
74
+ * which in practice is what makes them belong together.
75
+ */
76
+ masonry?: boolean;
77
+ }
78
+ /**
79
+ * Marks an element as a frame around content that others draw, such as the
80
+ * console's widget zone stacking the cards plugins render (AGL-3050).
81
+ *
82
+ * `GridItems masonry` and `CardColumns` hide an item that rendered nothing.
83
+ * An item holding only a frame whose contents all drew nothing is the same
84
+ * absent card one level down, and the item is not `:empty` while the frame is
85
+ * in it, so both hide that item too. The mark is what tells a frame apart
86
+ * from an element that draws something with no children of its own: an item
87
+ * whose one element is an image, a divider or a loading skeleton is never
88
+ * mistaken for an absent card.
89
+ */
90
+ export declare const ABSENT_WHEN_EMPTY_ATTRIBUTE = "data-absent-when-empty";
91
+ /** The mark, as props to spread onto the frame: `<Stack {...ABSENT_WHEN_EMPTY}>`. */
92
+ export declare const ABSENT_WHEN_EMPTY: {
93
+ readonly "data-absent-when-empty": "";
94
+ };
95
+ /**
96
+ * A marked frame that is its parent's only element and drew nothing.
97
+ *
98
+ * Attribute last: the selector engine jsdom ships misreads an attribute
99
+ * selector that opens a compound inside `:has()`, and throws.
100
+ */
101
+ export declare const EMPTY_FRAME_SELECTOR = ":only-child:empty[data-absent-when-empty]";
102
+ export declare const GridItems: import("react").ForwardRefExoticComponent<Omit<GridItemsProps, "ref"> & import("react").RefAttributes<any>>;
103
+ export default GridItems;
@@ -0,0 +1,336 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ /**
5
+ * @license
6
+ * Copyright 2024 Aglyn LLC
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */ import { Box, Grid } from "@mui/material";
20
+ import { forwardRef } from "react";
21
+ /**
22
+ * Cards of unequal height are the common case, and a row is as tall as its
23
+ * tallest card, so the default leaves no hole for a short card to sit in.
24
+ * Pass `masonry={false}` where the items really are a ROW — tiles, buttons, a
25
+ * navigation column beside its content, a band of stat figures — and say so
26
+ * where you pass it, because a row is now the deliberate choice.
27
+ */ const MASONRY_BY_DEFAULT = true;
28
+ /** The breakpoint an item with no explicit `size` is sized at. */ const BASE_BREAKPOINT = 'xs';
29
+ const FULL_SPAN = 12;
30
+ /**
31
+ * MUI Grid props that describe the flex-row layout masonry replaces, and so
32
+ * must not reach the masonry container.
33
+ */ const FLEX_ROW_PROPS = [
34
+ 'container',
35
+ 'spacing',
36
+ 'rowSpacing',
37
+ 'columnSpacing',
38
+ 'columns',
39
+ 'direction',
40
+ 'wrap',
41
+ 'size',
42
+ 'offset'
43
+ ];
44
+ /**
45
+ * An item's `size` as a per-breakpoint column count.
46
+ *
47
+ * `'auto'`/`'grow'` have no column-count equivalent and become full width,
48
+ * which is the safe reading: an item that wanted to size itself gets a band of
49
+ * its own rather than being bucketed against a width it never declared.
50
+ */ function spanProfile(size) {
51
+ const one = (value)=>typeof value === 'number' && value > 0 ? Math.min(FULL_SPAN, Math.round(value)) : FULL_SPAN;
52
+ if (size == null) return {
53
+ [BASE_BREAKPOINT]: FULL_SPAN
54
+ };
55
+ if (typeof size === 'number' || typeof size === 'string') return {
56
+ [BASE_BREAKPOINT]: one(size)
57
+ };
58
+ if (Array.isArray(size)) return {
59
+ [BASE_BREAKPOINT]: one(size[0])
60
+ };
61
+ const entries = Object.entries(size).map(([breakpoint, value])=>[
62
+ breakpoint,
63
+ one(value)
64
+ ]);
65
+ return entries.length ? Object.fromEntries(entries) : {
66
+ [BASE_BREAKPOINT]: FULL_SPAN
67
+ };
68
+ }
69
+ /** The profile as a `grid-column` value `sx` can resolve per breakpoint. */ const gridColumnFor = (profile)=>Object.fromEntries(Object.entries(profile).map(([breakpoint, span])=>[
70
+ breakpoint,
71
+ `span ${span}`
72
+ ]));
73
+ /** MUI's breakpoint keys, narrowest first. */ const BREAKPOINT_ORDER = [
74
+ 'xs',
75
+ 'sm',
76
+ 'md',
77
+ 'lg',
78
+ 'xl'
79
+ ];
80
+ /**
81
+ * The column count at the WIDEST breakpoint the item declares — the width it is
82
+ * bucketed by.
83
+ *
84
+ * Not `Math.max` over the profile, which was the first attempt and is wrong in
85
+ * a way that silently disables the whole mode: essentially every item in this
86
+ * codebase is written `{ xs: 12, md: 4 }`, so the maximum is 12 for all of them
87
+ * and every card reads as full width. It has to be the value at the widest
88
+ * declared breakpoint — 4 — because the multi-column arrangement only exists at
89
+ * wide viewports in the first place.
90
+ *
91
+ * Read from the profile rather than from the current viewport on purpose:
92
+ * measuring the breakpoint in JS would make the server and client renders
93
+ * disagree. Bucketing is decided once; `sx` resolves the responsive
94
+ * `grid-column` in CSS, so the narrow layout still collapses to a stack.
95
+ */ const layoutSpan = (profile)=>{
96
+ const declared = BREAKPOINT_ORDER.filter((breakpoint)=>profile[breakpoint] != null);
97
+ const widest = declared[declared.length - 1];
98
+ return widest ? profile[widest] : FULL_SPAN;
99
+ };
100
+ /** `sx` (which may already be an array or a function) as a flat array. */ const sxArray = (sx)=>sx == null ? [] : Array.isArray(sx) ? sx : [
101
+ sx
102
+ ];
103
+ /**
104
+ * A band of ONE width fans out; a band of mixed widths does not.
105
+ *
106
+ * Same-size items sharing a column is right when something else occupies the
107
+ * rest of the row — billing's two 4-wide cards stacked beside its 8-wide
108
+ * `Usage` is the case this mode was built for. It is wrong when the band is
109
+ * ALL of that width: eight `md: 6` health probes then queue in one 6-wide
110
+ * column with six columns of nothing beside them, which is a worse layout than
111
+ * the rigid rows masonry replaced.
112
+ *
113
+ * So a single-width band spreads across the `12 / span` columns it was asking
114
+ * for, round-robin, which keeps left-to-right reading order — item 0 top-left,
115
+ * item 1 top-right — rather than the column-major order that filling one
116
+ * column at a time would give.
117
+ */ function fanOut(band) {
118
+ if (band.length !== 1) return band;
119
+ const [column] = band;
120
+ const span = layoutSpan(column.profile);
121
+ const columns = Math.floor(FULL_SPAN / span);
122
+ if (columns < 2 || column.entries.length < 2) return band;
123
+ const spread = Array.from({
124
+ length: columns
125
+ }, (_, i)=>({
126
+ key: `${column.key}#${i}`,
127
+ profile: column.profile,
128
+ // Typed, not inferred: an empty literal is `any[]` under the stricter
129
+ // library tsconfigs even though the annotation above it is not enough to
130
+ // narrow a property inside `Array.from`'s callback.
131
+ entries: []
132
+ }));
133
+ column.entries.forEach((entry, index)=>{
134
+ spread[index % columns].entries.push(entry);
135
+ });
136
+ return spread.filter((candidate)=>candidate.entries.length > 0);
137
+ }
138
+ /**
139
+ * Marks an element as a frame around content that others draw, such as the
140
+ * console's widget zone stacking the cards plugins render (AGL-3050).
141
+ *
142
+ * `GridItems masonry` and `CardColumns` hide an item that rendered nothing.
143
+ * An item holding only a frame whose contents all drew nothing is the same
144
+ * absent card one level down, and the item is not `:empty` while the frame is
145
+ * in it, so both hide that item too. The mark is what tells a frame apart
146
+ * from an element that draws something with no children of its own: an item
147
+ * whose one element is an image, a divider or a loading skeleton is never
148
+ * mistaken for an absent card.
149
+ */ export const ABSENT_WHEN_EMPTY_ATTRIBUTE = 'data-absent-when-empty';
150
+ /** The mark, as props to spread onto the frame: `<Stack {...ABSENT_WHEN_EMPTY}>`. */ export const ABSENT_WHEN_EMPTY = {
151
+ [ABSENT_WHEN_EMPTY_ATTRIBUTE]: ''
152
+ };
153
+ /**
154
+ * A marked frame that is its parent's only element and drew nothing.
155
+ *
156
+ * Attribute last: the selector engine jsdom ships misreads an attribute
157
+ * selector that opens a compound inside `:has()`, and throws.
158
+ */ export const EMPTY_FRAME_SELECTOR = `:only-child:empty[${ABSENT_WHEN_EMPTY_ATTRIBUTE}]`;
159
+ /**
160
+ * A column with nothing to draw, hidden wherever it spans the whole row.
161
+ *
162
+ * Hiding its item is not enough. The column is a grid item of its own, so a
163
+ * column whose item is hidden would stay behind as a zero-height grid row with
164
+ * the grid's `gap` on both sides of it: a double gap between the cards around
165
+ * an absent full-width band. A full-width item is always the only item in its
166
+ * column, and it is absent in two shapes: it rendered nothing, or it holds
167
+ * only a frame that drew nothing.
168
+ *
169
+ * Only at the widths where the column spans all twelve tracks. A narrower
170
+ * column shares its row with the columns beside it, so an empty one adds no
171
+ * row there, and hiding it would let auto-placement slide the next column into
172
+ * its tracks.
173
+ */ function emptyColumnRules(profile) {
174
+ const display = Object.fromEntries(Object.entries(profile).map(([breakpoint, span])=>[
175
+ breakpoint,
176
+ span >= FULL_SPAN ? 'none' : 'flex'
177
+ ]));
178
+ return {
179
+ '&:has(> :only-child:empty)': {
180
+ display
181
+ },
182
+ [`&:has(> :only-child > ${EMPTY_FRAME_SELECTOR})`]: {
183
+ display
184
+ }
185
+ };
186
+ }
187
+ /**
188
+ * Items → bands → columns.
189
+ *
190
+ * A band is a maximal run of items that are not full width; a full-width item
191
+ * is a band on its own. Within a band, items that declare the same `size` share
192
+ * a column, in source order — unless the band is entirely one width, which
193
+ * {@link fanOut} spreads.
194
+ */ function buildBands(items) {
195
+ const bands = [];
196
+ let current = null;
197
+ items.forEach((item, index)=>{
198
+ const profile = spanProfile(item.size);
199
+ const key = JSON.stringify(profile);
200
+ if (layoutSpan(profile) >= FULL_SPAN) {
201
+ bands.push([
202
+ {
203
+ key,
204
+ profile,
205
+ entries: [
206
+ {
207
+ item,
208
+ index
209
+ }
210
+ ]
211
+ }
212
+ ]);
213
+ current = null;
214
+ return;
215
+ }
216
+ if (!current) {
217
+ current = [];
218
+ bands.push(current);
219
+ }
220
+ const column = current.find((candidate)=>candidate.key === key);
221
+ if (column) column.entries.push({
222
+ item,
223
+ index
224
+ });
225
+ else current.push({
226
+ key,
227
+ profile,
228
+ entries: [
229
+ {
230
+ item,
231
+ index
232
+ }
233
+ ]
234
+ });
235
+ });
236
+ return bands.map(fanOut);
237
+ }
238
+ export const GridItems = /*#__PURE__*/ forwardRef((props, ref)=>{
239
+ const { items = [], itemComponent: ItemComponent = Grid, masonry = MASONRY_BY_DEFAULT, spacing = 0, sx } = props, rest = _object_without_properties_loose(props, [
240
+ "items",
241
+ "itemComponent",
242
+ "masonry",
243
+ "spacing",
244
+ "sx"
245
+ ]);
246
+ if (!masonry) {
247
+ return /*#__PURE__*/ _jsx(Grid, _extends({
248
+ ref: ref,
249
+ container: true,
250
+ spacing: spacing,
251
+ sx: sx
252
+ }, rest, {
253
+ children: items.map((_0, _1)=>{
254
+ let _ref = [
255
+ _0,
256
+ _1
257
+ ], [_ref1, ..._rest] = _ref, { key: itemKey, id } = _ref1, item = _object_without_properties_loose(_ref1, [
258
+ "key",
259
+ "id"
260
+ ]), [index] = _rest;
261
+ var _ref2;
262
+ return /*#__PURE__*/ _jsx(ItemComponent, _extends({}, item), (_ref2 = itemKey != null ? itemKey : id) != null ? _ref2 : index);
263
+ })
264
+ }));
265
+ }
266
+ const gap = spacing;
267
+ const containerProps = Object.fromEntries(Object.entries(rest).filter(([key])=>!FLEX_ROW_PROPS.includes(key)));
268
+ return /*#__PURE__*/ _jsx(Box, _extends({
269
+ ref: ref
270
+ }, containerProps, {
271
+ sx: [
272
+ {
273
+ display: 'grid',
274
+ // Twelve fractional tracks with a zero minimum. A `span` can never
275
+ // resolve wider than its share of the container, and `minmax(0, 1fr)`
276
+ // stops a wide child (a table, a long unbroken string) from pushing a
277
+ // track past the edge — which is what used to shove the listing
278
+ // page's sidebar out of the viewport.
279
+ gridTemplateColumns: `repeat(${FULL_SPAN}, minmax(0, 1fr))`,
280
+ // Columns are as tall as their own contents, never as tall as the
281
+ // tallest column beside them.
282
+ alignItems: 'start',
283
+ gap
284
+ },
285
+ ...sxArray(sx)
286
+ ],
287
+ children: buildBands(items).map((band, bandIndex)=>band.map((column)=>/*#__PURE__*/ _jsx(Box, {
288
+ sx: _extends({
289
+ gridColumn: gridColumnFor(column.profile),
290
+ display: 'flex',
291
+ flexDirection: 'column',
292
+ gap,
293
+ // Without this a flex column refuses to shrink below its content's
294
+ // intrinsic width and the grid track overflows with it.
295
+ minWidth: 0,
296
+ // An item whose children rendered NOTHING must not leave a gap.
297
+ // A plugin widget slot renders nothing when no plugin is
298
+ // entitled for it, and the wrapper it leaves behind is still a
299
+ // flex child — so the column's `gap` is applied on both sides of
300
+ // a zero-height box, drawing a hole exactly where the absent card
301
+ // was. `:empty` is exact: the wrapper has no element and no text
302
+ // node in that case and only in that case.
303
+ '& > *:empty': {
304
+ display: 'none'
305
+ },
306
+ // The same absent card one level down: the item's one element is
307
+ // a marked frame whose contents all drew nothing.
308
+ [`& > *:has(> ${EMPTY_FRAME_SELECTOR})`]: {
309
+ display: 'none'
310
+ }
311
+ }, emptyColumnRules(column.profile)),
312
+ children: column.entries.map(({ item, index })=>{
313
+ var _ref;
314
+ const { key: itemKey, id, size, sx: itemSx } = item, itemRest = _object_without_properties_loose(item, [
315
+ "key",
316
+ "id",
317
+ "size",
318
+ "sx"
319
+ ]);
320
+ return /*#__PURE__*/ _jsx(ItemComponent, _extends({}, itemRest, {
321
+ sx: [
322
+ {
323
+ minWidth: 0
324
+ },
325
+ ...sxArray(itemSx)
326
+ ]
327
+ }), (_ref = itemKey != null ? itemKey : id) != null ? _ref : index);
328
+ })
329
+ }, `${bandIndex}:${column.key}`)))
330
+ }));
331
+ });
332
+ GridItems.displayName = 'GridItems';
333
+ GridItems.aglyn = true;
334
+ export default GridItems;
335
+
336
+ //# sourceMappingURL=grid-items.js.map