snice 7.8.0 → 7.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. package/README.md +1 -1
  2. package/adapters/react/SniceProvider.js +1 -1
  3. package/adapters/react/SniceRouter.js +1 -1
  4. package/adapters/react/matchRoute.js +1 -1
  5. package/adapters/react/table.d.ts +1 -0
  6. package/adapters/react/table.d.ts.map +1 -1
  7. package/adapters/react/table.js +1 -1
  8. package/adapters/react/table.js.map +1 -1
  9. package/adapters/react/table.tsx +2 -1
  10. package/adapters/react/useRequestHandler.js +1 -1
  11. package/bin/analyzer-contracts.js +17 -1
  12. package/custom-elements.json +57 -3
  13. package/dist/cdn/accordion/snice-accordion.js +1 -1
  14. package/dist/cdn/action-bar/snice-action-bar.js +1 -1
  15. package/dist/cdn/activity-feed/snice-activity-feed.js +1 -1
  16. package/dist/cdn/alert/snice-alert.js +1 -1
  17. package/dist/cdn/app-tiles/snice-app-tiles.js +1 -1
  18. package/dist/cdn/approval-flow/snice-approval-flow.js +1 -1
  19. package/dist/cdn/audio-recorder/snice-audio-recorder.js +1 -1
  20. package/dist/cdn/availability/snice-availability.js +1 -1
  21. package/dist/cdn/avatar/snice-avatar.js +1 -1
  22. package/dist/cdn/avatar-group/snice-avatar-group.js +1 -1
  23. package/dist/cdn/badge/snice-badge.js +1 -1
  24. package/dist/cdn/banner/snice-banner.js +1 -1
  25. package/dist/cdn/binpack/snice-binpack.js +1 -1
  26. package/dist/cdn/book/snice-book.js +1 -1
  27. package/dist/cdn/booking/snice-booking.js +1 -1
  28. package/dist/cdn/breadcrumbs/snice-breadcrumbs.js +1 -1
  29. package/dist/cdn/button/snice-button.js +1 -1
  30. package/dist/cdn/calendar/README.md +2 -2
  31. package/dist/cdn/calendar/snice-calendar.js +537 -44
  32. package/dist/cdn/calendar/snice-calendar.js.map +1 -1
  33. package/dist/cdn/calendar/snice-calendar.min.js +2 -2
  34. package/dist/cdn/calendar/snice-calendar.min.js.map +1 -1
  35. package/dist/cdn/camera/snice-camera.js +1 -1
  36. package/dist/cdn/camera-annotate/snice-camera-annotate.js +1 -1
  37. package/dist/cdn/candlestick/snice-candlestick.js +1 -1
  38. package/dist/cdn/card/snice-card.js +1 -1
  39. package/dist/cdn/carousel/snice-carousel.js +1 -1
  40. package/dist/cdn/cart/snice-cart.js +1 -1
  41. package/dist/cdn/chart/snice-chart.js +1 -1
  42. package/dist/cdn/chat/snice-chat.js +1 -1
  43. package/dist/cdn/checkbox/snice-checkbox.js +1 -1
  44. package/dist/cdn/chip/snice-chip.js +1 -1
  45. package/dist/cdn/code-block/README.md +2 -2
  46. package/dist/cdn/code-block/snice-code-block.js +177 -167
  47. package/dist/cdn/code-block/snice-code-block.js.map +1 -1
  48. package/dist/cdn/code-block/snice-code-block.min.js +2 -2
  49. package/dist/cdn/code-block/snice-code-block.min.js.map +1 -1
  50. package/dist/cdn/color-display/snice-color-display.js +1 -1
  51. package/dist/cdn/color-picker/snice-color-picker.js +1 -1
  52. package/dist/cdn/command-palette/README.md +1 -1
  53. package/dist/cdn/command-palette/snice-command-palette.js +2 -2
  54. package/dist/cdn/command-palette/snice-command-palette.js.map +1 -1
  55. package/dist/cdn/command-palette/snice-command-palette.min.js +1 -1
  56. package/dist/cdn/command-palette/snice-command-palette.min.js.map +1 -1
  57. package/dist/cdn/comments/snice-comments.js +1 -1
  58. package/dist/cdn/countdown/snice-countdown.js +1 -1
  59. package/dist/cdn/cropper/snice-cropper.js +1 -1
  60. package/dist/cdn/data-card/snice-data-card.js +1 -1
  61. package/dist/cdn/date-picker/snice-date-picker.js +1 -1
  62. package/dist/cdn/date-range-picker/snice-date-range-picker.js +1 -1
  63. package/dist/cdn/date-time-picker/snice-date-time-picker.js +1 -1
  64. package/dist/cdn/diff/snice-diff.js +1 -1
  65. package/dist/cdn/divider/snice-divider.js +1 -1
  66. package/dist/cdn/doc/snice-doc.js +1 -1
  67. package/dist/cdn/draw/snice-draw.js +1 -1
  68. package/dist/cdn/drawer/snice-drawer.js +1 -1
  69. package/dist/cdn/empty-state/snice-empty-state.js +1 -1
  70. package/dist/cdn/estimate/snice-estimate.js +1 -1
  71. package/dist/cdn/file-gallery/snice-file-gallery.js +1 -1
  72. package/dist/cdn/file-upload/snice-file-upload.js +1 -1
  73. package/dist/cdn/flip-card/snice-flip-card.js +1 -1
  74. package/dist/cdn/flow/snice-flow.js +1 -1
  75. package/dist/cdn/form-layout/snice-form-layout.js +1 -1
  76. package/dist/cdn/funnel/snice-funnel.js +1 -1
  77. package/dist/cdn/gantt/snice-gantt.js +1 -1
  78. package/dist/cdn/gauge/snice-gauge.js +1 -1
  79. package/dist/cdn/grid/snice-grid.js +1 -1
  80. package/dist/cdn/heatmap/snice-heatmap.js +1 -1
  81. package/dist/cdn/image/snice-image.js +1 -1
  82. package/dist/cdn/input/snice-input.js +1 -1
  83. package/dist/cdn/invoice/snice-invoice.js +1 -1
  84. package/dist/cdn/kanban/snice-kanban.js +1 -1
  85. package/dist/cdn/key-value/snice-key-value.js +1 -1
  86. package/dist/cdn/kpi/snice-kpi.js +1 -1
  87. package/dist/cdn/layout/snice-layout.js +1 -1
  88. package/dist/cdn/leaderboard/snice-leaderboard.js +1 -1
  89. package/dist/cdn/link/snice-link.js +1 -1
  90. package/dist/cdn/link-preview/snice-link-preview.js +1 -1
  91. package/dist/cdn/list/snice-list.js +1 -1
  92. package/dist/cdn/location/snice-location.js +1 -1
  93. package/dist/cdn/login/snice-login.js +1 -1
  94. package/dist/cdn/map/snice-map.js +1 -1
  95. package/dist/cdn/markdown/snice-markdown.js +1 -1
  96. package/dist/cdn/masonry/snice-masonry.js +1 -1
  97. package/dist/cdn/menu/snice-menu.js +1 -1
  98. package/dist/cdn/message-strip/snice-message-strip.js +1 -1
  99. package/dist/cdn/modal/snice-modal.js +1 -1
  100. package/dist/cdn/music-player/snice-music-player.js +1 -1
  101. package/dist/cdn/nav/snice-nav.js +1 -1
  102. package/dist/cdn/network-graph/snice-network-graph.js +1 -1
  103. package/dist/cdn/notification-center/snice-notification-center.js +1 -1
  104. package/dist/cdn/order-tracker/snice-order-tracker.js +1 -1
  105. package/dist/cdn/org-chart/snice-org-chart.js +1 -1
  106. package/dist/cdn/pagination/snice-pagination.js +1 -1
  107. package/dist/cdn/paint/snice-paint.js +1 -1
  108. package/dist/cdn/pdf-viewer/snice-pdf-viewer.js +1 -1
  109. package/dist/cdn/permission-matrix/snice-permission-matrix.js +1 -1
  110. package/dist/cdn/podcast-player/snice-podcast-player.js +1 -1
  111. package/dist/cdn/popover/snice-popover.js +1 -1
  112. package/dist/cdn/pricing-table/snice-pricing-table.js +1 -1
  113. package/dist/cdn/product-card/snice-product-card.js +1 -1
  114. package/dist/cdn/progress/snice-progress.js +2 -2
  115. package/dist/cdn/progress/snice-progress.js.map +1 -1
  116. package/dist/cdn/progress/snice-progress.min.js +1 -1
  117. package/dist/cdn/progress/snice-progress.min.js.map +1 -1
  118. package/dist/cdn/progress-ring/snice-progress-ring.js +1 -1
  119. package/dist/cdn/qr-code/README.md +2 -2
  120. package/dist/cdn/qr-code/snice-qr-code.js +19 -3
  121. package/dist/cdn/qr-code/snice-qr-code.js.map +1 -1
  122. package/dist/cdn/qr-code/snice-qr-code.min.js +2 -2
  123. package/dist/cdn/qr-code/snice-qr-code.min.js.map +1 -1
  124. package/dist/cdn/qr-reader/snice-qr-reader.js +1 -1
  125. package/dist/cdn/radio/snice-radio.js +1 -1
  126. package/dist/cdn/range-slider/snice-range-slider.js +1 -1
  127. package/dist/cdn/rating/snice-rating.js +1 -1
  128. package/dist/cdn/receipt/snice-receipt.js +5 -2
  129. package/dist/cdn/receipt/snice-receipt.js.map +1 -1
  130. package/dist/cdn/receipt/snice-receipt.min.js +1 -1
  131. package/dist/cdn/receipt/snice-receipt.min.js.map +1 -1
  132. package/dist/cdn/recipe/snice-recipe.js +1 -1
  133. package/dist/cdn/runtime/snice-runtime.esm.js +4 -4
  134. package/dist/cdn/runtime/snice-runtime.esm.js.map +1 -1
  135. package/dist/cdn/runtime/snice-runtime.esm.min.js.map +1 -1
  136. package/dist/cdn/runtime/snice-runtime.js +4 -4
  137. package/dist/cdn/runtime/snice-runtime.js.map +1 -1
  138. package/dist/cdn/runtime/snice-runtime.min.js.map +1 -1
  139. package/dist/cdn/sankey/snice-sankey.js +1 -1
  140. package/dist/cdn/segmented-control/snice-segmented-control.js +1 -1
  141. package/dist/cdn/select/README.md +2 -2
  142. package/dist/cdn/select/snice-select.js +6 -9
  143. package/dist/cdn/select/snice-select.js.map +1 -1
  144. package/dist/cdn/select/snice-select.min.js +2 -2
  145. package/dist/cdn/select/snice-select.min.js.map +1 -1
  146. package/dist/cdn/skeleton/snice-skeleton.js +1 -1
  147. package/dist/cdn/slider/snice-slider.js +1 -1
  148. package/dist/cdn/sortable/snice-sortable.js +1 -1
  149. package/dist/cdn/sparkline/snice-sparkline.js +1 -1
  150. package/dist/cdn/spinner/snice-spinner.js +1 -1
  151. package/dist/cdn/split-button/snice-split-button.js +1 -1
  152. package/dist/cdn/split-pane/snice-split-pane.js +1 -1
  153. package/dist/cdn/spotlight/snice-spotlight.js +1 -1
  154. package/dist/cdn/stat-group/snice-stat-group.js +1 -1
  155. package/dist/cdn/step-input/snice-step-input.js +1 -1
  156. package/dist/cdn/stepper/snice-stepper.js +1 -1
  157. package/dist/cdn/switch/snice-switch.js +1 -1
  158. package/dist/cdn/table/README.md +2 -2
  159. package/dist/cdn/table/snice-table.esm.js +1940 -407
  160. package/dist/cdn/table/snice-table.esm.js.map +1 -1
  161. package/dist/cdn/table/snice-table.esm.min.js +242 -53
  162. package/dist/cdn/table/snice-table.esm.min.js.map +1 -1
  163. package/dist/cdn/table/snice-table.js +1940 -407
  164. package/dist/cdn/table/snice-table.js.map +1 -1
  165. package/dist/cdn/table/snice-table.min.js +234 -45
  166. package/dist/cdn/table/snice-table.min.js.map +1 -1
  167. package/dist/cdn/tabs/snice-tabs.js +1 -1
  168. package/dist/cdn/tag/snice-tag.js +1 -1
  169. package/dist/cdn/tag-input/snice-tag-input.js +1 -1
  170. package/dist/cdn/terminal/snice-terminal.js +1 -1
  171. package/dist/cdn/testimonial/snice-testimonial.js +1 -1
  172. package/dist/cdn/textarea/snice-textarea.js +1 -1
  173. package/dist/cdn/time-picker/snice-time-picker.js +1 -1
  174. package/dist/cdn/time-range-picker/snice-time-range-picker.js +1 -1
  175. package/dist/cdn/timeline/snice-timeline.js +1 -1
  176. package/dist/cdn/timer/snice-timer.js +1 -1
  177. package/dist/cdn/toast/snice-toast.js +1 -1
  178. package/dist/cdn/tooltip/snice-tooltip.js +1 -1
  179. package/dist/cdn/tree/snice-tree.js +1 -1
  180. package/dist/cdn/treemap/snice-treemap.js +1 -1
  181. package/dist/cdn/user-card/snice-user-card.js +1 -1
  182. package/dist/cdn/video-player/snice-video-player.js +1 -1
  183. package/dist/cdn/virtual-scroller/snice-virtual-scroller.js +1 -1
  184. package/dist/cdn/waterfall/snice-waterfall.js +1 -1
  185. package/dist/cdn/weather/snice-weather.js +1 -1
  186. package/dist/cdn/work-order/snice-work-order.js +1 -1
  187. package/dist/components/calendar/snice-calendar.d.ts +187 -5
  188. package/dist/components/calendar/snice-calendar.js +537 -44
  189. package/dist/components/calendar/snice-calendar.js.map +1 -1
  190. package/dist/components/calendar/snice-calendar.types.d.ts +2 -1
  191. package/dist/components/code-block/formatter.d.ts +6 -0
  192. package/dist/components/code-block/formatter.js +174 -164
  193. package/dist/components/code-block/formatter.js.map +1 -1
  194. package/dist/components/code-block/grammars/snice.json +1 -1
  195. package/dist/components/code-block/grammars/typescript.json +1 -1
  196. package/dist/components/command-palette/snice-command-palette.js +1 -1
  197. package/dist/components/command-palette/snice-command-palette.js.map +1 -1
  198. package/dist/components/progress/snice-progress.js +1 -1
  199. package/dist/components/progress/snice-progress.js.map +1 -1
  200. package/dist/components/qr-code/qrcode.d.ts +1 -1
  201. package/dist/components/qr-code/qrcode.js +18 -2
  202. package/dist/components/qr-code/qrcode.js.map +1 -1
  203. package/dist/components/receipt/snice-receipt.js +4 -1
  204. package/dist/components/receipt/snice-receipt.js.map +1 -1
  205. package/dist/components/select/snice-select.d.ts +1 -1
  206. package/dist/components/select/snice-select.js +5 -8
  207. package/dist/components/select/snice-select.js.map +1 -1
  208. package/dist/components/table/snice-cell-actions.js +1 -1
  209. package/dist/components/table/snice-cell-actions.js.map +1 -1
  210. package/dist/components/table/snice-cell-color.js +1 -1
  211. package/dist/components/table/snice-cell-color.js.map +1 -1
  212. package/dist/components/table/snice-cell-date.js +20 -8
  213. package/dist/components/table/snice-cell-date.js.map +1 -1
  214. package/dist/components/table/snice-cell-email.js +1 -1
  215. package/dist/components/table/snice-cell-email.js.map +1 -1
  216. package/dist/components/table/snice-cell-image.js +1 -1
  217. package/dist/components/table/snice-cell-image.js.map +1 -1
  218. package/dist/components/table/snice-cell-json.js +1 -1
  219. package/dist/components/table/snice-cell-json.js.map +1 -1
  220. package/dist/components/table/snice-cell-link.js +1 -1
  221. package/dist/components/table/snice-cell-link.js.map +1 -1
  222. package/dist/components/table/snice-cell-location.js +1 -1
  223. package/dist/components/table/snice-cell-location.js.map +1 -1
  224. package/dist/components/table/snice-cell-phone.js +1 -1
  225. package/dist/components/table/snice-cell-phone.js.map +1 -1
  226. package/dist/components/table/snice-cell-status.js +1 -1
  227. package/dist/components/table/snice-cell-status.js.map +1 -1
  228. package/dist/components/table/snice-cell.d.ts +10 -0
  229. package/dist/components/table/snice-cell.js +59 -13
  230. package/dist/components/table/snice-cell.js.map +1 -1
  231. package/dist/components/table/snice-row.d.ts +0 -1
  232. package/dist/components/table/snice-row.js +4 -10
  233. package/dist/components/table/snice-row.js.map +1 -1
  234. package/dist/components/table/snice-table.d.ts +170 -2
  235. package/dist/components/table/snice-table.js +868 -189
  236. package/dist/components/table/snice-table.js.map +1 -1
  237. package/dist/components/table/snice-table.types.d.ts +17 -0
  238. package/dist/components/table/table-cell-presentation.d.ts +17 -4
  239. package/dist/components/table/table-cell-presentation.js +37 -11
  240. package/dist/components/table/table-cell-presentation.js.map +1 -1
  241. package/dist/components/table/table-column-manager.d.ts +153 -2
  242. package/dist/components/table/table-column-manager.js +364 -43
  243. package/dist/components/table/table-column-manager.js.map +1 -1
  244. package/dist/components/table/table-date.d.ts +29 -0
  245. package/dist/components/table/table-date.js +78 -0
  246. package/dist/components/table/table-date.js.map +1 -0
  247. package/dist/components/table/table-export.js +6 -2
  248. package/dist/components/table/table-export.js.map +1 -1
  249. package/dist/components/table/table-filter-engine.d.ts +9 -0
  250. package/dist/components/table/table-filter-engine.js +58 -14
  251. package/dist/components/table/table-filter-engine.js.map +1 -1
  252. package/dist/components/table/table-keyboard.d.ts +8 -0
  253. package/dist/components/table/table-keyboard.js +14 -3
  254. package/dist/components/table/table-keyboard.js.map +1 -1
  255. package/dist/components/table/table-toolbar.js +1 -0
  256. package/dist/components/table/table-toolbar.js.map +1 -1
  257. package/dist/components/table/table-tree-data.d.ts +2 -0
  258. package/dist/components/table/table-tree-data.js +35 -9
  259. package/dist/components/table/table-tree-data.js.map +1 -1
  260. package/dist/components/table/table-virtualizer.d.ts +44 -7
  261. package/dist/components/table/table-virtualizer.js +101 -54
  262. package/dist/components/table/table-virtualizer.js.map +1 -1
  263. package/dist/components/theme/theme.css +9 -0
  264. package/dist/index.cjs +1 -1
  265. package/dist/index.esm.js +1 -1
  266. package/dist/index.iife.js +1 -1
  267. package/dist/react/SniceProvider.js +1 -1
  268. package/dist/react/SniceRouter.js +1 -1
  269. package/dist/react/index.js +1 -1
  270. package/dist/react/matchRoute.js +1 -1
  271. package/dist/react/useRequestHandler.js +1 -1
  272. package/dist/symbols.cjs +1 -1
  273. package/dist/symbols.esm.js +1 -1
  274. package/dist/testing-dom.cjs +1 -1
  275. package/dist/testing-dom.esm.js +1 -1
  276. package/dist/transitions.cjs +1 -1
  277. package/dist/transitions.esm.js +1 -1
  278. package/docs/ai/DEVELOPMENT.md +93 -2
  279. package/docs/ai/components/calendar.md +113 -10
  280. package/docs/ai/components/code-block.md +4 -0
  281. package/docs/ai/components/doc.md +1 -1
  282. package/docs/ai/components/progress.md +1 -0
  283. package/docs/ai/components/receipt.md +1 -1
  284. package/docs/ai/components/table.md +29 -30
  285. package/docs/ai/components/theme.md +1 -0
  286. package/docs/ai/events.md +30 -0
  287. package/docs/ai/theme.md +1 -0
  288. package/docs/components/calendar.md +171 -11
  289. package/docs/components/code-block.md +2 -0
  290. package/docs/components/doc.md +1 -1
  291. package/docs/components/progress.md +13 -0
  292. package/docs/components/receipt.md +1 -0
  293. package/docs/components/table.md +274 -15
  294. package/docs/components/theme.md +5 -0
  295. package/docs/events.md +49 -0
  296. package/docs/plans/2026-03-06-date-range-picker-plan.md +4 -4
  297. package/docs/plans/2026-03-07-table-mui-parity-design.md +1 -1
  298. package/docs/plans/2026-03-09-action-bar-plan.md +11 -11
  299. package/docs/superpowers/specs/2026-07-09-table-incredible-design.md +1 -1
  300. package/docs/superpowers/specs/2026-07-09-table-phase0-implementation.md +2 -2
  301. package/package.json +3 -1
  302. package/vscode.html-custom-data.json +13 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * snice v7.7.0
2
+ * snice v7.8.0
3
3
  * A decorator-driven web component library with routing, controllers, daemons, and 130+ UI components. For better coding-agent results, run npx snice init-ai.
4
4
  * (c) 2024
5
5
  * Released under the MIT License.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * snice v7.7.0
2
+ * snice v7.8.0
3
3
  * A decorator-driven web component library with routing, controllers, daemons, and 130+ UI components. For better coding-agent results, run npx snice init-ai.
4
4
  * (c) 2024
5
5
  * Released under the MIT License.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * snice v7.7.0
2
+ * snice v7.8.0
3
3
  * A decorator-driven web component library with routing, controllers, daemons, and 130+ UI components. For better coding-agent results, run npx snice init-ai.
4
4
  * (c) 2024
5
5
  * Released under the MIT License.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * snice v7.7.0
2
+ * snice v7.8.0
3
3
  * A decorator-driven web component library with routing, controllers, daemons, and 130+ UI components. For better coding-agent results, run npx snice init-ai.
4
4
  * (c) 2024
5
5
  * Released under the MIT License.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * snice v7.7.0
2
+ * snice v7.8.0
3
3
  * A decorator-driven web component library with routing, controllers, daemons, and 130+ UI components. For better coding-agent results, run npx snice init-ai.
4
4
  * (c) 2024
5
5
  * Released under the MIT License.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * snice v7.7.0
2
+ * snice v7.8.0
3
3
  * A decorator-driven web component library with routing, controllers, daemons, and 130+ UI components. For better coding-agent results, run npx snice init-ai.
4
4
  * (c) 2024
5
5
  * Released under the MIT License.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * snice v7.7.0
2
+ * snice v7.8.0
3
3
  * A decorator-driven web component library with routing, controllers, daemons, and 130+ UI components. For better coding-agent results, run npx snice init-ai.
4
4
  * (c) 2024
5
5
  * Released under the MIT License.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * snice v7.7.0
2
+ * snice v7.8.0
3
3
  * A decorator-driven web component library with routing, controllers, daemons, and 130+ UI components. For better coding-agent results, run npx snice init-ai.
4
4
  * (c) 2024
5
5
  * Released under the MIT License.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * snice v7.7.0
2
+ * snice v7.8.0
3
3
  * A decorator-driven web component library with routing, controllers, daemons, and 130+ UI components. For better coding-agent results, run npx snice init-ai.
4
4
  * (c) 2024
5
5
  * Released under the MIT License.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * snice v7.7.0
2
+ * snice v7.8.0
3
3
  * A decorator-driven web component library with routing, controllers, daemons, and 130+ UI components. For better coding-agent results, run npx snice init-ai.
4
4
  * (c) 2024
5
5
  * Released under the MIT License.
@@ -11,8 +11,8 @@ CDN build of the Snice code-block component. Requires the Snice runtime (`snice-
11
11
  ```
12
12
 
13
13
  ## Size
14
- - Minified: 26.6 KB
15
- - Gzipped: 6.8 KB
14
+ - Minified: 26.7 KB
15
+ - Gzipped: 6.9 KB
16
16
 
17
17
  ## Theme
18
18
  For proper styling, link the Snice theme CSS:
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * snice v7.7.0
2
+ * snice v7.8.0
3
3
  * A decorator-driven web component library with routing, controllers, daemons, and 130+ UI components. For better coding-agent results, run npx snice init-ai.
4
4
  * (c) 2024
5
5
  * Released under the MIT License.
@@ -245,6 +245,12 @@ var SniceCodeBlock = (function (exports, snice) {
245
245
  * Rules are defined in grammar JSON files under "formatters" section.
246
246
  * The engine scans code char by char, tracks string/comment context,
247
247
  * and applies newline/space/indent rules based on regex char classes.
248
+ *
249
+ * Semantics: a code display formats authored code — it does not re-flow it.
250
+ * Author line breaks are preserved; rule-driven newlines fire only where
251
+ * they do not duplicate an author break and are suppressed inside
252
+ * parentheses/bracket depth. Leading indentation is renormalized from the
253
+ * indent/dedent char-class depth.
248
254
  */
249
255
  /**
250
256
  * Format code using declarative rules.
@@ -253,7 +259,6 @@ var SniceCodeBlock = (function (exports, snice) {
253
259
  const tabSize = rules.tabSize ?? 2;
254
260
  const useTabs = rules.useTabs ?? false;
255
261
  const indentUnit = useTabs ? '\t' : ' '.repeat(tabSize);
256
- const trimTrailing = rules.trimTrailing ?? true;
257
262
  const skipStrings = rules.skipStrings ?? true;
258
263
  const skipComments = rules.skipComments ?? true;
259
264
  const newlineAfter = rules.newlineAfter ? new RegExp(rules.newlineAfter) : null;
@@ -263,206 +268,211 @@ var SniceCodeBlock = (function (exports, snice) {
263
268
  const spaceAround = rules.spaceAround ? new RegExp(rules.spaceAround) : null;
264
269
  const indentRe = rules.indent ? new RegExp(rules.indent) : null;
265
270
  const dedentRe = rules.dedent ? new RegExp(rules.dedent) : null;
266
- // Strip existing formatting: collapse whitespace outside strings/comments
267
- const stripped = stripWhitespace(code, skipStrings, skipComments);
268
- // Build formatted output
269
- let result = '';
271
+ // Chars whose newline rules stay active inside […] depth: JSON-style
272
+ // structural brackets and separators must keep exploding one-liners.
273
+ const bracketExemptRe = /[[\],]/;
274
+ const lines = [];
275
+ let line = '';
276
+ let lineHasContent = false;
277
+ let needIndent = false;
278
+ // True while the current line begins inside a string/block comment: its
279
+ // content is emitted verbatim, never re-indented or rule-processed.
280
+ let inContinuation = false;
281
+ let pendingSpace = false;
270
282
  let depth = 0;
271
- let lineStart = true;
283
+ let parenDepth = 0;
284
+ let bracketDepth = 0;
285
+ // One flag per open indent group: did a line break occur inside it? A
286
+ // closing char only starts its own line when the group it closes is
287
+ // multi-line, so `import { a } from 'x'` never breaks.
288
+ const brokenGroups = [];
272
289
  let inString = null;
273
- let inComment = false; // block comment
290
+ let inBlockComment = false;
274
291
  let inLineComment = false;
275
- for (let i = 0; i < stripped.length; i++) {
276
- const ch = stripped[i];
277
- const prev = i > 0 ? stripped[i - 1] : '';
278
- const next = i + 1 < stripped.length ? stripped[i + 1] : '';
279
- // Track string context
280
- if (!inComment && !inLineComment && skipStrings) {
281
- if (inString) {
282
- result += ch;
283
- if (ch === inString && prev !== '\\') {
284
- inString = null;
285
- }
286
- continue;
292
+ /** Rule-driven newlines are suppressed inside () or (for non-bracket
293
+ * chars) inside [], so `({ ... })`, `f([a, b])` and `for (;;)` never
294
+ * explode. */
295
+ const newlineSuppressed = (ch) => {
296
+ if (parenDepth > 0)
297
+ return true;
298
+ if (bracketDepth > 0 && !bracketExemptRe.test(ch))
299
+ return true;
300
+ return false;
301
+ };
302
+ const beginLine = () => {
303
+ line = '';
304
+ lineHasContent = false;
305
+ needIndent = true;
306
+ pendingSpace = false;
307
+ inContinuation = inString !== null || inBlockComment;
308
+ if (brokenGroups.length > 0)
309
+ brokenGroups[brokenGroups.length - 1] = true;
310
+ };
311
+ const endLine = () => {
312
+ lines.push(line.replace(/[ \t]+$/, ''));
313
+ beginLine();
314
+ };
315
+ const appendContent = (ch) => {
316
+ if (needIndent) {
317
+ needIndent = false;
318
+ // Current depth, not a line-start snapshot: a dedent char re-indents
319
+ // its own line (the closing brace drops back before being written).
320
+ if (!inContinuation)
321
+ line += indentUnit.repeat(depth);
322
+ }
323
+ if (pendingSpace) {
324
+ line += ' ';
325
+ pendingSpace = false;
326
+ }
327
+ line += ch;
328
+ lineHasContent = true;
329
+ };
330
+ beginLine();
331
+ for (let i = 0; i < code.length; i++) {
332
+ const ch = code[i];
333
+ const next = i + 1 < code.length ? code[i + 1] : '';
334
+ // Line comment content: verbatim until the author newline
335
+ if (inLineComment) {
336
+ if (ch === '\n') {
337
+ inLineComment = false;
338
+ endLine();
287
339
  }
288
- if (ch === '"' || ch === "'" || ch === '`') {
289
- inString = ch;
290
- if (lineStart) {
291
- result += indentUnit.repeat(depth);
292
- lineStart = false;
293
- }
294
- result += ch;
295
- continue;
340
+ else {
341
+ appendContent(ch);
296
342
  }
343
+ continue;
297
344
  }
298
- // Track comment context
299
- if (skipComments) {
300
- if (inLineComment) {
301
- result += ch;
302
- if (ch === '\n') {
303
- inLineComment = false;
304
- lineStart = true;
305
- }
345
+ // Block comment content: verbatim, may span lines
346
+ if (inBlockComment) {
347
+ if (ch === '\n') {
348
+ endLine();
306
349
  continue;
307
350
  }
308
- if (inComment) {
309
- result += ch;
310
- if (ch === '/' && prev === '*') {
311
- inComment = false;
312
- }
351
+ appendContent(ch);
352
+ if (ch === '/' && code[i - 1] === '*')
353
+ inBlockComment = false;
354
+ continue;
355
+ }
356
+ // String content: verbatim, may span lines (template literals)
357
+ if (inString) {
358
+ if (ch === '\n') {
359
+ endLine();
313
360
  continue;
314
361
  }
362
+ appendContent(ch);
363
+ if (ch === inString && code[i - 1] !== '\\')
364
+ inString = null;
365
+ continue;
366
+ }
367
+ // Entering a string
368
+ if (skipStrings && (ch === '"' || ch === "'" || ch === '`')) {
369
+ inString = ch;
370
+ appendContent(ch);
371
+ continue;
372
+ }
373
+ // Entering a comment
374
+ if (skipComments) {
315
375
  if (ch === '/' && next === '/') {
316
- if (lineStart) {
317
- result += indentUnit.repeat(depth);
318
- lineStart = false;
319
- }
320
376
  inLineComment = true;
321
- result += ch;
377
+ appendContent(ch);
322
378
  continue;
323
379
  }
324
380
  if (ch === '/' && next === '*') {
325
- if (lineStart) {
326
- result += indentUnit.repeat(depth);
327
- lineStart = false;
328
- }
329
- inComment = true;
330
- result += ch;
381
+ inBlockComment = true;
382
+ appendContent(ch);
331
383
  continue;
332
384
  }
333
385
  }
334
- // Dedent before the char
335
- if (dedentRe && dedentRe.test(ch)) {
336
- depth = Math.max(0, depth - 1);
337
- }
338
- // Newline before
339
- if (newlineBefore && newlineBefore.test(ch)) {
340
- if (!lineStart) {
341
- result = trimTrailingSpaces(result);
342
- result += '\n';
343
- lineStart = true;
344
- }
386
+ // Author newline: preserved
387
+ if (ch === '\n') {
388
+ endLine();
389
+ continue;
345
390
  }
346
- // Space before (including spaceAround)
347
- if ((spaceBefore && spaceBefore.test(ch)) || (spaceAround && spaceAround.test(ch))) {
348
- if (!lineStart && result.length > 0 && result[result.length - 1] !== ' ' && result[result.length - 1] !== '\n') {
349
- result += ' ';
350
- }
391
+ if (ch === '\r') {
392
+ if (next !== '\n')
393
+ endLine();
394
+ continue;
351
395
  }
352
- // Write indent if at line start
353
- if (lineStart && ch !== '\n') {
354
- result += indentUnit.repeat(depth);
355
- lineStart = false;
396
+ // Whitespace within a line: collapsed to a single pending space;
397
+ // leading indentation is dropped (renormalized from depth)
398
+ if (ch === ' ' || ch === '\t') {
399
+ if (lineHasContent)
400
+ pendingSpace = true;
401
+ continue;
356
402
  }
357
- result += ch;
403
+ // Bracket/paren depth (outside strings/comments)
404
+ if (ch === '(')
405
+ parenDepth++;
406
+ else if (ch === ')')
407
+ parenDepth = Math.max(0, parenDepth - 1);
408
+ else if (ch === '[')
409
+ bracketDepth++;
410
+ else if (ch === ']')
411
+ bracketDepth = Math.max(0, bracketDepth - 1);
412
+ // Dedent before the char; a closer pops its group's multi-line flag
413
+ let closesBrokenGroup = false;
414
+ if (dedentRe && dedentRe.test(ch)) {
415
+ depth = Math.max(0, depth - 1);
416
+ closesBrokenGroup = brokenGroups.pop() ?? false;
417
+ }
418
+ // Newline before (only where it does not duplicate an author break, and
419
+ // for closers only when the group being closed is multi-line)
420
+ if (newlineBefore && newlineBefore.test(ch) && lineHasContent &&
421
+ !newlineSuppressed(ch) && (!dedentRe || !dedentRe.test(ch) || closesBrokenGroup)) {
422
+ endLine();
423
+ }
424
+ // Space before (including spaceAround). A rule char glued to a
425
+ // preceding operator char is a compound operator (`+=`, `===`), not a
426
+ // fresh token — it keeps its left side.
427
+ const prevRaw = i > 0 ? code[i - 1] : '';
428
+ const partOfOperator = prevRaw !== '' && !/[ \t\n\r]/.test(prevRaw) && /[+\-*/%=<>!&|^~?:]/.test(prevRaw);
429
+ if (((spaceBefore && spaceBefore.test(ch)) || (spaceAround && spaceAround.test(ch))) &&
430
+ lineHasContent && !partOfOperator) {
431
+ pendingSpace = true;
432
+ }
433
+ appendContent(ch);
358
434
  // Indent after the char
359
435
  if (indentRe && indentRe.test(ch)) {
360
436
  depth++;
437
+ brokenGroups.push(false);
361
438
  }
362
- // Space after (including spaceAround)
439
+ // Space after (including spaceAround). An `=` directly followed by
440
+ // another `=` is an equality chain and `=>` is an arrow — not two tokens.
363
441
  if ((spaceAfter && spaceAfter.test(ch)) || (spaceAround && spaceAround.test(ch))) {
364
- if (next && next !== '\n' && next !== ' ') {
365
- result += ' ';
442
+ const continuesOperator = ch === '=' && (next === '=' || next === '>');
443
+ if (next && next !== ' ' && next !== '\t' && next !== '\n' && next !== '\r' && !continuesOperator) {
444
+ pendingSpace = true;
366
445
  }
367
446
  }
368
- // Newline after
369
- if (newlineAfter && newlineAfter.test(ch)) {
370
- result = trimTrailingSpaces(result);
371
- result += '\n';
372
- lineStart = true;
447
+ // Newline after: fires only where it does not duplicate an author
448
+ // break or detach a same-line trailing comment
449
+ if (newlineAfter && newlineAfter.test(ch) && !newlineSuppressed(ch)) {
450
+ let j = i + 1;
451
+ while (j < code.length && (code[j] === ' ' || code[j] === '\t'))
452
+ j++;
453
+ const ahead = j < code.length ? code[j] : '';
454
+ const atAuthorBreak = ahead === '' || ahead === '\n' || ahead === '\r';
455
+ const atTrailingComment = ahead === '/' && (code[j + 1] === '/' || code[j + 1] === '*');
456
+ if (!atAuthorBreak && !atTrailingComment) {
457
+ endLine();
458
+ }
373
459
  }
374
460
  }
461
+ lines.push(line.replace(/[ \t]+$/, ''));
375
462
  // Post-processing
376
- let lines = result.split('\n');
377
- if (trimTrailing) {
378
- lines = lines.map(l => l.replace(/\s+$/, ''));
463
+ let out = lines;
464
+ if (rules.trimTrailing ?? true) {
465
+ out = out.map(l => l.replace(/[ \t]+$/, ''));
379
466
  }
380
467
  if (rules.collapseBlankLines !== undefined) {
381
- lines = collapseBlankLinesArr(lines, rules.collapseBlankLines);
468
+ out = collapseBlankLinesArr(out, rules.collapseBlankLines);
382
469
  }
383
470
  // Trim leading/trailing blank lines
384
- while (lines.length > 0 && lines[0].trim() === '')
385
- lines.shift();
386
- while (lines.length > 0 && lines[lines.length - 1].trim() === '')
387
- lines.pop();
388
- return lines.join('\n');
389
- }
390
- /**
391
- * Strip existing whitespace: replace runs of whitespace (outside strings/comments)
392
- * with a single space, and remove all newlines.
393
- */
394
- function stripWhitespace(code, skipStrings, skipComments) {
395
- let result = '';
396
- let inString = null;
397
- let inComment = false;
398
- let inLineComment = false;
399
- for (let i = 0; i < code.length; i++) {
400
- const ch = code[i];
401
- const prev = i > 0 ? code[i - 1] : '';
402
- const next = i + 1 < code.length ? code[i + 1] : '';
403
- // Track strings
404
- if (!inComment && !inLineComment && skipStrings) {
405
- if (inString) {
406
- result += ch;
407
- if (ch === inString && prev !== '\\') {
408
- inString = null;
409
- }
410
- continue;
411
- }
412
- if (ch === '"' || ch === "'" || ch === '`') {
413
- inString = ch;
414
- result += ch;
415
- continue;
416
- }
417
- }
418
- // Track comments
419
- if (skipComments) {
420
- if (inLineComment) {
421
- if (ch === '\n') {
422
- inLineComment = false;
423
- // Emit the newline so line comments stay separate
424
- result += ch;
425
- }
426
- else {
427
- result += ch;
428
- }
429
- continue;
430
- }
431
- if (inComment) {
432
- result += ch;
433
- if (ch === '/' && prev === '*') {
434
- inComment = false;
435
- }
436
- continue;
437
- }
438
- if (ch === '/' && next === '/') {
439
- inLineComment = true;
440
- result += ch;
441
- continue;
442
- }
443
- if (ch === '/' && next === '*') {
444
- inComment = true;
445
- result += ch;
446
- continue;
447
- }
448
- }
449
- // Collapse whitespace
450
- if (/\s/.test(ch)) {
451
- if (result.length > 0 && !/\s/.test(result[result.length - 1])) {
452
- result += ' ';
453
- }
454
- }
455
- else {
456
- result += ch;
457
- }
458
- }
459
- return result;
460
- }
461
- function trimTrailingSpaces(s) {
462
- let end = s.length;
463
- while (end > 0 && s[end - 1] === ' ')
464
- end--;
465
- return s.slice(0, end);
471
+ while (out.length > 0 && out[0].trim() === '')
472
+ out.shift();
473
+ while (out.length > 0 && out[out.length - 1].trim() === '')
474
+ out.pop();
475
+ return out.join('\n');
466
476
  }
467
477
  function collapseBlankLinesArr(lines, max) {
468
478
  const result = [];