@nanoporetech-digital/components 4.9.4 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/cjs/drag-777bd8dd.js +74 -0
  3. package/dist/cjs/drag-777bd8dd.js.map +1 -0
  4. package/dist/cjs/{form-control-2e900f54.js → form-control-443e90bf.js} +2 -3
  5. package/dist/cjs/form-control-443e90bf.js.map +1 -0
  6. package/dist/cjs/index-71f899a7.js +10 -2
  7. package/dist/cjs/loader.cjs.js +1 -1
  8. package/dist/cjs/nano-components.cjs.js +1 -1
  9. package/dist/cjs/nano-global-nav-user-profile_3.cjs.entry.js +6 -6
  10. package/dist/cjs/nano-global-nav-user-profile_3.cjs.entry.js.map +1 -1
  11. package/dist/cjs/nano-grid-item.cjs.entry.js +29 -0
  12. package/dist/cjs/nano-grid-item.cjs.entry.js.map +1 -0
  13. package/dist/cjs/nano-grid_2.cjs.entry.js +436 -0
  14. package/dist/cjs/nano-grid_2.cjs.entry.js.map +1 -0
  15. package/dist/cjs/nano-hero.cjs.entry.js +4 -10
  16. package/dist/cjs/nano-hero.cjs.entry.js.map +1 -1
  17. package/dist/cjs/nano-icon-button_2.cjs.entry.js +40 -3
  18. package/dist/cjs/nano-icon-button_2.cjs.entry.js.map +1 -1
  19. package/dist/cjs/nano-input.cjs.entry.js +2 -2
  20. package/dist/cjs/nano-input.cjs.entry.js.map +1 -1
  21. package/dist/cjs/nano-range.cjs.entry.js +1 -1
  22. package/dist/cjs/nano-range.cjs.entry.js.map +1 -1
  23. package/dist/cjs/nano-sortable.cjs.entry.js +654 -0
  24. package/dist/cjs/nano-sortable.cjs.entry.js.map +1 -0
  25. package/dist/cjs/nano-split-pane.cjs.entry.js +30 -45
  26. package/dist/cjs/nano-split-pane.cjs.entry.js.map +1 -1
  27. package/dist/cjs/nano-tab-group.cjs.entry.js +39 -43
  28. package/dist/cjs/nano-tab-group.cjs.entry.js.map +1 -1
  29. package/dist/cjs/nano-tab.cjs.entry.js +3 -3
  30. package/dist/cjs/nano-tab.cjs.entry.js.map +1 -1
  31. package/dist/cjs/{nano-table-54a4ba34.js → nano-table-11052a34.js} +52 -172
  32. package/dist/cjs/nano-table-11052a34.js.map +1 -0
  33. package/dist/cjs/nano-table.cjs.entry.js +1 -1
  34. package/dist/cjs/{table.worker-20ed37a5.js → table.worker-83433a8b.js} +3 -3
  35. package/dist/cjs/table.worker-83433a8b.js.map +1 -0
  36. package/dist/cjs/{table.worker-f820b411.js → table.worker-bd51e29f.js} +1 -1
  37. package/dist/collection/collection-manifest.json +1 -0
  38. package/dist/collection/components/form-control/form-control.js +1 -2
  39. package/dist/collection/components/form-control/form-control.js.map +1 -1
  40. package/dist/collection/components/grid/grid-item.js +11 -136
  41. package/dist/collection/components/grid/grid-item.js.map +1 -1
  42. package/dist/collection/components/grid/grid.css +9 -242
  43. package/dist/collection/components/grid/grid.js +248 -240
  44. package/dist/collection/components/grid/grid.js.map +1 -1
  45. package/dist/collection/components/hero/hero.css +42 -89
  46. package/dist/collection/components/hero/hero.js +4 -11
  47. package/dist/collection/components/hero/hero.js.map +1 -1
  48. package/dist/collection/components/icon-button/icon-button.css +18 -4
  49. package/dist/collection/components/icon-button/icon-button.js +83 -4
  50. package/dist/collection/components/icon-button/icon-button.js.map +1 -1
  51. package/dist/collection/components/input/input.css +8 -9
  52. package/dist/collection/components/nav-item/nav-item.js +4 -4
  53. package/dist/collection/components/nav-item/nav-item.js.map +1 -1
  54. package/dist/collection/components/range/range.css +0 -3
  55. package/dist/collection/components/select/select.css +8 -9
  56. package/dist/collection/components/sortable/sortable.css +28 -0
  57. package/dist/collection/components/sortable/sortable.js +1181 -0
  58. package/dist/collection/components/sortable/sortable.js.map +1 -0
  59. package/dist/collection/components/split-pane/split-pane.js +29 -27
  60. package/dist/collection/components/split-pane/split-pane.js.map +1 -1
  61. package/dist/collection/components/table/table-interface.js.map +1 -1
  62. package/dist/collection/components/table/table.css +18 -38
  63. package/dist/collection/components/table/table.header.js +3 -86
  64. package/dist/collection/components/table/table.header.js.map +1 -1
  65. package/dist/collection/components/table/table.js +27 -108
  66. package/dist/collection/components/table/table.js.map +1 -1
  67. package/dist/collection/components/table/table.row.js +7 -7
  68. package/dist/collection/components/table/table.row.js.map +1 -1
  69. package/dist/collection/components/table/table.store.js +1 -1
  70. package/dist/collection/components/table/table.store.js.map +1 -1
  71. package/dist/collection/components/table/table.worker.js +3 -3
  72. package/dist/collection/components/table/table.worker.js.map +1 -1
  73. package/dist/collection/components/tabs/tab-group.css +9 -13
  74. package/dist/collection/components/tabs/tab-group.js +39 -43
  75. package/dist/collection/components/tabs/tab-group.js.map +1 -1
  76. package/dist/collection/components/tabs/tab.css +53 -14
  77. package/dist/collection/components/tabs/tab.js +8 -2
  78. package/dist/collection/components/tabs/tab.js.map +1 -1
  79. package/dist/collection/utils/constructible-style.js +129 -0
  80. package/dist/collection/utils/constructible-style.js.map +1 -0
  81. package/dist/collection/utils/drag.js +52 -4
  82. package/dist/collection/utils/drag.js.map +1 -1
  83. package/dist/components/drag.js +72 -0
  84. package/dist/components/drag.js.map +1 -0
  85. package/dist/components/form-control.js +1 -2
  86. package/dist/components/form-control.js.map +1 -1
  87. package/dist/components/grid.js +268 -183
  88. package/dist/components/grid.js.map +1 -1
  89. package/dist/components/icon-button.js +45 -5
  90. package/dist/components/icon-button.js.map +1 -1
  91. package/dist/components/index.d.ts +1 -0
  92. package/dist/components/index.js +1 -0
  93. package/dist/components/index.js.map +1 -1
  94. package/dist/components/input.js +1 -1
  95. package/dist/components/input.js.map +1 -1
  96. package/dist/components/nano-grid-item.js +33 -1
  97. package/dist/components/nano-grid-item.js.map +1 -1
  98. package/dist/components/nano-hero.js +6 -19
  99. package/dist/components/nano-hero.js.map +1 -1
  100. package/dist/components/nano-range.js +1 -1
  101. package/dist/components/nano-range.js.map +1 -1
  102. package/dist/components/nano-sortable.d.ts +11 -0
  103. package/dist/components/nano-sortable.js +692 -0
  104. package/dist/components/nano-sortable.js.map +1 -0
  105. package/dist/components/nano-split-pane.js +30 -45
  106. package/dist/components/nano-split-pane.js.map +1 -1
  107. package/dist/components/nano-tab-group.js +40 -44
  108. package/dist/components/nano-tab-group.js.map +1 -1
  109. package/dist/components/nano-tab.js +3 -3
  110. package/dist/components/nano-tab.js.map +1 -1
  111. package/dist/components/nav-item.js +4 -4
  112. package/dist/components/nav-item.js.map +1 -1
  113. package/dist/components/select.js +1 -1
  114. package/dist/components/select.js.map +1 -1
  115. package/dist/components/table.js +52 -173
  116. package/dist/components/table.js.map +1 -1
  117. package/dist/components/table.worker.js +1 -1
  118. package/dist/esm/drag-1723a4cc.js +72 -0
  119. package/dist/esm/drag-1723a4cc.js.map +1 -0
  120. package/dist/esm/{form-control-269ba84f.js → form-control-e8739b2e.js} +2 -3
  121. package/dist/esm/form-control-e8739b2e.js.map +1 -0
  122. package/dist/esm/index-dad5627b.js +10 -2
  123. package/dist/esm/loader.js +1 -1
  124. package/dist/esm/nano-components.js +1 -1
  125. package/dist/esm/nano-global-nav-user-profile_3.entry.js +6 -6
  126. package/dist/esm/nano-global-nav-user-profile_3.entry.js.map +1 -1
  127. package/dist/esm/nano-grid-item.entry.js +25 -0
  128. package/dist/esm/nano-grid-item.entry.js.map +1 -0
  129. package/dist/esm/nano-grid_2.entry.js +431 -0
  130. package/dist/esm/nano-grid_2.entry.js.map +1 -0
  131. package/dist/esm/nano-hero.entry.js +4 -10
  132. package/dist/esm/nano-hero.entry.js.map +1 -1
  133. package/dist/esm/nano-icon-button_2.entry.js +41 -4
  134. package/dist/esm/nano-icon-button_2.entry.js.map +1 -1
  135. package/dist/esm/nano-input.entry.js +2 -2
  136. package/dist/esm/nano-input.entry.js.map +1 -1
  137. package/dist/esm/nano-range.entry.js +1 -1
  138. package/dist/esm/nano-range.entry.js.map +1 -1
  139. package/dist/esm/nano-sortable.entry.js +650 -0
  140. package/dist/esm/nano-sortable.entry.js.map +1 -0
  141. package/dist/esm/nano-split-pane.entry.js +30 -45
  142. package/dist/esm/nano-split-pane.entry.js.map +1 -1
  143. package/dist/esm/nano-tab-group.entry.js +39 -43
  144. package/dist/esm/nano-tab-group.entry.js.map +1 -1
  145. package/dist/esm/nano-tab.entry.js +3 -3
  146. package/dist/esm/nano-tab.entry.js.map +1 -1
  147. package/dist/esm/{nano-table-929ac4d9.js → nano-table-ba637f26.js} +53 -173
  148. package/dist/esm/nano-table-ba637f26.js.map +1 -0
  149. package/dist/esm/nano-table.entry.js +1 -1
  150. package/dist/esm/{table.worker-2425382a.js → table.worker-1cae39c9.js} +3 -3
  151. package/dist/esm/table.worker-1cae39c9.js.map +1 -0
  152. package/dist/{nano-components/p-f820b411.js → esm/table.worker-bd51e29f.js} +1 -1
  153. package/dist/nano-components/nano-components.css +1 -1
  154. package/dist/nano-components/nano-components.esm.js +1 -1
  155. package/dist/nano-components/nano-components.esm.js.map +1 -1
  156. package/dist/nano-components/p-00cf8021.entry.js +5 -0
  157. package/dist/nano-components/p-00cf8021.entry.js.map +1 -0
  158. package/dist/nano-components/{p-906de5a2.entry.js → p-158c73b0.entry.js} +2 -2
  159. package/dist/nano-components/p-365c997a.js +5 -0
  160. package/dist/nano-components/p-553acf24.entry.js +5 -0
  161. package/dist/nano-components/p-553acf24.entry.js.map +1 -0
  162. package/dist/nano-components/p-6975f110.entry.js +5 -0
  163. package/dist/nano-components/p-6975f110.entry.js.map +1 -0
  164. package/dist/nano-components/p-71057181.js +5 -0
  165. package/dist/nano-components/p-71057181.js.map +1 -0
  166. package/dist/nano-components/p-842cf127.js +5 -0
  167. package/dist/nano-components/p-842cf127.js.map +1 -0
  168. package/dist/nano-components/p-ad6209ec.entry.js +5 -0
  169. package/dist/nano-components/p-ad6209ec.entry.js.map +1 -0
  170. package/dist/nano-components/p-b8e76fdf.entry.js +5 -0
  171. package/dist/nano-components/p-b8e76fdf.entry.js.map +1 -0
  172. package/dist/{esm/table.worker-f820b411.js → nano-components/p-bd51e29f.js} +1 -1
  173. package/dist/nano-components/p-bdef618c.entry.js +5 -0
  174. package/dist/nano-components/p-bdef618c.entry.js.map +1 -0
  175. package/dist/nano-components/p-d79c6862.entry.js +5 -0
  176. package/dist/nano-components/p-d79c6862.entry.js.map +1 -0
  177. package/dist/nano-components/p-deb0799c.entry.js +5 -0
  178. package/dist/nano-components/{p-6a3a29c6.entry.js.map → p-deb0799c.entry.js.map} +1 -1
  179. package/dist/nano-components/p-ebb98a9e.entry.js +5 -0
  180. package/dist/nano-components/p-ebb98a9e.entry.js.map +1 -0
  181. package/dist/nano-components/p-f60fe933.entry.js +5 -0
  182. package/dist/nano-components/p-f60fe933.entry.js.map +1 -0
  183. package/dist/nano-components/p-f7535f45.entry.js +5 -0
  184. package/dist/nano-components/p-f7535f45.entry.js.map +1 -0
  185. package/dist/nano-components/p-fc585ea2.js +5 -0
  186. package/dist/nano-components/p-fc585ea2.js.map +1 -0
  187. package/dist/types/components/grid/grid-item.d.ts +3 -11
  188. package/dist/types/components/grid/grid.d.ts +44 -68
  189. package/dist/types/components/hero/hero.d.ts +1 -3
  190. package/dist/types/components/icon-button/icon-button.d.ts +14 -0
  191. package/dist/types/components/sortable/sortable.d.ts +204 -0
  192. package/dist/types/components/table/table-interface.d.ts +2 -4
  193. package/dist/types/components/table/table.d.ts +5 -30
  194. package/dist/types/components/table/table.header.d.ts +0 -3
  195. package/dist/types/components/tabs/tab-group.d.ts +0 -1
  196. package/dist/types/components/tabs/tab.d.ts +6 -0
  197. package/dist/types/components.d.ts +333 -89
  198. package/dist/types/utils/constructible-style.d.ts +31 -0
  199. package/dist/types/utils/drag.d.ts +21 -1
  200. package/docs-json.json +743 -168
  201. package/docs-vscode.json +102 -26
  202. package/hydrate/index.js +1210 -552
  203. package/package.json +2 -2
  204. package/dist/cjs/form-control-2e900f54.js.map +0 -1
  205. package/dist/cjs/nano-grid_3.cjs.entry.js +0 -431
  206. package/dist/cjs/nano-grid_3.cjs.entry.js.map +0 -1
  207. package/dist/cjs/nano-table-54a4ba34.js.map +0 -1
  208. package/dist/cjs/table.worker-20ed37a5.js.map +0 -1
  209. package/dist/collection/components/grid/grid-item.css +0 -15
  210. package/dist/components/grid-item.js +0 -107
  211. package/dist/components/grid-item.js.map +0 -1
  212. package/dist/esm/form-control-269ba84f.js.map +0 -1
  213. package/dist/esm/nano-grid_3.entry.js +0 -425
  214. package/dist/esm/nano-grid_3.entry.js.map +0 -1
  215. package/dist/esm/nano-table-929ac4d9.js.map +0 -1
  216. package/dist/esm/table.worker-2425382a.js.map +0 -1
  217. package/dist/nano-components/p-068bdd89.entry.js +0 -5
  218. package/dist/nano-components/p-068bdd89.entry.js.map +0 -1
  219. package/dist/nano-components/p-107d4549.entry.js +0 -5
  220. package/dist/nano-components/p-107d4549.entry.js.map +0 -1
  221. package/dist/nano-components/p-239d343a.entry.js +0 -5
  222. package/dist/nano-components/p-239d343a.entry.js.map +0 -1
  223. package/dist/nano-components/p-4f260028.js +0 -5
  224. package/dist/nano-components/p-4f260028.js.map +0 -1
  225. package/dist/nano-components/p-5381c118.js +0 -5
  226. package/dist/nano-components/p-58b53239.entry.js +0 -5
  227. package/dist/nano-components/p-58b53239.entry.js.map +0 -1
  228. package/dist/nano-components/p-5ac74848.js +0 -5
  229. package/dist/nano-components/p-5ac74848.js.map +0 -1
  230. package/dist/nano-components/p-64b56ee6.entry.js +0 -5
  231. package/dist/nano-components/p-64b56ee6.entry.js.map +0 -1
  232. package/dist/nano-components/p-6a3a29c6.entry.js +0 -5
  233. package/dist/nano-components/p-a5a560e7.entry.js +0 -5
  234. package/dist/nano-components/p-a5a560e7.entry.js.map +0 -1
  235. package/dist/nano-components/p-a761ac89.entry.js +0 -5
  236. package/dist/nano-components/p-a761ac89.entry.js.map +0 -1
  237. package/dist/nano-components/p-d792f692.entry.js +0 -5
  238. package/dist/nano-components/p-d792f692.entry.js.map +0 -1
  239. /package/dist/nano-components/{p-5381c118.js.map → p-158c73b0.entry.js.map} +0 -0
  240. /package/dist/nano-components/{p-906de5a2.entry.js.map → p-365c997a.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sortable.js","sourceRoot":"","sources":["../../../src/components/sortable/sortable.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,OAAO,EACP,KAAK,EAEL,CAAC,EACD,SAAS,EAET,KAAK,EACL,MAAM,EACN,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,+DAA+D;AAC/D,MAAM,cAAc,GAAG;EACrB,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;EAC1B,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;CACzB,CAAC;AAEF,IAAI,WAAW,GAAG,CAAC,CAAC;AAEpB;;;;;;;;;;GAUG;AAMH,MAAM,OAAO,QAAQ;EAMnB,wBAAwB;IACtB,IAAI,CAAC,sBAAsB,EAAE,CAAC;EAChC,CAAC;EAOD,0BAA0B;IACxB,IAAI,CAAC,sBAAsB,EAAE,CAAC;IAC9B,IAAI,CAAC,sBAAsB,EAAE,CAAC;EAChC,CAAC;EAmFD,gCAAgC;IAC9B,IAAI,CAAC,sBAAsB,EAAE,CAAC;EAChC,CAAC;EAMD,yBAAyB,CAAC,OAAQ,EAAE,MAAoB;IACtD,IAAI,MAAM;MAAE,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAE7C,IAAI,CAAC,gBAAgB,EAAE,CAAC;IACxB,IAAI,CAAC,sBAAsB,EAAE,CAAC;IAC9B,IAAI,CAAC,sBAAsB,EAAE,CAAC;IAE9B,IAAI,IAAI,CAAC,mBAAmB,EAAE;MAC5B,4CAA4C;MAC5C,IAAI,CAAC,mBAA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AClB,IAAI,EAAC,KAAK,EACV,IAAI,EAAC,eAAe,IAEnB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAC9B,eAAM,GAAG,CAAO,CACjB,CAAC,CACE;MACN,eAAQ,CACH,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Prop,\n Element,\n Event,\n EventEmitter,\n h,\n Component,\n ComponentInterface,\n Watch,\n Method,\n State,\n Host,\n readTask,\n writeTask,\n Build,\n} from '@stencil/core';\nimport { drag } from '../../utils/drag';\nimport { nanoDebounce } from '../..';\n\n// Orientation map to limit dragging to horizontal or vertical.\nconst orientationMap = {\n horizontal: { x: 1, y: 0 },\n vertical: { x: 0, y: 1 },\n};\n\nlet sortableIds = 0;\n\n/**\n * An accessible and flexible re-order / sort utility component.\n *\n *- Drag and drop via mouse, touch or keyboard\n *- Live announcements for screen readers\n *- Works with or without an explicit handle (although with is preferable)\n\n * @part announcements - the a11y, live region. Visually hidden by default\n *\n * @slot - The default slot containing any items you might want to sort\n */\n@Component({\n tag: 'nano-sortable',\n shadow: true,\n styleUrl: 'sortable.scss',\n})\nexport class Sortable implements ComponentInterface {\n /// Public API & surface ///\n\n /** A css query selector which matches a set of elements that should be sortable. e.g. `<li>` or `<tr>` */\n @Prop() itemSelector = 'li';\n @Watch('itemSelector')\n handleItemSelectorChange() {\n this.refreshKeyboardHandles();\n }\n\n /** A css query selector which matches an element *within* the `itemSelector` element\n * which will act like a drag handle. **Note** For keyboard a11y it's recommended\n * to use `handleSelector` when possible. Alternatively, the `createKeyboardHandle` prop will be used */\n @Prop() handleSelector?: string;\n @Watch('handleSelector')\n handleHandleSelectorChange() {\n this.refreshKeyboardHandles();\n this.attachMutationObserver();\n }\n\n /** When dragging between grouped collections of items, it is possible to drag all sortable items from one group to another.\n * At that point, you will not be able to drag items back to the original group.\n * A `dropzoneSelector` allows you to define a placeholder area where items can always be dropped.\n */\n @Prop() dropzoneSelector?: string;\n\n /** Accessibility helper text applied to handle controls */\n @Prop() helperText =\n 'Press \"Space\" or \"Enter\" to enable element reordering and use the arrow keys to reorder items.' +\n 'Press \"Escape\" to cancel reordering. Alternatively, use your mouse to drag / reorder.';\n\n /**\n * As a sortable element is interacted with, announcements are made to screen readers\n * - informing the user what is changing.\n * By default, the text from the element is extracted to describe the interacted with element.\n * Use this function to provide a more meaningful, concise item descriptor\n * @param el the element being interacted with\n * @returns a string, describing the element being interacted with\n */\n @Prop() itemDescriptor = (el: Element) => `\"${el.textContent.trim()}\"`;\n\n /**\n * Used to generate a screen reader live update, informing the user of the current element being grabbed.\n * @param el the element that has been grabbed by the user\n * @returns a string, describing the element being grabbed\n */\n @Prop() grabbedHelperText = (el: Element) =>\n `${this.itemDescriptor(el)} grabbed`;\n\n /**\n * Used to generate a screen reader live update, informing the user of the current element being dropped.\n * @param el the element that has been dropped by the user\n * @returns a string, describing the element that has been dropped\n */\n @Prop() droppedHelperText = (el: Element) =>\n `${this.itemDescriptor(el)} dropped`;\n\n /**\n * Used to generate a screen reader live update, informing the user when items have been reordered.\n * @param el the element that has been reordered by the user\n * @param elements the elements in the sortable list\n * @param position the new position of the dropped element\n * @returns a string, describing the element being dropped\n */\n @Prop() reorderHelperText = (\n el: Element,\n elements: Element[],\n position: number\n ) =>\n `The list has been reordered, ${this.itemDescriptor(\n el\n )} is now item ${position} of ${elements.length}`;\n\n /**\n * A function that should attach a keyboard accessible control.\n * When a `handleSelector` is not used - to allow keyboard accessibility -\n * `createKeyboardHandle` should render a focusable element.\n *\n * If your sortable item is itself focusable,\n * you must use this function to render a control *outside* of the focusable element.\n * @param _number\n * @param _element\n * @returns a function that attaches a keyboard accessible handle control element.\n * The function itself *must* return the handle element.\n */\n @Prop() createKeyboardHandle = (_number: number, _element: Element) => {\n const handleTpl = /* html */ `\n <nano-icon-button\n slot=\"end\"\n icon-name=\"light/arrows\"\n class=\"nano-sortable__keyboard-handle visually-hidden\"\n label=\"Re-order this item\"\n ></nano-icon-button>`;\n const div = globalThis.document.createElement('div');\n div.innerHTML = handleTpl;\n\n const handle = div.children[0] as HTMLElement;\n _element.append(handle);\n return handle;\n };\n @Watch('createKeyboardHandle')\n handleCreateKeyboardHandleChange() {\n this.refreshKeyboardHandles();\n }\n\n /** use `sortableHostElement` to watch a sortable list without needing to wrap in `nano-sortable`.\n * Note that the `sortableHostElement` element css `position` will be set to `relative` */\n @Prop() sortableHostElement?: HTMLElement;\n @Watch('sortableHostElement')\n handleSortableHostElement(_newVal?, oldVal?: HTMLElement) {\n if (oldVal) this.removeEventHandlers(oldVal);\n\n this.addEventHandlers();\n this.refreshKeyboardHandles();\n this.attachMutationObserver();\n\n if (this.sortableHostElement) {\n // sortable host must have position relative\n this.sortableHostElement.style.position = 'relative';\n }\n }\n\n /** Items being sorted will animate into place */\n @Prop() animationEnabled = true;\n\n /** Use this class to change how the element looks whilst being sorted */\n @Prop() draggedClass = 'nano-sortable__dragged';\n\n /** Use this class to change how the handle looks whilst being sorted */\n @Prop() handleDraggedClass = 'nano-sortable__handle-dragged';\n\n /** Use this class to change how the element looks when acting as a placeholder */\n @Prop() placeholderClass = 'nano-sortable__placeholder';\n\n /** Used in-conjunction with `dropzoneSelector`, applied when a dropzone is dragged over */\n @Prop() dropzoneActiveClass?: string = '';\n\n /** The css animation timing applied when `animationEnabled` is `true` */\n @Prop() animationTiming: any = { duration: 200, easing: 'ease-out' };\n\n /** The axis to lock dragging elements to. `undefined` means any axis */\n @Prop() orientation?: 'horizontal' | 'vertical';\n\n /** Dragged items by default, will take whatever default css is applied in situ.\n * When sortable items' dimensions are dynamic (i.e they can shrink / grow via the space allowed) dragging items can look 'wrong'.\n * Apply `dragResize` to read & recreate the dragged items current dimensions when dragged. */\n @Prop() dragResize = false;\n\n /** Fired when an the order changes. Use this to update any underlying data model.\n * `event.preventDefault()` to prevent the element being moved; will revert to original position. */\n @Event() nanoOrderChange: EventEmitter<{\n element: HTMLElement;\n originalIndex: number;\n targetIndex: number;\n }>;\n\n /** Fired when a sortable element is picked-up; via keyboard, mouse or touch.\n * `event.preventDefault()` to prevent the element being picked-up. */\n @Event() nanoGrabbed: EventEmitter<{ element: HTMLElement; index: number }>;\n\n /** Fired when a sortable element is dropped after having been picked up. */\n @Event() nanoDropped: EventEmitter<{ element: HTMLElement }>;\n\n /** If sortable elements change dynamically, use this method to add handle controls to new elements */\n @Method()\n async refreshKeyboardHandles() {\n if (this.handleSelector) {\n if (this.keyboardHandleMap?.size) {\n this.keyboardHandleMap.clear();\n }\n\n this.sortableHost\n .querySelectorAll<HTMLElement>(this.handleSelector)\n .forEach((handle) => {\n if (!handle.getAttribute('aria-describedby'))\n handle.setAttribute('aria-describedby', this.sortableId);\n const sortEle = handle.closest<HTMLElement>(this.itemSelector);\n if (sortEle) this.keyboardHandleMap.set(handle, sortEle);\n });\n return;\n }\n\n if (this.keyboardHandleMap?.size) {\n this.keyboardHandleMap?.forEach((_ele, handle) => handle.remove());\n this.keyboardHandleMap.clear();\n }\n this.sortableHost\n .querySelectorAll<HTMLElement>(this.itemSelector)\n .forEach((ele, i) => {\n const handle = this.createKeyboardHandle(i, ele);\n if (!handle) {\n console.error(\n '`createKeyboardHandle` *must* return the handle element it creates'\n );\n return;\n }\n this.keyboardHandleMap.set(handle, ele);\n handle.setAttribute('aria-describedby', this.sortableId);\n });\n }\n\n /// Private state & logic ///\n\n @Element() host: HTMLNanoSortableElement;\n private dragRequestPending = false;\n private draggedElement?: HTMLElement;\n private draggedElementClone?: HTMLElement;\n private draggedElementOrigin?: HTMLElement;\n private sortableNodes: HTMLElement[] = [];\n private dropzoneNodes: HTMLElement[] = [];\n private animatedElements: HTMLElement[] = [];\n private animationPromise?: Promise<void>;\n private keyboardHandleMap: Map<HTMLElement, HTMLElement> = new Map();\n private sortableId = `nano-sortable-${sortableIds++}`;\n private mouseDownTimer: number;\n private mutationObserver: MutationObserver;\n\n @State() keyboardSortActive = false;\n @State() ariaTextList: string[] = [];\n\n /**\n * Get instance of sortable host.\n * By default it is `nano-sortable` which can be overridden by property `sortableHostElement`\n */\n get sortableHost() {\n if (this.sortableHostElement) return this.sortableHostElement;\n return this.host;\n }\n\n /**\n * Queues aria messages which are then displayed in a 'live' region.\n * Messages are cleared after 10s\n * @param msg aria message to announce\n */\n private addAriaMsg(msg: string) {\n this.ariaTextList = [...this.ariaTextList, msg];\n\n setTimeout(() => {\n const mIdx = this.ariaTextList.indexOf(msg);\n this.ariaTextList.splice(mIdx, 1);\n this.ariaTextList = [...this.ariaTextList];\n }, 10000);\n }\n\n /**\n * Try to stop text highlight whilst dragging\n * @param userSelect\n */\n private updateUserSelectStyle(userSelect: '' | 'none') {\n this.host.style.userSelect = userSelect;\n // @ts-ignore\n this.host.style.MozUserSelect = userSelect;\n // @ts-ignore\n this.host.style.msUserSelect = userSelect;\n this.host.style.webkitUserSelect = userSelect;\n }\n\n /**\n * Fast and simple hit test to check whether the center of a node intersects with the rectangle of any of the\n * given targets. Returns an array of matches.\n * @param node\n * @param targets\n * @returns all the items that currently intersect with the target node\n */\n private hitTest(node: HTMLElement, targets: HTMLElement[]): HTMLElement[] {\n const {\n left: l,\n top: t,\n width: w,\n height: h,\n } = node.getBoundingClientRect();\n const x = l + w / 2;\n const y = t + h / 2;\n\n return targets.filter((item) => {\n const { left, right, top, bottom } = item.getBoundingClientRect();\n return !(x < left || x > right || y < top || y > bottom);\n });\n }\n\n /**\n * Returns a boolean indicating whether the node is currently in an animation.\n * @param node\n * @returns whether a node is currently animating or not\n */\n private isAnimating(node: HTMLElement) {\n return this.animatedElements.indexOf(node) !== -1;\n }\n\n /**\n * Triggers a CSS animation on a node with the given dx and dy. Used following dom updates to make it appear as\n * if nodes animate from their old to their new position in the dom. */\n private animateNode(node: HTMLElement, dx = 0, dy = 0) {\n if (!node.animate) {\n return;\n }\n\n // keep a stack of currently animating nodes to exclude as drag & drop targets.\n this.animatedElements.push(node);\n\n node.style.willChange = 'transform';\n\n // animate from dx/dy (old node position) to none (new node position)\n writeTask(() => {\n this.animationPromise = new Promise((resolve) => {\n node\n .animate(\n [\n { transform: `translate3d(${dx}px, ${dy}px, 0)` },\n { transform: 'none' },\n ],\n this.animationTiming\n )\n .addEventListener(\n 'finish',\n () => {\n const index = this.animatedElements.indexOf(node);\n node.style.willChange = '';\n\n if (index !== -1) {\n // splice out when done to unlock as a valid target\n this.animatedElements.splice(index, 1);\n }\n\n resolve();\n delete this.animationPromise;\n },\n { once: true }\n );\n });\n });\n }\n\n /**\n * Inserts node at target to update sibling sorting. If the node precedes the target, it is inserted after it;\n * If it follows the target, it is inserted before it. This ensures any node can be dragged from the very\n * beginning to the very end and vice versa. The animateNode function is called for all nodes that moved because\n * of this dom update */\n private insertAtTarget(node: Element, target: HTMLElement) {\n if (!node || !target) return;\n\n let offsets: any[] = [];\n if (this.animationEnabled) {\n offsets = this.sortableNodes.map((item) => ({\n x: item.offsetLeft,\n y: item.offsetTop,\n }));\n }\n\n if (!node.isConnected || !target.isConnected) return;\n\n if (this.dropzoneNodes.indexOf(target) > -1) {\n target.append(node);\n } else {\n const nodeComparison = node.compareDocumentPosition(target);\n let position;\n\n if (nodeComparison & this.host.DOCUMENT_POSITION_FOLLOWING) {\n position =\n target.parentNode === node.parentNode ? 'afterend' : 'beforebegin';\n }\n if (nodeComparison & this.host.DOCUMENT_POSITION_PRECEDING) {\n position =\n target.parentNode === node.parentNode ? 'beforebegin' : 'afterend';\n }\n if (position) target.insertAdjacentElement(position, node);\n }\n\n if (this.animationEnabled) {\n this.sortableNodes.forEach((sortableNode, i) => {\n const { x, y } = offsets[i];\n const dx = x - sortableNode.offsetLeft;\n const dy = y - sortableNode.offsetTop;\n if (dx !== 0 || dy !== 0) {\n this.animateNode(sortableNode, dx, dy);\n }\n });\n }\n }\n\n private reset() {\n if (\n this.draggedElementClone !== undefined &&\n this.draggedElementClone.parentNode !== null\n ) {\n this.draggedElementClone.parentNode.removeChild(this.draggedElementClone);\n }\n\n if (\n this.draggedElement &&\n this.draggedElement.parentNode &&\n this.draggedElementOrigin\n ) {\n this.draggedElement.classList.remove(this.placeholderClass);\n }\n\n if (this.dropzoneActiveClass && this.dropzoneNodes.length) {\n this.dropzoneNodes.forEach((dze) =>\n dze.classList.remove(this.dropzoneActiveClass)\n );\n }\n\n delete this.draggedElementClone;\n delete this.draggedElement;\n\n this.dropzoneNodes = [];\n this.sortableNodes = [];\n this.animatedElements = [];\n this.dragRequestPending = false;\n this.updateUserSelectStyle('');\n }\n\n /**\n * Clones a given node to visually drag around. The original node is left in the same flow as its siblings.\n * Clone styles are added onto the style object directly, since the ::slotted()\n * selector can't universally target nodes that may be nested an unknown amount of shadow dom levels deep\n * @param node html node to clone\n * @returns the cloned html node\n */\n private createClone(node: HTMLElement): HTMLElement {\n const clone = node.cloneNode(true) as HTMLElement;\n if (node.id) clone.id = 'clone__' + clone.id;\n\n /**\n * Bugfix for table row sorting.\n * During dragging table rows shrink, so we manually set them width of original node.\n */\n Array.from(clone.children).forEach((nodeChild: HTMLElement, index) => {\n const clonedNodeChild = nodeChild;\n const originalNodeChild = node.children.item(index) as HTMLElement;\n\n if (originalNodeChild) {\n clonedNodeChild.style.width = `${originalNodeChild.offsetWidth}px`;\n }\n });\n const {\n offsetLeft: x,\n offsetTop: y,\n offsetWidth: w,\n offsetHeight: h,\n } = node;\n\n Object.assign(clone.style, {\n position: 'absolute',\n left: `calc(${x}px - var(--grab-offset-x, 0px))`,\n top: `calc(${y}px - var(--grab-offset-y, 0px))`,\n height: this.dragResize ? `${h}px` : undefined,\n width: this.dragResize ? `${w}px` : undefined,\n willChange: 'transform,opacity',\n });\n\n clone.classList.add(this.draggedClass);\n\n return node.parentNode!.appendChild(clone);\n }\n\n /// Event handlers ///\n\n private removeEventHandlers(ele?: HTMLElement) {\n ele = ele || this.sortableHost;\n ele.removeEventListener('mousedown', this.handleTrack);\n ele.removeEventListener('touchstart', this.handleTrack);\n ele.removeEventListener('keydown', this.handleKeydown);\n }\n\n private addEventHandlers(ele?: HTMLElement) {\n ele = ele || this.sortableHost;\n ele.addEventListener('mousedown', this.handleTrack);\n ele.addEventListener('touchstart', this.handleTrack);\n ele.addEventListener('keydown', this.handleKeydown);\n }\n\n /**\n * Watch for any changes in grab-able handle elements.\n */\n private attachMutationObserver() {\n if (!Build.isBrowser) return;\n\n if (this.mutationObserver) {\n this.mutationObserver.disconnect();\n this.mutationObserver = undefined;\n }\n\n this.mutationObserver = new MutationObserver(() => {\n const currHandles = Array.from(this.keyboardHandleMap.values());\n const newHandles = Array.from(\n this.sortableHost.querySelectorAll<HTMLElement>(this.itemSelector)\n );\n\n // simple test for equality\n if (\n currHandles.length !== newHandles.length ||\n !!newHandles.find((h) => !currHandles.includes(h))\n ) {\n this.refreshKeyboardHandles();\n }\n });\n this.mutationObserver.observe(this.sortableHost, {\n subtree: true,\n childList: true,\n });\n }\n\n private handleKeydown(e: KeyboardEvent) {\n const targetElement = e.target as HTMLElement;\n let foundHandle: HTMLElement;\n let sortEle: HTMLElement;\n\n if (this.handleSelector) {\n foundHandle = targetElement.closest(this.handleSelector);\n sortEle = targetElement.closest(this.itemSelector);\n } else {\n sortEle = this.keyboardHandleMap.get(targetElement);\n foundHandle = targetElement;\n }\n\n // have we found a handle and matching sort element from the keydown element\n if (!foundHandle || !sortEle) return;\n\n const activateSort = (isActive: boolean) => {\n this.keyboardSortActive = isActive;\n this.draggedElement = isActive ? sortEle : undefined;\n sortEle.classList.toggle(this.draggedClass, isActive);\n foundHandle.classList.toggle(this.handleDraggedClass, isActive);\n\n if (isActive) {\n this.addAriaMsg(this.grabbedHelperText(sortEle));\n document.addEventListener('mousedown', () => activateSort(false), {\n once: true,\n });\n } else {\n this.addAriaMsg(this.droppedHelperText(sortEle));\n }\n };\n\n // start editing this element's order?\n if ([' ', 'Space', 'Enter'].includes(e.key)) {\n e.preventDefault();\n\n if (!this.keyboardSortActive) {\n // grabbed the element\n activateSort(true);\n\n this.sortableNodes =\n Array.from(this.sortableHost.querySelectorAll(this.itemSelector)) ||\n [];\n const nanoGrabbedEv = this.nanoGrabbed.emit({\n element: sortEle,\n index: this.sortableNodes.indexOf(sortEle),\n });\n\n if (nanoGrabbedEv.defaultPrevented) {\n activateSort(false);\n return;\n }\n } else {\n // dropped the element\n activateSort(false);\n this.nanoDropped.emit({ element: sortEle });\n }\n return;\n }\n if (!this.keyboardSortActive) return;\n\n // Tabbing away from this handle - deactivate\n if (['Escape', 'Tab'].includes(e.key)) activateSort(false);\n\n let moveKeys = ['Home', 'End'];\n if (!this.orientation || this.orientation === 'horizontal')\n moveKeys = [...moveKeys, 'ArrowRight', 'ArrowLeft'];\n if (!this.orientation || this.orientation === 'vertical')\n moveKeys = [...moveKeys, 'ArrowUp', 'ArrowDown'];\n\n if (!moveKeys.includes(e.key)) return;\n\n // move the element with the keyboard\n e.preventDefault();\n\n /** Collect all elements that have drag positions.\n * Both sortable elements and 'dropzones' (placeholders where items can always be placed) */\n\n this.sortableNodes =\n Array.from(this.sortableHost.querySelectorAll(this.itemSelector)) || [];\n this.dropzoneNodes =\n Array.from(this.sortableHost.querySelectorAll(this.dropzoneSelector)) ||\n [];\n const currIdx = this.sortableNodes.indexOf(this.draggedElement);\n let curDzIdx: number = -1;\n\n if (this.dropzoneNodes.length) {\n const curDropzone = this.draggedElement.closest<HTMLElement>(\n this.dropzoneSelector\n );\n curDzIdx = this.dropzoneNodes.indexOf(curDropzone);\n curDzIdx = curDzIdx > -1 ? curDzIdx : -1;\n }\n\n /** If we don't have a next / prev sortable element in our list, test to see if there's a dropzone instead */\n const prevEle =\n currIdx - 1 < 0 && curDzIdx > -1\n ? this.dropzoneNodes[curDzIdx - 1]\n : this.sortableNodes[currIdx - 1];\n const nextEle =\n currIdx + 1 === this.sortableNodes.length && curDzIdx > -1\n ? this.dropzoneNodes[curDzIdx + 1]\n : this.sortableNodes[currIdx + 1];\n\n if (e.key === 'Home') {\n this.insertAtTarget(this.draggedElement, this.sortableNodes[0]);\n }\n if (e.key === 'End') {\n this.insertAtTarget(\n this.draggedElement,\n this.sortableNodes[this.sortableNodes.length - 1]\n );\n }\n if (['ArrowRight', 'ArrowDown'].includes(e.key)) {\n this.insertAtTarget(this.draggedElement, nextEle);\n }\n if (['ArrowLeft', 'ArrowUp'].includes(e.key)) {\n this.insertAtTarget(this.draggedElement, prevEle);\n }\n\n this.finishOrder();\n this.draggedElement = sortEle;\n\n const focus = () => {\n requestAnimationFrame(() => {\n typeof foundHandle['setFocus'] === 'function'\n ? (foundHandle as HTMLNanoIconButtonElement).setFocus()\n : foundHandle.focus();\n });\n };\n\n // replace focus to handle so we don't 'drop' the element\n if (this.animationPromise) this.animationPromise.then(() => focus());\n else focus();\n }\n\n /**\n * Tracks a pointer from touchstart/mousedown to touchend/mouseup. Note that the start state is fired following\n * the first actual move event following a touchstart/mousedown */\n private handleTrack(e: PointerEvent) {\n if (this.dragRequestPending || (e.button && e.button !== 1)) return;\n\n clearTimeout(this.mouseDownTimer);\n this.mouseDownTimer = window?.setTimeout(() => {\n if (!this.trackStart(e)) return;\n\n this.addAriaMsg(this.grabbedHelperText(this.draggedElement));\n\n drag(this.sortableHost, {\n initialEvent: e,\n relative: true,\n onMove: (x, y) => {\n this.trackMove(x, y);\n },\n onStop: () => {\n this.nanoDropped.emit({ element: this.draggedElement });\n\n const didStop = () => {\n this.addAriaMsg(this.droppedHelperText(this.draggedElement));\n requestAnimationFrame(() => this.finishOrder());\n };\n if (this.animationPromise) {\n this.animationPromise.then(() => didStop());\n } else didStop();\n },\n });\n }, 100);\n document.addEventListener(\n 'mouseup',\n () => clearTimeout(this.mouseDownTimer),\n { once: true }\n );\n }\n\n /**\n * Initialized a drag and drop sequence if a child node was clicked that matches the itemSelector property.\n * OR If a handleSelector is defined, a node matching this selector must be clicked instead\n * @returns boolean - whether tracking for this event should continue or not\n */\n private trackStart(e: Event) {\n const targetElement = e.target as HTMLElement;\n let targetHandle: HTMLElement;\n\n // If we have a handle set, return now if not being pressed\n if (this.handleSelector) {\n targetHandle = targetElement.closest(this.handleSelector);\n\n if (!targetHandle) return;\n targetHandle.classList.add(this.handleDraggedClass);\n }\n\n // Check that we've found the target element via itemSelector\n const node = targetElement.closest<HTMLElement>(this.itemSelector);\n if (!node) return false;\n\n this.sortableNodes =\n Array.from(this.sortableHost.querySelectorAll(this.itemSelector)) || [];\n const nanoGrabbedEv = this.nanoGrabbed.emit({\n element: node,\n index: this.sortableNodes.indexOf(node),\n });\n if (nanoGrabbedEv.defaultPrevented) return false;\n\n // Element found... start everything\n e.preventDefault();\n this.updateUserSelectStyle('none');\n this.dragRequestPending = true;\n this.draggedElement = node;\n this.dropzoneNodes =\n Array.from(this.sortableHost.querySelectorAll(this.dropzoneSelector)) ||\n [];\n this.draggedElementClone = this.createClone(node);\n this.draggedElementOrigin = node.nextSibling as HTMLElement;\n this.animatedElements = [];\n this.draggedElement!.classList.add(this.placeholderClass);\n return true;\n }\n\n /** Ends re-ordering */\n private finishOrder() {\n if (!this.draggedElement) return;\n\n const updated = Array.from(\n this.sortableHost.querySelectorAll<HTMLElement>(this.itemSelector)\n ).filter((ele) => ele !== this.draggedElementClone);\n const originalIndex = this.sortableNodes.indexOf(this.draggedElement);\n const targetIndex = updated.indexOf(this.draggedElement);\n\n if (this.handleSelector) {\n const targetHandle = this.draggedElement.querySelector(\n this.handleSelector\n );\n targetHandle.classList.remove(this.handleDraggedClass);\n }\n\n if (originalIndex !== targetIndex) {\n const orderChangeEv = this.nanoOrderChange.emit({\n element: this.draggedElement,\n originalIndex,\n targetIndex,\n });\n\n if (orderChangeEv.defaultPrevented) {\n /** Event was prevented, wait a moment to send element back to whence it came - gives a nicer visual queue */\n this.animationPromise = new Promise((resolve) => {\n setTimeout(() => {\n this.insertAtTarget(this.draggedElement, updated[originalIndex]);\n this.reset();\n this.dragRequestPending = false;\n resolve();\n }, 200);\n });\n return;\n }\n this.addAriaMsg(\n this.reorderHelperText(this.draggedElement, updated, targetIndex + 1)\n );\n }\n\n this.reset();\n this.dragRequestPending = false;\n }\n\n /**\n * Moves the active node's clone to follow the pointer. The node that the clone intersects with (via hitTest) is\n * the insert point for updated sorting */\n private trackMove = (x: number, y: number) => {\n if (!this.draggedElementClone) {\n return;\n }\n\n if (this.orientation) {\n x = x * orientationMap[this.orientation].x;\n y = y * orientationMap[this.orientation].y;\n }\n\n writeTask(() => {\n Object.assign(this.draggedElementClone!.style, {\n transform: `translate3d(${x}px, ${y}px, 0)`,\n });\n });\n\n let target = this.hitTest(this.draggedElementClone!, this.sortableNodes)[0];\n let activeDropzone: HTMLElement;\n\n if (this.dropzoneSelector && this.dropzoneActiveClass) {\n readTask(() => {\n activeDropzone = this.draggedElement.closest(this.dropzoneSelector);\n\n writeTask(() => {\n this.dropzoneNodes\n .filter((dze) => dze !== activeDropzone)\n .forEach((dze) => dze.classList.remove(this.dropzoneActiveClass));\n activeDropzone.classList.add(this.dropzoneActiveClass);\n });\n });\n }\n\n // didn't find a target - let's test to see if we can use a drop-zone instead\n if (!target && this.dropzoneNodes.length) {\n target = this.hitTest(this.draggedElementClone!, this.dropzoneNodes)[0];\n if (this.draggedElement.closest(this.dropzoneSelector) === target) return;\n }\n\n if (\n // if clone intersects with a valid target,\n target &&\n // other than its own origin,\n target !== this.draggedElement &&\n // and the target isn't currently animating, which causes false hit tests,\n !this.isAnimating(target)\n ) {\n this.insertAtTarget(this.draggedElement!, target);\n }\n };\n\n /// Component lifecycle ///\n\n constructor() {\n this.handleTrack = this.handleTrack.bind(this);\n this.handleKeydown = this.handleKeydown.bind(this);\n this.refreshKeyboardHandles = this.refreshKeyboardHandles.bind(this);\n this.refreshKeyboardHandles = nanoDebounce(\n this.refreshKeyboardHandles,\n 500\n );\n }\n\n connectedCallback() {\n this.addEventHandlers();\n this.refreshKeyboardHandles();\n this.attachMutationObserver();\n\n if (Build.isBrowser && !this.host.querySelector(`#${this.sortableId}`)) {\n // inject a light-dom / a11y description that we can connect sortable items to\n this.host.insertAdjacentHTML(\n 'beforeend',\n `<div class=\"visually-hidden\" id=\"${this.sortableId}\">${this.helperText}</div>`\n );\n }\n }\n\n disconnectedCallback() {\n this.removeEventHandlers();\n this.host.querySelector(`#${this.sortableId}`)?.remove();\n\n if (this.mutationObserver) {\n this.mutationObserver.disconnect();\n this.mutationObserver = undefined;\n }\n }\n\n render() {\n return (\n <Host>\n <div\n class=\"sortable__live-region\"\n aria-live=\"polite\"\n aria-relevant=\"additions\"\n aria-atomic=\"true\"\n role=\"log\"\n part=\"announcements\"\n >\n {this.ariaTextList.map((str) => (\n <div>{str}</div>\n ))}\n </div>\n <slot />\n </Host>\n );\n }\n}\n"]}
@@ -39,33 +39,35 @@ export class SplitPane {
39
39
  }
40
40
  // Prevent text selection when dragging
41
41
  e.preventDefault();
42
- drag(this.host, (x, y) => {
43
- let newPositionInPixels = this.vertical ? y : x;
44
- this.nanoDragging.emit(newPositionInPixels);
45
- // Flip for end panels
46
- if (this.primary === 'end') {
47
- newPositionInPixels = this.size - newPositionInPixels;
48
- }
49
- // Check snap points
50
- if (this.snap) {
51
- const snaps = this.snap.split(' ');
52
- snaps.forEach((value) => {
53
- let snapPoint;
54
- if (value.endsWith('%')) {
55
- snapPoint = this.size * (parseFloat(value) / 100);
56
- }
57
- else {
58
- snapPoint = parseFloat(value);
59
- }
60
- if (newPositionInPixels >= snapPoint - this.snapThreshold &&
61
- newPositionInPixels <= snapPoint + this.snapThreshold) {
62
- newPositionInPixels = snapPoint;
63
- }
64
- });
65
- }
66
- this.shouldAnimate = false;
67
- this.position = clamp(this.pixelsToPercentage(newPositionInPixels), 0, 100);
68
- requestAnimationFrame(() => (this.shouldAnimate = true));
42
+ drag(this.host, {
43
+ onMove: (x, y) => {
44
+ let newPositionInPixels = this.vertical ? y : x;
45
+ this.nanoDragging.emit(newPositionInPixels);
46
+ // Flip for end panels
47
+ if (this.primary === 'end') {
48
+ newPositionInPixels = this.size - newPositionInPixels;
49
+ }
50
+ // Check snap points
51
+ if (this.snap) {
52
+ const snaps = this.snap.split(' ');
53
+ snaps.forEach((value) => {
54
+ let snapPoint;
55
+ if (value.endsWith('%')) {
56
+ snapPoint = this.size * (parseFloat(value) / 100);
57
+ }
58
+ else {
59
+ snapPoint = parseFloat(value);
60
+ }
61
+ if (newPositionInPixels >= snapPoint - this.snapThreshold &&
62
+ newPositionInPixels <= snapPoint + this.snapThreshold) {
63
+ newPositionInPixels = snapPoint;
64
+ }
65
+ });
66
+ }
67
+ this.shouldAnimate = false;
68
+ this.position = clamp(this.pixelsToPercentage(newPositionInPixels), 0, 100);
69
+ requestAnimationFrame(() => (this.shouldAnimate = true));
70
+ },
69
71
  });
70
72
  };
71
73
  this.handleKeyDown = (event) => {
@@ -1 +1 @@
1
- {"version":3,"file":"split-pane.js","sourceRoot":"","sources":["../../../src/components/split-pane/split-pane.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,SAAS,EACT,KAAK,EACL,KAAK,EAGL,OAAO,EACP,IAAI,EACJ,CAAC,EACD,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,kBA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method,\n} from '@stencil/core';\nimport { drag } from '../../utils/drag';\nimport { clamp } from '../../utils/math';\nimport { debounce } from '../../utils/throttle';\n\n/**\n * Split panes display two adjacent panels, allowing the user to reposition them.\n *\n * @part start - The start panel.\n * @part end - The end panel.\n * @part panel - Targets both the start and end panels.\n * @part divider - The divider that separates the start and end panels.\n *\n * @slot start - The start panel.\n * @slot end - The end panel.\n * @slot handle - An optional handle to render at the center of the divider.\n */\n@Component({\n tag: 'nano-split-pane',\n styleUrl: 'split-pane.scss',\n shadow: true,\n})\nexport class SplitPane implements ComponentInterface {\n @Element() host: HTMLNanoSplitPaneElement;\n private cachedPositionInPixels: number;\n private ro: ResizeObserver;\n private isAnimating = false;\n private didLoad = false;\n\n private get size() {\n const { width, height } = this.host.getBoundingClientRect();\n return this.vertical ? height : width;\n }\n\n private get shouldAnimate() {\n return this.didLoad && this._shouldAnimate;\n }\n private set shouldAnimate(sa: boolean) {\n this._shouldAnimate = sa;\n }\n private _shouldAnimate: boolean = true;\n\n constructor() {\n this.handlePositionChange = debounce(\n this.handlePositionChange.bind(this),\n 100\n );\n }\n\n /**\n * The current position of the divider from the primary panel's edge\n * as a percentage 0-100. Defaults to 50% of the container's initial size.\n */\n @Prop()\n get position() {\n return this._position;\n }\n set position(pos: number) {\n // override too high / low\n pos = Math.min(Math.max(pos, 0), 100);\n if (isNaN(pos) || pos === this._position) return;\n\n if (\n this.shouldAnimate &&\n this.animationDuration > 0 &&\n !isNaN(this.position)\n ) {\n this.animatePosition(pos);\n return;\n }\n this._position = pos;\n }\n private _position: number;\n\n // eslint-disable-next-line @stencil-community/no-unused-watch\n @Watch('position')\n handlePositionChange() {\n this.cachedPositionInPixels = this.percentageToPixels(this.position);\n this.positionInPixels = this.percentageToPixels(this.position);\n this.nanoReposition.emit();\n }\n\n /**\n * The current position of the divider from the primary panel's edge in pixels.\n */\n @Prop({ mutable: true }) positionInPixels: number;\n\n @Watch('positionInPixels')\n handlePositionInPixelsChange() {\n this.position = this.pixelsToPercentage(this.positionInPixels);\n }\n\n /** Draws the split panel in a vertical orientation with the start and end panels stacked. */\n @Prop({ reflect: true }) vertical = false;\n\n /** Disables resizing. Note that the position may still change as a result of resizing the host element. */\n @Prop({ reflect: true }) disabled = false;\n\n /**\n * If no primary panel is designated, both panels will resize proportionally when the host element is resized. If a\n * primary panel is designated, it will maintain its size and the other panel will grow or shrink as needed when the\n * host element is resized.\n */\n @Prop() primary?: 'start' | 'end';\n\n /**\n * One or more space-separated values at which the divider should snap. Values can be in pixels or percentages, e.g.\n * `\"100px 50%\"`.\n */\n @Prop() snap?: string;\n\n /** How close the divider must be to a snap point until snapping occurs. */\n @Prop() snapThreshold = 12;\n\n /** When changing `position` via property, the pane will animate into position. Make `animationDuration` 0 to disable. */\n @Prop() animationDuration = 0.6;\n\n /** Emitted when the divider's position changes. */\n @Event() nanoReposition: EventEmitter;\n\n /** Emitted when the divider is being dragged. */\n @Event() nanoDragging: EventEmitter<number>;\n\n /** Utility to convert % to pixels */\n @Method()\n async getPercentageToPixels(value: number) {\n return this.percentageToPixels(value);\n }\n\n /** Utility to convert pixels to % (`position`) */\n @Method()\n async getPixelsToPercentage(value: number) {\n return this.pixelsToPercentage(value);\n }\n\n // Private logic\n\n private animatePosition(end: number) {\n if (this.isAnimating) return;\n\n const duration = this.animationDuration; // seconds\n const fps = 60;\n const start = this.position;\n const distance = end - start;\n\n let position = start;\n let time = 0;\n\n function easeInOutQuad(t: number, s: number, e: number, d: number) {\n if ((t /= d / 2) < 1) return (e / 2) * t * t + s;\n else return (-e / 2) * (--t * (t - 2) - 1) + s;\n }\n\n const go = () => {\n time += 1 / fps;\n position = easeInOutQuad(time, start, distance, duration);\n\n if (\n (end > start && position >= end) ||\n (end < start && position <= end)\n ) {\n this.position = end;\n this.shouldAnimate = true;\n this.isAnimating = false;\n return;\n }\n this.position = position;\n requestAnimationFrame(go);\n };\n\n this.shouldAnimate = false;\n this.isAnimating = true;\n requestAnimationFrame(go);\n }\n\n private percentageToPixels(value: number) {\n return this.size * (value / 100);\n }\n\n private pixelsToPercentage(value: number) {\n return (value / this.size) * 100;\n }\n\n private attachRO() {\n if (!window['ResizeObserver']) return;\n\n this.detachRO();\n this.ro = new ResizeObserver(() => this.handleResize());\n this.ro.observe(this.host);\n }\n\n private detachRO() {\n if (!this.ro) return;\n this.ro.unobserve(this.host);\n this.ro = undefined;\n }\n\n // Event handlers\n\n private handleDrag = (e: Event) => {\n if (this.disabled) {\n return;\n }\n\n // Prevent text selection when dragging\n e.preventDefault();\n\n drag(this.host, (x, y) => {\n let newPositionInPixels = this.vertical ? y : x;\n\n this.nanoDragging.emit(newPositionInPixels);\n\n // Flip for end panels\n if (this.primary === 'end') {\n newPositionInPixels = this.size - newPositionInPixels;\n }\n\n // Check snap points\n if (this.snap) {\n const snaps = this.snap.split(' ');\n\n snaps.forEach((value) => {\n let snapPoint: number;\n\n if (value.endsWith('%')) {\n snapPoint = this.size * (parseFloat(value) / 100);\n } else {\n snapPoint = parseFloat(value);\n }\n\n if (\n newPositionInPixels >= snapPoint - this.snapThreshold &&\n newPositionInPixels <= snapPoint + this.snapThreshold\n ) {\n newPositionInPixels = snapPoint;\n }\n });\n }\n this.shouldAnimate = false;\n this.position = clamp(\n this.pixelsToPercentage(newPositionInPixels),\n 0,\n 100\n );\n requestAnimationFrame(() => (this.shouldAnimate = true));\n });\n };\n\n private handleKeyDown = (event: KeyboardEvent) => {\n if (this.disabled) {\n return;\n }\n\n if (\n [\n 'ArrowLeft',\n 'ArrowRight',\n 'ArrowUp',\n 'ArrowDown',\n 'Home',\n 'End',\n ].includes(event.key)\n ) {\n let newPosition = this.position;\n const incr =\n (event.shiftKey ? 10 : 1) * (this.primary === 'end' ? -1 : 1);\n\n event.preventDefault();\n\n if (\n (event.key === 'ArrowLeft' && !this.vertical) ||\n (event.key === 'ArrowUp' && this.vertical)\n ) {\n newPosition -= incr;\n }\n\n if (\n (event.key === 'ArrowRight' && !this.vertical) ||\n (event.key === 'ArrowDown' && this.vertical)\n ) {\n newPosition += incr;\n }\n\n if (event.key === 'Home') {\n newPosition = this.primary === 'end' ? 100 : 0;\n }\n\n if (event.key === 'End') {\n newPosition = this.primary === 'end' ? 0 : 100;\n }\n\n this.shouldAnimate = false;\n\n this.position = clamp(newPosition, 0, 100);\n requestAnimationFrame(() => (this.shouldAnimate = true));\n }\n };\n\n private handleResize = () => {\n if (!this.didLoad || this.isAnimating) return;\n\n // Resize when a primary panel is set\n if (this.primary) {\n this.shouldAnimate = false;\n this.position = this.pixelsToPercentage(this.cachedPositionInPixels);\n requestAnimationFrame(() => (this.shouldAnimate = true));\n }\n };\n\n componentDidLoad(): void {\n if (this.positionInPixels) this.handlePositionInPixelsChange();\n setTimeout(() => (this.didLoad = true));\n }\n\n connectedCallback() {\n this.cachedPositionInPixels = this.percentageToPixels(this.position);\n this.attachRO();\n }\n\n disconnectedCallback() {\n this.detachRO();\n }\n\n componentDidRender(): void {\n // bit hacky ... because we use getter / setter for position, there's a render *before* `position` is passed in via attribute\n // if we set a default position in the class, this causes the divider to jump (from default to user set position)\n // so - wait a render, see if there's a position passed in via attribute, *then* set default if not\n requestAnimationFrame(() => {\n if (typeof this.position === 'undefined') {\n this.position = 50;\n }\n });\n }\n\n render() {\n if (typeof this.position === 'undefined') return;\n const styles: { gridTemplateRows?: string; gridTemplateColumns?: string } =\n {};\n const gridTemplate = this.vertical\n ? 'gridTemplateRows'\n : 'gridTemplateColumns';\n const primary = `\n clamp(\n 0%,\n clamp(\n var(--min),\n ${this.position}% - var(--divider-width) / 2,\n var(--max)\n ),\n calc(100% - var(--divider-width))\n )\n `;\n const secondary = 'auto';\n\n if (this.primary === 'end') {\n styles[gridTemplate] = `${secondary} var(--divider-width) ${primary}`;\n } else {\n styles[gridTemplate] = `${primary} var(--divider-width) ${secondary}`;\n }\n\n return (\n <Host style={styles}>\n <div part=\"panel start\" class=\"start\">\n <slot name=\"start\"></slot>\n </div>\n <div\n part=\"divider\"\n class=\"divider\"\n tabindex={this.disabled ? undefined : '0'}\n role=\"separator\"\n aria-label=\"Resize\"\n onKeyDown={this.handleKeyDown}\n onMouseDown={this.handleDrag}\n onTouchStart={this.handleDrag}\n >\n <slot name=\"handle\">\n {!this.disabled && this.vertical ? (\n <nano-icon slot=\"handle\" name=\"solid/grip-lines\" />\n ) : (\n <nano-icon slot=\"handle\" name=\"solid/grip-lines-vertical\" />\n )}\n </slot>\n </div>\n <div part=\"panel end\" class=\"end\">\n <slot name=\"end\"></slot>\n </div>\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"split-pane.js","sourceRoot":"","sources":["../../../src/components/split-pane/split-pane.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,SAAS,EACT,KAAK,EACL,KAAK,EAGL,OAAO,EACP,IAAI,EACJ,CAAC,EACD,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD;;;;;;;;;;;GAWG;AAMH,MAAM,OAAO,SAAS;EAOpB,IAAY,IAAI;IACd,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC;IAC5D,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;EACxC,CAAC;EAED,IAAY,aAAa;IACvB,OAAO,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,cAAc,CAAC;EAC7C,CAAC;EACD,IAAY,aAAa,CAAC,EAAW;IACnC,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;EAC3B,CAAC;EAGD;IAhBQ,gBAAW,GAAG,KAAK,CAAC;IACpB,YAAO,GAAG,KAAK,CAAC;IAahB,mBAAc,GAAY,IAAI,CAAC;IA6JvC,iBAAiB;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CAAC,CACF,iBAAW,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAC,2BAA2B,GAAG,CAC7D,CACI,CACH;MACN,WAAK,IAAI,EAAC,WAAW,EAAC,KAAK,EAAC,KAAK;QAC/B,YAAM,IAAI,EAAC,KAAK,GAAQ,CACpB,CACD,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Prop,\n Component,\n Watch,\n Event,\n EventEmitter,\n ComponentInterface,\n Element,\n Host,\n h,\n Method,\n} from '@stencil/core';\nimport { drag } from '../../utils/drag';\nimport { clamp } from '../../utils/math';\nimport { debounce } from '../../utils/throttle';\n\n/**\n * Split panes display two adjacent panels, allowing the user to reposition them.\n *\n * @part start - The start panel.\n * @part end - The end panel.\n * @part panel - Targets both the start and end panels.\n * @part divider - The divider that separates the start and end panels.\n *\n * @slot start - The start panel.\n * @slot end - The end panel.\n * @slot handle - An optional handle to render at the center of the divider.\n */\n@Component({\n tag: 'nano-split-pane',\n styleUrl: 'split-pane.scss',\n shadow: true,\n})\nexport class SplitPane implements ComponentInterface {\n @Element() host: HTMLNanoSplitPaneElement;\n private cachedPositionInPixels: number;\n private ro: ResizeObserver;\n private isAnimating = false;\n private didLoad = false;\n\n private get size() {\n const { width, height } = this.host.getBoundingClientRect();\n return this.vertical ? height : width;\n }\n\n private get shouldAnimate() {\n return this.didLoad && this._shouldAnimate;\n }\n private set shouldAnimate(sa: boolean) {\n this._shouldAnimate = sa;\n }\n private _shouldAnimate: boolean = true;\n\n constructor() {\n this.handlePositionChange = debounce(\n this.handlePositionChange.bind(this),\n 100\n );\n }\n\n /**\n * The current position of the divider from the primary panel's edge\n * as a percentage 0-100. Defaults to 50% of the container's initial size.\n */\n @Prop()\n get position() {\n return this._position;\n }\n set position(pos: number) {\n // override too high / low\n pos = Math.min(Math.max(pos, 0), 100);\n if (isNaN(pos) || pos === this._position) return;\n\n if (\n this.shouldAnimate &&\n this.animationDuration > 0 &&\n !isNaN(this.position)\n ) {\n this.animatePosition(pos);\n return;\n }\n this._position = pos;\n }\n private _position: number;\n\n // eslint-disable-next-line @stencil-community/no-unused-watch\n @Watch('position')\n handlePositionChange() {\n this.cachedPositionInPixels = this.percentageToPixels(this.position);\n this.positionInPixels = this.percentageToPixels(this.position);\n this.nanoReposition.emit();\n }\n\n /**\n * The current position of the divider from the primary panel's edge in pixels.\n */\n @Prop({ mutable: true }) positionInPixels: number;\n\n @Watch('positionInPixels')\n handlePositionInPixelsChange() {\n this.position = this.pixelsToPercentage(this.positionInPixels);\n }\n\n /** Draws the split panel in a vertical orientation with the start and end panels stacked. */\n @Prop({ reflect: true }) vertical = false;\n\n /** Disables resizing. Note that the position may still change as a result of resizing the host element. */\n @Prop({ reflect: true }) disabled = false;\n\n /**\n * If no primary panel is designated, both panels will resize proportionally when the host element is resized. If a\n * primary panel is designated, it will maintain its size and the other panel will grow or shrink as needed when the\n * host element is resized.\n */\n @Prop() primary?: 'start' | 'end';\n\n /**\n * One or more space-separated values at which the divider should snap. Values can be in pixels or percentages, e.g.\n * `\"100px 50%\"`.\n */\n @Prop() snap?: string;\n\n /** How close the divider must be to a snap point until snapping occurs. */\n @Prop() snapThreshold = 12;\n\n /** When changing `position` via property, the pane will animate into position. Make `animationDuration` 0 to disable. */\n @Prop() animationDuration = 0.6;\n\n /** Emitted when the divider's position changes. */\n @Event() nanoReposition: EventEmitter;\n\n /** Emitted when the divider is being dragged. */\n @Event() nanoDragging: EventEmitter<number>;\n\n /** Utility to convert % to pixels */\n @Method()\n async getPercentageToPixels(value: number) {\n return this.percentageToPixels(value);\n }\n\n /** Utility to convert pixels to % (`position`) */\n @Method()\n async getPixelsToPercentage(value: number) {\n return this.pixelsToPercentage(value);\n }\n\n // Private logic\n\n private animatePosition(end: number) {\n if (this.isAnimating) return;\n\n const duration = this.animationDuration; // seconds\n const fps = 60;\n const start = this.position;\n const distance = end - start;\n\n let position = start;\n let time = 0;\n\n function easeInOutQuad(t: number, s: number, e: number, d: number) {\n if ((t /= d / 2) < 1) return (e / 2) * t * t + s;\n else return (-e / 2) * (--t * (t - 2) - 1) + s;\n }\n\n const go = () => {\n time += 1 / fps;\n position = easeInOutQuad(time, start, distance, duration);\n\n if (\n (end > start && position >= end) ||\n (end < start && position <= end)\n ) {\n this.position = end;\n this.shouldAnimate = true;\n this.isAnimating = false;\n return;\n }\n this.position = position;\n requestAnimationFrame(go);\n };\n\n this.shouldAnimate = false;\n this.isAnimating = true;\n requestAnimationFrame(go);\n }\n\n private percentageToPixels(value: number) {\n return this.size * (value / 100);\n }\n\n private pixelsToPercentage(value: number) {\n return (value / this.size) * 100;\n }\n\n private attachRO() {\n if (!window['ResizeObserver']) return;\n\n this.detachRO();\n this.ro = new ResizeObserver(() => this.handleResize());\n this.ro.observe(this.host);\n }\n\n private detachRO() {\n if (!this.ro) return;\n this.ro.unobserve(this.host);\n this.ro = undefined;\n }\n\n // Event handlers\n\n private handleDrag = (e: Event) => {\n if (this.disabled) {\n return;\n }\n\n // Prevent text selection when dragging\n e.preventDefault();\n\n drag(this.host, {\n onMove: (x, y) => {\n let newPositionInPixels = this.vertical ? y : x;\n\n this.nanoDragging.emit(newPositionInPixels);\n\n // Flip for end panels\n if (this.primary === 'end') {\n newPositionInPixels = this.size - newPositionInPixels;\n }\n\n // Check snap points\n if (this.snap) {\n const snaps = this.snap.split(' ');\n\n snaps.forEach((value) => {\n let snapPoint: number;\n\n if (value.endsWith('%')) {\n snapPoint = this.size * (parseFloat(value) / 100);\n } else {\n snapPoint = parseFloat(value);\n }\n\n if (\n newPositionInPixels >= snapPoint - this.snapThreshold &&\n newPositionInPixels <= snapPoint + this.snapThreshold\n ) {\n newPositionInPixels = snapPoint;\n }\n });\n }\n this.shouldAnimate = false;\n this.position = clamp(\n this.pixelsToPercentage(newPositionInPixels),\n 0,\n 100\n );\n requestAnimationFrame(() => (this.shouldAnimate = true));\n },\n });\n };\n\n private handleKeyDown = (event: KeyboardEvent) => {\n if (this.disabled) {\n return;\n }\n\n if (\n [\n 'ArrowLeft',\n 'ArrowRight',\n 'ArrowUp',\n 'ArrowDown',\n 'Home',\n 'End',\n ].includes(event.key)\n ) {\n let newPosition = this.position;\n const incr =\n (event.shiftKey ? 10 : 1) * (this.primary === 'end' ? -1 : 1);\n\n event.preventDefault();\n\n if (\n (event.key === 'ArrowLeft' && !this.vertical) ||\n (event.key === 'ArrowUp' && this.vertical)\n ) {\n newPosition -= incr;\n }\n\n if (\n (event.key === 'ArrowRight' && !this.vertical) ||\n (event.key === 'ArrowDown' && this.vertical)\n ) {\n newPosition += incr;\n }\n\n if (event.key === 'Home') {\n newPosition = this.primary === 'end' ? 100 : 0;\n }\n\n if (event.key === 'End') {\n newPosition = this.primary === 'end' ? 0 : 100;\n }\n\n this.shouldAnimate = false;\n\n this.position = clamp(newPosition, 0, 100);\n requestAnimationFrame(() => (this.shouldAnimate = true));\n }\n };\n\n private handleResize = () => {\n if (!this.didLoad || this.isAnimating) return;\n\n // Resize when a primary panel is set\n if (this.primary) {\n this.shouldAnimate = false;\n this.position = this.pixelsToPercentage(this.cachedPositionInPixels);\n requestAnimationFrame(() => (this.shouldAnimate = true));\n }\n };\n\n componentDidLoad(): void {\n if (this.positionInPixels) this.handlePositionInPixelsChange();\n setTimeout(() => (this.didLoad = true));\n }\n\n connectedCallback() {\n this.cachedPositionInPixels = this.percentageToPixels(this.position);\n this.attachRO();\n }\n\n disconnectedCallback() {\n this.detachRO();\n }\n\n componentDidRender(): void {\n // bit hacky ... because we use getter / setter for position, there's a render *before* `position` is passed in via attribute\n // if we set a default position in the class, this causes the divider to jump (from default to user set position)\n // so - wait a render, see if there's a position passed in via attribute, *then* set default if not\n requestAnimationFrame(() => {\n if (typeof this.position === 'undefined') {\n this.position = 50;\n }\n });\n }\n\n render() {\n if (typeof this.position === 'undefined') return;\n const styles: { gridTemplateRows?: string; gridTemplateColumns?: string } =\n {};\n const gridTemplate = this.vertical\n ? 'gridTemplateRows'\n : 'gridTemplateColumns';\n const primary = `\n clamp(\n 0%,\n clamp(\n var(--min),\n ${this.position}% - var(--divider-width) / 2,\n var(--max)\n ),\n calc(100% - var(--divider-width))\n )\n `;\n const secondary = 'auto';\n\n if (this.primary === 'end') {\n styles[gridTemplate] = `${secondary} var(--divider-width) ${primary}`;\n } else {\n styles[gridTemplate] = `${primary} var(--divider-width) ${secondary}`;\n }\n\n return (\n <Host style={styles}>\n <div part=\"panel start\" class=\"start\">\n <slot name=\"start\"></slot>\n </div>\n <div\n part=\"divider\"\n class=\"divider\"\n tabindex={this.disabled ? undefined : '0'}\n role=\"separator\"\n aria-label=\"Resize\"\n onKeyDown={this.handleKeyDown}\n onMouseDown={this.handleDrag}\n onTouchStart={this.handleDrag}\n >\n <slot name=\"handle\">\n {!this.disabled && this.vertical ? (\n <nano-icon slot=\"handle\" name=\"solid/grip-lines\" />\n ) : (\n <nano-icon slot=\"handle\" name=\"solid/grip-lines-vertical\" />\n )}\n </slot>\n </div>\n <div part=\"panel end\" class=\"end\">\n <slot name=\"end\"></slot>\n </div>\n </Host>\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"table-interface.js","sourceRoot":"","sources":["../../../src/components/table/table-interface.ts"],"names":[],"mappings":"","sourcesContent":["import type { JSXBase } from '@stencil/core/internal';\nimport type { VNode, FunctionalComponent } from '@stencil/core';\n\nexport declare namespace TableTypes {\n /** The column property */\n type ColumnProp = string | number;\n\n /** Possible positions. Horizontally means l/r. Vertically means top/bottom */\n type Position = 'start' | 'end' | 'top' | 'bottom';\n\n /** A function to assess whether a rendered row will be pinned to the top or bottom */\n type PinFunc = (props?: RowDataSchemaModel) => Position;\n\n /** Function called, via intersection observer, when an element's pinned status changes */\n type PinnedCb = (positions: { [key in Position]?: boolean }) => void;\n\n /** Potential column ordering options */\n type Order = 'asc' | 'desc' | undefined;\n\n /** Column filtering */\n interface Filter {\n prop: TableTypes.Prop;\n filter: string | boolean;\n }\n\n /** Column sorting */\n interface Sort {\n prop: TableTypes.Prop;\n order: TableTypes.Order;\n }\n\n /** Potential html properties which can be passed to a cell or column */\n type CellProps = JSXBase.ThHTMLAttributes<HTMLTableCellElement>;\n\n /** Potential html properties which can be passed to a row */\n type RowProps = JSXBase.HTMLAttributes<HTMLTableRowElement>;\n\n /** data model passed to cell rendering functions */\n interface RenderModel<T = RowGeneric> {\n /** The column property being iterated over */\n prop: keyof T;\n /** The data for this cell */\n cellModel: any;\n /** The column config object */\n column: ColumnConfig<T>;\n /** The row index currently being iterated over */\n rowIndex: number;\n /** The row model currently being iterated over */\n rowModel: RowData<T>;\n }\n\n /** data model passed to row rendering functions */\n interface RowDataSchemaModel<T = RowGeneric> {\n /** the current data row model being iterated over */\n rowModel?: RowData<T>;\n /** the current data row index */\n rowIndex?: number;\n /** The row being rendered. You *must* nest this in your render function otherwise it will not be shown */\n renderedRow?: VNode;\n }\n\n /** A JSX `createElement` function passed to rendering functions.\n * You can use this to create markup outside of JSX environments\n * e.g. https://reactjs.org/docs/react-without-jsx.html */\n interface HFunc<T> {\n (tag: any): T;\n }\n interface HFunc<T> {\n (tag: any, data: any): T;\n }\n interface HFunc<T> {\n (tag: any, text: string): T;\n }\n interface HFunc<T> {\n (sel: any, children: Array<T | undefined | null>): T;\n }\n interface HFunc<T> {\n (sel: any, data: any, text: string): T;\n }\n interface HFunc<T> {\n (sel: any, data: any, children: Array<T | undefined | null>): T;\n }\n interface HFunc<T> {\n (sel: any, data: any, children: T): T;\n }\n\n /**\n * A row render function, called during a any row's render to the dom.\n * It can be used to add extra markup around any given table row\n **/\n type RowTemplateFunc<T, P> = (\n /** use this to create markup outside of JSX environments\n * e.g. https://reactjs.org/docs/react-without-jsx.html */\n createElement: HFunc<T>,\n /** data passed to each template */\n props: RowDataSchemaModel<P>,\n /** a helper template to minimise boilerplate.\n * A shortcut for `<td><div class=\"nano-tbl__cell-content\"></div></td>` */\n TableCell: FunctionalComponent<{ header?: boolean }>\n ) => T | undefined;\n\n /**\n * A cell render function, called during any cell's render to the dom.\n * It can be used to add any markup within a table cell.\n */\n type CellTemplateFunc<T, P> = (\n createElement: HFunc<T>,\n props: RenderModel<P>\n ) => T | string | undefined;\n\n /**\n * A table header render function, called during any column's render to the dom.\n * It can be used to add any markup within a table header `th`.\n */\n type ColumnTemplateFunc<T, P> = (\n createElement: HFunc<T>,\n col: ColumnConfig<P>\n ) => T | string | undefined;\n\n /** A function used to assess the order of any given column.\n * e.g. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort\n */\n type ColSortComparator = (\n prop: keyof RowData,\n order: Order\n ) => (a: RowData, b: RowData) => number;\n\n /** A function which can be used to apply any html attribute/s onto a table cell `td` */\n type PropertiesFunc = (props: RenderModel) => CellProps | void | undefined;\n\n /** A function which can be used to apply any html attribute/s onto a table head `th` */\n type ColPropertiesFunc<T> = (\n props: ColumnConfig<T>\n ) => CellProps | void | undefined;\n\n /** A function which can be used to apply any html attribute/s onto a table row `tr` */\n type RowPropertiesFunc<T> = (\n props: RowDataSchemaModel<T>\n ) => RowProps | void | undefined;\n\n type RowGeneric = { [key: string | number]: any };\n\n /** An individual table cell's data */\n type RowData<T = RowGeneric> = T & {\n __uuid?: string | number;\n __index?: number;\n };\n\n /** A data property */\n type Prop = keyof RowData;\n\n /** Valid column data types */\n type ColumnType =\n | 'text'\n | 'string'\n | 'number'\n | 'date'\n | 'boolean'\n | 'unknown';\n\n /**\n * A table column's configuration\n */\n interface ColumnConfig<T = RowData> {\n /** The title of the column. Displayed in the table header `th` */\n title: string;\n /** The row's data property to retrieve per cell render */\n prop: keyof T;\n /** The type of data. Will affect how it is sorted and the available\n * filter operations ('text' uses browser locale to compare).\n * If none supplied, it will be derived by default using the first row of data retrieved. */\n type?: ColumnType;\n /** Whether this column is horizontally pinned to viewport */\n pinned?: Position;\n /** By default cell content too wide for the cell will not wrap,\n * but rather be trimmed with '...'.\n * *Note* 'wrap' is mutually-exclusive from `autoTooltip` */\n wrap?: boolean;\n /** Setting this to true, will automatically watch content that\n * doesn't fit and duplicate it to show in a tooltip.\n * *Note* 'autoTooltip' is mutually-exclusive from `wrap` */\n autoTooltip?: boolean;\n /** Whether this column is a row header; the cell will render a `th` not a `td` */\n rowHeader?: boolean;\n /** Whether this column can be sorted. Defaults to true */\n sortable?: boolean;\n /** Current order of this column */\n order?: Order;\n /** Whether to include this column when doing a general search. Defaults to true */\n searchable?: boolean;\n /** Current filters applied to this column */\n filter?: string | boolean;\n /** Whether this column can be dragged to change column order */\n draggable?: boolean;\n /**\n * A cell render function, called during any cell's render to the dom.\n * It can be used to add any markup within a table cell.\n */\n cellTemplate?: CellTemplateFunc<VNode | VNode[], T>;\n /** A function which can be used to apply any html attribute/s onto a table cell `td` */\n cellProperties?: PropertiesFunc;\n /**\n * A table header render function, called during any column's render to the dom.\n * It can be used to add any markup within a table header `th`.\n */\n columnTemplate?: ColumnTemplateFunc<VNode | VNode[], T>;\n /** A function which can be used to apply any html attribute/s onto a table head `th` */\n columnProperties?: ColPropertiesFunc<T>;\n /** A custom sorting comparator function - assess the order of any given column.\n * e.g. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort */\n sortCompareFn?: ColSortComparator | string;\n }\n\n /**\n * Row renderer property. Called during the rendering of any table row\n * controlling it's visual state.\n */\n interface RowRenderer<T = RowData> {\n /** Function to decide whether the row is vertically pinned. */\n pinned?: PinFunc;\n /**\n * A row render function, called during a any row's render to the dom.\n * It can be used to add extra markup around any given table row\n **/\n template?: RowTemplateFunc<VNode | VNode[], T>;\n /** A function which can be used to apply any html attribute/s onto a table row `tr` */\n rowProperties?: RowPropertiesFunc<T>;\n }\n\n /**\n * Row renderer property. Called during the rendering of a tables head and foot\n * controlling their visual state.\n */\n interface HeadFootRenderer<T = RowData> {\n /** Function to decide whether the row is vertically pinned. Defaults to `start` for the header and `end` the footer */\n pinned: Position;\n /**\n * A row render function, called during a any row's render to the dom.\n * It can be used to add extra markup around any given table row.\n * If used, and you want to see the rendered row, you *must* nest it within your\n * jsx function e.g. `(h, props) => { return [props.renderedRow, <tr><td>Custom thing</td></tr>]}`\n **/\n template?: RowTemplateFunc<VNode | VNode[], T>;\n /** A function which can be used to apply any html attribute/s onto a table row `tr` */\n rowProperties?: () => RowProps | void | undefined;\n }\n\n type TBody = {\n rows: TableTypes.NanoTable['rows'];\n __uuid: string | number;\n };\n\n class NanoTable<T = RowGeneric> {\n rows: T[];\n columns: ColumnConfig<T>[];\n rowRender: RowRenderer<T>;\n headRender: HeadFootRenderer<T>;\n footRender: HeadFootRenderer<T>;\n }\n\n type Falsy = false | 0 | '' | null | undefined;\n}\n"]}
1
+ {"version":3,"file":"table-interface.js","sourceRoot":"","sources":["../../../src/components/table/table-interface.ts"],"names":[],"mappings":"","sourcesContent":["import type { JSXBase } from '@stencil/core/internal';\nimport type { VNode, FunctionalComponent } from '@stencil/core';\n\nexport declare namespace TableTypes {\n /** The column property */\n type ColumnProp = string | number;\n\n /** Possible positions. Horizontally means l/r. Vertically means top/bottom */\n type Position = 'start' | 'end' | 'top' | 'bottom';\n\n /** A function to assess whether a rendered row will be pinned to the top or bottom */\n type PinFunc = (props?: RowDataSchemaModel) => Position;\n\n /** Function called, via intersection observer, when an element's pinned status changes */\n type PinnedCb = (positions: { [key in Position]?: boolean }) => void;\n\n /** Potential column ordering options */\n type Order = 'asc' | 'desc' | undefined;\n\n /** Column filtering */\n interface Filter {\n prop: TableTypes.Prop;\n filter: string | boolean;\n }\n\n /** Column sorting */\n interface Sort {\n prop: TableTypes.Prop;\n order: TableTypes.Order;\n }\n\n /** Potential html properties which can be passed to a cell or column */\n type CellProps = JSXBase.ThHTMLAttributes<HTMLTableCellElement>;\n\n /** Potential html properties which can be passed to a row */\n type RowProps = JSXBase.HTMLAttributes<HTMLTableRowElement>;\n\n /** data model passed to cell rendering functions */\n interface RenderModel<T = RowGeneric> {\n /** The column property being iterated over */\n prop: keyof T;\n /** The data for this cell */\n cellModel: any;\n /** The column config object */\n column: ColumnConfig<T>;\n /** The row index currently being iterated over */\n rowIndex: number;\n /** The row model currently being iterated over */\n rowModel: RowData<T>;\n }\n\n /** data model passed to row rendering functions */\n interface RowDataSchemaModel<T = RowGeneric> {\n /** the current data row model being iterated over */\n rowModel?: RowData<T>;\n /** the current data row index */\n rowIndex?: number;\n /** The row being rendered. You *must* nest this in your render function otherwise it will not be shown */\n renderedRow?: VNode;\n }\n\n /** A JSX `createElement` function passed to rendering functions.\n * You can use this to create markup outside of JSX environments\n * e.g. https://reactjs.org/docs/react-without-jsx.html */\n interface HFunc<T> {\n (tag: any): T;\n }\n interface HFunc<T> {\n (tag: any, data: any): T;\n }\n interface HFunc<T> {\n (tag: any, text: string): T;\n }\n interface HFunc<T> {\n (sel: any, children: Array<T | undefined | null>): T;\n }\n interface HFunc<T> {\n (sel: any, data: any, text: string): T;\n }\n interface HFunc<T> {\n (sel: any, data: any, children: Array<T | undefined | null>): T;\n }\n interface HFunc<T> {\n (sel: any, data: any, children: T): T;\n }\n\n /**\n * A row render function, called during a any row's render to the dom.\n * It can be used to add extra markup around any given table row\n **/\n type RowTemplateFunc<T, P> = (\n /** use this to create markup outside of JSX environments\n * e.g. https://reactjs.org/docs/react-without-jsx.html */\n createElement: HFunc<T>,\n /** data passed to each template */\n props: RowDataSchemaModel<P>,\n /** a helper template to minimise boilerplate.\n * A shortcut for `<td><div class=\"nano-tbl__cell-content\"></div></td>` */\n TableCell: FunctionalComponent<{ header?: boolean }>\n ) => T | undefined;\n\n /**\n * A cell render function, called during any cell's render to the dom.\n * It can be used to add any markup within a table cell.\n */\n type CellTemplateFunc<T, P> = (\n createElement: HFunc<T>,\n props: RenderModel<P>\n ) => T | string | undefined;\n\n /**\n * A table header render function, called during any column's render to the dom.\n * It can be used to add any markup within a table header `th`.\n */\n type ColumnTemplateFunc<T, P> = (\n createElement: HFunc<T>,\n col: ColumnConfig<P>\n ) => T | string | undefined;\n\n /** A function used to assess the order of any given column.\n * e.g. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort\n */\n type ColSortComparator = (\n prop: keyof RowData,\n order: Order\n ) => (a: RowData, b: RowData) => number;\n\n /** A function which can be used to apply any html attribute/s onto a table cell `td` */\n type PropertiesFunc = (props: RenderModel) => CellProps | void | undefined;\n\n /** A function which can be used to apply any html attribute/s onto a table head `th` */\n type ColPropertiesFunc<T> = (\n props: ColumnConfig<T>\n ) => CellProps | void | undefined;\n\n /** A function which can be used to apply any html attribute/s onto a table row `tr` */\n type RowPropertiesFunc<T> = (\n props: RowDataSchemaModel<T>\n ) => RowProps | void | undefined;\n\n type RowGeneric = { [key: string | number]: any };\n\n /** An individual table cell's data */\n type RowData<T = RowGeneric> = T & {\n __uuid?: string | number;\n __index?: number;\n };\n\n /** A data property */\n type Prop = keyof RowData;\n\n /** Valid column data types */\n type ColumnType =\n | 'text'\n | 'string'\n | 'number'\n | 'date'\n | 'boolean'\n | 'unknown';\n\n /**\n * A table column's configuration\n */\n interface ColumnConfig<T = RowData> {\n /** The title of the column. Displayed in the table header `th` */\n title?: string;\n /** The row's data property to retrieve per cell render */\n prop?: keyof T;\n /** The type of data. Will affect how it is sorted and the available\n * filter operations ('text' uses browser locale to compare).\n * If none supplied, it will be derived by default using the first row of data retrieved. */\n type?: ColumnType;\n /** Whether this column is horizontally pinned to viewport */\n pinned?: Position;\n /** By default cell content too wide for the cell will not wrap,\n * but rather be trimmed with '...'.\n * *Note* 'wrap' is mutually-exclusive from `autoTooltip` */\n wrap?: boolean;\n /** Setting this to true, will automatically watch content that\n * doesn't fit and duplicate it to show in a tooltip.\n * *Note* 'autoTooltip' is mutually-exclusive from `wrap` */\n autoTooltip?: boolean;\n /** Whether this column is a row header; the cell will render a `th` not a `td` */\n rowHeader?: boolean;\n /** Whether this column can be sorted. Defaults to true */\n sortable?: boolean;\n /** Current order of this column */\n order?: Order;\n /** Whether to include this column when doing a general search. Defaults to true */\n searchable?: boolean;\n /** Current filters applied to this column */\n filter?: string | boolean;\n /**\n * A cell render function, called during any cell's render to the dom.\n * It can be used to add any markup within a table cell.\n */\n cellTemplate?: CellTemplateFunc<VNode | VNode[], T>;\n /** A function which can be used to apply any html attribute/s onto a table cell `td` */\n cellProperties?: PropertiesFunc;\n /**\n * A table header render function, called during any column's render to the dom.\n * It can be used to add any markup within a table header `th`.\n */\n columnTemplate?: ColumnTemplateFunc<VNode | VNode[], T>;\n /** A function which can be used to apply any html attribute/s onto a table head `th` */\n columnProperties?: ColPropertiesFunc<T>;\n /** A custom sorting comparator function - assess the order of any given column.\n * e.g. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort */\n sortCompareFn?: ColSortComparator | string;\n }\n\n /**\n * Row renderer property. Called during the rendering of any table row\n * controlling it's visual state.\n */\n interface RowRenderer<T = RowData> {\n /** Function to decide whether the row is vertically pinned. */\n pinned?: PinFunc;\n /**\n * A row render function, called during a any row's render to the dom.\n * It can be used to add extra markup around any given table row\n **/\n template?: RowTemplateFunc<VNode | VNode[], T>;\n /** A function which can be used to apply any html attribute/s onto a table row `tr` */\n rowProperties?: RowPropertiesFunc<T>;\n }\n\n /**\n * Row renderer property. Called during the rendering of a tables head and foot\n * controlling their visual state.\n */\n interface HeadFootRenderer<T = RowData> {\n /** Function to decide whether the row is vertically pinned. Defaults to `start` for the header and `end` the footer */\n pinned: Position;\n /**\n * A row render function, called during a any row's render to the dom.\n * It can be used to add extra markup around any given table row.\n * If used, and you want to see the rendered row, you *must* nest it within your\n * jsx function e.g. `(h, props) => { return [props.renderedRow, <tr><td>Custom thing</td></tr>]}`\n **/\n template?: RowTemplateFunc<VNode | VNode[], T>;\n /** A function which can be used to apply any html attribute/s onto a table row `tr` */\n rowProperties?: () => RowProps | void | undefined;\n }\n\n type TBody = {\n rows: TableTypes.NanoTable['rows'];\n __uuid: string | number;\n };\n\n class NanoTable<T = RowGeneric> {\n rows: T[];\n columns: ColumnConfig<T>[];\n rowRender: RowRenderer<T>;\n headRender: HeadFootRenderer<T>;\n footRender: HeadFootRenderer<T>;\n }\n\n type Falsy = false | 0 | '' | null | undefined;\n}\n"]}
@@ -128,43 +128,6 @@ nano-table {
128
128
  -webkit-border-end: var(--border-style);
129
129
  border-inline-end: var(--border-style);
130
130
  }
131
- .nano-tbl__drag-mask {
132
- display: none;
133
- position: absolute;
134
- inset-block: -2px -2px;
135
- z-index: 10;
136
- opacity: 0;
137
- transition: 0.2s ease opacity;
138
- }
139
- .nano-tbl__drag-mask--start {
140
- width: calc(50% + 2px);
141
- inset-inline-start: -2px;
142
- -webkit-border-start: 2px dashed var(--border-tint-color);
143
- border-inline-start: 2px dashed var(--border-tint-color);
144
- }
145
- .nano-tbl__drag-mask--end {
146
- width: 50%;
147
- inset-inline-end: 0;
148
- -webkit-border-end: 2px dashed var(--border-tint-color);
149
- border-inline-end: 2px dashed var(--border-tint-color);
150
- }
151
- .nano-tbl__drag-mask--active {
152
- opacity: 1;
153
- }
154
- .nano-tbl__dragging .nano-tbl__drag-mask {
155
- display: block;
156
- }
157
- .nano-tbl__drag--start {
158
- opacity: 0.4;
159
- }
160
- .nano-tbl__dragging .nano-tbl__td,
161
- .nano-tbl__dragging .nano-tbl__th {
162
- cursor: no-drop;
163
- }
164
- .nano-tbl__dragging .nano-tbl__td .nano-tbl__cell-content,
165
- .nano-tbl__dragging .nano-tbl__th .nano-tbl__cell-content {
166
- pointer-events: none;
167
- }
168
131
  .nano-tbl__order-btn {
169
132
  padding: 0;
170
133
  border: none;
@@ -179,6 +142,10 @@ nano-table {
179
142
  align-items: center;
180
143
  width: 100%;
181
144
  }
145
+ .nano-tbl__order-btn:focus-visible {
146
+ outline: none;
147
+ box-shadow: var(--nano-control-focus-shadow, 0 0 0 0.1875rem var(--nano-control-focus-color, rgba(144, 198, 231, 0.8))) inset;
148
+ }
182
149
  .nano-tbl__status-icons {
183
150
  margin-inline: auto 10px;
184
151
  display: flex;
@@ -251,12 +218,19 @@ thead .nano-tbl__td, thead .nano-tbl__th {
251
218
  font-size: var(--thead-font-size);
252
219
  -webkit-border-before: none !important;
253
220
  border-block-start: none !important;
254
- transition: all 0.2s ease;
255
221
  }
256
222
  thead .nano-tbl__td .nano-tbl__cell-content, thead .nano-tbl__th .nano-tbl__cell-content {
257
223
  padding-block: var(--head-th-padding-v);
258
224
  padding-inline: var(--head-th-padding-h);
259
225
  }
226
+ thead .nano-tbl__td .nano-sortable__keyboard-handle, thead .nano-tbl__th .nano-sortable__keyboard-handle {
227
+ position: absolute;
228
+ inset-inline-end: 5px;
229
+ inset-block-start: 50%;
230
+ transform: translateY(-50%);
231
+ background: white;
232
+ z-index: 10;
233
+ }
260
234
  tfoot .nano-tbl__td, tfoot .nano-tbl__th {
261
235
  color: var(--tfoot-color);
262
236
  font-weight: 800;
@@ -295,6 +269,12 @@ tfoot .nano-tbl__td .nano-tbl__cell-content, tfoot .nano-tbl__th .nano-tbl__cell
295
269
  .nano-tbl tbody.nano-tbl__inactive {
296
270
  opacity: 0;
297
271
  }
272
+ .nano-tbl tbody .nano-tbl__tr:has(~ .nano-tbl__tr--placeholder) {
273
+ display: none;
274
+ }
275
+ .nano-tbl tbody .nano-tbl__tr--placeholder ~ .nano-tbl__tr {
276
+ display: none;
277
+ }
298
278
  .nano-tbl th[scope=row] {
299
279
  font-weight: 800;
300
280
  margin: 0;
@@ -3,75 +3,8 @@
3
3
  */
4
4
  import { Fragment, h } from '@stencil/core';
5
5
  import { CSSNAMESPACE } from './table.constants';
6
- import { addHObserver, addVObserver, colheadFootRender, fetchStores, headerPinClasses, mergeProperties, } from './table.utils';
7
- // TABLE HEADERS
8
- // (thead > tr > th, tfoot > tr > th)
9
- let draggingCol;
10
- let draggingColEle;
11
- let dragEnterEle;
12
- let draggingParent;
13
- export const TableColHead = ({ column, headRenderer, onColumnSortClick, onColumnPinned, onColumnDrag, onColumnDrop, defaults, }) => {
14
- const store = fetchStores();
15
- // Drag to re-order columns handling
16
- function handleDragStart(e, column) {
17
- draggingCol = column;
18
- draggingColEle = dragEnterEle = e.target;
19
- draggingParent = draggingColEle.closest('.' + `${CSSNAMESPACE}__tr`);
20
- draggingParent.classList.add(`${CSSNAMESPACE}__dragging`);
21
- draggingColEle.classList.add(`${CSSNAMESPACE}__drag--start`);
22
- e.dataTransfer.effectAllowed = 'move';
23
- e.dataTransfer.setData('text/html', draggingColEle.innerHTML);
24
- onColumnDrag(column.prop, draggingColEle);
25
- }
26
- function handleDragEnd() {
27
- draggingParent.classList.remove(`${CSSNAMESPACE}__dragging`);
28
- draggingColEle.classList.remove(`${CSSNAMESPACE}__drag--start`);
29
- draggingParent
30
- .querySelectorAll(`.${CSSNAMESPACE}__drag-mask--active`)
31
- .forEach((el) => {
32
- el.classList.remove(`${CSSNAMESPACE}__drag-mask--active`);
33
- });
34
- draggingColEle = null;
35
- draggingCol = null;
36
- draggingParent = null;
37
- dragEnterEle = null;
38
- }
39
- function handleDragEnter(e) {
40
- if (dragEnterEle === e.target)
41
- return;
42
- e.preventDefault();
43
- e.stopImmediatePropagation();
44
- e.dataTransfer.dropEffect = 'move';
45
- draggingParent
46
- .querySelectorAll(`.${CSSNAMESPACE}__drag-mask--active`)
47
- .forEach((el) => {
48
- el.classList.remove(`${CSSNAMESPACE}__drag-mask--active`);
49
- });
50
- dragEnterEle = e.target;
51
- if (!dragEnterEle.classList.contains(`${CSSNAMESPACE}__drag-mask`)) {
52
- e.dataTransfer.dropEffect = 'none';
53
- return;
54
- }
55
- dragEnterEle.classList.add(`${CSSNAMESPACE}__drag-mask--active`);
56
- }
57
- function handleDrop(e) {
58
- e.stopPropagation();
59
- const { colName } = this.dataset;
60
- if (colName === draggingCol.prop)
61
- return;
62
- const cols = store.config.state.columns;
63
- let toIndex = cols.findIndex((col) => col.prop === colName);
64
- const fromIndex = cols.findIndex((col) => col === draggingCol);
65
- if (toIndex < fromIndex &&
66
- this.classList.contains(`${CSSNAMESPACE}__drag-mask--end`))
67
- toIndex++;
68
- if (toIndex > fromIndex &&
69
- this.classList.contains(`${CSSNAMESPACE}__drag-mask--start`))
70
- toIndex--;
71
- if (toIndex === fromIndex)
72
- return;
73
- onColumnDrop(draggingCol.prop, store.config.state.columns[toIndex].prop, draggingColEle);
74
- }
6
+ import { addHObserver, addVObserver, colheadFootRender, headerPinClasses, mergeProperties, } from './table.utils';
7
+ export const TableColHead = ({ column, headRenderer, onColumnSortClick, onColumnPinned, defaults, }) => {
75
8
  // Sort handling
76
9
  function handleColumnSortClick(e) {
77
10
  let order;
@@ -91,10 +24,6 @@ export const TableColHead = ({ column, headRenderer, onColumnSortClick, onColumn
91
24
  return ((!!defaults.sortable && column.sortable !== false) ||
92
25
  (!defaults.sortable && column.sortable === true));
93
26
  }
94
- function isDraggable() {
95
- return ((!!defaults.draggable && column.draggable !== false) ||
96
- (!defaults.draggable && column.draggable === true));
97
- }
98
27
  let extraProps = {};
99
28
  if (column.columnProperties) {
100
29
  extraProps = column.columnProperties(column) || extraProps;
@@ -117,24 +46,12 @@ export const TableColHead = ({ column, headRenderer, onColumnSortClick, onColumn
117
46
  : 'none';
118
47
  props = Object.assign(Object.assign({}, props), { 'aria-sort': sort });
119
48
  }
120
- if (isDraggable()) {
121
- props = Object.assign(Object.assign({}, props), { draggable: true, onDragStart: (e) => handleDragStart(e, column), onDragOver: (e) => e.preventDefault(), onDragEnd: () => handleDragEnd() });
122
- }
123
49
  return (h("th", Object.assign({}, props, { ref: (th) => {
124
50
  if (['end', 'start'].includes(column.pinned))
125
51
  addHObserver(th, column.pinned, onColumnPinned);
126
52
  if (['top', 'bottom'].includes(headRenderer.pinned))
127
53
  addVObserver(th, headRenderer.pinned, onColumnPinned);
128
- }, key: column.prop }), isDraggable() && [
129
- h("div", { class: {
130
- [`${CSSNAMESPACE}__drag-mask`]: true,
131
- [`${CSSNAMESPACE}__drag-mask--start`]: true,
132
- }, "data-col-name": column.prop, onDragEnter: handleDragEnter, onDrop: handleDrop, onDragOver: (e) => e.preventDefault() }),
133
- h("div", { class: {
134
- [`${CSSNAMESPACE}__drag-mask`]: true,
135
- [`${CSSNAMESPACE}__drag-mask--end`]: true,
136
- }, "data-col-name": column.prop, onDragEnter: handleDragEnter, onDrop: handleDrop, onDragOver: (e) => e.preventDefault() }),
137
- ], isSortable() ? (h("button", { class: {
54
+ }, key: column.prop }), isSortable() ? (h("button", { class: {
138
55
  [`${CSSNAMESPACE}__order-btn`]: true,
139
56
  [`${CSSNAMESPACE}__cell-content`]: true,
140
57
  }, onClick: handleColumnSortClick }, colheadFootRender(column), column.filter !== undefined && column.filter !== null && (h("nano-icon", { name: "light/filter" })), !!column.order &&
@@ -1 +1 @@
1
- {"version":3,"file":"table.header.js","sourceRoot":"","sources":["../../../src/components/table/table.header.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAuB,CAAC,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,eAAe,GAChB,MAAM,eAAe,CAAC;AAGvB,gBAAgB;AAChB,qCAAqC;AAErC,IAAI,WAAoC,CAAC;AACzC,IAAI,cAAoC,CAAC;AACzC,IAAI,YAAyB,CAAC;AAC9B,IAAI,cAAmC,CAAC;AAoBxC,MAAM,CAAC,MAAM,YAAY,GAA2C,CAAC,EACnE,MAAM,EACN,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,QAAQ,GACT,EAAE,EAAE;EACH,MAAM,KAAK,GAAG,WAAW,EAAE,CAAC;EAE5B,oCAAoC;EAEpC,SAAS,eAA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CACd,cACE,KAAK,EAAE;QACL,CAAC,GAAG,YAAY,aAAa,CAAC,EAAE,IAAI;QACpC,CAAC,GAAG,YAAY,gBAAgB,CAAC,EAAE,IAAI;OACxC,EACD,OAAO,EAAE,qBAAqB;MAE7B,iBAAiB,CAAC,MAAM,CAAC;MACzB,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,IAAI,CACxD,iBAAW,IAAI,EAAC,cAAc,GAAG,CAClC;MACA,CAAC,CAAC,MAAM,CAAC,KAAK;QACb,CAAC,MAAM,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CACzB,iBAAW,IAAI,EAAC,uBAAuB,GAAG,CAC3C,CAAC,CAAC,CAAC,CACF,iBAAW,IAAI,EAAC,qBAAqB,GAAG,CACzC,CAAC;MACJ,WAAK,KAAK,EAAE,GAAG,YAAY,gBAAgB;QACzC,iBAAW,IAAI,EAAC,oBAAoB,GAAG,CACnC,CACC,CACV,CAAC,CAAC,CAAC,CACF,WAAK,KAAK,EAAE,GAAG,YAAY,gBAAgB;MACxC,iBAAiB,CAAC,MAAM,CAAC;MACzB,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,IAAI,CACxD,iBAAW,IAAI,EAAC,mBAAmB,GAAG,CACvC,CACG,CACP,CACE,CACN,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { Fragment, FunctionalComponent, h } from '@stencil/core';\nimport { CSSNAMESPACE } from './table.constants';\nimport {\n addHObserver,\n addVObserver,\n colheadFootRender,\n fetchStores,\n headerPinClasses,\n mergeProperties,\n} from './table.utils';\nimport type { TableTypes } from '../../interface';\n\n// TABLE HEADERS\n// (thead > tr > th, tfoot > tr > th)\n\nlet draggingCol: TableTypes.ColumnConfig;\nlet draggingColEle: HTMLTableCellElement;\nlet dragEnterEle: HTMLElement;\nlet draggingParent: HTMLTableRowElement;\n\ntype TableColHeadProps = {\n column: TableTypes.ColumnConfig;\n headRenderer: TableTypes.HeadFootRenderer;\n onColumnSortClick?: (\n order: TableTypes.Order,\n column: TableTypes.Prop,\n el: HTMLTableCellElement\n ) => void;\n onColumnPinned?: TableTypes.PinnedCb;\n onColumnDrag?: (column: TableTypes.Prop, el: HTMLTableCellElement) => void;\n onColumnDrop?: (\n fromColumn: TableTypes.Prop,\n toColumn: TableTypes.Prop,\n el: HTMLTableCellElement\n ) => void;\n defaults: { draggable?: boolean; sortable?: boolean };\n};\n\nexport const TableColHead: FunctionalComponent<TableColHeadProps> = ({\n column,\n headRenderer,\n onColumnSortClick,\n onColumnPinned,\n onColumnDrag,\n onColumnDrop,\n defaults,\n}) => {\n const store = fetchStores();\n\n // Drag to re-order columns handling\n\n function handleDragStart(e: DragEvent, column: TableTypes.ColumnConfig) {\n draggingCol = column;\n draggingColEle = dragEnterEle = e.target as HTMLTableCellElement;\n draggingParent = draggingColEle.closest('.' + `${CSSNAMESPACE}__tr`);\n\n draggingParent.classList.add(`${CSSNAMESPACE}__dragging`);\n draggingColEle.classList.add(`${CSSNAMESPACE}__drag--start`);\n\n e.dataTransfer.effectAllowed = 'move';\n e.dataTransfer.setData('text/html', draggingColEle.innerHTML);\n\n onColumnDrag(column.prop, draggingColEle);\n }\n\n function handleDragEnd() {\n draggingParent.classList.remove(`${CSSNAMESPACE}__dragging`);\n draggingColEle.classList.remove(`${CSSNAMESPACE}__drag--start`);\n\n draggingParent\n .querySelectorAll(`.${CSSNAMESPACE}__drag-mask--active`)\n .forEach((el) => {\n el.classList.remove(`${CSSNAMESPACE}__drag-mask--active`);\n });\n\n draggingColEle = null;\n draggingCol = null;\n draggingParent = null;\n dragEnterEle = null;\n }\n\n function handleDragEnter(e: DragEvent) {\n if (dragEnterEle === e.target) return;\n\n e.preventDefault();\n e.stopImmediatePropagation();\n e.dataTransfer.dropEffect = 'move';\n\n draggingParent\n .querySelectorAll(`.${CSSNAMESPACE}__drag-mask--active`)\n .forEach((el) => {\n el.classList.remove(`${CSSNAMESPACE}__drag-mask--active`);\n });\n dragEnterEle = e.target as HTMLElement;\n\n if (!dragEnterEle.classList.contains(`${CSSNAMESPACE}__drag-mask`)) {\n e.dataTransfer.dropEffect = 'none';\n return;\n }\n dragEnterEle.classList.add(`${CSSNAMESPACE}__drag-mask--active`);\n }\n\n function handleDrop(this: HTMLElement, e: DragEvent) {\n e.stopPropagation();\n\n const { colName } = this.dataset as { colName: keyof TableTypes.RowData };\n if (colName === draggingCol.prop) return;\n\n const cols = store.config.state.columns;\n let toIndex = cols.findIndex((col) => col.prop === colName);\n const fromIndex = cols.findIndex((col) => col === draggingCol);\n\n if (\n toIndex < fromIndex &&\n this.classList.contains(`${CSSNAMESPACE}__drag-mask--end`)\n )\n toIndex++;\n if (\n toIndex > fromIndex &&\n this.classList.contains(`${CSSNAMESPACE}__drag-mask--start`)\n )\n toIndex--;\n if (toIndex === fromIndex) return;\n\n onColumnDrop(\n draggingCol.prop,\n store.config.state.columns[toIndex].prop,\n draggingColEle\n );\n }\n\n // Sort handling\n\n function handleColumnSortClick(e: MouseEvent & { target: HTMLElement }) {\n let order;\n switch (column.order) {\n case 'asc':\n order = 'desc';\n break;\n case 'desc':\n order = null;\n break;\n default:\n order = 'asc';\n }\n onColumnSortClick(order, column.prop, e.target.closest('th'));\n }\n\n function isSortable() {\n return (\n (!!defaults.sortable && column.sortable !== false) ||\n (!defaults.sortable && column.sortable === true)\n );\n }\n\n function isDraggable() {\n return (\n (!!defaults.draggable && column.draggable !== false) ||\n (!defaults.draggable && column.draggable === true)\n );\n }\n\n let extraProps = {};\n if (column.columnProperties) {\n extraProps = column.columnProperties(column) || extraProps;\n }\n\n const baseProps = {\n class: {\n ...headerPinClasses('th', headRenderer?.pinned),\n [`${CSSNAMESPACE}__pin--start`]: column.pinned === 'start',\n [`${CSSNAMESPACE}__pin--end`]: column.pinned === 'end',\n [`${CSSNAMESPACE}__ordered`]: !!column.order,\n [`${CSSNAMESPACE}__filtered`]:\n column.filter !== undefined && column.filter !== null,\n },\n };\n let props = extraProps ? mergeProperties(baseProps, extraProps) : baseProps;\n const content = colheadFootRender(column);\n\n if (!content) return <Fragment></Fragment>;\n\n props =\n Number((props as TableTypes.CellProps).colSpan) > 1\n ? { ...props, scope: 'colgroup' }\n : { ...props, scope: 'col' };\n\n if (isSortable()) {\n const sort = column.order\n ? column.order === 'asc'\n ? 'ascending'\n : 'descending'\n : 'none';\n\n props = { ...props, 'aria-sort': sort };\n }\n\n if (isDraggable()) {\n props = {\n ...props,\n draggable: true,\n onDragStart: (e) => handleDragStart(e, column),\n onDragOver: (e) => e.preventDefault(),\n onDragEnd: () => handleDragEnd(),\n };\n }\n\n return (\n <th\n {...props}\n ref={(th) => {\n if (['end', 'start'].includes(column.pinned))\n addHObserver(th, column.pinned, onColumnPinned);\n if (['top', 'bottom'].includes(headRenderer.pinned))\n addVObserver(th, headRenderer.pinned, onColumnPinned);\n }}\n key={column.prop}\n >\n {isDraggable() && [\n <div\n class={{\n [`${CSSNAMESPACE}__drag-mask`]: true,\n [`${CSSNAMESPACE}__drag-mask--start`]: true,\n }}\n data-col-name={column.prop}\n onDragEnter={handleDragEnter}\n onDrop={handleDrop}\n onDragOver={(e) => e.preventDefault()}\n ></div>,\n <div\n class={{\n [`${CSSNAMESPACE}__drag-mask`]: true,\n [`${CSSNAMESPACE}__drag-mask--end`]: true,\n }}\n data-col-name={column.prop}\n onDragEnter={handleDragEnter}\n onDrop={handleDrop}\n onDragOver={(e) => e.preventDefault()}\n ></div>,\n ]}\n {isSortable() ? (\n <button\n class={{\n [`${CSSNAMESPACE}__order-btn`]: true,\n [`${CSSNAMESPACE}__cell-content`]: true,\n }}\n onClick={handleColumnSortClick}\n >\n {colheadFootRender(column)}\n {column.filter !== undefined && column.filter !== null && (\n <nano-icon name=\"light/filter\" />\n )}\n {!!column.order &&\n (column.order === 'desc' ? (\n <nano-icon name=\"solid/long-arrow-down\" />\n ) : (\n <nano-icon name=\"solid/long-arrow-up\" />\n ))}\n <div class={`${CSSNAMESPACE}__status-icons`}>\n <nano-icon name=\"light/chevron-down\" />\n </div>\n </button>\n ) : (\n <div class={`${CSSNAMESPACE}__cell-content`}>\n {colheadFootRender(column)}\n {column.filter !== undefined && column.filter !== null && (\n <nano-icon name=\"light/bars-filter\" />\n )}\n </div>\n )}\n </th>\n );\n};\n"]}
1
+ {"version":3,"file":"table.header.js","sourceRoot":"","sources":["../../../src/components/table/table.header.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAuB,CAAC,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,GAChB,MAAM,eAAe,CAAC;AAkBvB,MAAM,CAAC,MAAM,YAAY,GAA2C,CAAC,EACnE,MAAM,EACN,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,QAAQ,GACT,EAAE,EAAE;EACH,gBAAgB;EAEhB,SAAS,qBAAqB,CAAC,CAAuC;IACpE,IAAI,KAAK,CAAC;IACV,QAAQ,MAAM,CAAC,KAAK,EAAE;MACpB,KAAK,KAAK;QACR,KAAK,GAAG,MAAM,CAAC;QACf,MAAM;MACR,KAAK,MAAM;QACT,KAAK,GAAG,IAAI,CAAC;QACb,MAAM;MACR;QACE,KAAK,GAAG,KAAK,CAAC;KACjB;IACD,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;EAChE,CAAC;EAED,SAAS,UAAU;IACjB,OAAO,CACL,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,KAAK,KAAK,CAAC;MAClD,CAAC,CAAC,QAAQ,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,CACjD,CAAC;EACJ,CAAC;EAED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MAAM,CAAC;IACzB,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,IAAI,CACxD,iBAAW,IAAI,EAAC,mBAAmB,GAAG,CACvC,CACG,CACP,CACE,CACN,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { Fragment, FunctionalComponent, h } from '@stencil/core';\nimport { CSSNAMESPACE } from './table.constants';\nimport {\n addHObserver,\n addVObserver,\n colheadFootRender,\n headerPinClasses,\n mergeProperties,\n} from './table.utils';\nimport type { TableTypes } from '../../interface';\n\n// TABLE HEADERS\n// (thead > tr > th, tfoot > tr > th)\n\ntype TableColHeadProps = {\n column: TableTypes.ColumnConfig;\n headRenderer: TableTypes.HeadFootRenderer;\n onColumnSortClick?: (\n order: TableTypes.Order,\n column: TableTypes.Prop,\n el: HTMLTableCellElement\n ) => void;\n onColumnPinned?: TableTypes.PinnedCb;\n defaults: { sortable?: boolean };\n};\n\nexport const TableColHead: FunctionalComponent<TableColHeadProps> = ({\n column,\n headRenderer,\n onColumnSortClick,\n onColumnPinned,\n defaults,\n}) => {\n // Sort handling\n\n function handleColumnSortClick(e: MouseEvent & { target: HTMLElement }) {\n let order;\n switch (column.order) {\n case 'asc':\n order = 'desc';\n break;\n case 'desc':\n order = null;\n break;\n default:\n order = 'asc';\n }\n onColumnSortClick(order, column.prop, e.target.closest('th'));\n }\n\n function isSortable() {\n return (\n (!!defaults.sortable && column.sortable !== false) ||\n (!defaults.sortable && column.sortable === true)\n );\n }\n\n let extraProps = {};\n if (column.columnProperties) {\n extraProps = column.columnProperties(column) || extraProps;\n }\n\n const baseProps = {\n class: {\n ...headerPinClasses('th', headRenderer?.pinned),\n [`${CSSNAMESPACE}__pin--start`]: column.pinned === 'start',\n [`${CSSNAMESPACE}__pin--end`]: column.pinned === 'end',\n [`${CSSNAMESPACE}__ordered`]: !!column.order,\n [`${CSSNAMESPACE}__filtered`]:\n column.filter !== undefined && column.filter !== null,\n },\n };\n let props = extraProps ? mergeProperties(baseProps, extraProps) : baseProps;\n const content = colheadFootRender(column);\n\n if (!content) return <Fragment></Fragment>;\n\n props =\n Number((props as TableTypes.CellProps).colSpan) > 1\n ? { ...props, scope: 'colgroup' }\n : { ...props, scope: 'col' };\n\n if (isSortable()) {\n const sort = column.order\n ? column.order === 'asc'\n ? 'ascending'\n : 'descending'\n : 'none';\n\n props = { ...props, 'aria-sort': sort };\n }\n\n return (\n <th\n {...props}\n ref={(th) => {\n if (['end', 'start'].includes(column.pinned))\n addHObserver(th, column.pinned, onColumnPinned);\n if (['top', 'bottom'].includes(headRenderer.pinned))\n addVObserver(th, headRenderer.pinned, onColumnPinned);\n }}\n key={column.prop}\n >\n {isSortable() ? (\n <button\n class={{\n [`${CSSNAMESPACE}__order-btn`]: true,\n [`${CSSNAMESPACE}__cell-content`]: true,\n }}\n onClick={handleColumnSortClick}\n >\n {colheadFootRender(column)}\n {column.filter !== undefined && column.filter !== null && (\n <nano-icon name=\"light/filter\" />\n )}\n {!!column.order &&\n (column.order === 'desc' ? (\n <nano-icon name=\"solid/long-arrow-down\" />\n ) : (\n <nano-icon name=\"solid/long-arrow-up\" />\n ))}\n <div class={`${CSSNAMESPACE}__status-icons`}>\n <nano-icon name=\"light/chevron-down\" />\n </div>\n </button>\n ) : (\n <div class={`${CSSNAMESPACE}__cell-content`}>\n {colheadFootRender(column)}\n {column.filter !== undefined && column.filter !== null && (\n <nano-icon name=\"light/bars-filter\" />\n )}\n </div>\n )}\n </th>\n );\n};\n"]}