@epam/ai-dial-ui-kit 0.16.0-dev.67 → 0.16.0-dev.69

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.
@@ -1,127 +1,130 @@
1
- import { jsx as o } from "react/jsx-runtime";
2
- import { themeBalham as Te, colorSchemeDark as Ge, colorSchemeLight as Le } from "../../../node_modules/ag-grid-community/dist/package/main.esm.js";
3
- import { AgGridReact as be } from "../../../node_modules/ag-grid-react/dist/package/index.esm.js";
4
- import { IconZoomCancel as we } from "@tabler/icons-react";
5
- import { useState as Oe, useRef as b, useId as ye, useCallback as s, useMemo as m, useEffect as _ } from "react";
6
- import { useIsMobileScreen as He } from "../../../hooks/use-is-mobile-screen.js";
7
- import { useIsTabletScreen as ve } from "../../../hooks/use-is-tablet-screen.js";
8
- import { GridSelectionMode as ee } from "../../../models/selection-mode.js";
9
- import { DropdownTrigger as xe } from "../../../types/dropdown.js";
10
- import { GridAppearance as re, GridColorScheme as te } from "../../../types/grid.js";
11
- import { debounceFn as ke } from "../../../utils/debounce.js";
12
- import { baseColumnComparator as We, omitUndefined as ze } from "../../../utils/grid-comparators.js";
13
- import { registerAgGridModulesOnce as Pe } from "../../../utils/grid-registration.js";
14
- import { mergeClasses as w } from "../../../utils/merge-classes.js";
15
- import { Dropdown as Ue } from "../Dropdown/Dropdown.js";
16
- import { EllipsisTooltip as Fe } from "../EllipsisTooltip/EllipsisTooltip.js";
17
- import { NoDataContent as Me } from "../NoDataContent/NoDataContent.js";
18
- import { SelectionCell as Be } from "./components/SelectionCell.js";
19
- import { SelectionHeader as Ve } from "./components/SelectionHeader.js";
20
- import { GRID_THEME_PARAMS as O, SelectionEventSourceType as p, GRID_ROW_SELECT_CLASS as je, GRID_HEADER_SELECT_CLASS as Je, ROW_HEIGHT as oe, GRID_CHAT_CLASS as Ye, GRID_WITHOUT_HEADER_BORDERS_CLASS as Ze, GRID_SELECTION_VISIBLE_CLASS as $e, GRID_WITH_SELECTION_CLASS as qe, GRID_ROOT_CLASS as Ke } from "./constants.js";
21
- import { SELECTION_COL_DEF as Qe } from "./renderers/constants.js";
22
- const Xe = "dial-kit-grid-selection", er = 150, rr = 100, tr = ["rightAligned", "numericColumn"], ne = (f) => [f?.type ?? []].flat().some((a) => tr.includes(a)), Ar = ({
1
+ import { jsx as l } from "react/jsx-runtime";
2
+ import { themeBalham as we, colorSchemeDark as Oe, colorSchemeLight as ve } from "../../../node_modules/ag-grid-community/dist/package/main.esm.js";
3
+ import { AgGridReact as ye } from "../../../node_modules/ag-grid-react/dist/package/index.esm.js";
4
+ import { useState as He, useRef as w, useId as xe, useCallback as a, useMemo as d, useEffect as _ } from "react";
5
+ import { useIsMobileScreen as Pe } from "../../../hooks/use-is-mobile-screen.js";
6
+ import { useIsTabletScreen as ke } from "../../../hooks/use-is-tablet-screen.js";
7
+ import { GridSelectionMode as ne } from "../../../models/selection-mode.js";
8
+ import { DropdownTrigger as We } from "../../../types/dropdown.js";
9
+ import { GridAppearance as ie, GridColorScheme as se } from "../../../types/grid.js";
10
+ import { debounceFn as ze } from "../../../utils/debounce.js";
11
+ import { baseColumnComparator as Ue, omitUndefined as Fe } from "../../../utils/grid-comparators.js";
12
+ import { registerAgGridModulesOnce as Me } from "../../../utils/grid-registration.js";
13
+ import { mergeClasses as O } from "../../../utils/merge-classes.js";
14
+ import { Dropdown as Be } from "../Dropdown/Dropdown.js";
15
+ import { EllipsisTooltip as Ve } from "../EllipsisTooltip/EllipsisTooltip.js";
16
+ import { selectGridEmptyStateOverlay as je } from "./components/GridEmptyState.js";
17
+ import { SelectionCell as Je } from "./components/SelectionCell.js";
18
+ import { SelectionHeader as Ye } from "./components/SelectionHeader.js";
19
+ import { GRID_THEME_PARAMS as v, SelectionEventSourceType as p, GRID_ROW_SELECT_CLASS as $e, GRID_HEADER_SELECT_CLASS as qe, ROW_HEIGHT as le, GRID_CHAT_CLASS as Ke, GRID_WITHOUT_HEADER_BORDERS_CLASS as Qe, GRID_SELECTION_VISIBLE_CLASS as Xe, GRID_WITH_SELECTION_CLASS as Ze, GRID_ROOT_CLASS as er } from "./constants.js";
20
+ import { SELECTION_COL_DEF as rr } from "./renderers/constants.js";
21
+ const tr = "dial-kit-grid-selection", or = 150, nr = 100, ir = ["rightAligned", "numericColumn"], ae = (f) => [f?.type ?? []].flat().some((i) => ir.includes(i)), Ar = ({
23
22
  columnDefs: f,
24
- rowData: a,
23
+ rowData: i,
25
24
  additionalGridOptions: y,
26
25
  getContextMenuItems: N,
27
- className: ie,
28
- ariaLabel: se = "Data grid",
29
- wrapCustomCellRenderers: I = !0,
26
+ className: ce,
27
+ ariaLabel: de = "Data grid",
28
+ wrapCustomCellRenderers: G = !0,
30
29
  disabledRowIds: C,
31
30
  selectedRowIds: c,
32
31
  onSelectionChange: H,
33
- onGridApiChange: ae,
34
- getRowId: v,
35
- alternateOddRowColors: x = !1,
32
+ onGridApiChange: ue,
33
+ getRowId: x,
34
+ alternateOddRowColors: P = !1,
36
35
  filterPlaceholder: k = "Enter value",
37
- emptyStateIcon: W,
38
- emptyStateTitle: z = "No results found",
39
- emptyStateDescription: P = "Sorry, we couldn't find any results for your search.",
40
- loading: U = !1,
41
- wrapperBorder: F = !0,
42
- withoutHeaderBorders: le = !1,
43
- allowDisabledContextMenu: M = !1,
44
- selectionMode: n,
45
- selectRowLabel: B,
46
- selectAllLabel: V = "Select all rows",
47
- colorScheme: A = te.Light,
48
- appearance: ce = re.Default
36
+ emptyStateIcon: I,
37
+ emptyStateTitle: W = "No items yet",
38
+ emptyStateDescription: z = "Items will appear here once they are added.",
39
+ emptyStateAction: U,
40
+ emptyStateLive: F = !1,
41
+ filteredEmptyStateTitle: M = "No items found",
42
+ filteredEmptyStateDescription: B = "Try a different search term or check your filters.",
43
+ loading: V = !1,
44
+ wrapperBorder: j = !0,
45
+ withoutHeaderBorders: me = !1,
46
+ allowDisabledContextMenu: J = !1,
47
+ selectionMode: o,
48
+ selectRowLabel: Y,
49
+ selectAllLabel: $ = "Select all rows",
50
+ colorScheme: T = se.Light,
51
+ appearance: fe = ie.Default
49
52
  }) => {
50
- Pe();
51
- const [t, de] = Oe(), ue = He(), me = ve(), D = b(/* @__PURE__ */ new Set()), j = b(
53
+ Me();
54
+ const [t, Se] = He(), pe = Pe(), Ce = ke(), A = w(/* @__PURE__ */ new Set()), q = w(
52
55
  void 0
53
- ), J = `dial-kit-grid-selection-${ye()}`, d = b({
54
- getRowId: v,
56
+ ), K = `dial-kit-grid-selection-${xe()}`, u = w({
57
+ getRowId: x,
55
58
  getContextMenuItems: N,
56
59
  onSelectionChange: H,
57
- selectRowLabel: B,
58
- wrapCustomCellRenderers: I
60
+ selectRowLabel: Y,
61
+ wrapCustomCellRenderers: G
59
62
  });
60
- d.current = {
61
- getRowId: v,
63
+ u.current = {
64
+ getRowId: x,
62
65
  getContextMenuItems: N,
63
66
  onSelectionChange: H,
64
- selectRowLabel: B,
65
- wrapCustomCellRenderers: I
67
+ selectRowLabel: Y,
68
+ wrapCustomCellRenderers: G
66
69
  };
67
- const l = s((e) => {
68
- const r = d.current.getRowId;
70
+ const s = a((e) => {
71
+ const r = u.current.getRowId;
69
72
  return r ? r(e) : String(e.id ?? JSON.stringify(e));
70
- }, []), Y = !!N, Z = !!I, T = ce === re.Chat, fe = m(
71
- () => Te.withPart(
72
- A === te.Dark ? Ge : Le
73
+ }, []), Q = !!N, X = !!G, D = fe === ie.Chat, he = d(
74
+ () => we.withPart(
75
+ T === se.Dark ? Oe : ve
73
76
  ).withParams({
74
- ...O,
77
+ ...v,
75
78
  // The shared params pin `browserColorScheme` to light and are applied
76
79
  // after the part, so the chosen scheme is set again here.
77
- browserColorScheme: A,
78
- oddRowBackgroundColor: x ? O.oddRowBackgroundColor : O.backgroundColor,
80
+ browserColorScheme: T,
81
+ oddRowBackgroundColor: P ? v.oddRowBackgroundColor : v.backgroundColor,
79
82
  // The Chat table is a borderless card whose row dividers stop at the
80
83
  // cell padding, so `styles/grid.scss` draws them instead. Its header
81
84
  // and row cells take 12px on each side, not Balham's 8px.
82
- ...T ? {
85
+ ...D ? {
83
86
  wrapperBorder: !1,
84
87
  rowBorder: !1,
85
88
  cellHorizontalPadding: 12
86
- } : { wrapperBorder: F }
89
+ } : { wrapperBorder: j }
87
90
  }),
88
- [x, A, F, T]
89
- ), Se = s((e) => {
91
+ [P, T, j, D]
92
+ ), Re = a((e) => {
90
93
  e.api.sizeColumnsToFit();
91
- }, []), pe = ue || me || (c?.size ?? 0) > 0, u = s(
92
- (e) => !!e && !!C?.has(l(e)),
93
- [C, l]
94
- ), h = s(
95
- (e, r, i) => Y ? /* @__PURE__ */ o(
96
- Ue,
94
+ }, []), ge = pe || Ce || (c?.size ?? 0) > 0, m = a(
95
+ (e) => !!e && !!C?.has(s(e)),
96
+ [C, s]
97
+ ), h = a(
98
+ (e, r, n) => Q ? /* @__PURE__ */ l(
99
+ Be,
97
100
  {
98
- trigger: [xe.ContextMenu],
99
- items: e.data ? d.current.getContextMenuItems?.(e.data) ?? [] : [],
101
+ trigger: [We.ContextMenu],
102
+ items: e.data ? u.current.getContextMenuItems?.(e.data) ?? [] : [],
100
103
  anchorToMouse: !0,
101
104
  matchReferenceWidth: !0,
102
- className: w(
105
+ className: O(
103
106
  "size-full",
104
- i && "cursor-not-allowed opacity-75",
105
- ne(e.colDef) && "text-end"
107
+ n && "cursor-not-allowed opacity-75",
108
+ ae(e.colDef) && "text-end"
106
109
  ),
107
- disabled: i && !M,
108
- children: /* @__PURE__ */ o("span", { className: "block min-w-0 max-w-full flex-1", children: r })
110
+ disabled: n && !J,
111
+ children: /* @__PURE__ */ l("span", { className: "block min-w-0 max-w-full flex-1", children: r })
109
112
  }
110
113
  ) : r,
111
- [Y, M]
112
- ), G = s(
114
+ [Q, J]
115
+ ), L = a(
113
116
  (e) => {
114
117
  if (!e.data) return null;
115
- const r = u(e.data);
118
+ const r = m(e.data);
116
119
  return h(
117
120
  e,
118
- /* @__PURE__ */ o(
119
- Fe,
121
+ /* @__PURE__ */ l(
122
+ Ve,
120
123
  {
121
124
  text: e.value == null ? "" : String(e.value),
122
- className: w(
125
+ className: O(
123
126
  "max-w-full dial-small-text text-primary",
124
- ne(e.colDef) && "text-end"
127
+ ae(e.colDef) && "text-end"
125
128
  ),
126
129
  hideTooltip: r
127
130
  }
@@ -129,72 +132,72 @@ const Xe = "dial-kit-grid-selection", er = 150, rr = 100, tr = ["rightAligned",
129
132
  r
130
133
  );
131
134
  },
132
- [u, h]
133
- ), R = s(
135
+ [m, h]
136
+ ), R = a(
134
137
  (e) => e === p.API || e === p.ROW_DATA_CHANGED,
135
138
  []
136
- ), Ce = m(
137
- () => ke((e) => {
138
- const i = (e.selectedNodes ?? []).map((Q) => Q.data), S = new Set(i.map(l));
139
- D.current = S, j.current = e.source, !R(e.source) && d.current.onSelectionChange?.(S, i);
140
- }, rr),
141
- [R, l]
142
- ), L = m(() => {
143
- if (n)
139
+ ), Ee = d(
140
+ () => ze((e) => {
141
+ const n = (e.selectedNodes ?? []).map((te) => te.data), S = new Set(n.map(s));
142
+ A.current = S, q.current = e.source, !R(e.source) && u.current.onSelectionChange?.(S, n);
143
+ }, nr),
144
+ [R, s]
145
+ ), b = d(() => {
146
+ if (o)
144
147
  return {
145
- ...Qe,
146
- colId: Xe,
148
+ ...rr,
149
+ colId: tr,
147
150
  headerName: "",
148
- headerClass: Je,
149
- cellClass: je,
150
- headerComponent: n === ee.MULTIPLE ? Ve : void 0,
151
- headerComponentParams: { label: V },
151
+ headerClass: qe,
152
+ cellClass: $e,
153
+ headerComponent: o === ne.MULTIPLE ? Ye : void 0,
154
+ headerComponentParams: { label: $ },
152
155
  cellRenderer: (e) => {
153
156
  if (!e.data) return null;
154
- const r = l(e.data);
155
- return /* @__PURE__ */ o(
156
- Be,
157
+ const r = s(e.data);
158
+ return /* @__PURE__ */ l(
159
+ Je,
157
160
  {
158
161
  params: e,
159
- mode: n,
162
+ mode: o,
160
163
  rowId: r,
161
- radioName: J,
162
- label: d.current.selectRowLabel?.(e.data) ?? "Select row",
164
+ radioName: K,
165
+ label: u.current.selectRowLabel?.(e.data) ?? "Select row",
163
166
  disabled: C?.has(r)
164
167
  }
165
168
  );
166
169
  }
167
170
  };
168
171
  }, [
169
- n,
170
- V,
171
- l,
172
+ o,
173
+ $,
174
+ s,
172
175
  C,
173
- J
174
- ]), $ = s(
176
+ K
177
+ ]), Z = a(
175
178
  (e) => {
176
179
  if (!e.cellRenderer)
177
- return { ...e, cellRenderer: G };
178
- const r = d.current.wrapCustomCellRenderers;
180
+ return { ...e, cellRenderer: L };
181
+ const r = u.current.wrapCustomCellRenderers;
179
182
  if (!(typeof r == "function" ? r(e) : !!r))
180
183
  return e;
181
184
  const S = e.cellRenderer;
182
185
  return { ...e, cellRenderer: (E) => {
183
- const Ae = u(E.data), X = typeof S == "function" ? S : void 0, De = X ? /* @__PURE__ */ o(X, { ...E }) : G(E);
184
- return h(E, De, Ae);
186
+ const Le = m(E.data), oe = typeof S == "function" ? S : void 0, be = oe ? /* @__PURE__ */ l(oe, { ...E }) : L(E);
187
+ return h(E, be, Le);
185
188
  } };
186
189
  },
187
- [u, G, h]
188
- ), he = m(() => {
189
- const e = Z ? (f ?? []).map($) : f ?? [];
190
- return L ? [L, ...e] : e;
191
- }, [f, Z, $, L]), {
192
- defaultColDef: q,
190
+ [m, L, h]
191
+ ), _e = d(() => {
192
+ const e = X ? (f ?? []).map(Z) : f ?? [];
193
+ return b ? [b, ...e] : e;
194
+ }, [f, X, Z, b]), {
195
+ defaultColDef: ee,
193
196
  rowSelection: g,
194
- ...Re
195
- } = y ?? {}, ge = m(
197
+ ...Ne
198
+ } = y ?? {}, Ge = d(
196
199
  () => ({
197
- minWidth: er,
200
+ minWidth: or,
198
201
  resizable: !0,
199
202
  sortable: !0,
200
203
  floatingFilter: !0,
@@ -203,119 +206,135 @@ const Xe = "dial-kit-grid-selection", er = 150, rr = 100, tr = ["rightAligned",
203
206
  filterPlaceholder: k,
204
207
  buttons: ["reset"]
205
208
  },
206
- comparator: We,
207
- ...ze(q)
209
+ comparator: Ue,
210
+ ...Fe(ee)
208
211
  }),
209
- [k, q]
210
- ), Ee = (e) => {
211
- e.api.sizeColumnsToFit(), de(e.api), y?.onGridReady?.(e), ae?.(e.api);
212
+ [k, ee]
213
+ ), Ie = (e) => {
214
+ e.api.sizeColumnsToFit(), Se(e.api), y?.onGridReady?.(e), ue?.(e.api);
212
215
  };
213
216
  _(() => {
214
- t && a && t.setGridOption("rowData", a);
215
- }, [t, a]);
216
- const _e = s(
217
- () => /* @__PURE__ */ o(
218
- Me,
219
- {
220
- live: !0,
221
- title: z,
222
- description: P,
223
- icon: W ?? /* @__PURE__ */ o(we, { size: 100, stroke: 0.5, "aria-hidden": "true" })
217
+ t && i && t.setGridOption("rowData", i);
218
+ }, [t, i]);
219
+ const Te = d(
220
+ () => ({
221
+ empty: {
222
+ title: W,
223
+ description: z,
224
+ icon: I,
225
+ action: U,
226
+ live: F
227
+ },
228
+ // The user has just changed a filter, so this one is always announced.
229
+ filtered: {
230
+ title: M,
231
+ description: B,
232
+ icon: I,
233
+ live: !0
224
234
  }
225
- ),
226
- [z, P, W]
227
- ), K = typeof g == "object" ? g : void 0, Ne = m(() => n ? {
228
- isRowSelectable: (e) => !u(e.data),
235
+ }),
236
+ [
237
+ W,
238
+ z,
239
+ I,
240
+ U,
241
+ F,
242
+ M,
243
+ B
244
+ ]
245
+ ), re = typeof g == "object" ? g : void 0, Ae = d(() => o ? {
246
+ isRowSelectable: (e) => !m(e.data),
229
247
  /*
230
248
  Merged, not replaced, the way `defaultColDef` is: a consumer reaching
231
249
  for `isRowSelectable` alone would otherwise hand ag-Grid a whole new
232
250
  object and lose the three settings below with it.
233
251
  */
234
- ...K,
252
+ ...re,
235
253
  /*
236
254
  `selectionMode` owns the mode, because it also decides whether the
237
255
  selection column draws checkboxes or radios.
238
256
  */
239
- mode: n === ee.SINGLE ? "singleRow" : "multiRow",
257
+ mode: o === ne.SINGLE ? "singleRow" : "multiRow",
240
258
  // The controls live in this component's own selection column, so
241
259
  // ag-Grid's inputs are switched off and only its behaviour is used.
242
260
  checkboxes: !1,
243
261
  headerCheckbox: !1
244
262
  } : g, [
245
263
  g,
246
- K,
247
- u,
248
- n
264
+ re,
265
+ m,
266
+ o
249
267
  ]);
250
268
  _(() => {
251
- t && a && D.current.size && D.current.forEach((e) => {
269
+ t && i && A.current.size && A.current.forEach((e) => {
252
270
  const r = t.getRowNode(e);
253
271
  r && !r.isSelected() && r.setSelected(!0, !1, p.API);
254
272
  });
255
- }, [t, a]), _(() => {
273
+ }, [t, i]), _(() => {
256
274
  t && c && (t.deselectAll("all", p.API), c.forEach((e) => {
257
275
  const r = t.getRowNode(e);
258
276
  r && !r.isSelected() && r.setSelected(!0, !1, p.API);
259
277
  }));
260
278
  }, [t, c]);
261
- const Ie = s(
262
- (e) => e.data ? l(e.data) : "",
263
- [l]
279
+ const De = a(
280
+ (e) => e.data ? s(e.data) : "",
281
+ [s]
264
282
  );
265
283
  return _(() => {
266
284
  const e = R(
267
- j.current
285
+ q.current
268
286
  );
269
287
  if (t && c?.size && e) {
270
288
  const r = Array.from(c)[0];
271
289
  if (r) {
272
- const i = t.getRowNode(r);
273
- i && t.ensureNodeVisible(i);
290
+ const n = t.getRowNode(r);
291
+ n && t.ensureNodeVisible(n);
274
292
  }
275
293
  }
276
- }, [t, R, c]), /* @__PURE__ */ o(
294
+ }, [t, R, c]), /* @__PURE__ */ l(
277
295
  "div",
278
296
  {
279
- className: w(
280
- Ke,
297
+ className: O(
298
+ er,
281
299
  "size-full",
282
- n && qe,
283
- n && pe && $e,
284
- le && Ze,
285
- T && Ye,
286
- ie
300
+ o && Ze,
301
+ o && ge && Xe,
302
+ me && Qe,
303
+ D && Ke,
304
+ ce
287
305
  ),
288
306
  role: "region",
289
- "aria-label": se,
290
- "aria-busy": U,
291
- children: /* @__PURE__ */ o("div", { className: "h-full overflow-x-auto", children: /* @__PURE__ */ o(
292
- be,
307
+ "aria-label": de,
308
+ "aria-busy": V,
309
+ children: /* @__PURE__ */ l("div", { className: "h-full overflow-x-auto", children: /* @__PURE__ */ l(
310
+ ye,
293
311
  {
294
312
  rowModelType: "clientSide",
295
- headerHeight: oe,
296
- rowHeight: oe,
313
+ headerHeight: le,
314
+ rowHeight: le,
297
315
  cellSelection: !1,
298
- theme: fe,
316
+ theme: he,
299
317
  autoSizeStrategy: { type: "fitGridWidth" },
300
- columnDefs: he,
301
- defaultColDef: ge,
302
- onGridSizeChanged: Se,
303
- onGridReady: Ee,
304
- loading: U,
318
+ columnDefs: _e,
319
+ defaultColDef: Ge,
320
+ onGridSizeChanged: Re,
321
+ onGridReady: Ie,
322
+ loading: V,
305
323
  suppressCellFocus: !0,
306
324
  suppressDragLeaveHidesColumns: !0,
307
- noRowsOverlayComponent: _e,
308
- rowData: a,
309
- rowSelection: Ne,
310
- onSelectionChanged: Ce,
311
- getRowId: Ie,
312
- ...Re
325
+ overlayComponentSelector: je,
326
+ overlayComponentParams: Te,
327
+ rowData: i,
328
+ rowSelection: Ae,
329
+ onSelectionChanged: Ee,
330
+ getRowId: De,
331
+ ...Ne
313
332
  }
314
333
  ) })
315
334
  }
316
335
  );
317
336
  };
318
337
  export {
319
- Xe as GRID_SELECTION_COLUMN_ID,
338
+ tr as GRID_SELECTION_COLUMN_ID,
320
339
  Ar as Grid
321
340
  };
@@ -0,0 +1,13 @@
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import { NoDataContent as s } from "../../NoDataContent/NoDataContent.js";
3
+ const c = ["noRows", "noMatchingRows"], i = ({
4
+ overlayType: o,
5
+ empty: t,
6
+ filtered: n
7
+ }) => /* @__PURE__ */ e(s, { ...o === "noMatchingRows" ? n : t }), m = ({
8
+ overlayType: o
9
+ }) => c.includes(o) ? { component: i } : void 0;
10
+ export {
11
+ i as GridEmptyState,
12
+ m as selectGridEmptyStateOverlay
13
+ };