@colisweb/rescript-toolkit 5.42.3 → 5.42.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "5.42.3",
3
+ "version": "5.42.4",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "clean": "rescript clean",
@@ -696,9 +696,9 @@ module Make = (StateLenses: Config) => {
696
696
  ?dropdownClassName
697
697
  ?itemClassName
698
698
  options
699
- defaultValue={value}
699
+ defaultValue={options->Array.keep(item => value->Array.some(v => v === item.value))}
700
700
  ?disabled
701
- onChange={items => handleChange(items)}
701
+ onChange={items => handleChange(items->Array.map(item => item.value))}
702
702
  onClose
703
703
  placeholder
704
704
  />
@@ -58,14 +58,14 @@ let make = (
58
58
  dropdownClassName
59
59
  label={switch selectedOptions {
60
60
  | [] =>
61
- <p className="flex flex-row gap-2 w-full items-center relative">
61
+ <div className="flex flex-row gap-2 w-full items-center relative">
62
62
  {placeholder->Option.mapWithDefault(React.null, placeholder => {
63
63
  <span className={cx(["ml-1", placeholderClassName])}> {placeholder} </span>
64
64
  })}
65
65
  <span className="absolute inset-y-0 right-0 flex items-center">
66
66
  <ReactIcons.FaAngleDown />
67
67
  </span>
68
- </p>
68
+ </div>
69
69
  | options =>
70
70
  <>
71
71
  <div
@@ -75,7 +75,7 @@ let make = (
75
75
  {options->Array.map(({label}) => label)->Js.Array2.joinWith(", ")->React.string}
76
76
  </span>
77
77
  </div>
78
- <button
78
+ <div
79
79
  className={"absolute right-1 bg-info-100 text-info-600 text-sm rounded px-1.5 py-0.5 inline-flex items-center gap-2"}
80
80
  onClick={event => {
81
81
  event->JsxEventC.Mouse.stopPropagation
@@ -86,7 +86,7 @@ let make = (
86
86
  <span className={"rounded-full bg-info-600 text-info-100 p-0.5"}>
87
87
  <ReactIcons.MdClose size={14} />
88
88
  </span>
89
- </button>
89
+ </div>
90
90
  </>
91
91
  }}>
92
92
  {_ =>
@@ -1,10 +1,13 @@
1
1
  type coreRowModel
2
+ type sortedRowModel
2
3
  type filteredRowModel
3
4
  type paginationRowModel
4
5
 
5
6
  @module("@tanstack/react-table")
6
7
  external getCoreRowModel: unit => coreRowModel = "getCoreRowModel"
7
8
  @module("@tanstack/react-table")
9
+ external getSortedRowModel: unit => sortedRowModel = "getSortedRowModel"
10
+ @module("@tanstack/react-table")
8
11
  external getFilteredRowModel: unit => filteredRowModel = "getFilteredRowModel"
9
12
  @module("@tanstack/react-table")
10
13
  external getPaginationRowModel: unit => paginationRowModel = "getPaginationRowModel"
@@ -18,6 +21,8 @@ type rowSelectionState = Js.Dict.t<bool>
18
21
  type filterState = {id: string, value: unknown}
19
22
  type sortingState = {id: string, desc: bool}
20
23
 
24
+ @unboxed type sortState = Bool(bool) | SortOrder(string)
25
+
21
26
  type tableState = {
22
27
  pagination: paginationState,
23
28
  rowSelection: rowSelectionState,
@@ -108,6 +113,9 @@ and parentColumn<'filterValue, 'filterVariant> = {
108
113
  columnDef: parentColumnDef<'filterVariant>,
109
114
  getFilterValue: unit => 'filterValue,
110
115
  setFilterValue: 'filterValue => unit,
116
+ getCanSort: unit => bool,
117
+ getIsSorted: unit => sortState,
118
+ getToggleSortingHandler: 'a. (. unit) => 'a => unit,
111
119
  }
112
120
  and parentColumnDef<'filterVariant> = {
113
121
  header: Header.t,
@@ -122,14 +130,10 @@ and header<'filterVariant> = {
122
130
  colSpan: int,
123
131
  getSize: unit => int,
124
132
  getContext: unit => Header.context,
125
- getIsSorted: unit => bool,
126
- getCanFilter: unit => bool,
127
- getCanSort: unit => bool,
128
- getToggleSortingHandler: unit => unit,
129
133
  id: string,
130
134
  }
131
135
 
132
- type columnInstance = {setFilterValue: 'a. ('a) => unit}
136
+ type columnInstance = {setFilterValue: 'a. 'a => unit}
133
137
 
134
138
  type rec tableInstance<'tableData, 'filterVariant> = {
135
139
  getHeaderGroups: unit => array<headerGroup<'filterVariant>>,
@@ -150,18 +154,21 @@ type rec tableInstance<'tableData, 'filterVariant> = {
150
154
  tableOptions<'tableData, 'filterVariant> => tableOptions<'tableData, 'filterVariant>
151
155
  ) => unit,
152
156
  setColumnFilters: (array<filterState> => array<filterState>) => unit,
153
- getColumn: ( string) => option<columnInstance>,
157
+ getColumn: string => option<columnInstance>,
154
158
  }
155
159
  and tableOptions<'tableData, 'filterVariant> = {
156
160
  data: array<'tableData>,
157
161
  columns: array<ColumnDef.t<'tableData, 'filterVariant>>,
158
162
  getCoreRowModel: coreRowModel,
163
+ getSortedRowModel?: sortedRowModel,
164
+ onSortingChange?: (array<sortingState> => array<sortingState>) => unit,
159
165
  getFilteredRowModel?: filteredRowModel,
160
166
  getPaginationRowModel?: paginationRowModel,
161
167
  onPaginationChange?: (paginationState => paginationState) => paginationState,
162
168
  onRowSelectionChange?: (rowSelectionState => rowSelectionState) => unit,
163
169
  pageCount?: int,
164
170
  initialState?: tableInitialState,
171
+ state?: tableInitialState,
165
172
  manualPagination?: bool,
166
173
  manualSorting?: bool,
167
174
  manualFiltering?: bool,