apex-grid 1.0.0 → 1.1.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 (337) hide show
  1. package/{dist/src/components → components}/cell.d.ts +2 -3
  2. package/{dist/src/components → components}/cell.js +4 -11
  3. package/components/cell.js.map +1 -0
  4. package/{dist/src/components → components}/filter-row.d.ts +8 -9
  5. package/{dist/src/components → components}/filter-row.js +112 -114
  6. package/components/filter-row.js.map +1 -0
  7. package/{dist/src/components → components}/grid.d.ts +9 -9
  8. package/{dist/src/components → components}/grid.js +72 -148
  9. package/components/grid.js.map +1 -0
  10. package/{dist/src/components → components}/header-row.d.ts +5 -6
  11. package/{dist/src/components → components}/header-row.js +20 -25
  12. package/components/header-row.js.map +1 -0
  13. package/{dist/src/components → components}/header.d.ts +5 -6
  14. package/components/header.js +137 -0
  15. package/components/header.js.map +1 -0
  16. package/{dist/src/components → components}/row.d.ts +2 -3
  17. package/{dist/src/components → components}/row.js +7 -10
  18. package/components/row.js.map +1 -0
  19. package/{dist/src/components → components}/virtualizer.d.ts +2 -3
  20. package/{dist/src/components → components}/virtualizer.js +2 -2
  21. package/components/virtualizer.js.map +1 -0
  22. package/{dist/src/controllers → controllers}/data-operation.d.ts +5 -6
  23. package/{dist/src/controllers → controllers}/data-operation.js +10 -11
  24. package/controllers/data-operation.js.map +1 -0
  25. package/{dist/src/controllers → controllers}/dom.d.ts +5 -6
  26. package/controllers/dom.js +54 -0
  27. package/controllers/dom.js.map +1 -0
  28. package/{dist/src/controllers → controllers}/filter.d.ts +5 -6
  29. package/controllers/filter.js +105 -0
  30. package/controllers/filter.js.map +1 -0
  31. package/{dist/src/controllers → controllers}/navigation.d.ts +3 -4
  32. package/{dist/src/controllers → controllers}/navigation.js +9 -14
  33. package/controllers/navigation.js.map +1 -0
  34. package/{dist/src/controllers → controllers}/resize.d.ts +2 -3
  35. package/controllers/resize.js +52 -0
  36. package/controllers/resize.js.map +1 -0
  37. package/{dist/src/controllers → controllers}/sort.d.ts +1 -2
  38. package/controllers/sort.js +94 -0
  39. package/controllers/sort.js.map +1 -0
  40. package/{dist/src/controllers → controllers}/state.d.ts +5 -6
  41. package/{dist/src/controllers → controllers}/state.js +4 -7
  42. package/controllers/state.js.map +1 -0
  43. package/custom-elements.json +1229 -980
  44. package/{dist/src/define.d.ts → define.d.ts} +0 -1
  45. package/define.js.map +1 -0
  46. package/docs/assets/hierarchy.js +1 -0
  47. package/{dist/docs → docs}/assets/highlight.css +28 -0
  48. package/docs/assets/icons.js +18 -0
  49. package/docs/assets/icons.svg +1 -0
  50. package/docs/assets/main.js +60 -0
  51. package/docs/assets/navigation.js +1 -0
  52. package/docs/assets/search.js +1 -0
  53. package/docs/assets/style.css +1633 -0
  54. package/docs/classes/ApexGrid.html +74 -0
  55. package/docs/hierarchy.html +1 -0
  56. package/docs/index.html +10 -0
  57. package/docs/interfaces/ApexFilteredEvent.html +6 -0
  58. package/docs/interfaces/ApexFilteringEvent.html +12 -0
  59. package/docs/interfaces/ApexGridEventMap.html +17 -0
  60. package/docs/interfaces/ApexHeaderContext.html +6 -0
  61. package/docs/interfaces/BaseApexCellContext.html +10 -0
  62. package/docs/interfaces/BaseColumnConfiguration.html +28 -0
  63. package/docs/interfaces/BaseColumnSortConfiguration.html +6 -0
  64. package/docs/interfaces/BaseFilterExpression.html +15 -0
  65. package/docs/interfaces/BaseSortExpression.html +12 -0
  66. package/docs/interfaces/ColumnFilterConfiguration.html +4 -0
  67. package/docs/interfaces/DataPipelineConfiguration.html +6 -0
  68. package/docs/interfaces/GridSortConfiguration.html +6 -0
  69. package/docs/modules.html +1 -0
  70. package/docs/types/ApexCellContext.html +2 -0
  71. package/docs/types/BasePropertyType.html +2 -0
  72. package/docs/types/BaseSortComparer.html +2 -0
  73. package/docs/types/ColumnConfiguration.html +2 -0
  74. package/docs/types/ColumnSortConfiguration.html +2 -0
  75. package/docs/types/DataPipelineHook.html +2 -0
  76. package/docs/types/DataPipelineParams.html +8 -0
  77. package/docs/types/DataType.html +2 -0
  78. package/docs/types/FilterCriteria.html +6 -0
  79. package/docs/types/FilterExpression.html +2 -0
  80. package/docs/types/Keys.html +2 -0
  81. package/docs/types/PropertyType.html +2 -0
  82. package/docs/types/SortComparer.html +2 -0
  83. package/docs/types/SortExpression.html +2 -0
  84. package/docs/types/SortState.html +2 -0
  85. package/docs/types/SortingDirection.html +3 -0
  86. package/{dist/src/index.d.ts → index.d.ts} +4 -5
  87. package/index.js.map +1 -0
  88. package/{dist/src/internal → internal}/constants.d.ts +2 -3
  89. package/internal/constants.js.map +1 -0
  90. package/{dist/src/internal → internal}/icon-registry.d.ts +0 -1
  91. package/internal/icon-registry.js.map +1 -0
  92. package/{dist/src/internal → internal}/is-defined.d.ts +0 -1
  93. package/internal/is-defined.js.map +1 -0
  94. package/{dist/src/internal → internal}/mixins/event-emitter.d.ts +0 -1
  95. package/internal/mixins/event-emitter.js.map +1 -0
  96. package/{dist/src/internal → internal}/normalize-case.d.ts +0 -1
  97. package/internal/normalize-case.js.map +1 -0
  98. package/{dist/src/internal → internal}/part-map.d.ts +0 -1
  99. package/{dist/src/internal → internal}/part-map.js +1 -1
  100. package/internal/part-map.js.map +1 -0
  101. package/{dist/src/internal → internal}/register.d.ts +3 -4
  102. package/internal/register.js +9 -0
  103. package/internal/register.js.map +1 -0
  104. package/{dist/src/internal → internal}/tags.d.ts +0 -1
  105. package/internal/tags.js.map +1 -0
  106. package/internal/theming.d.ts +34 -0
  107. package/internal/theming.js +123 -0
  108. package/internal/theming.js.map +1 -0
  109. package/{dist/src/internal → internal}/types.d.ts +3 -4
  110. package/internal/types.js.map +1 -0
  111. package/{dist/src/internal → internal}/utils.d.ts +1 -2
  112. package/{dist/src/internal → internal}/utils.js +3 -6
  113. package/internal/utils.js.map +1 -0
  114. package/{dist/src/internal → internal}/watch.d.ts +0 -1
  115. package/{dist/src/internal → internal}/watch.js +2 -2
  116. package/internal/watch.js.map +1 -0
  117. package/{dist/src/operations → operations}/base.d.ts +0 -1
  118. package/operations/base.js.map +1 -0
  119. package/{dist/src/operations → operations}/filter/operands/boolean.d.ts +0 -1
  120. package/{dist/src/operations → operations}/filter/operands/boolean.js +5 -5
  121. package/operations/filter/operands/boolean.js.map +1 -0
  122. package/{dist/src/operations → operations}/filter/operands/number.d.ts +0 -1
  123. package/{dist/src/operations → operations}/filter/operands/number.js +2 -2
  124. package/operations/filter/operands/number.js.map +1 -0
  125. package/{dist/src/operations → operations}/filter/operands/string.d.ts +0 -1
  126. package/{dist/src/operations → operations}/filter/operands/string.js +2 -2
  127. package/operations/filter/operands/string.js.map +1 -0
  128. package/{dist/src/operations → operations}/filter/state.d.ts +1 -2
  129. package/{dist/src/operations → operations}/filter/state.js +3 -4
  130. package/operations/filter/state.js.map +1 -0
  131. package/{dist/src/operations → operations}/filter/tree.d.ts +4 -5
  132. package/{dist/src/operations → operations}/filter/tree.js +5 -6
  133. package/operations/filter/tree.js.map +1 -0
  134. package/{dist/src/operations → operations}/filter/types.d.ts +0 -1
  135. package/operations/filter/types.js.map +1 -0
  136. package/{dist/src/operations → operations}/filter.d.ts +0 -1
  137. package/{dist/src/operations → operations}/filter.js +4 -7
  138. package/operations/filter.js.map +1 -0
  139. package/{dist/src/operations → operations}/sort/types.d.ts +0 -1
  140. package/operations/sort/types.js.map +1 -0
  141. package/{dist/src/operations → operations}/sort.d.ts +0 -1
  142. package/{dist/src/operations → operations}/sort.js +5 -5
  143. package/operations/sort.js.map +1 -0
  144. package/package.json +23 -82
  145. package/{dist/src/styles/body-row/body-row-styles.css.d.ts → styles/_common.css.d.ts} +0 -1
  146. package/styles/_common.css.js +3 -0
  147. package/styles/_common.css.js.map +1 -0
  148. package/{dist/src/styles/body-cell/body-cell-styles.css.d.ts → styles/body-cell/body-cell.css.d.ts} +0 -1
  149. package/styles/body-cell/body-cell.css.js +3 -0
  150. package/styles/body-cell/body-cell.css.js.map +1 -0
  151. package/{dist/src/styles/filter-row/filter-row-styles.css.d.ts → styles/body-row/body-row.css.d.ts} +0 -1
  152. package/styles/body-row/body-row.css.js +3 -0
  153. package/styles/body-row/body-row.css.js.map +1 -0
  154. package/{dist/src/styles/grid/themes/light/grid.fluent-styles.css.d.ts → styles/filter-row/filter-row.css.d.ts} +0 -1
  155. package/styles/filter-row/filter-row.css.js +3 -0
  156. package/styles/filter-row/filter-row.css.js.map +1 -0
  157. package/styles/grid/_grid.base.css.d.ts +1 -0
  158. package/styles/grid/_grid.base.css.js +3 -0
  159. package/styles/grid/_grid.base.css.js.map +1 -0
  160. package/styles/grid/themes/light/grid.bootstrap.css.d.ts +1 -0
  161. package/styles/grid/themes/light/grid.bootstrap.css.js +3 -0
  162. package/styles/grid/themes/light/grid.bootstrap.css.js.map +1 -0
  163. package/styles/grid/themes/light/grid.fluent.css.d.ts +1 -0
  164. package/styles/grid/themes/light/grid.fluent.css.js +3 -0
  165. package/styles/grid/themes/light/grid.fluent.css.js.map +1 -0
  166. package/styles/grid/themes/light/grid.indigo.css.d.ts +1 -0
  167. package/styles/grid/themes/light/grid.indigo.css.js +3 -0
  168. package/styles/grid/themes/light/grid.indigo.css.js.map +1 -0
  169. package/styles/grid/themes/light/grid.material.css.d.ts +1 -0
  170. package/styles/grid/themes/light/grid.material.css.js +3 -0
  171. package/styles/grid/themes/light/grid.material.css.js.map +1 -0
  172. package/styles/header-cell/header-cell.css.d.ts +1 -0
  173. package/styles/header-cell/header-cell.css.js +3 -0
  174. package/styles/header-cell/header-cell.css.js.map +1 -0
  175. package/styles/header-row/header-row.base.css.d.ts +1 -0
  176. package/styles/header-row/header-row.base.css.js +3 -0
  177. package/styles/header-row/header-row.base.css.js.map +1 -0
  178. package/dist/bundle.js +0 -2191
  179. package/dist/docs/assets/main.js +0 -58
  180. package/dist/docs/assets/search.js +0 -1
  181. package/dist/docs/assets/style.css +0 -1280
  182. package/dist/docs/classes/ApexGrid.html +0 -301
  183. package/dist/docs/index.html +0 -88
  184. package/dist/docs/interfaces/ApexFilteredEvent.html +0 -78
  185. package/dist/docs/interfaces/ApexFilteringEvent.html +0 -90
  186. package/dist/docs/interfaces/ApexGridEventMap.html +0 -101
  187. package/dist/docs/interfaces/ApexHeaderContext.html +0 -78
  188. package/dist/docs/interfaces/BaseApexCellContext.html +0 -94
  189. package/dist/docs/interfaces/BaseColumnConfiguration.html +0 -170
  190. package/dist/docs/interfaces/BaseColumnSortConfiguration.html +0 -80
  191. package/dist/docs/interfaces/BaseFilterExpression.html +0 -106
  192. package/dist/docs/interfaces/BaseSortExpression.html +0 -98
  193. package/dist/docs/interfaces/ColumnFilterConfiguration.html +0 -66
  194. package/dist/docs/interfaces/DataPipelineConfiguration.html +0 -78
  195. package/dist/docs/interfaces/GridSortConfiguration.html +0 -73
  196. package/dist/docs/modules.html +0 -107
  197. package/dist/docs/types/ApexCellContext.html +0 -79
  198. package/dist/docs/types/BasePropertyType.html +0 -79
  199. package/dist/docs/types/BaseSortComparer.html +0 -94
  200. package/dist/docs/types/ColumnConfiguration.html +0 -79
  201. package/dist/docs/types/ColumnSortConfiguration.html +0 -79
  202. package/dist/docs/types/DataPipelineHook.html +0 -90
  203. package/dist/docs/types/DataPipelineParams.html +0 -92
  204. package/dist/docs/types/DataType.html +0 -72
  205. package/dist/docs/types/FilterCriteria.html +0 -76
  206. package/dist/docs/types/FilterExpression.html +0 -79
  207. package/dist/docs/types/Keys.html +0 -77
  208. package/dist/docs/types/PropertyType.html +0 -79
  209. package/dist/docs/types/SortComparer.html +0 -79
  210. package/dist/docs/types/SortExpression.html +0 -79
  211. package/dist/docs/types/SortState.html +0 -77
  212. package/dist/docs/types/SortingDirection.html +0 -74
  213. package/dist/src/components/cell.d.ts.map +0 -1
  214. package/dist/src/components/cell.js.map +0 -1
  215. package/dist/src/components/filter-row.d.ts.map +0 -1
  216. package/dist/src/components/filter-row.js.map +0 -1
  217. package/dist/src/components/grid.d.ts.map +0 -1
  218. package/dist/src/components/grid.js.map +0 -1
  219. package/dist/src/components/header-row.d.ts.map +0 -1
  220. package/dist/src/components/header-row.js.map +0 -1
  221. package/dist/src/components/header.d.ts.map +0 -1
  222. package/dist/src/components/header.js +0 -143
  223. package/dist/src/components/header.js.map +0 -1
  224. package/dist/src/components/row.d.ts.map +0 -1
  225. package/dist/src/components/row.js.map +0 -1
  226. package/dist/src/components/virtualizer.d.ts.map +0 -1
  227. package/dist/src/components/virtualizer.js.map +0 -1
  228. package/dist/src/controllers/data-operation.d.ts.map +0 -1
  229. package/dist/src/controllers/data-operation.js.map +0 -1
  230. package/dist/src/controllers/dom.d.ts.map +0 -1
  231. package/dist/src/controllers/dom.js +0 -60
  232. package/dist/src/controllers/dom.js.map +0 -1
  233. package/dist/src/controllers/filter.d.ts.map +0 -1
  234. package/dist/src/controllers/filter.js +0 -119
  235. package/dist/src/controllers/filter.js.map +0 -1
  236. package/dist/src/controllers/navigation.d.ts.map +0 -1
  237. package/dist/src/controllers/navigation.js.map +0 -1
  238. package/dist/src/controllers/resize.d.ts.map +0 -1
  239. package/dist/src/controllers/resize.js +0 -70
  240. package/dist/src/controllers/resize.js.map +0 -1
  241. package/dist/src/controllers/sort.d.ts.map +0 -1
  242. package/dist/src/controllers/sort.js +0 -94
  243. package/dist/src/controllers/sort.js.map +0 -1
  244. package/dist/src/controllers/state.d.ts.map +0 -1
  245. package/dist/src/controllers/state.js.map +0 -1
  246. package/dist/src/define.d.ts.map +0 -1
  247. package/dist/src/define.js.map +0 -1
  248. package/dist/src/index.d.ts.map +0 -1
  249. package/dist/src/index.js.map +0 -1
  250. package/dist/src/internal/constants.d.ts.map +0 -1
  251. package/dist/src/internal/constants.js.map +0 -1
  252. package/dist/src/internal/icon-registry.d.ts.map +0 -1
  253. package/dist/src/internal/icon-registry.js.map +0 -1
  254. package/dist/src/internal/is-defined.d.ts.map +0 -1
  255. package/dist/src/internal/is-defined.js.map +0 -1
  256. package/dist/src/internal/mixins/event-emitter.d.ts.map +0 -1
  257. package/dist/src/internal/mixins/event-emitter.js.map +0 -1
  258. package/dist/src/internal/normalize-case.d.ts.map +0 -1
  259. package/dist/src/internal/normalize-case.js.map +0 -1
  260. package/dist/src/internal/part-map.d.ts.map +0 -1
  261. package/dist/src/internal/part-map.js.map +0 -1
  262. package/dist/src/internal/register.d.ts.map +0 -1
  263. package/dist/src/internal/register.js +0 -9
  264. package/dist/src/internal/register.js.map +0 -1
  265. package/dist/src/internal/tags.d.ts.map +0 -1
  266. package/dist/src/internal/tags.js.map +0 -1
  267. package/dist/src/internal/types.d.ts.map +0 -1
  268. package/dist/src/internal/types.js.map +0 -1
  269. package/dist/src/internal/utils.d.ts.map +0 -1
  270. package/dist/src/internal/utils.js.map +0 -1
  271. package/dist/src/internal/watch.d.ts.map +0 -1
  272. package/dist/src/internal/watch.js.map +0 -1
  273. package/dist/src/operations/base.d.ts.map +0 -1
  274. package/dist/src/operations/base.js.map +0 -1
  275. package/dist/src/operations/filter/operands/boolean.d.ts.map +0 -1
  276. package/dist/src/operations/filter/operands/boolean.js.map +0 -1
  277. package/dist/src/operations/filter/operands/number.d.ts.map +0 -1
  278. package/dist/src/operations/filter/operands/number.js.map +0 -1
  279. package/dist/src/operations/filter/operands/string.d.ts.map +0 -1
  280. package/dist/src/operations/filter/operands/string.js.map +0 -1
  281. package/dist/src/operations/filter/state.d.ts.map +0 -1
  282. package/dist/src/operations/filter/state.js.map +0 -1
  283. package/dist/src/operations/filter/tree.d.ts.map +0 -1
  284. package/dist/src/operations/filter/tree.js.map +0 -1
  285. package/dist/src/operations/filter/types.d.ts.map +0 -1
  286. package/dist/src/operations/filter/types.js.map +0 -1
  287. package/dist/src/operations/filter.d.ts.map +0 -1
  288. package/dist/src/operations/filter.js.map +0 -1
  289. package/dist/src/operations/sort/types.d.ts.map +0 -1
  290. package/dist/src/operations/sort/types.js.map +0 -1
  291. package/dist/src/operations/sort.d.ts.map +0 -1
  292. package/dist/src/operations/sort.js.map +0 -1
  293. package/dist/src/styles/body-cell/body-cell-styles.css.d.ts.map +0 -1
  294. package/dist/src/styles/body-cell/body-cell-styles.css.js +0 -71
  295. package/dist/src/styles/body-cell/body-cell-styles.css.js.map +0 -1
  296. package/dist/src/styles/body-row/body-row-styles.css.d.ts.map +0 -1
  297. package/dist/src/styles/body-row/body-row-styles.css.js +0 -38
  298. package/dist/src/styles/body-row/body-row-styles.css.js.map +0 -1
  299. package/dist/src/styles/filter-row/filter-row-styles.css.d.ts.map +0 -1
  300. package/dist/src/styles/filter-row/filter-row-styles.css.js +0 -96
  301. package/dist/src/styles/filter-row/filter-row-styles.css.js.map +0 -1
  302. package/dist/src/styles/grid/themes/light/grid.bootstrap-styles.css.d.ts +0 -2
  303. package/dist/src/styles/grid/themes/light/grid.bootstrap-styles.css.d.ts.map +0 -1
  304. package/dist/src/styles/grid/themes/light/grid.bootstrap-styles.css.js +0 -83
  305. package/dist/src/styles/grid/themes/light/grid.bootstrap-styles.css.js.map +0 -1
  306. package/dist/src/styles/grid/themes/light/grid.fluent-styles.css.d.ts.map +0 -1
  307. package/dist/src/styles/grid/themes/light/grid.fluent-styles.css.js +0 -83
  308. package/dist/src/styles/grid/themes/light/grid.fluent-styles.css.js.map +0 -1
  309. package/dist/src/styles/grid/themes/light/grid.indigo-styles.css.d.ts +0 -2
  310. package/dist/src/styles/grid/themes/light/grid.indigo-styles.css.d.ts.map +0 -1
  311. package/dist/src/styles/grid/themes/light/grid.indigo-styles.css.js +0 -83
  312. package/dist/src/styles/grid/themes/light/grid.indigo-styles.css.js.map +0 -1
  313. package/dist/src/styles/grid/themes/light/grid.material-styles.css.d.ts +0 -2
  314. package/dist/src/styles/grid/themes/light/grid.material-styles.css.d.ts.map +0 -1
  315. package/dist/src/styles/grid/themes/light/grid.material-styles.css.js +0 -83
  316. package/dist/src/styles/grid/themes/light/grid.material-styles.css.js.map +0 -1
  317. package/dist/src/styles/header-cell/header-cell-styles.css.d.ts +0 -2
  318. package/dist/src/styles/header-cell/header-cell-styles.css.d.ts.map +0 -1
  319. package/dist/src/styles/header-cell/header-cell-styles.css.js +0 -141
  320. package/dist/src/styles/header-cell/header-cell-styles.css.js.map +0 -1
  321. package/dist/src/styles/header-row/header-row.base-styles.css.d.ts +0 -2
  322. package/dist/src/styles/header-row/header-row.base-styles.css.d.ts.map +0 -1
  323. package/dist/src/styles/header-row/header-row.base-styles.css.js +0 -35
  324. package/dist/src/styles/header-row/header-row.base-styles.css.js.map +0 -1
  325. /package/{dist/src/define.js → define.js} +0 -0
  326. /package/{dist/docs → docs}/.nojekyll +0 -0
  327. /package/{dist/src/index.js → index.js} +0 -0
  328. /package/{dist/src/internal → internal}/constants.js +0 -0
  329. /package/{dist/src/internal → internal}/icon-registry.js +0 -0
  330. /package/{dist/src/internal → internal}/is-defined.js +0 -0
  331. /package/{dist/src/internal → internal}/mixins/event-emitter.js +0 -0
  332. /package/{dist/src/internal → internal}/normalize-case.js +0 -0
  333. /package/{dist/src/internal → internal}/tags.js +0 -0
  334. /package/{dist/src/internal → internal}/types.js +0 -0
  335. /package/{dist/src/operations → operations}/base.js +0 -0
  336. /package/{dist/src/operations → operations}/filter/types.js +0 -0
  337. /package/{dist/src/operations → operations}/sort/types.js +0 -0
@@ -0,0 +1,123 @@
1
+ import { adoptStyles, css, isServer } from 'lit';
2
+ const CHANGE_THEME_EVENT = 'igc-change-theme';
3
+ let theme;
4
+ let themeVariant;
5
+ function isStyleRule(rule) {
6
+ return rule != null && 'style' in rule;
7
+ }
8
+ function cssKeyToJsKey(key) {
9
+ return key.replace(/^--|-./g, (match) => {
10
+ return match.startsWith('--') ? '' : match.charAt(1).toUpperCase();
11
+ });
12
+ }
13
+ function getAllCssVariableNames() {
14
+ const cssVars = new Set();
15
+ const styleSheets = Array.from(document.styleSheets);
16
+ for (const sheet of styleSheets) {
17
+ let rules;
18
+ try {
19
+ rules = sheet.cssRules;
20
+ }
21
+ catch {
22
+ continue;
23
+ }
24
+ if (!rules) {
25
+ continue;
26
+ }
27
+ for (const rule of Array.from(rules)) {
28
+ if (isStyleRule(rule)) {
29
+ const length = rule.style.length;
30
+ for (let i = 0; i < length; i++) {
31
+ const style = rule.style[i];
32
+ if (style.startsWith('--')) {
33
+ cssVars.add(style);
34
+ }
35
+ }
36
+ }
37
+ }
38
+ }
39
+ return cssVars;
40
+ }
41
+ function getElementCssVariables(allCssVars, element, pseudo) {
42
+ const cssVars = {};
43
+ const styles = getComputedStyle(element, pseudo);
44
+ for (const key of allCssVars) {
45
+ const value = styles.getPropertyValue(key);
46
+ if (value) {
47
+ cssVars[cssKeyToJsKey(key)] = value.trim();
48
+ }
49
+ }
50
+ return cssVars;
51
+ }
52
+ function getAllCssVariables() {
53
+ return isServer ? {} : getElementCssVariables(getAllCssVariableNames(), document.documentElement);
54
+ }
55
+ function isOfTypeTheme(theme) {
56
+ return ['bootstrap', 'material', 'indigo', 'fluent'].includes(theme);
57
+ }
58
+ function isOfTypeThemeVariant(variant) {
59
+ return ['light', 'dark'].includes(variant);
60
+ }
61
+ function getTheme() {
62
+ if (!(theme && themeVariant)) {
63
+ const cssVars = getAllCssVariables();
64
+ const foundTheme = cssVars.igTheme;
65
+ const foundVariant = cssVars.igThemeVariant;
66
+ theme = isOfTypeTheme(foundTheme) ? foundTheme : 'bootstrap';
67
+ themeVariant = isOfTypeThemeVariant(foundVariant) ? foundVariant : 'light';
68
+ }
69
+ return { theme, themeVariant };
70
+ }
71
+ class ThemingController {
72
+ get theme() {
73
+ return this._theme;
74
+ }
75
+ constructor(host, themes, config) {
76
+ this._theme = 'bootstrap';
77
+ this._variant = 'light';
78
+ this._host = host;
79
+ this._themes = themes;
80
+ this._options = config;
81
+ this._host.addController(this);
82
+ }
83
+ hostConnected() {
84
+ this._handleThemeChanged();
85
+ globalThis.addEventListener(CHANGE_THEME_EVENT, this);
86
+ }
87
+ hostDisconnected() {
88
+ globalThis.addEventListener(CHANGE_THEME_EVENT, this);
89
+ }
90
+ handleEvent() {
91
+ this._handleThemeChanged();
92
+ }
93
+ _getStyles() {
94
+ const props = this._themes[this._variant];
95
+ const styles = { shared: css ``, theme: css `` };
96
+ for (const [name, sheet] of Object.entries(props)) {
97
+ if (name === 'shared') {
98
+ styles.shared = sheet;
99
+ }
100
+ if (name === this.theme) {
101
+ styles.theme = sheet;
102
+ }
103
+ }
104
+ return styles;
105
+ }
106
+ _adoptStyles() {
107
+ const { theme: currentTheme, themeVariant } = getTheme();
108
+ this._theme = currentTheme;
109
+ this._variant = themeVariant;
110
+ const ctor = this._host.constructor;
111
+ const { shared, theme } = this._getStyles();
112
+ adoptStyles(this._host.shadowRoot, [...ctor.elementStyles, shared, theme]);
113
+ }
114
+ _handleThemeChanged() {
115
+ this._adoptStyles();
116
+ this._options?.themeChange?.call(this._host, this._theme);
117
+ this._host.requestUpdate();
118
+ }
119
+ }
120
+ export function addThemingController(host, themes, config) {
121
+ return new ThemingController(host, themes, config);
122
+ }
123
+ //# sourceMappingURL=theming.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theming.js","sourceRoot":"","sources":["../../src/internal/theming.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAmBjD,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AAC9C,IAAI,KAAY,CAAC;AACjB,IAAI,YAA0B,CAAC;AAE/B,SAAS,WAAW,CAAC,IAAa;IAChC,OAAO,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,IAAI,CAAC;AACzC,CAAC;AAED,SAAS,aAAa,CAAC,GAAW;IAChC,OAAO,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;QACtC,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,sBAAsB;IAC7B,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,MAAM,W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AAC,WAAgC,CAAC;QACzD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAE5C,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,UAAW,EAAE,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAC9E,CAAC;IAEO,mBAAmB;QACzB,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,IAAI,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1D,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,UAAU,oBAAoB,CAClC,IAA8C,EAC9C,MAAc,EACd,MAAgC;IAEhC,OAAO,IAAI,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import type {\n CSSResult,\n LitElement,\n ReactiveController,\n ReactiveControllerHost,\n ReactiveElement,\n} from 'lit';\nimport { adoptStyles, css, isServer } from 'lit';\n\ntype Theme = 'material' | 'bootstrap' | 'indigo' | 'fluent';\ntype ThemeVariant = 'light' | 'dark';\n\ntype Themes = {\n light: {\n [K in Theme | 'shared']?: CSSResult;\n };\n dark: {\n [K in Theme | 'shared']?: CSSResult;\n };\n};\n\ntype ThemeChangedCallback = (theme: Theme) => unknown;\ntype ThemingControllerConfig = {\n themeChange?: ThemeChangedCallback;\n};\n\nconst CHANGE_THEME_EVENT = 'igc-change-theme';\nlet theme: Theme;\nlet themeVariant: ThemeVariant;\n\nfunction isStyleRule(rule: CSSRule): rule is CSSStyleRule {\n return rule != null && 'style' in rule;\n}\n\nfunction cssKeyToJsKey(key: string): string {\n return key.replace(/^--|-./g, (match) => {\n return match.startsWith('--') ? '' : match.charAt(1).toUpperCase();\n });\n}\n\nfunction getAllCssVariableNames(): Set<string> {\n const cssVars = new Set<string>();\n const styleSheets = Array.from(document.styleSheets);\n\n for (const sheet of styleSheets) {\n let rules: CSSRuleList | undefined;\n\n // Potential CORS or access errors\n try {\n rules = sheet.cssRules;\n } catch {\n continue;\n }\n\n if (!rules) {\n continue;\n }\n\n for (const rule of Array.from(rules)) {\n if (isStyleRule(rule)) {\n const length = rule.style.length;\n\n for (let i = 0; i < length; i++) {\n const style = rule.style[i];\n\n if (style.startsWith('--')) {\n cssVars.add(style);\n }\n }\n }\n }\n }\n\n return cssVars;\n}\n\nfunction getElementCssVariables(\n allCssVars: Set<string>,\n element: HTMLElement,\n pseudo?: string\n): Record<string, string> {\n const cssVars: Record<string, string> = {};\n const styles = getComputedStyle(element, pseudo);\n\n for (const key of allCssVars) {\n const value = styles.getPropertyValue(key);\n\n if (value) {\n cssVars[cssKeyToJsKey(key)] = value.trim();\n }\n }\n\n return cssVars;\n}\n\nfunction getAllCssVariables(): Record<string, string> {\n /* c8 ignore next 2 */\n return isServer ? {} : getElementCssVariables(getAllCssVariableNames(), document.documentElement);\n}\n\nfunction isOfTypeTheme(theme: string): theme is Theme {\n return ['bootstrap', 'material', 'indigo', 'fluent'].includes(theme);\n}\n\nfunction isOfTypeThemeVariant(variant: string): variant is ThemeVariant {\n return ['light', 'dark'].includes(variant);\n}\n\nfunction getTheme() {\n if (!(theme && themeVariant)) {\n const cssVars = getAllCssVariables();\n const foundTheme = cssVars.igTheme;\n const foundVariant = cssVars.igThemeVariant;\n\n theme = isOfTypeTheme(foundTheme) ? foundTheme : 'bootstrap';\n themeVariant = isOfTypeThemeVariant(foundVariant) ? foundVariant : 'light';\n }\n\n return { theme, themeVariant };\n}\n\nclass ThemingController implements ReactiveController {\n private readonly _host: ReactiveControllerHost & ReactiveElement;\n private readonly _themes: Themes;\n private readonly _options?: ThemingControllerConfig;\n\n private _theme: Theme = 'bootstrap';\n private _variant: ThemeVariant = 'light';\n\n public get theme(): Theme {\n return this._theme;\n }\n\n constructor(\n host: ReactiveControllerHost & ReactiveElement,\n themes: Themes,\n config?: ThemingControllerConfig\n ) {\n this._host = host;\n this._themes = themes;\n this._options = config;\n this._host.addController(this);\n }\n\n /** @internal */\n public hostConnected(): void {\n this._handleThemeChanged();\n globalThis.addEventListener(CHANGE_THEME_EVENT, this);\n }\n\n /** @internal */\n public hostDisconnected(): void {\n globalThis.addEventListener(CHANGE_THEME_EVENT, this);\n }\n\n /** @internal */\n public handleEvent(): void {\n this._handleThemeChanged();\n }\n\n private _getStyles() {\n const props = this._themes[this._variant];\n const styles = { shared: css``, theme: css`` };\n\n for (const [name, sheet] of Object.entries(props)) {\n if (name === 'shared') {\n styles.shared = sheet;\n }\n if (name === this.theme) {\n styles.theme = sheet;\n }\n }\n\n return styles;\n }\n\n protected _adoptStyles(): void {\n const { theme: currentTheme, themeVariant } = getTheme();\n this._theme = currentTheme;\n this._variant = themeVariant;\n\n const ctor = this._host.constructor as typeof LitElement;\n const { shared, theme } = this._getStyles();\n\n adoptStyles(this._host.shadowRoot!, [...ctor.elementStyles, shared, theme]);\n }\n\n private _handleThemeChanged(): void {\n this._adoptStyles();\n this._options?.themeChange?.call(this._host, this._theme);\n this._host.requestUpdate();\n }\n}\n\nexport function addThemingController(\n host: ReactiveControllerHost & ReactiveElement,\n themes: Themes,\n config?: ThemingControllerConfig\n): ThemingController {\n return new ThemingController(host, themes, config);\n}\n\nexport type { ThemingController };\n"]}
@@ -1,8 +1,8 @@
1
- import { ReactiveControllerHost, TemplateResult } from 'lit';
2
- import type { ApexGrid } from '../components/grid.js';
1
+ import type { ReactiveControllerHost, TemplateResult } from 'lit';
3
2
  import type ApexGridCell from '../components/cell.js';
4
- import type ApexGridRow from '../components/row.js';
3
+ import type { ApexGrid } from '../components/grid.js';
5
4
  import type ApexGridHeader from '../components/header.js';
5
+ import type ApexGridRow from '../components/row.js';
6
6
  import type { SortComparer } from '../operations/sort/types.js';
7
7
  export type NavigationState = 'previous' | 'current';
8
8
  export type GridHost<T extends object> = ReactiveControllerHost & ApexGrid<T>;
@@ -196,4 +196,3 @@ export interface DataPipelineConfiguration<T extends object> {
196
196
  */
197
197
  filter?: DataPipelineHook<T>;
198
198
  }
199
- //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/internal/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactiveControllerHost, TemplateResult } from 'lit';\nimport type ApexGridCell from '../components/cell.js';\nimport type { ApexGrid } from '../components/grid.js';\nimport type ApexGridHeader from '../components/header.js';\nimport type ApexGridRow from '../components/row.js';\nimport type { SortComparer } from '../operations/sort/types.js';\n\nexport type NavigationState = 'previous' | 'current';\nexport type GridHost<T extends object> = ReactiveControllerHost & ApexGrid<T>;\n\n/**\n * Helper type for resolving keys of type T.\n */\nexport type Keys<T> = keyof T;\n\n/**\n * Helper type for resolving types of type T.\n */\nexport type BasePropertyType<T, K extends Keys<T> = Keys<T>> = T[K];\n\n/**\n * Helper type for resolving types of type T.\n */\nexport type PropertyType<T, K extends Keys<T> = Keys<T>> = K extends Keys<T>\n ? BasePropertyType<T, K>\n : never;\n\n/** The data for the current column. */\nexport type DataType = 'number' | 'string' | 'boolean';\n\n/**\n * Configures the sort behavior for the grid.\n */\nexport interface GridSortConfiguration {\n /**\n * Whether multiple sorting is enabled.\n */\n multiple: boolean;\n /**\n * Whether tri-state sorting is enabled.\n */\n triState: boolean;\n}\n\n/**\n * Extended sort configuration for a column.\n */\nexport interface BaseColumnSortConfiguration<T, K extends Keys<T> = Keys<T>> {\n /**\n * Whether the sort operations will be case sensitive.\n */\n caseSensitive?: boolean;\n /**\n * Custom comparer function for sort operations for this column.\n */\n comparer?: SortComparer<T, K>;\n}\n\n/**\n * See {@link BaseColumnSortConfiguration} for the full documentation.\n */\nexport type ColumnSortConfiguration<T, K extends Keys<T> = Keys<T>> = K extends Keys<T>\n ? BaseColumnSortConfiguration<T, K>\n : never;\n\n/**\n * Extended filter configuration for a column.\n */\nexport interface ColumnFilterConfiguration {\n /**\n * Whether the filter operations will be case sensitive.\n */\n caseSensitive?: boolean;\n}\n\n/** Configuration object for grid columns. */\nexport interface BaseColumnConfiguration<T extends object, K extends Keys<T> = Keys<T>> {\n /**\n * The field for from the data the this column will reference.\n */\n key: K;\n /**\n * The type of data this column will reference.\n *\n * Affects the default filter operands if the column is with filtering enabled.\n *\n * @remarks\n * If not passed, `string` is assumed to be the default type.\n *\n */\n type?: DataType;\n /**\n * Optional text to display in the column header. By default, the column key is used\n * to render the header text.\n */\n headerText?: string;\n /**\n * Width for the current column.\n *\n * Accepts most CSS units for controlling width.\n *\n * @remarks\n * If not passed, the column will try to size itself based on the number of other\n * columns and the total width of the grid.\n *\n */\n width?: string;\n /**\n * Whether the column is hidden or not.\n */\n hidden?: boolean;\n /**\n * Whether the the column can be resized or not.\n */\n resizable?: boolean;\n /**\n * Whether the column can be sorted or not.\n */\n sort?: ColumnSortConfiguration<T, K> | boolean;\n /**\n * Whether filter operation can be applied on the column or not.\n */\n filter?: ColumnFilterConfiguration | boolean;\n /**\n * Header template callback.\n */\n headerTemplate?: (params: ApexHeaderContext<T>) => TemplateResult | unknown;\n /**\n * Cell template callback.\n */\n cellTemplate?: (params: ApexCellContext<T, K>) => TemplateResult | unknown;\n}\n\n/**\n * See {@link BaseColumnConfiguration} for the full documentation.\n */\nexport type ColumnConfiguration<T extends object, K extends Keys<T> = Keys<T>> = K extends Keys<T>\n ? BaseColumnConfiguration<T, K>\n : never;\n\nexport interface ActiveNode<T> {\n column: Keys<T>;\n row: number;\n}\n\n/**\n * Context object for the column header template callback.\n */\nexport interface ApexHeaderContext<T extends object> {\n /**\n * The header element parent of the template.\n */\n parent: ApexGridHeader<T>;\n /**\n * The current configuration for the column.\n */\n column: ColumnConfiguration<T>;\n}\n\n/**\n * Context object for the row cell template callback.\n */\nexport interface BaseApexCellContext<T extends object, K extends Keys<T> = Keys<T>> {\n /**\n * The cell element parent of the template.\n */\n parent: ApexGridCell<T>;\n /**\n * The row element containing the cell.\n */\n row: ApexGridRow<T>;\n /**\n * The current configuration for the column.\n */\n column: ColumnConfiguration<T, K>;\n /**\n * The value from the data source for this cell.\n */\n value: PropertyType<T, K>;\n}\n\n/**\n * See {@link BaseApexCellContext} for the full documentation.\n */\nexport type ApexCellContext<T extends object, K extends Keys<T> = Keys<T>> = K extends Keys<T>\n ? BaseApexCellContext<T, K>\n : never;\n\n/**\n * The parameters passed to a {@link DataPipelineHook} callback.\n */\nexport type DataPipelineParams<T extends object> = {\n /**\n * The current data state of the grid.\n */\n data: T[];\n /**\n * The grid component itself.\n */\n grid: ApexGrid<T>;\n /**\n * The type of data operation being performed.\n */\n type: 'sort' | 'filter';\n};\n\n/**\n * Callback function for customizing data operations in the grid.\n */\nexport type DataPipelineHook<T extends object> = (\n state: DataPipelineParams<T>\n) => T[] | Promise<T[]>;\n\n/**\n * Configuration for customizing the various data operations of the grid.\n */\nexport interface DataPipelineConfiguration<T extends object> {\n /**\n * Hook for customizing sort operations.\n */\n sort?: DataPipelineHook<T>;\n /**\n * Hook for customizing filter operations.\n */\n filter?: DataPipelineHook<T>;\n}\n"]}
@@ -3,5 +3,4 @@ import type { ColumnConfiguration, GridHost } from './types.js';
3
3
  export declare function applyColumnWidths<T extends object>(columns: Array<ColumnConfiguration<T>>): StyleInfo;
4
4
  export declare function autoGenerateColumns<T extends object>(grid: GridHost<T>): void;
5
5
  export declare function asArray<T>(value: T | T[]): T[];
6
- export declare function getFilterOperandsFor<T extends object>(column: ColumnConfiguration<T>): Readonly<import("../operations/filter/types").FilterOperands<number, import("../operations/filter/operands/number.js").NumberKeys>> | Readonly<import("../operations/filter/types").FilterOperands<string, import("../operations/filter/operands/string.js").StringKeys>> | Readonly<import("../operations/filter/types").FilterOperands<boolean, import("../operations/filter/operands/boolean.js").BooleanKeys>>;
7
- //# sourceMappingURL=utils.d.ts.map
6
+ export declare function getFilterOperandsFor<T extends object>(column: ColumnConfiguration<T>): Readonly<import("../operations/filter/types.js").FilterOperands<number, import("../operations/filter/operands/number.js").NumberKeys>> | Readonly<import("../operations/filter/types.js").FilterOperands<string, import("../operations/filter/operands/string.js").StringKeys>> | Readonly<import("../operations/filter/types.js").FilterOperands<boolean, import("../operations/filter/operands/boolean.js").BooleanKeys>>;
@@ -1,19 +1,17 @@
1
1
  import { BooleanOperands } from '../operations/filter/operands/boolean.js';
2
2
  import { NumberOperands } from '../operations/filter/operands/number.js';
3
3
  import { StringOperands } from '../operations/filter/operands/string.js';
4
- // TODO: Revise if this is needed
5
4
  export function applyColumnWidths(columns) {
6
5
  return {
7
6
  'grid-template-columns': columns
8
- .filter(each => !each.hidden)
9
- .map(({ width }) => width !== null && width !== void 0 ? width : 'minmax(136px, 1fr)')
7
+ .filter((each) => !each.hidden)
8
+ .map(({ width }) => width ?? 'minmax(136px, 1fr)')
10
9
  .join(' '),
11
10
  };
12
11
  }
13
12
  export function autoGenerateColumns(grid) {
14
- var _a;
15
13
  if (grid.autoGenerate && grid.columns.length < 1) {
16
- const record = (_a = grid.data[0]) !== null && _a !== void 0 ? _a : {};
14
+ const record = grid.data[0] ?? {};
17
15
  grid.columns = Object.entries(record).map(([key, value]) => {
18
16
  const type = typeof value === 'boolean' ? 'boolean' : typeof value === 'number' ? 'number' : 'string';
19
17
  return { key, type };
@@ -24,7 +22,6 @@ export function asArray(value) {
24
22
  return Array.isArray(value) ? value : [value];
25
23
  }
26
24
  export function getFilterOperandsFor(column) {
27
- // Check for custom class in the filter config
28
25
  switch (column.type) {
29
26
  case 'boolean':
30
27
  return BooleanOperands;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/internal/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAIzE,MAAM,UAAU,iBAAiB,CAC/B,OAAs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B,CAAC;AACH,CAAC","sourcesContent":["import type { StyleInfo } from 'lit/directives/style-map.js';\nimport { BooleanOperands } from '../operations/filter/operands/boolean.js';\nimport { NumberOperands } from '../operations/filter/operands/number.js';\nimport { StringOperands } from '../operations/filter/operands/string.js';\nimport type { ColumnConfiguration, DataType, GridHost } from './types.js';\n\n// TODO: Revise if this is needed\nexport function applyColumnWidths<T extends object>(\n columns: Array<ColumnConfiguration<T>>\n): StyleInfo {\n return {\n 'grid-template-columns': columns\n .filter((each) => !each.hidden)\n .map(({ width }) => width ?? 'minmax(136px, 1fr)')\n .join(' '),\n };\n}\n\nexport function autoGenerateColumns<T extends object>(grid: GridHost<T>) {\n if (grid.autoGenerate && grid.columns.length < 1) {\n const record = grid.data[0] ?? {};\n\n grid.columns = Object.entries(record).map(([key, value]) => {\n const type: DataType =\n typeof value === 'boolean' ? 'boolean' : typeof value === 'number' ? 'number' : 'string';\n return { key, type } as ColumnConfiguration<T>;\n });\n }\n}\n\nexport function asArray<T>(value: T | T[]) {\n return Array.isArray(value) ? value : [value];\n}\n\nexport function getFilterOperandsFor<T extends object>(column: ColumnConfiguration<T>) {\n // Check for custom class in the filter config\n switch (column.type) {\n case 'boolean':\n return BooleanOperands;\n case 'number':\n return NumberOperands;\n default:\n return StringOperands;\n }\n}\n"]}
@@ -3,4 +3,3 @@ interface WatchOptions {
3
3
  }
4
4
  export declare function watch(propName: string, options?: WatchOptions): (protoOrDescriptor: any, name: string) => any;
5
5
  export {};
6
- //# sourceMappingURL=watch.d.ts.map
@@ -1,14 +1,14 @@
1
1
  export function watch(propName, options) {
2
2
  return (protoOrDescriptor, name) => {
3
3
  const { willUpdate } = protoOrDescriptor;
4
- options = Object.assign({ waitUntilFirstUpdate: false }, options);
4
+ const _options = Object.assign({ waitUntilFirstUpdate: false }, options);
5
5
  protoOrDescriptor.willUpdate = function (changedProps) {
6
6
  willUpdate.call(this, changedProps);
7
7
  if (changedProps.has(propName)) {
8
8
  const oldValue = changedProps.get(propName);
9
9
  const newValue = this[propName];
10
10
  if (oldValue !== newValue) {
11
- if (!(options === null || options === void 0 ? void 0 : options.waitUntilFirstUpdate) || this.hasUpdated) {
11
+ if (!_options?.waitUntilFirstUpdate || this.hasUpdated) {
12
12
  this[name].call(this, oldValue, newValue);
13
13
  }
14
14
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/internal/watch.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,KAAK,CAAC,QAAgB,EAAE,OAAsB;IAC5D,OAAO,CAAC,iBAAsB,EAAE,IAAY,EAAO,EAAE;QACnD,MAAM,EAAE,UAAU,EAAE,GAAG,iBAAiB,CAAC;QAEzC,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,oBAAoB,EAAE,KAAK,EAAE,EAAE,OAAO,CAAiB,CAAC;QAEzF,iBAAiB,CAAC,UAAU,GAAG,UAAU,YAA8B;YACrE,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;YAEpC,IAAI,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC/B,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAEhC,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;oBAC1B,IAAI,CAAC,QAAQ,EAAE,oBAAoB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;wBACvD,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;oBAC5C,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["interface WatchOptions {\n waitUntilFirstUpdate?: boolean;\n}\n\nexport function watch(propName: string, options?: WatchOptions) {\n return (protoOrDescriptor: any, name: string): any => {\n const { willUpdate } = protoOrDescriptor;\n\n const _options = Object.assign({ waitUntilFirstUpdate: false }, options) as WatchOptions;\n\n protoOrDescriptor.willUpdate = function (changedProps: Map<string, any>) {\n willUpdate.call(this, changedProps);\n\n if (changedProps.has(propName)) {\n const oldValue = changedProps.get(propName);\n const newValue = this[propName];\n\n if (oldValue !== newValue) {\n if (!_options?.waitUntilFirstUpdate || this.hasUpdated) {\n this[name].call(this, oldValue, newValue);\n }\n }\n }\n };\n };\n}\n"]}
@@ -4,4 +4,3 @@ export default abstract class DataOperation<T, K extends Keys<T> = Keys<T>> {
4
4
  protected resolveCase<U = T[K]>(value: U, caseSensitive?: boolean): U;
5
5
  abstract apply(...args: unknown[]): T[];
6
6
  }
7
- //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/operations/base.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,OAAgB,aAAa;IAC/B,YAAY,CAAC,MAAS,EAAE,GAAM;QACtC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IAES,WAAW,CAAW,KAAQ,EAAE,aAAuB;QAC/D,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,aAAa,CAAC,CAAC,CAAE,KAAK,CAAC,WAAW,EAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1F,CAAC;CAGF","sourcesContent":["import type { Keys } from '../internal/types.js';\n\nexport default abstract class DataOperation<T, K extends Keys<T> = Keys<T>> {\n protected resolveValue(record: T, key: K) {\n return record[key];\n }\n\n protected resolveCase<U = T[K]>(value: U, caseSensitive?: boolean) {\n return typeof value === 'string' && !caseSensitive ? (value.toLowerCase() as U) : value;\n }\n\n public abstract apply(...args: unknown[]): T[];\n}\n"]}
@@ -1,4 +1,3 @@
1
1
  import type { FilterOperands } from '../types.js';
2
2
  export type BooleanKeys = 'all' | 'true' | 'false' | 'empty' | 'notEmpty';
3
3
  export declare const BooleanOperands: Readonly<FilterOperands<boolean, BooleanKeys>>;
4
- //# sourceMappingURL=boolean.d.ts.map
@@ -4,31 +4,31 @@ export const BooleanOperands = Object.freeze({
4
4
  name: 'all',
5
5
  label: 'All',
6
6
  unary: true,
7
- logic: _ => true,
7
+ logic: (_) => true,
8
8
  },
9
9
  true: {
10
10
  name: 'true',
11
11
  label: 'True',
12
12
  unary: true,
13
- logic: target => target === true,
13
+ logic: (target) => target === true,
14
14
  },
15
15
  false: {
16
16
  name: 'false',
17
17
  label: 'False',
18
18
  unary: true,
19
- logic: target => target === false,
19
+ logic: (target) => target === false,
20
20
  },
21
21
  empty: {
22
22
  name: 'empty',
23
23
  label: 'Empty',
24
24
  unary: true,
25
- logic: target => !isDefined(target),
25
+ logic: (target) => !isDefined(target),
26
26
  },
27
27
  notEmpty: {
28
28
  name: 'notEmpty',
29
29
  label: 'Not empty',
30
30
  unary: true,
31
- logic: target => isDefined(target),
31
+ logic: (target) => isDefined(target),
32
32
  },
33
33
  });
34
34
  //# sourceMappingURL=boolean.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boolean.js","sourceRoot":"","sources":["../../../../src/operations/filter/operands/boolean.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAK5D,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAuC;IACjF,GAAG,EAAE;QACH,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI;KACnB;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI;KACnC;IACD,KAAK,EAAE;QACL,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,KAAK;KACpC;IACD,KAAK,EAAE;QACL,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC;KACtC;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,WAAW;QAClB,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC;KACrC;CACF,CAAC,CAAC","sourcesContent":["import { isDefined } from '../../../internal/is-defined.js';\nimport type { FilterOperands } from '../types.js';\n\nexport type BooleanKeys = 'all' | 'true' | 'false' | 'empty' | 'notEmpty';\n\nexport const BooleanOperands = Object.freeze<FilterOperands<boolean, BooleanKeys>>({\n all: {\n name: 'all',\n label: 'All',\n unary: true,\n logic: (_) => true,\n },\n true: {\n name: 'true',\n label: 'True',\n unary: true,\n logic: (target) => target === true,\n },\n false: {\n name: 'false',\n label: 'False',\n unary: true,\n logic: (target) => target === false,\n },\n empty: {\n name: 'empty',\n label: 'Empty',\n unary: true,\n logic: (target) => !isDefined(target),\n },\n notEmpty: {\n name: 'notEmpty',\n label: 'Not empty',\n unary: true,\n logic: (target) => isDefined(target),\n },\n});\n"]}
@@ -1,4 +1,3 @@
1
1
  import type { FilterOperands } from '../types.js';
2
2
  export type NumberKeys = 'equals' | 'doesNotEqual' | 'greaterThan' | 'lessThan' | 'greaterThanOrEqual' | 'lessThanOrEqual' | 'empty' | 'notEmpty';
3
3
  export declare const NumberOperands: Readonly<FilterOperands<number, NumberKeys>>;
4
- //# sourceMappingURL=number.d.ts.map
@@ -40,13 +40,13 @@ export const NumberOperands = Object.freeze({
40
40
  name: 'empty',
41
41
  label: 'Empty',
42
42
  unary: true,
43
- logic: target => !isDefined(target) || isNaN(target),
43
+ logic: (target) => !isDefined(target) || Number.isNaN(target),
44
44
  },
45
45
  notEmpty: {
46
46
  name: 'notEmpty',
47
47
  label: 'Not empty',
48
48
  unary: true,
49
- logic: target => isDefined(target) && !isNaN(target),
49
+ logic: (target) => isDefined(target) && !Number.isNaN(target),
50
50
  },
51
51
  });
52
52
  //# sourceMappingURL=number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number.js","sourceRoot":"","sources":["../../../../src/operations/filter/operands/number.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAa5D,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAqC;IAC9E,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI;KACzC;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,gBAAgB;QACvB,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI;KACzC;IACD,WAAW,EAAE;QACX,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,cAAc;QACrB,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,GAAG,IAAI;KACvC;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,WAAW;QAClB,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,GAAG,IAAI;KACvC;IACD,kBAAkB,EAAE;QAClB,IAAI,EAAE,oBAAoB;QAC1B,KAAK,EAAE,uBAAuB;QAC9B,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,IAAI,IAAI;KACxC;IACD,eAAe,EAAE;QACf,IAAI,EAAE,iBAAiB;QACvB,KAAK,EAAE,oBAAoB;QAC3B,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,IAAI,IAAI;KACxC;IACD,KAAK,EAAE;QACL,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;KAC9D;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,WAAW;QAClB,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;KAC9D;CACF,CAAC,CAAC","sourcesContent":["import { isDefined } from '../../../internal/is-defined.js';\nimport type { FilterOperands } from '../types.js';\n\nexport type NumberKeys =\n | 'equals'\n | 'doesNotEqual'\n | 'greaterThan'\n | 'lessThan'\n | 'greaterThanOrEqual'\n | 'lessThanOrEqual'\n | 'empty'\n | 'notEmpty';\n\nexport const NumberOperands = Object.freeze<FilterOperands<number, NumberKeys>>({\n equals: {\n name: 'equals',\n label: 'Equals',\n unary: false,\n logic: (target, term) => target === term,\n },\n doesNotEqual: {\n name: 'doesNotEqual',\n label: 'Does not equal',\n unary: false,\n logic: (target, term) => target !== term,\n },\n greaterThan: {\n name: 'greaterThan',\n label: 'Greater than',\n unary: false,\n logic: (target, term) => target > term,\n },\n lessThan: {\n name: 'lessThan',\n label: 'Less than',\n unary: false,\n logic: (target, term) => target < term,\n },\n greaterThanOrEqual: {\n name: 'greaterThanOrEqual',\n label: 'Greater than or equal',\n unary: false,\n logic: (target, term) => target >= term,\n },\n lessThanOrEqual: {\n name: 'lessThanOrEqual',\n label: 'Less than or equal',\n unary: false,\n logic: (target, term) => target <= term,\n },\n empty: {\n name: 'empty',\n label: 'Empty',\n unary: true,\n logic: (target) => !isDefined(target) || Number.isNaN(target),\n },\n notEmpty: {\n name: 'notEmpty',\n label: 'Not empty',\n unary: true,\n logic: (target) => isDefined(target) && !Number.isNaN(target),\n },\n});\n"]}
@@ -1,4 +1,3 @@
1
1
  import type { FilterOperands } from '../types.js';
2
2
  export type StringKeys = 'contains' | 'doesNotContain' | 'startsWith' | 'endsWith' | 'equals' | 'doesNotEqual' | 'empty' | 'notEmpty';
3
3
  export declare const StringOperands: Readonly<FilterOperands<string, StringKeys>>;
4
- //# sourceMappingURL=string.d.ts.map
@@ -41,13 +41,13 @@ export const StringOperands = Object.freeze({
41
41
  name: 'empty',
42
42
  label: 'Empty',
43
43
  unary: true,
44
- logic: target => !isDefined(target) || target.length < 1,
44
+ logic: (target) => !isDefined(target) || target.length < 1,
45
45
  },
46
46
  notEmpty: {
47
47
  name: 'notEmpty',
48
48
  label: 'Not empty',
49
49
  unary: true,
50
- logic: target => isDefined(target) && target.length > 0,
50
+ logic: (target) => isDefined(target) && target.length > 0,
51
51
  },
52
52
  });
53
53
  //# sourceMappingURL=string.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.js","sourceRoot":"","sources":["../../../../src/operations/filter/operands/string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAapE,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAqC;IAC9E,QAAQ,EAAE;QACR,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,UAAU;QACjB,KAAK,EAAE,KAAK;QAC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AY,EAAE;QACZ,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,gBAAgB;QACvB,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,EAAE,CAC3C,aAAa,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,aAAa,CAAC,UAAU,EAAE,aAAa,CAAC;KACpF;IAED,KAAK,EAAE;QACL,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;KAC3D;IAED,QAAQ,EAAE;QACR,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,WAAW;QAClB,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;KAC1D;CACF,CAAC,CAAC","sourcesContent":["import { isDefined } from '../../../internal/is-defined.js';\nimport { normalizeCase } from '../../../internal/normalize-case.js';\nimport type { FilterOperands } from '../types.js';\n\nexport type StringKeys =\n | 'contains'\n | 'doesNotContain'\n | 'startsWith'\n | 'endsWith'\n | 'equals'\n | 'doesNotEqual'\n | 'empty'\n | 'notEmpty';\n\nexport const StringOperands = Object.freeze<FilterOperands<string, StringKeys>>({\n contains: {\n name: 'contains',\n label: 'Contains',\n unary: false,\n logic: (target, term, caseSensitive?) =>\n normalizeCase(target, caseSensitive).includes(normalizeCase(term, caseSensitive)),\n },\n doesNotContain: {\n name: 'doesNotContain',\n label: 'Does not contain',\n unary: false,\n logic: (target, term, caseSensitive?) =>\n !normalizeCase(target, caseSensitive).includes(normalizeCase(term, caseSensitive)),\n },\n startsWith: {\n name: 'startsWith',\n label: 'Starts with',\n unary: false,\n logic: (target, searchTerm, caseSensitive?) =>\n normalizeCase(target, caseSensitive).startsWith(normalizeCase(searchTerm, caseSensitive)),\n },\n endsWith: {\n name: 'endsWith',\n label: 'Ends with',\n unary: false,\n logic: (target, searchTerm, caseSensitive?) =>\n normalizeCase(target, caseSensitive).endsWith(normalizeCase(searchTerm, caseSensitive)),\n },\n equals: {\n name: 'equals',\n label: 'Equals',\n unary: false,\n logic: (target, searchTerm, caseSensitive) =>\n normalizeCase(target, caseSensitive) === normalizeCase(searchTerm, caseSensitive),\n },\n\n doesNotEqual: {\n name: 'doesNotEqual',\n label: 'Does not equal',\n unary: false,\n logic: (target, searchTerm, caseSensitive) =>\n normalizeCase(target, caseSensitive) !== normalizeCase(searchTerm, caseSensitive),\n },\n\n empty: {\n name: 'empty',\n label: 'Empty',\n unary: true,\n logic: (target) => !isDefined(target) || target.length < 1,\n },\n\n notEmpty: {\n name: 'notEmpty',\n label: 'Not empty',\n unary: true,\n logic: (target) => isDefined(target) && target.length > 0,\n },\n});\n"]}
@@ -1,5 +1,5 @@
1
- import { FilterExpressionTree } from './tree.js';
2
1
  import type { Keys } from '../../internal/types.js';
2
+ import { FilterExpressionTree } from './tree.js';
3
3
  import type { FilterExpression } from './types.js';
4
4
  export declare class FilterState<T> {
5
5
  protected state: Map<Keys<T>, FilterExpressionTree<T>>;
@@ -14,4 +14,3 @@ export declare class FilterState<T> {
14
14
  clear(): void;
15
15
  set(expression: FilterExpression<T>): void;
16
16
  }
17
- //# sourceMappingURL=state.d.ts.map
@@ -13,10 +13,10 @@ export class FilterState {
13
13
  return Array.from(this.state.values());
14
14
  }
15
15
  get ands() {
16
- return this.values.map(each => each.ands).flat();
16
+ return this.values.flatMap((each) => each.ands);
17
17
  }
18
18
  get ors() {
19
- return this.values.map(each => each.ors).flat();
19
+ return this.values.flatMap((each) => each.ors);
20
20
  }
21
21
  has(key) {
22
22
  return this.state.has(key);
@@ -31,9 +31,8 @@ export class FilterState {
31
31
  this.state.clear();
32
32
  }
33
33
  set(expression) {
34
- var _a;
35
34
  if (this.has(expression.key)) {
36
- (_a = this.get(expression.key)) === null || _a === void 0 ? void 0 : _a.add(expression);
35
+ this.get(expression.key)?.add(expression);
37
36
  return;
38
37
  }
39
38
  this.state.set(expression.key, new FilterExpressionTree(expression.key).add(expression));
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../../src/operations/filter/state.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAGjD,MAAM,OAAO,WAAW;IAAxB;QACY,UAAK,GAA0C,IAAI,GAAG,EAAE,CAAC;IA8CrE,CAAC;IA5CC,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,IAAW,IAAI;QACb,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC;IAED,IAAW,MAAM;QACf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACzC,CAAC;IAED,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAED,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjD,CAAC;IAEM,GAAG,CAAC,GAAY;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAEM,GAAG,CAAC,GAAY;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAEM,MAAM,CAAC,GAAY;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAEM,GAAG,CAAC,UAA+B;QACxC,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;YAC1C,OAAO;QACT,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,oBAAoB,CAAI,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9F,CAAC;CACF","sourcesContent":["import type { Keys } from '../../internal/types.js';\nimport { FilterExpressionTree } from './tree.js';\nimport type { FilterExpression } from './types.js';\n\nexport class FilterState<T> {\n protected state: Map<Keys<T>, FilterExpressionTree<T>> = new Map();\n\n public get empty() {\n return this.state.size < 1;\n }\n\n public get keys() {\n return Array.from(this.state.keys());\n }\n\n public get values() {\n return Array.from(this.state.values());\n }\n\n public get ands() {\n return this.values.flatMap((each) => each.ands);\n }\n\n public get ors() {\n return this.values.flatMap((each) => each.ors);\n }\n\n public has(key: Keys<T>) {\n return this.state.has(key);\n }\n\n public get(key: Keys<T>) {\n return this.state.get(key);\n }\n\n public delete(key: Keys<T>) {\n return this.state.delete(key);\n }\n\n public clear() {\n this.state.clear();\n }\n\n public set(expression: FilterExpression<T>) {\n if (this.has(expression.key)) {\n this.get(expression.key)?.add(expression);\n return;\n }\n\n this.state.set(expression.key, new FilterExpressionTree<T>(expression.key).add(expression));\n }\n}\n"]}
@@ -7,12 +7,11 @@ export declare class FilterExpressionTree<T> {
7
7
  get empty(): boolean;
8
8
  get length(): number;
9
9
  get all(): FilterExpression<T, keyof T>[];
10
- get ands(): FilterExpression<T, keyof T>[];
11
- get ors(): FilterExpression<T, keyof T>[];
10
+ get ands(): FilterExpression<T>[];
11
+ get ors(): FilterExpression<T>[];
12
12
  has(expression: FilterExpression<T>): boolean;
13
13
  add(expression: FilterExpression<T>): this;
14
14
  remove(expression: FilterExpression<T>): this;
15
- protected iterator(): Generator<FilterExpression<T, keyof T>, void, unknown>;
16
- [Symbol.iterator](): Generator<FilterExpression<T, keyof T>, void, unknown>;
15
+ protected iterator(): Generator<FilterExpression<T>, void, unknown>;
16
+ [Symbol.iterator](): Generator<FilterExpression<T>, void, unknown>;
17
17
  }
18
- //# sourceMappingURL=tree.d.ts.map
@@ -13,10 +13,10 @@ export class FilterExpressionTree {
13
13
  return Array.from(this.iterator());
14
14
  }
15
15
  get ands() {
16
- return this.operands.filter(each => each.criteria === 'and');
16
+ return this.operands.filter((each) => each.criteria === 'and');
17
17
  }
18
18
  get ors() {
19
- return this.operands.filter(each => each.criteria === 'or');
19
+ return this.operands.filter((each) => each.criteria === 'or');
20
20
  }
21
21
  has(expression) {
22
22
  return this.operands.includes(expression);
@@ -25,14 +25,13 @@ export class FilterExpressionTree {
25
25
  if (!expression.criteria) {
26
26
  expression.criteria = 'and';
27
27
  }
28
- if (this.operands.includes(expression)) {
29
- return this;
28
+ if (!this.has(expression)) {
29
+ this.operands.push(expression);
30
30
  }
31
- this.operands.push(expression);
32
31
  return this;
33
32
  }
34
33
  remove(expression) {
35
- this.operands = this.operands.filter(each => each !== expression);
34
+ this.operands = this.operands.filter((each) => each !== expression);
36
35
  return this;
37
36
  }
38
37
  *iterator() {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree.js","sourceRoot":"","sources":["../../../src/operations/filter/tree.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,oBAAoB;IAG/B,YAAmB,GAAY;QAAZ,QAAG,GAAH,GAAG,CAAS;QAFrB,aAAQ,GAA+B,EAAE,CAAC;IAElB,CAAC;IAEnC,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,G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,CAAC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtB,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;CACF","sourcesContent":["import type { Keys } from '../../internal/types.js';\nimport type { FilterExpression } from './types.js';\n\nexport class FilterExpressionTree<T> {\n protected operands: Array<FilterExpression<T>> = [];\n\n constructor(public key: Keys<T>) {}\n\n public get empty() {\n return this.operands.length < 1;\n }\n\n public get length() {\n return this.operands.length;\n }\n\n public get all() {\n return Array.from(this.iterator());\n }\n\n public get ands() {\n return this.operands.filter((each) => each.criteria === 'and');\n }\n\n public get ors() {\n return this.operands.filter((each) => each.criteria === 'or');\n }\n\n public has(expression: FilterExpression<T>) {\n return this.operands.includes(expression);\n }\n\n public add(expression: FilterExpression<T>) {\n if (!expression.criteria) {\n expression.criteria = 'and';\n }\n\n if (!this.has(expression)) {\n this.operands.push(expression);\n }\n\n return this;\n }\n\n public remove(expression: FilterExpression<T>) {\n this.operands = this.operands.filter((each) => each !== expression);\n return this;\n }\n\n protected *iterator() {\n for (const operand of this.operands) {\n yield operand;\n }\n }\n\n public [Symbol.iterator]() {\n return this.iterator();\n }\n}\n"]}
@@ -55,4 +55,3 @@ export interface BaseFilterExpression<T, K extends Keys<T> = Keys<T>> {
55
55
  */
56
56
  export type FilterExpression<T, K extends Keys<T> = Keys<T>> = K extends Keys<T> ? BaseFilterExpression<T, K> : never;
57
57
  export type OperandKeys<Type> = Type extends number ? keyof typeof NumberOperands : Type extends string ? keyof typeof StringOperands : Type extends boolean ? keyof typeof BooleanOperands : Type;
58
- //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/operations/filter/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Keys } from '../../internal/types.js';\nimport type { BooleanOperands } from './operands/boolean.js';\nimport type { NumberOperands } from './operands/number.js';\nimport type { StringOperands } from './operands/string.js';\n\n/**\n * Controls how a data record should resolve in a filter operation:\n * - `'and'` - the record must pass all the conditions.\n * - `'or'` - the record must pass at least one condition.\n */\nexport type FilterCriteria = 'and' | 'or';\n\nexport type FilterOperationLogic<T> = (\n target: T,\n searchTerm: T,\n caseSensitive?: boolean\n) => boolean;\n\nexport interface FilterOperation<T> {\n name: string;\n label?: string;\n unary: boolean;\n logic: FilterOperationLogic<T>;\n}\n\nexport type FilterOperands<DataType, Operands extends string> = {\n [key in Operands]: FilterOperation<DataType>;\n};\n\n/**\n * Represents a filter operation for a given column.\n */\nexport interface BaseFilterExpression<T, K extends Keys<T> = Keys<T>> {\n /**\n * The target column for the filter operation.\n */\n key: K;\n /**\n * The filter function which will be executed against the data records.\n */\n condition: FilterOperation<T[K]> | OperandKeys<T[K]>;\n\n /**\n * The filtering value used in the filter condition function.\n *\n * @remarks\n * Optional for unary conditions.\n */\n searchTerm?: T[K];\n /**\n * Dictates how this expression should resolve in the filter operation in relation to\n * other expressions.\n */\n criteria?: FilterCriteria;\n /**\n * Whether the sort operation should be case sensitive.\n *\n * @remarks\n * If not provided, the value is resolved based on the column filter configuration (if any).\n */\n caseSensitive?: boolean;\n}\n\n/**\n * See {@link BaseFilterExpression} for the full documentation.\n */\nexport type FilterExpression<T, K extends Keys<T> = Keys<T>> = K extends Keys<T>\n ? BaseFilterExpression<T, K>\n : never;\n\nexport type OperandKeys<Type> = Type extends number\n ? keyof typeof NumberOperands\n : Type extends string\n ? keyof typeof StringOperands\n : Type extends boolean\n ? keyof typeof BooleanOperands\n : Type;\n"]}
@@ -6,4 +6,3 @@ export default class FilterDataOperation<T extends object> extends DataOperation
6
6
  protected match(record: T, ands: FilterExpression<T>[], ors: FilterExpression<T>[]): boolean;
7
7
  apply(data: T[], state: FilterState<T>): T[];
8
8
  }
9
- //# sourceMappingURL=filter.d.ts.map
@@ -2,24 +2,21 @@ import DataOperation from './base.js';
2
2
  export default class FilterDataOperation extends DataOperation {
3
3
  resolveFilter(record, expr) {
4
4
  const condition = expr.condition;
5
- return condition.logic(
6
- // XXX: Types
7
- // @ts-expect-error - resolve
8
- this.resolveValue(record, expr.key), expr.searchTerm, expr.caseSensitive);
5
+ return condition.logic(this.resolveValue(record, expr.key), expr.searchTerm, expr.caseSensitive);
9
6
  }
10
7
  match(record, ands, ors) {
11
8
  for (const or of ors) {
12
9
  if (this.resolveFilter(record, or)) {
13
- return this.match(record, ands.filter(f => f.key !== or.key), []);
10
+ return this.match(record, ands.filter((f) => f.key !== or.key), []);
14
11
  }
15
12
  }
16
- return ands.every(f => this.resolveFilter(record, f));
13
+ return ands.every((f) => this.resolveFilter(record, f));
17
14
  }
18
15
  apply(data, state) {
19
16
  if (state.empty)
20
17
  return data;
21
18
  const { ands, ors } = state;
22
- return data.filter(record => this.match(record, ands, ors));
19
+ return data.filter((record) => this.match(record, ands, ors));
23
20
  }
24
21
  }
25
22
  //# sourceMappingURL=filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.js","sourceRoot":"","sources":["../../src/operations/filter.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,WAAW,CAAC;AAItC,MAAM,CAAC,OAAO,OAAO,mBAAsC,SAAQ,aAAgB;IACvE,aAAa,CAAC,MAAS,EAAE,IAAyB;QAC1D,MAAM,SAAS,GAAG,IAAI,CAAC,SAA+B,CAAC;QACvD,OAAO,SAAS,CAAC,KAAK,CAEpB,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAM,EACxC,IAAI,CAAC,UAAe,EACpB,IAAI,CAAC,aAAa,CACnB,CAAC;IACJ,CAAC;IAES,KAAK,CAAC,MAAS,EAAE,IAA2B,EAAE,GAA0B;QAChF,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;YACrB,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;gBACnC,OAAO,IAAI,CAAC,KAAK,CACf,MAAM,EACN,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,CAAC,EACpC,EAAE,CACH,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1D,CAAC;IAEM,KAAK,CAAC,IAAS,EAAE,KAAqB;QAC3C,IAAI,KAAK,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QAE7B,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;QAC5B,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IAChE,CAAC;CACF","sourcesContent":["import DataOperation from './base.js';\nimport type { FilterState } from './filter/state.js';\nimport type { FilterExpression, FilterOperation } from './filter/types.js';\n\nexport default class FilterDataOperation<T extends object> extends DataOperation<T> {\n protected resolveFilter(record: T, expr: FilterExpression<T>) {\n const condition = expr.condition as FilterOperation<T>;\n return condition.logic(\n // XXX: Types\n this.resolveValue(record, expr.key) as T,\n expr.searchTerm as T,\n expr.caseSensitive\n );\n }\n\n protected match(record: T, ands: FilterExpression<T>[], ors: FilterExpression<T>[]): boolean {\n for (const or of ors) {\n if (this.resolveFilter(record, or)) {\n return this.match(\n record,\n ands.filter((f) => f.key !== or.key),\n []\n );\n }\n }\n return ands.every((f) => this.resolveFilter(record, f));\n }\n\n public apply(data: T[], state: FilterState<T>): T[] {\n if (state.empty) return data;\n\n const { ands, ors } = state;\n return data.filter((record) => this.match(record, ands, ors));\n }\n}\n"]}
@@ -47,4 +47,3 @@ export interface BaseSortExpression<T, K extends Keys<T> = Keys<T>> {
47
47
  export type SortExpression<T, K extends Keys<T> = Keys<T>> = K extends Keys<T> ? BaseSortExpression<T, K> : never;
48
48
  /** Represents the sort state of the grid. */
49
49
  export type SortState<T> = Map<Keys<T>, SortExpression<T>>;
50
- //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/operations/sort/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Keys } from '../../internal/types.js';\n\n/**\n * Sort direction for a given sort expression.\n *\n * @remarks\n * `none` is used\n */\nexport type SortingDirection = 'ascending' | 'descending' | 'none';\n\n/**\n * Custom comparer function for a given column used when sorting is performed.\n */\nexport type BaseSortComparer<T, K extends Keys<T> = Keys<T>> = (a: T[K], b: T[K]) => number;\n\n/**\n * See {@link BaseSortComparer} for the full documentation.\n */\nexport type SortComparer<T, K extends Keys<T> = Keys<T>> = K extends Keys<T>\n ? BaseSortComparer<T, K>\n : never;\n\n/**\n * Represents a sort operation for a given column.\n */\nexport interface BaseSortExpression<T, K extends Keys<T> = Keys<T>> {\n /**\n * The target column.\n */\n key: K;\n /**\n * Sort direction for this operation.\n */\n direction: SortingDirection;\n /**\n * Whether the sort operation should be case sensitive.\n *\n * @remarks\n * If not provided, the value is resolved based on the column sort configuration (if any).\n */\n caseSensitive?: boolean;\n /**\n * Custom comparer function for this operation.\n *\n * @remarks\n * If not provided, the value is resolved based on the column sort configuration (if any).\n */\n comparer?: SortComparer<T, K>;\n}\n\n/**\n * See {@link BaseSortExpression} for the full documentation.\n */\nexport type SortExpression<T, K extends Keys<T> = Keys<T>> = K extends Keys<T>\n ? BaseSortExpression<T, K>\n : never;\n\n/** Represents the sort state of the grid. */\nexport type SortState<T> = Map<Keys<T>, SortExpression<T>>;\n"]}
@@ -6,4 +6,3 @@ export default class SortDataOperation<T> extends DataOperation<T> {
6
6
  protected compareObjects(first: T, second: T, expression: SortExpression<T>): number;
7
7
  apply(data: T[], state: SortState<T>): T[];
8
8
  }
9
- //# sourceMappingURL=sort.d.ts.map
@@ -14,17 +14,17 @@ export default class SortDataOperation extends DataOperation {
14
14
  return first > second ? 1 : first < second ? -1 : 0;
15
15
  }
16
16
  compareObjects(first, second, expression) {
17
- var _a;
18
17
  const { direction, key, caseSensitive, comparer } = expression;
19
18
  const a = this.resolveCase(this.resolveValue(first, key), caseSensitive);
20
19
  const b = this.resolveCase(this.resolveValue(second, key), caseSensitive);
21
- // TODO: Remove casting as any
22
- return (this.orderBy.get(direction) * ((_a = comparer === null || comparer === void 0 ? void 0 : comparer(a, b)) !== null && _a !== void 0 ? _a : this.compareValues(a, b)));
20
+ return (this.orderBy.get(direction) * (comparer?.(a, b) ?? this.compareValues(a, b)));
23
21
  }
24
22
  apply(data, state) {
25
- const expressions = Array.from(state.values()), length = expressions.length;
23
+ const expressions = Array.from(state.values());
24
+ const length = expressions.length;
26
25
  data.sort((a, b) => {
27
- let i = 0, result = 0;
26
+ let i = 0;
27
+ let result = 0;
28
28
  while (i < length && !result) {
29
29
  result = this.compareObjects(a, b, expressions[i]);
30
30
  i++;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort.js","sourceRoot":"","sources":["../../src/operations/sort.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,WAAW,CAAC;AAGtC,MAAM,CAAC,OAAO,OAAO,iBAAqB,SAAQ,aAAgB;IAAlE;;QACY,YAAO,GAAG,IAAI,GAAG,CACzB,MAAM,CAAC,OAAO,CAAC;YACb,SAAS,EAAE,CAAC;YACZ,UAAU,EAAE,CAAC,CAAC;SACf,CAAC,CACH,CAAC;IAuCJ,CAAC;IArCW,aAAa,CAAI,KAAQ,EAAE,MAAS;QAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC5D,OAAO,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CA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from './base.js';\nimport type { SortExpression, SortState } from './sort/types.js';\n\nexport default class SortDataOperation<T> extends DataOperation<T> {\n protected orderBy = new Map(\n Object.entries({\n ascending: 1,\n descending: -1,\n })\n );\n\n protected compareValues<U>(first: U, second: U) {\n if (typeof first === 'string' && typeof second === 'string') {\n return first.localeCompare(second);\n }\n return first > second ? 1 : first < second ? -1 : 0;\n }\n\n protected compareObjects(first: T, second: T, expression: SortExpression<T>) {\n const { direction, key, caseSensitive, comparer } = expression;\n\n const a = this.resolveCase(this.resolveValue(first, key), caseSensitive);\n const b = this.resolveCase(this.resolveValue(second, key), caseSensitive);\n\n // TODO: Remove casting as any\n return (\n this.orderBy.get(direction)! * (comparer?.(a as any, b as any) ?? this.compareValues(a, b))\n );\n }\n\n public apply(data: T[], state: SortState<T>) {\n const expressions = Array.from(state.values());\n const length = expressions.length;\n\n data.sort((a, b) => {\n let i = 0;\n let result = 0;\n\n while (i < length && !result) {\n result = this.compareObjects(a, b, expressions[i]);\n i++;\n }\n\n return result;\n });\n\n return data;\n }\n}\n"]}