@optimum-intelligence/opti-ui 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/dist/components/calendar/Calendar.js +29 -17
  3. package/dist/components/calendar/Calendar.js.map +1 -1
  4. package/dist/components/data-table/DataTable.d.ts +4 -1
  5. package/dist/components/data-table/DataTable.js +20 -16
  6. package/dist/components/data-table/DataTable.js.map +1 -1
  7. package/dist/components/data-table/DataTableFilters.d.ts +3 -2
  8. package/dist/components/data-table/DataTableFilters.js +287 -171
  9. package/dist/components/data-table/DataTableFilters.js.map +1 -1
  10. package/dist/components/data-table/DataTableRow.js +76 -72
  11. package/dist/components/data-table/DataTableRow.js.map +1 -1
  12. package/dist/components/data-table/layout.js +1 -1
  13. package/dist/components/data-table/layout.js.map +1 -1
  14. package/dist/components/data-table/types.d.ts +35 -3
  15. package/dist/components/data-table/useDataTable.d.ts +1 -1
  16. package/dist/components/data-table/useDataTable.js +312 -299
  17. package/dist/components/data-table/useDataTable.js.map +1 -1
  18. package/dist/components/dialog/ConfirmDialog.d.ts +6 -1
  19. package/dist/components/dialog/ConfirmDialog.js +88 -85
  20. package/dist/components/dialog/ConfirmDialog.js.map +1 -1
  21. package/dist/components/table/Table.d.ts +5 -1
  22. package/dist/components/table/Table.js +2 -1
  23. package/dist/components/table/Table.js.map +1 -1
  24. package/dist/components.json +23 -4
  25. package/dist/fonts/JetBrainsMono-OFL.txt +93 -0
  26. package/dist/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
  27. package/dist/fonts/jetbrains-mono-latin.woff2 +0 -0
  28. package/dist/fonts.css +22 -1
  29. package/dist/llms-full.txt +8 -4
  30. package/dist/opti-ui.css +134 -32
  31. package/dist/utils/scroll-fade.d.ts +5 -1
  32. package/dist/utils/scroll-fade.js +11 -1
  33. package/dist/utils/scroll-fade.js.map +1 -1
  34. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { cx } from "../../utils/cx.js";
3
+ import { useDateConfig } from "../calendar/DateConfig.js";
3
4
  import { ChevronDownIcon, FilterIcon, XIcon } from "../../icons/index.js";
4
5
  import { Button } from "../button/Button.js";
5
6
  import { Toggle, ToggleGroup } from "../toggle/Toggle.js";
@@ -16,88 +17,86 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
16
17
  //#region src/components/data-table/DataTableFilters.tsx
17
18
  /** The control of one filter: a dropdown, a toggle chip, a row of chips or a date range picker. */
18
19
  function DataTableFilter(t0) {
19
- const $ = c(48);
20
+ const $ = c(87);
20
21
  const { id, size: t1, className } = t0;
21
22
  const size = t1 === void 0 ? "md" : t1;
22
23
  const table = useDataTableContext();
24
+ const dates = useDateConfig();
23
25
  const t2 = table.filters;
24
- let T0;
25
- let T1;
26
+ let classes;
27
+ let filter;
28
+ let style;
26
29
  let t3;
27
- let t4;
28
- let t5;
29
- let t6;
30
- let t7;
31
- let t8;
32
- let t9;
33
- if ($[0] !== className || $[1] !== id || $[2] !== size || $[3] !== table) {
34
- t9 = Symbol.for("react.early_return_sentinel");
30
+ let value;
31
+ if ($[0] !== className || $[1] !== dates || $[2] !== id || $[3] !== size || $[4] !== table) {
32
+ t3 = Symbol.for("react.early_return_sentinel");
35
33
  bb0: {
36
- let t10;
37
- if ($[13] !== id) {
38
- t10 = (candidate) => candidate.id === id;
39
- $[13] = id;
40
- $[14] = t10;
41
- } else t10 = $[14];
42
- const filter = t2.find(t10);
34
+ let t4;
35
+ if ($[10] !== id) {
36
+ t4 = (candidate) => candidate.id === id;
37
+ $[10] = id;
38
+ $[11] = t4;
39
+ } else t4 = $[11];
40
+ filter = t2.find(t4);
43
41
  if (!filter) {
44
- t9 = null;
42
+ t3 = null;
45
43
  break bb0;
46
44
  }
47
- const value = table.filterValues[id];
48
- let t11;
49
- if ($[15] !== className) {
50
- t11 = cx("oui-data-table__filter", className);
51
- $[15] = className;
52
- $[16] = t11;
53
- } else t11 = $[16];
54
- const classes = t11;
45
+ value = table.filterValues[id];
46
+ let t5;
47
+ if ($[12] !== className) {
48
+ t5 = cx("oui-data-table__filter", className);
49
+ $[12] = className;
50
+ $[13] = t5;
51
+ } else t5 = $[13];
52
+ classes = t5;
53
+ style = filter.width ? { "--_filter-width": filter.width } : void 0;
55
54
  if (filter.type === "toggle") {
56
- let t12;
57
- if ($[17] !== id || $[18] !== table) {
58
- t12 = (pressed) => table.setFilterValue(id, pressed || void 0);
59
- $[17] = id;
60
- $[18] = table;
61
- $[19] = t12;
62
- } else t12 = $[19];
63
- t9 = /* @__PURE__ */ jsx(Toggle, {
55
+ let t6;
56
+ if ($[14] !== id || $[15] !== table) {
57
+ t6 = (pressed) => table.setFilterValue(id, pressed || void 0);
58
+ $[14] = id;
59
+ $[15] = table;
60
+ $[16] = t6;
61
+ } else t6 = $[16];
62
+ t3 = /* @__PURE__ */ jsx(Toggle, {
64
63
  size,
65
64
  className: classes,
66
65
  pressed: value !== void 0,
67
- onPressedChange: t12,
66
+ onPressedChange: t6,
68
67
  children: filter.label
69
68
  });
70
69
  break bb0;
71
70
  }
72
71
  if (filter.type === "chips") {
73
- const t12 = filter.label;
74
- let t13;
75
- if ($[20] !== className) {
76
- t13 = cx("oui-data-table__chips", className);
77
- $[20] = className;
78
- $[21] = t13;
79
- } else t13 = $[21];
80
- let t14;
81
- if ($[22] !== value) {
82
- t14 = value ?? [];
83
- $[22] = value;
84
- $[23] = t14;
85
- } else t14 = $[23];
86
- let t15;
87
- if ($[24] !== id || $[25] !== table) {
88
- t15 = (next) => table.setFilterValue(id, next.length ? next : void 0);
89
- $[24] = id;
90
- $[25] = table;
91
- $[26] = t15;
92
- } else t15 = $[26];
93
- t9 = /* @__PURE__ */ jsx(ToggleGroup, {
72
+ const t6 = filter.label;
73
+ let t7;
74
+ if ($[17] !== className) {
75
+ t7 = cx("oui-data-table__chips", className);
76
+ $[17] = className;
77
+ $[18] = t7;
78
+ } else t7 = $[18];
79
+ let t8;
80
+ if ($[19] !== value) {
81
+ t8 = value ?? [];
82
+ $[19] = value;
83
+ $[20] = t8;
84
+ } else t8 = $[20];
85
+ let t9;
86
+ if ($[21] !== id || $[22] !== table) {
87
+ t9 = (next) => table.setFilterValue(id, next.length ? next : void 0);
88
+ $[21] = id;
89
+ $[22] = table;
90
+ $[23] = t9;
91
+ } else t9 = $[23];
92
+ t3 = /* @__PURE__ */ jsx(ToggleGroup, {
94
93
  multiple: true,
95
94
  size,
96
95
  variant: "outline",
97
- "aria-label": t12,
98
- className: t13,
99
- value: t14,
100
- onValueChange: t15,
96
+ "aria-label": t6,
97
+ className: t7,
98
+ value: t8,
99
+ onValueChange: t9,
101
100
  children: filter.options.map((option) => {
102
101
  const count = filter.counts && /* @__PURE__ */ jsx("span", {
103
102
  className: "oui-data-table__filter-count",
@@ -117,136 +116,253 @@ function DataTableFilter(t0) {
117
116
  }
118
117
  if (filter.type === "dateRange") {
119
118
  const range = value ?? null;
120
- let t12;
121
- if ($[27] !== id || $[28] !== table) {
122
- t12 = (next_0) => table.setFilterValue(id, next_0 ?? void 0);
123
- $[27] = id;
124
- $[28] = table;
125
- $[29] = t12;
126
- } else t12 = $[29];
127
- t9 = /* @__PURE__ */ jsx(DateRangePicker, {
119
+ let t6;
120
+ if ($[24] !== dates.formats || $[25] !== dates.locale || $[26] !== table.locale) {
121
+ const day = (date) => formatDate(date, {
122
+ formats: dates.formats,
123
+ granularity: "day",
124
+ locale: table.locale ?? dates.locale
125
+ });
126
+ t6 = (next_0) => `${day(next_0.start)} – ${day(next_0.end)}`;
127
+ $[24] = dates.formats;
128
+ $[25] = dates.locale;
129
+ $[26] = table.locale;
130
+ $[27] = t6;
131
+ } else t6 = $[27];
132
+ const text = t6;
133
+ const sized = (content) => filter.width ? content : /* @__PURE__ */ jsxs("span", {
134
+ className: "oui-data-table__range",
135
+ children: [/* @__PURE__ */ jsx("span", {
136
+ className: "oui-data-table__range-sizer",
137
+ "aria-hidden": true,
138
+ children: text({
139
+ start: "2000-12-28",
140
+ end: "2000-12-31"
141
+ })
142
+ }), /* @__PURE__ */ jsx("span", { children: content })]
143
+ });
144
+ let t7;
145
+ if ($[28] !== sized || $[29] !== text) {
146
+ t7 = (next_1) => sized(text(next_1));
147
+ $[28] = sized;
148
+ $[29] = text;
149
+ $[30] = t7;
150
+ } else t7 = $[30];
151
+ let t8;
152
+ if ($[31] !== id || $[32] !== table) {
153
+ t8 = (next_2) => table.setFilterValue(id, next_2 ?? void 0);
154
+ $[31] = id;
155
+ $[32] = table;
156
+ $[33] = t8;
157
+ } else t8 = $[33];
158
+ const t9 = range ? `${filter.label}: ${text(range)}` : filter.label;
159
+ let t10;
160
+ if ($[34] !== style || $[35] !== t9) {
161
+ t10 = {
162
+ "aria-label": t9,
163
+ style
164
+ };
165
+ $[34] = style;
166
+ $[35] = t9;
167
+ $[36] = t10;
168
+ } else t10 = $[36];
169
+ t3 = /* @__PURE__ */ jsx(DateRangePicker, {
128
170
  size,
129
171
  className: classes,
130
- placeholder: filter.label,
172
+ placeholder: sized(filter.label),
173
+ formatValue: t7,
131
174
  value: range,
132
- onValueChange: t12,
175
+ onValueChange: t8,
133
176
  presets: filter.presets,
134
177
  min: filter.min,
135
178
  max: filter.max,
136
179
  locale: table.locale,
137
- triggerProps: { "aria-label": range ? `${filter.label}: ${formatDate(range.start)} – ${formatDate(range.end)}` : filter.label }
180
+ triggerProps: t10
138
181
  });
139
182
  break bb0;
140
183
  }
141
- T1 = Select.Root;
142
- t5 = [{
143
- value: null,
144
- label: table.labels.filterAll
145
- }, ...filter.options];
146
- t6 = value ?? null;
147
- if ($[30] !== id || $[31] !== table) {
148
- t7 = (next_1) => table.setFilterValue(id, next_1 ?? void 0);
149
- $[30] = id;
150
- $[31] = table;
151
- $[32] = t7;
152
- } else t7 = $[32];
153
- let t12;
154
- if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
155
- t12 = /* @__PURE__ */ jsx(Select.Value, {});
156
- $[33] = t12;
157
- } else t12 = $[33];
158
- let t13;
159
- if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
160
- t13 = /* @__PURE__ */ jsx("span", {
161
- className: "oui-select__icon",
162
- children: /* @__PURE__ */ jsx(ChevronDownIcon, {})
163
- });
164
- $[34] = t13;
165
- } else t13 = $[34];
166
- t8 = /* @__PURE__ */ jsxs(Select.Trigger, {
167
- size,
168
- className: classes,
169
- "data-active": value !== void 0 ? "" : void 0,
170
- children: [
171
- /* @__PURE__ */ jsx("span", {
172
- className: "oui-data-table__filter-label",
173
- children: filter.label
174
- }),
175
- t12,
176
- t13
177
- ]
178
- });
179
- T0 = Select.Content;
180
- if ($[35] !== table.labels.filterAll) {
181
- t3 = /* @__PURE__ */ jsx(Select.Item, {
182
- value: null,
183
- children: table.labels.filterAll
184
- });
185
- $[35] = table.labels.filterAll;
186
- $[36] = t3;
187
- } else t3 = $[36];
188
- t4 = filter.options.map(_temp);
189
184
  }
190
185
  $[0] = className;
191
- $[1] = id;
192
- $[2] = size;
193
- $[3] = table;
194
- $[4] = T0;
195
- $[5] = T1;
196
- $[6] = t3;
197
- $[7] = t4;
198
- $[8] = t5;
199
- $[9] = t6;
200
- $[10] = t7;
201
- $[11] = t8;
202
- $[12] = t9;
186
+ $[1] = dates;
187
+ $[2] = id;
188
+ $[3] = size;
189
+ $[4] = table;
190
+ $[5] = classes;
191
+ $[6] = filter;
192
+ $[7] = style;
193
+ $[8] = t3;
194
+ $[9] = value;
203
195
  } else {
204
- T0 = $[4];
205
- T1 = $[5];
206
- t3 = $[6];
207
- t4 = $[7];
208
- t5 = $[8];
209
- t6 = $[9];
210
- t7 = $[10];
211
- t8 = $[11];
212
- t9 = $[12];
196
+ classes = $[5];
197
+ filter = $[6];
198
+ style = $[7];
199
+ t3 = $[8];
200
+ value = $[9];
213
201
  }
214
- if (t9 !== Symbol.for("react.early_return_sentinel")) return t9;
215
- let t10;
216
- if ($[37] !== T0 || $[38] !== t3 || $[39] !== t4) {
217
- t10 = /* @__PURE__ */ jsxs(T0, { children: [t3, t4] });
218
- $[37] = T0;
219
- $[38] = t3;
202
+ if (t3 !== Symbol.for("react.early_return_sentinel")) return t3;
203
+ let t4;
204
+ if ($[37] !== filter.multiple || $[38] !== value) {
205
+ t4 = filter.multiple ? value ?? [] : [];
206
+ $[37] = filter.multiple;
207
+ $[38] = value;
220
208
  $[39] = t4;
221
- $[40] = t10;
222
- } else t10 = $[40];
209
+ } else t4 = $[39];
210
+ const chosen = t4;
211
+ const t5 = value !== void 0 ? "" : void 0;
212
+ let t6;
213
+ if ($[40] !== filter.label) {
214
+ t6 = /* @__PURE__ */ jsx("span", {
215
+ className: "oui-data-table__filter-label",
216
+ children: filter.label
217
+ });
218
+ $[40] = filter.label;
219
+ $[41] = t6;
220
+ } else t6 = $[41];
221
+ let t7;
222
+ if ($[42] !== chosen || $[43] !== filter.multiple || $[44] !== filter.options || $[45] !== table.labels) {
223
+ t7 = filter.multiple ? /* @__PURE__ */ jsx(Select.Value, { children: () => chosen.length ? [optionText(filter.options.find((option_0) => option_0.value === chosen[0]), chosen[0]), chosen.length > 1 && ` +${chosen.length - 1}`] : table.labels.filterAll }) : /* @__PURE__ */ jsx(Select.Value, {});
224
+ $[42] = chosen;
225
+ $[43] = filter.multiple;
226
+ $[44] = filter.options;
227
+ $[45] = table.labels;
228
+ $[46] = t7;
229
+ } else t7 = $[46];
230
+ let t8;
231
+ if ($[47] === Symbol.for("react.memo_cache_sentinel")) {
232
+ t8 = /* @__PURE__ */ jsx("span", {
233
+ className: "oui-select__icon",
234
+ children: /* @__PURE__ */ jsx(ChevronDownIcon, {})
235
+ });
236
+ $[47] = t8;
237
+ } else t8 = $[47];
238
+ let t9;
239
+ if ($[48] !== classes || $[49] !== size || $[50] !== style || $[51] !== t5 || $[52] !== t6 || $[53] !== t7) {
240
+ t9 = /* @__PURE__ */ jsxs(Select.Trigger, {
241
+ size,
242
+ className: classes,
243
+ style,
244
+ "data-active": t5,
245
+ children: [
246
+ t6,
247
+ t7,
248
+ t8
249
+ ]
250
+ });
251
+ $[48] = classes;
252
+ $[49] = size;
253
+ $[50] = style;
254
+ $[51] = t5;
255
+ $[52] = t6;
256
+ $[53] = t7;
257
+ $[54] = t9;
258
+ } else t9 = $[54];
259
+ const trigger = t9;
260
+ let t10;
261
+ if ($[55] !== filter.options) {
262
+ t10 = filter.options.map(_temp);
263
+ $[55] = filter.options;
264
+ $[56] = t10;
265
+ } else t10 = $[56];
266
+ const items = t10;
267
+ if (filter.multiple) {
268
+ let t11;
269
+ if ($[57] !== id || $[58] !== table) {
270
+ t11 = (next_3) => table.setFilterValue(id, next_3.length ? next_3 : void 0);
271
+ $[57] = id;
272
+ $[58] = table;
273
+ $[59] = t11;
274
+ } else t11 = $[59];
275
+ let t12;
276
+ if ($[60] !== items) {
277
+ t12 = /* @__PURE__ */ jsx(Select.Content, { children: items });
278
+ $[60] = items;
279
+ $[61] = t12;
280
+ } else t12 = $[61];
281
+ let t13;
282
+ if ($[62] !== chosen || $[63] !== filter.options || $[64] !== t11 || $[65] !== t12 || $[66] !== trigger) {
283
+ t13 = /* @__PURE__ */ jsxs(Select.Root, {
284
+ multiple: true,
285
+ items: filter.options,
286
+ value: chosen,
287
+ onValueChange: t11,
288
+ children: [trigger, t12]
289
+ });
290
+ $[62] = chosen;
291
+ $[63] = filter.options;
292
+ $[64] = t11;
293
+ $[65] = t12;
294
+ $[66] = trigger;
295
+ $[67] = t13;
296
+ } else t13 = $[67];
297
+ return t13;
298
+ }
223
299
  let t11;
224
- if ($[41] !== T1 || $[42] !== t10 || $[43] !== t5 || $[44] !== t6 || $[45] !== t7 || $[46] !== t8) {
225
- t11 = /* @__PURE__ */ jsxs(T1, {
226
- items: t5,
227
- value: t6,
228
- onValueChange: t7,
229
- children: [t8, t10]
300
+ if ($[68] !== table.labels.filterAll) {
301
+ t11 = {
302
+ value: null,
303
+ label: table.labels.filterAll
304
+ };
305
+ $[68] = table.labels.filterAll;
306
+ $[69] = t11;
307
+ } else t11 = $[69];
308
+ let t12;
309
+ if ($[70] !== filter.options || $[71] !== t11) {
310
+ t12 = [t11, ...filter.options];
311
+ $[70] = filter.options;
312
+ $[71] = t11;
313
+ $[72] = t12;
314
+ } else t12 = $[72];
315
+ const t13 = value ?? null;
316
+ let t14;
317
+ if ($[73] !== id || $[74] !== table) {
318
+ t14 = (next_4) => table.setFilterValue(id, next_4 ?? void 0);
319
+ $[73] = id;
320
+ $[74] = table;
321
+ $[75] = t14;
322
+ } else t14 = $[75];
323
+ let t15;
324
+ if ($[76] !== table.labels.filterAll) {
325
+ t15 = /* @__PURE__ */ jsx(Select.Item, {
326
+ value: null,
327
+ children: table.labels.filterAll
328
+ });
329
+ $[76] = table.labels.filterAll;
330
+ $[77] = t15;
331
+ } else t15 = $[77];
332
+ let t16;
333
+ if ($[78] !== items || $[79] !== t15) {
334
+ t16 = /* @__PURE__ */ jsxs(Select.Content, { children: [t15, items] });
335
+ $[78] = items;
336
+ $[79] = t15;
337
+ $[80] = t16;
338
+ } else t16 = $[80];
339
+ let t17;
340
+ if ($[81] !== t12 || $[82] !== t13 || $[83] !== t14 || $[84] !== t16 || $[85] !== trigger) {
341
+ t17 = /* @__PURE__ */ jsxs(Select.Root, {
342
+ items: t12,
343
+ value: t13,
344
+ onValueChange: t14,
345
+ children: [trigger, t16]
230
346
  });
231
- $[41] = T1;
232
- $[42] = t10;
233
- $[43] = t5;
234
- $[44] = t6;
235
- $[45] = t7;
236
- $[46] = t8;
237
- $[47] = t11;
238
- } else t11 = $[47];
239
- return t11;
347
+ $[81] = t12;
348
+ $[82] = t13;
349
+ $[83] = t14;
350
+ $[84] = t16;
351
+ $[85] = trigger;
352
+ $[86] = t17;
353
+ } else t17 = $[86];
354
+ return t17;
240
355
  }
241
- function _temp(option_0) {
356
+ function _temp(option_1) {
242
357
  return /* @__PURE__ */ jsx(Select.Item, {
243
- value: option_0.value,
244
- children: option_0.label
245
- }, option_0.value);
358
+ value: option_1.value,
359
+ children: option_1.label
360
+ }, option_1.value);
246
361
  }
247
362
  /**
248
- * The filters of the table, in a wrapping row. Children are added after the filters. Selects and date
249
- * ranges in the row have a fixed width (`--oui-data-table-filter-width`), so picking a value moves nothing.
363
+ * The filters of the table, in a wrapping row. Children are added after the filters. Selects in the row have
364
+ * a fixed width (`--oui-data-table-filter-width`), and date ranges the width of a full range, so picking a
365
+ * value moves nothing. A filter's `width` overrides both.
250
366
  */
251
367
  function DataTableFilters(t0) {
252
368
  const $ = c(26);
@@ -629,7 +745,7 @@ function valueText(filter, value) {
629
745
  const range = value;
630
746
  return `${formatDate(range.start)} – ${formatDate(range.end)}`;
631
747
  }
632
- if (filter.type === "chips") {
748
+ if (filter.type === "chips" || filter.multiple) {
633
749
  const items = value;
634
750
  return /* @__PURE__ */ jsxs(Fragment, { children: [items.slice(0, 2).map((item, index) => /* @__PURE__ */ jsxs(React.Fragment, { children: [index > 0 && ", ", option(item)] }, item)), items.length > 2 && ` +${items.length - 2}`] });
635
751
  }