@bolio-ui/core 3.0.0-alpha.1 → 3.0.0-alpha.2
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/dist/ContextMenu/index.js +3 -3
- package/dist/CssBaseline/index.js +2 -2
- package/dist/DateRangePicker/index.js +2 -2
- package/dist/ImageZoom/ImageZoom.d.ts +14 -0
- package/dist/ImageZoom/index.d.ts +3 -0
- package/dist/ImageZoom/index.js +17 -0
- package/dist/Menu/index.js +2 -2
- package/dist/Splitter/Splitter.d.ts +14 -0
- package/dist/Splitter/SplitterContext.d.ts +6 -0
- package/dist/Splitter/SplitterPanel.d.ts +13 -0
- package/dist/Splitter/index.d.ts +9 -0
- package/dist/Splitter/index.js +14 -0
- package/dist/Table/Table.d.ts +11 -1
- package/dist/Table/TableBody.d.ts +8 -2
- package/dist/Table/TableColumn.d.ts +2 -0
- package/dist/Table/TableHead.d.ts +9 -1
- package/dist/Table/TableSelectBox.d.ts +9 -0
- package/dist/Table/TableTypes.d.ts +8 -0
- package/dist/Table/index.d.ts +1 -1
- package/dist/Table/index.js +2 -2
- package/dist/Tour/Tour.d.ts +26 -0
- package/dist/Tour/index.d.ts +3 -0
- package/dist/Tour/index.js +23 -0
- package/dist/{chunk-AVO2SK2I.js → chunk-3S6G7WGK.js} +2 -2
- package/dist/{chunk-GYFW5NLU.js → chunk-BHQRX76X.js} +22 -4
- package/dist/chunk-FFEAKF3A.js +220 -0
- package/dist/{chunk-XLPOECCE.js → chunk-FL6J36B7.js} +3 -2
- package/dist/chunk-REWKR7S3.js +109 -0
- package/dist/chunk-STYC6O24.js +232 -0
- package/dist/{chunk-TDJGMSGT.js → chunk-WIIDIZYK.js} +3 -1
- package/dist/{chunk-TKICX5R6.js → chunk-ZNDN2VPZ.js} +225 -33
- package/dist/css/ButtonDropdown-ButtonDropdownItem.css +0 -1
- package/dist/css/ButtonGroup.css +0 -1
- package/dist/css/Calendar.css +0 -1
- package/dist/css/Carousel.css +0 -1
- package/dist/css/ColorInput.css +0 -2
- package/dist/css/ColorPicker.css +0 -3
- package/dist/css/Combobox.css +0 -2
- package/dist/css/DatePicker.css +0 -3
- package/dist/css/DateRangePicker.css +6 -3
- package/dist/css/Dropzone.css +0 -3
- package/dist/css/Fieldset-FieldsetGroup.css +0 -1
- package/dist/css/ImageZoom.css +93 -0
- package/dist/css/Input.css +0 -1
- package/dist/css/Menu-MenuList.css +0 -1
- package/dist/css/NumberInput.css +0 -1
- package/dist/css/PinInput.css +0 -1
- package/dist/css/Radio.css +0 -1
- package/dist/css/SegmentedControl.css +0 -1
- package/dist/css/Select-SelectDropdown.css +0 -1
- package/dist/css/Select-SelectOption.css +0 -1
- package/dist/css/Select.css +0 -1
- package/dist/css/Splitter.css +77 -0
- package/dist/css/Table-TableBody.css +10 -0
- package/dist/css/Table-TableHead.css +41 -0
- package/dist/css/Table-TableSelectBox.css +11 -0
- package/dist/css/TagsInput.css +0 -2
- package/dist/css/Textarea.css +0 -1
- package/dist/css/Toggle.css +0 -1
- package/dist/css/Tour.css +81 -0
- package/dist/css/use-toasts-toast-item.css +0 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +31 -19
- package/dist/styles.css +3227 -2939
- package/esm/ContextMenu/index.js +2 -2
- package/esm/CssBaseline/index.js +1 -1
- package/esm/DateRangePicker/index.js +1 -1
- package/esm/ImageZoom/ImageZoom.d.ts +14 -0
- package/esm/ImageZoom/index.d.ts +3 -0
- package/esm/ImageZoom/index.js +17 -0
- package/esm/Menu/index.js +1 -1
- package/esm/Splitter/Splitter.d.ts +14 -0
- package/esm/Splitter/SplitterContext.d.ts +6 -0
- package/esm/Splitter/SplitterPanel.d.ts +13 -0
- package/esm/Splitter/index.d.ts +9 -0
- package/esm/Splitter/index.js +14 -0
- package/esm/Table/Table.d.ts +11 -1
- package/esm/Table/TableBody.d.ts +8 -2
- package/esm/Table/TableColumn.d.ts +2 -0
- package/esm/Table/TableHead.d.ts +9 -1
- package/esm/Table/TableSelectBox.d.ts +9 -0
- package/esm/Table/TableTypes.d.ts +8 -0
- package/esm/Table/index.d.ts +1 -1
- package/esm/Table/index.js +1 -1
- package/esm/Tour/Tour.d.ts +26 -0
- package/esm/Tour/index.d.ts +3 -0
- package/esm/Tour/index.js +23 -0
- package/esm/{chunk-AVO2SK2I.js → chunk-3S6G7WGK.js} +1 -1
- package/esm/{chunk-GYFW5NLU.js → chunk-BHQRX76X.js} +22 -4
- package/esm/chunk-FFEAKF3A.js +220 -0
- package/esm/{chunk-XLPOECCE.js → chunk-FL6J36B7.js} +3 -2
- package/esm/chunk-REWKR7S3.js +109 -0
- package/esm/chunk-STYC6O24.js +232 -0
- package/esm/{chunk-TDJGMSGT.js → chunk-WIIDIZYK.js} +3 -1
- package/esm/chunk-ZNDN2VPZ.js +543 -0
- package/esm/css/ButtonDropdown-ButtonDropdownItem.css +0 -1
- package/esm/css/ButtonGroup.css +0 -1
- package/esm/css/Calendar.css +0 -1
- package/esm/css/Carousel.css +0 -1
- package/esm/css/ColorInput.css +0 -2
- package/esm/css/ColorPicker.css +0 -3
- package/esm/css/Combobox.css +0 -2
- package/esm/css/DatePicker.css +0 -3
- package/esm/css/DateRangePicker.css +6 -3
- package/esm/css/Dropzone.css +0 -3
- package/esm/css/Fieldset-FieldsetGroup.css +0 -1
- package/esm/css/ImageZoom.css +93 -0
- package/esm/css/Input.css +0 -1
- package/esm/css/Menu-MenuList.css +0 -1
- package/esm/css/NumberInput.css +0 -1
- package/esm/css/PinInput.css +0 -1
- package/esm/css/Radio.css +0 -1
- package/esm/css/SegmentedControl.css +0 -1
- package/esm/css/Select-SelectDropdown.css +0 -1
- package/esm/css/Select-SelectOption.css +0 -1
- package/esm/css/Select.css +0 -1
- package/esm/css/Splitter.css +77 -0
- package/esm/css/Table-TableBody.css +10 -0
- package/esm/css/Table-TableHead.css +41 -0
- package/esm/css/Table-TableSelectBox.css +11 -0
- package/esm/css/TagsInput.css +0 -2
- package/esm/css/Textarea.css +0 -1
- package/esm/css/Toggle.css +0 -1
- package/esm/css/Tour.css +81 -0
- package/esm/css/use-toasts-toast-item.css +0 -1
- package/esm/index.d.ts +7 -1
- package/esm/index.js +36 -24
- package/esm/styles.css +2987 -2699
- package/package.json +1 -1
- package/esm/chunk-TKICX5R6.js +0 -351
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Pagination_default
|
|
3
|
+
} from "./chunk-E5EDUOQT.js";
|
|
4
|
+
import {
|
|
5
|
+
use_resize_default
|
|
6
|
+
} from "./chunk-JJFOGZ6V.js";
|
|
7
|
+
import {
|
|
8
|
+
use_real_shape_default
|
|
9
|
+
} from "./chunk-HKOESPKZ.js";
|
|
10
|
+
import {
|
|
11
|
+
log_warning_default
|
|
12
|
+
} from "./chunk-AXYDJGTN.js";
|
|
13
|
+
import {
|
|
14
|
+
use_scale_default,
|
|
15
|
+
with_scale_default
|
|
16
|
+
} from "./chunk-MAICNLTY.js";
|
|
17
|
+
import {
|
|
18
|
+
use_theme_default
|
|
19
|
+
} from "./chunk-V5I4ORQQ.js";
|
|
20
|
+
import {
|
|
21
|
+
joinClasses,
|
|
22
|
+
use_classes_default
|
|
23
|
+
} from "./chunk-5KUROAEP.js";
|
|
24
|
+
|
|
25
|
+
// core/Table/Table.tsx
|
|
26
|
+
import React5, {
|
|
27
|
+
useCallback,
|
|
28
|
+
useEffect as useEffect3,
|
|
29
|
+
useImperativeHandle,
|
|
30
|
+
useMemo as useMemo2,
|
|
31
|
+
useRef as useRef2,
|
|
32
|
+
useState
|
|
33
|
+
} from "react";
|
|
34
|
+
|
|
35
|
+
// core/Table/TableHead.tsx
|
|
36
|
+
import { useMemo } from "react";
|
|
37
|
+
|
|
38
|
+
// core/Table/TableSelectBox.tsx
|
|
39
|
+
import { useEffect, useRef } from "react";
|
|
40
|
+
|
|
41
|
+
// css-module-source:/Users/brunnoandrade/Desktop/BolioUI/bolio-ui/core/Table/TableSelectBox.module.css.bolio-css-module-source
|
|
42
|
+
var TableSelectBox_module_css_default = { "box": "TableSelectBox-module_box__UXj-E" };
|
|
43
|
+
|
|
44
|
+
// core/Table/TableSelectBox.tsx
|
|
45
|
+
import { jsx } from "react/jsx-runtime";
|
|
46
|
+
function TableSelectBox({
|
|
47
|
+
checked,
|
|
48
|
+
indeterminate = false,
|
|
49
|
+
label,
|
|
50
|
+
onChange
|
|
51
|
+
}) {
|
|
52
|
+
const ref = useRef(null);
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (ref.current) ref.current.indeterminate = indeterminate;
|
|
55
|
+
}, [indeterminate]);
|
|
56
|
+
return /* @__PURE__ */ jsx(
|
|
57
|
+
"input",
|
|
58
|
+
{
|
|
59
|
+
ref,
|
|
60
|
+
type: "checkbox",
|
|
61
|
+
className: TableSelectBox_module_css_default.box,
|
|
62
|
+
checked,
|
|
63
|
+
"aria-label": label,
|
|
64
|
+
onChange,
|
|
65
|
+
onClick: (event) => event.stopPropagation()
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
var TableSelectBox_default = TableSelectBox;
|
|
70
|
+
|
|
71
|
+
// css-module-source:/Users/brunnoandrade/Desktop/BolioUI/bolio-ui/core/Table/TableHead.module.css.bolio-css-module-source
|
|
72
|
+
var TableHead_module_css_default = { "thead": "TableHead-module_thead__zMtMt", "th": "TableHead-module_th__GzIce", "theadBox": "TableHead-module_theadBox__6QaBJ", "selectCell": "TableHead-module_selectCell__JRdGg", "sortButton": "TableHead-module_sortButton__whwp3", "sortIcon": "TableHead-module_sortIcon__VsHqp", "sorted": "TableHead-module_sorted__-6XtK" };
|
|
73
|
+
|
|
74
|
+
// core/Table/TableHead.tsx
|
|
75
|
+
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
76
|
+
var SELECT_WIDTH = 40;
|
|
77
|
+
var makeColgroup = (fullWidth, columns, leading) => {
|
|
78
|
+
const width = fullWidth - leading;
|
|
79
|
+
const unsetWidthCount = columns.filter((c) => !c.width).length;
|
|
80
|
+
const customWidthTotal = columns.reduce((pre, current) => {
|
|
81
|
+
return current.width ? pre + current.width : pre;
|
|
82
|
+
}, 0);
|
|
83
|
+
const averageWidth = (width - customWidthTotal) / unsetWidthCount;
|
|
84
|
+
if (averageWidth <= 0) return /* @__PURE__ */ jsx2("colgroup", {});
|
|
85
|
+
return /* @__PURE__ */ jsxs("colgroup", { children: [
|
|
86
|
+
leading > 0 && /* @__PURE__ */ jsx2("col", { width: leading }),
|
|
87
|
+
columns.map((column, index) => /* @__PURE__ */ jsx2("col", { width: column.width || averageWidth }, `colgroup-${index}`))
|
|
88
|
+
] });
|
|
89
|
+
};
|
|
90
|
+
var TableHead = (props) => {
|
|
91
|
+
const theme = use_theme_default();
|
|
92
|
+
const { columns, width, sort, onSort, selection } = props;
|
|
93
|
+
const isScalableWidth = useMemo(
|
|
94
|
+
() => columns.find((item) => !!item.width),
|
|
95
|
+
[columns]
|
|
96
|
+
);
|
|
97
|
+
const colgroup = useMemo(() => {
|
|
98
|
+
if (!isScalableWidth) return /* @__PURE__ */ jsx2("colgroup", {});
|
|
99
|
+
return makeColgroup(width, columns, selection ? SELECT_WIDTH : 0);
|
|
100
|
+
}, [isScalableWidth, width, columns, selection]);
|
|
101
|
+
const theadStyle = {
|
|
102
|
+
"--table-head-text-color": theme.palette.accents_5,
|
|
103
|
+
"--table-head-bg": theme.palette.accents_1,
|
|
104
|
+
"--table-head-border-color": theme.palette.border,
|
|
105
|
+
"--table-head-radius": theme.layout.radius,
|
|
106
|
+
"--table-head-sorted-color": theme.palette.foreground,
|
|
107
|
+
"--table-head-focus-color": theme.palette.primary
|
|
108
|
+
};
|
|
109
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
110
|
+
colgroup,
|
|
111
|
+
/* @__PURE__ */ jsx2("thead", { className: TableHead_module_css_default.thead, style: theadStyle, children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
112
|
+
selection && /* @__PURE__ */ jsx2("th", { className: joinClasses(TableHead_module_css_default.th, TableHead_module_css_default.selectCell), children: /* @__PURE__ */ jsx2("div", { className: TableHead_module_css_default.theadBox, children: /* @__PURE__ */ jsx2(
|
|
113
|
+
TableSelectBox_default,
|
|
114
|
+
{
|
|
115
|
+
checked: selection.checked,
|
|
116
|
+
indeterminate: selection.indeterminate,
|
|
117
|
+
label: selection.label,
|
|
118
|
+
onChange: selection.onToggle
|
|
119
|
+
}
|
|
120
|
+
) }) }),
|
|
121
|
+
columns.map((column, index) => {
|
|
122
|
+
const prop = String(column.prop);
|
|
123
|
+
const direction = sort && sort.prop === prop ? sort.direction : null;
|
|
124
|
+
return /* @__PURE__ */ jsx2(
|
|
125
|
+
"th",
|
|
126
|
+
{
|
|
127
|
+
className: joinClasses(TableHead_module_css_default.th, column.className),
|
|
128
|
+
"aria-sort": column.sortable ? direction === "asc" ? "ascending" : direction === "desc" ? "descending" : "none" : void 0,
|
|
129
|
+
children: /* @__PURE__ */ jsx2("div", { className: TableHead_module_css_default.theadBox, children: column.sortable ? /* @__PURE__ */ jsxs(
|
|
130
|
+
"button",
|
|
131
|
+
{
|
|
132
|
+
type: "button",
|
|
133
|
+
className: TableHead_module_css_default.sortButton,
|
|
134
|
+
onClick: () => onSort && onSort(prop),
|
|
135
|
+
children: [
|
|
136
|
+
column.label,
|
|
137
|
+
/* @__PURE__ */ jsx2(
|
|
138
|
+
"svg",
|
|
139
|
+
{
|
|
140
|
+
viewBox: "0 0 24 24",
|
|
141
|
+
width: "1em",
|
|
142
|
+
height: "1em",
|
|
143
|
+
fill: "none",
|
|
144
|
+
stroke: "currentColor",
|
|
145
|
+
strokeWidth: "2",
|
|
146
|
+
strokeLinecap: "round",
|
|
147
|
+
strokeLinejoin: "round",
|
|
148
|
+
className: joinClasses(TableHead_module_css_default.sortIcon, {
|
|
149
|
+
[TableHead_module_css_default.sorted]: direction !== null
|
|
150
|
+
}),
|
|
151
|
+
"aria-hidden": "true",
|
|
152
|
+
children: /* @__PURE__ */ jsx2(
|
|
153
|
+
"path",
|
|
154
|
+
{
|
|
155
|
+
d: direction === "asc" ? "M12 19V5M5 12l7-7 7 7" : direction === "desc" ? "M12 5v14M19 12l-7 7-7-7" : "M8 9l4-4 4 4M8 15l4 4 4-4"
|
|
156
|
+
}
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
)
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
) : column.label })
|
|
163
|
+
},
|
|
164
|
+
`table-th-${prop}-${index}`
|
|
165
|
+
);
|
|
166
|
+
})
|
|
167
|
+
] }) })
|
|
168
|
+
] });
|
|
169
|
+
};
|
|
170
|
+
TableHead.displayName = "BolioUITableHead";
|
|
171
|
+
var TableHead_default = TableHead;
|
|
172
|
+
|
|
173
|
+
// core/Table/TableCell.tsx
|
|
174
|
+
import { Fragment as Fragment2, jsx as jsx3 } from "react/jsx-runtime";
|
|
175
|
+
var TableCell = ({
|
|
176
|
+
columns,
|
|
177
|
+
row,
|
|
178
|
+
rowIndex,
|
|
179
|
+
emptyText,
|
|
180
|
+
onCellClick
|
|
181
|
+
}) => {
|
|
182
|
+
return /* @__PURE__ */ jsx3(Fragment2, { children: columns.map((column, index) => {
|
|
183
|
+
const currentRowValue = row[column.prop];
|
|
184
|
+
const cellValue = currentRowValue || emptyText;
|
|
185
|
+
const shouldBeRenderElement = column.renderHandler(
|
|
186
|
+
currentRowValue,
|
|
187
|
+
row,
|
|
188
|
+
rowIndex
|
|
189
|
+
);
|
|
190
|
+
return /* @__PURE__ */ jsx3(
|
|
191
|
+
"td",
|
|
192
|
+
{
|
|
193
|
+
onClick: () => onCellClick && onCellClick(currentRowValue, rowIndex, index),
|
|
194
|
+
className: column.className,
|
|
195
|
+
children: /* @__PURE__ */ jsx3("div", { className: "cell", children: shouldBeRenderElement ? shouldBeRenderElement : cellValue })
|
|
196
|
+
},
|
|
197
|
+
`row-td-${index}-${String(column.prop)}`
|
|
198
|
+
);
|
|
199
|
+
}) });
|
|
200
|
+
};
|
|
201
|
+
var TableCell_default = TableCell;
|
|
202
|
+
|
|
203
|
+
// core/Table/TableContext.ts
|
|
204
|
+
import React3 from "react";
|
|
205
|
+
var defaultContext = {
|
|
206
|
+
columns: [],
|
|
207
|
+
updateColumn: () => {
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
var TableContext = React3.createContext(defaultContext);
|
|
211
|
+
var useTableContext = () => React3.useContext(TableContext);
|
|
212
|
+
|
|
213
|
+
// css-module-source:/Users/brunnoandrade/Desktop/BolioUI/bolio-ui/core/Table/TableBody.module.css.bolio-css-module-source
|
|
214
|
+
var TableBody_module_css_default = { "tr": "TableBody-module_tr__lTn-M", "hover": "TableBody-module_hover__AjVlq", "selected": "TableBody-module_selected__7adtQ", "selectCell": "TableBody-module_selectCell__S8ZZn" };
|
|
215
|
+
|
|
216
|
+
// core/Table/TableBody.tsx
|
|
217
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
218
|
+
var TableBody = ({
|
|
219
|
+
data,
|
|
220
|
+
keys,
|
|
221
|
+
selection,
|
|
222
|
+
hover,
|
|
223
|
+
emptyText,
|
|
224
|
+
onRow,
|
|
225
|
+
onCell,
|
|
226
|
+
rowClassName
|
|
227
|
+
}) => {
|
|
228
|
+
const theme = use_theme_default();
|
|
229
|
+
const { columns } = useTableContext();
|
|
230
|
+
const rowClickHandler = (row, index) => {
|
|
231
|
+
if (onRow) onRow(row, index);
|
|
232
|
+
};
|
|
233
|
+
const trStyle = {
|
|
234
|
+
"--table-body-hover-bg": theme.palette.accents_1,
|
|
235
|
+
"--table-body-border-color": theme.palette.border,
|
|
236
|
+
"--table-body-text-color": theme.palette.accents_6,
|
|
237
|
+
"--table-body-selected-bg": `color-mix(in srgb, ${theme.palette.primary} 10%, transparent)`
|
|
238
|
+
};
|
|
239
|
+
return /* @__PURE__ */ jsx4("tbody", { children: data.map((row, index) => {
|
|
240
|
+
const className = rowClassName(row, index);
|
|
241
|
+
const selected = Boolean(selection == null ? void 0 : selection.keys.includes(keys[index]));
|
|
242
|
+
return /* @__PURE__ */ jsxs2(
|
|
243
|
+
"tr",
|
|
244
|
+
{
|
|
245
|
+
className: joinClasses(
|
|
246
|
+
TableBody_module_css_default.tr,
|
|
247
|
+
{ [TableBody_module_css_default.hover]: hover, [TableBody_module_css_default.selected]: selected },
|
|
248
|
+
className
|
|
249
|
+
),
|
|
250
|
+
onClick: () => rowClickHandler(row, index),
|
|
251
|
+
style: trStyle,
|
|
252
|
+
children: [
|
|
253
|
+
selection && /* @__PURE__ */ jsx4("td", { className: TableBody_module_css_default.selectCell, children: /* @__PURE__ */ jsx4("div", { className: "cell", children: /* @__PURE__ */ jsx4(
|
|
254
|
+
TableSelectBox_default,
|
|
255
|
+
{
|
|
256
|
+
checked: selected,
|
|
257
|
+
label: selection.label,
|
|
258
|
+
onChange: () => selection.onToggle(keys[index])
|
|
259
|
+
}
|
|
260
|
+
) }) }),
|
|
261
|
+
/* @__PURE__ */ jsx4(
|
|
262
|
+
TableCell_default,
|
|
263
|
+
{
|
|
264
|
+
columns,
|
|
265
|
+
row,
|
|
266
|
+
rowIndex: index,
|
|
267
|
+
emptyText,
|
|
268
|
+
onCellClick: onCell
|
|
269
|
+
}
|
|
270
|
+
)
|
|
271
|
+
]
|
|
272
|
+
},
|
|
273
|
+
`tbody-row-${index}`
|
|
274
|
+
);
|
|
275
|
+
}) });
|
|
276
|
+
};
|
|
277
|
+
TableBody.displayName = "BolioUITableBody";
|
|
278
|
+
var TableBody_default = TableBody;
|
|
279
|
+
|
|
280
|
+
// core/Table/TableColumn.tsx
|
|
281
|
+
import { useEffect as useEffect2 } from "react";
|
|
282
|
+
var defaultRender = () => {
|
|
283
|
+
};
|
|
284
|
+
var TableColumn = (columnProps) => {
|
|
285
|
+
const {
|
|
286
|
+
children,
|
|
287
|
+
prop,
|
|
288
|
+
label,
|
|
289
|
+
width,
|
|
290
|
+
className = "",
|
|
291
|
+
sortable = false,
|
|
292
|
+
sorter,
|
|
293
|
+
render: renderHandler = defaultRender
|
|
294
|
+
} = columnProps;
|
|
295
|
+
const { updateColumn } = useTableContext();
|
|
296
|
+
const safeProp = String(prop).trim();
|
|
297
|
+
if (!safeProp) {
|
|
298
|
+
log_warning_default('The props "prop" is required.', "Table.Column");
|
|
299
|
+
}
|
|
300
|
+
useEffect2(() => {
|
|
301
|
+
updateColumn({
|
|
302
|
+
label: children || label,
|
|
303
|
+
prop: safeProp,
|
|
304
|
+
width,
|
|
305
|
+
className,
|
|
306
|
+
sortable,
|
|
307
|
+
sorter,
|
|
308
|
+
renderHandler
|
|
309
|
+
});
|
|
310
|
+
}, [
|
|
311
|
+
children,
|
|
312
|
+
label,
|
|
313
|
+
safeProp,
|
|
314
|
+
width,
|
|
315
|
+
className,
|
|
316
|
+
sortable,
|
|
317
|
+
sorter,
|
|
318
|
+
renderHandler,
|
|
319
|
+
updateColumn
|
|
320
|
+
]);
|
|
321
|
+
return null;
|
|
322
|
+
};
|
|
323
|
+
TableColumn.displayName = "BolioUITableColumn";
|
|
324
|
+
var TableColumn_default = TableColumn;
|
|
325
|
+
|
|
326
|
+
// css-module-source:/Users/brunnoandrade/Desktop/BolioUI/bolio-ui/core/Table/Table.module.css.bolio-css-module-source
|
|
327
|
+
var Table_module_css_default = { "table": "Table-module_table__H9ZOx", "footer": "Table-module_footer__7eFVi" };
|
|
328
|
+
|
|
329
|
+
// core/Table/Table.tsx
|
|
330
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
331
|
+
var noKeys = [];
|
|
332
|
+
var compareValues = (a, b) => typeof a === "number" && typeof b === "number" ? a - b : String(a != null ? a : "").localeCompare(String(b != null ? b : ""), void 0, {
|
|
333
|
+
numeric: true,
|
|
334
|
+
sensitivity: "base"
|
|
335
|
+
});
|
|
336
|
+
var defaultProps = {
|
|
337
|
+
hover: true,
|
|
338
|
+
initialData: [],
|
|
339
|
+
emptyText: "",
|
|
340
|
+
className: "",
|
|
341
|
+
rowClassName: () => ""
|
|
342
|
+
};
|
|
343
|
+
function TableComponent(tableProps, forwardedRef) {
|
|
344
|
+
var _a, _b;
|
|
345
|
+
const {
|
|
346
|
+
children,
|
|
347
|
+
data: customData,
|
|
348
|
+
initialData = defaultProps.initialData,
|
|
349
|
+
hover = defaultProps.hover,
|
|
350
|
+
emptyText = defaultProps.emptyText,
|
|
351
|
+
onRow,
|
|
352
|
+
onCell,
|
|
353
|
+
onChange,
|
|
354
|
+
pagination,
|
|
355
|
+
className = defaultProps.className,
|
|
356
|
+
rowClassName = defaultProps.rowClassName,
|
|
357
|
+
sort: customSort,
|
|
358
|
+
initialSort = null,
|
|
359
|
+
onSortChange,
|
|
360
|
+
selectable = false,
|
|
361
|
+
rowKey,
|
|
362
|
+
selectedKeys: customKeys,
|
|
363
|
+
initialSelectedKeys = noKeys,
|
|
364
|
+
onSelectionChange,
|
|
365
|
+
selectRowLabel = "Select row",
|
|
366
|
+
selectAllLabel = "Select all rows",
|
|
367
|
+
style,
|
|
368
|
+
...props
|
|
369
|
+
} = tableProps;
|
|
370
|
+
const theme = use_theme_default();
|
|
371
|
+
const { SCALES } = use_scale_default();
|
|
372
|
+
const tableRef = useRef2(null);
|
|
373
|
+
useImperativeHandle(forwardedRef, () => tableRef.current);
|
|
374
|
+
const [{ width }, updateShape] = use_real_shape_default(tableRef);
|
|
375
|
+
const [columns, setColumns] = useState([]);
|
|
376
|
+
const [data, setData] = useState(initialData);
|
|
377
|
+
const updateColumn = useCallback(
|
|
378
|
+
(column) => {
|
|
379
|
+
setColumns((last) => {
|
|
380
|
+
const hasColumn = last.find((item) => item.prop === column.prop);
|
|
381
|
+
if (!hasColumn) return [...last, column];
|
|
382
|
+
return last.map((item) => {
|
|
383
|
+
if (item.prop !== column.prop) return item;
|
|
384
|
+
return column;
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
},
|
|
388
|
+
[]
|
|
389
|
+
);
|
|
390
|
+
const contextValue = useMemo2(
|
|
391
|
+
() => ({
|
|
392
|
+
columns,
|
|
393
|
+
updateColumn
|
|
394
|
+
}),
|
|
395
|
+
[columns, updateColumn]
|
|
396
|
+
);
|
|
397
|
+
useEffect3(() => {
|
|
398
|
+
if (typeof customData === "undefined") return;
|
|
399
|
+
setData(customData);
|
|
400
|
+
}, [customData]);
|
|
401
|
+
use_resize_default(() => updateShape());
|
|
402
|
+
const [selfSort, setSelfSort] = useState(initialSort);
|
|
403
|
+
const sort = customSort !== void 0 ? customSort : selfSort;
|
|
404
|
+
const [selfKeys, setSelfKeys] = useState(initialSelectedKeys);
|
|
405
|
+
const selectedKeys = customKeys !== void 0 ? customKeys : selfKeys;
|
|
406
|
+
const keyOf = (row, index) => typeof rowKey === "function" ? rowKey(row) : rowKey !== void 0 ? row[rowKey] : index;
|
|
407
|
+
const sortedEntries = useMemo2(() => {
|
|
408
|
+
const entries = data.map((row, index) => ({ row, key: keyOf(row, index) }));
|
|
409
|
+
const column = sort && columns.find((item) => item.prop === sort.prop);
|
|
410
|
+
if (!sort || !column || (pagination == null ? void 0 : pagination.total) !== void 0) return entries;
|
|
411
|
+
const direction = sort.direction === "desc" ? -1 : 1;
|
|
412
|
+
const compare = column.sorter || ((a, b) => compareValues(a[column.prop], b[column.prop]));
|
|
413
|
+
return [...entries].sort((a, b) => direction * compare(a.row, b.row));
|
|
414
|
+
}, [data, sort, columns, pagination == null ? void 0 : pagination.total, rowKey]);
|
|
415
|
+
const [selfPage, setSelfPage] = useState(1);
|
|
416
|
+
const pageSize = pagination ? Math.max(1, pagination.pageSize) : 0;
|
|
417
|
+
const totalRows = (_a = pagination == null ? void 0 : pagination.total) != null ? _a : data.length;
|
|
418
|
+
const pageCount = pagination ? Math.ceil(totalRows / pageSize) : 0;
|
|
419
|
+
const page = Math.min((_b = pagination == null ? void 0 : pagination.page) != null ? _b : selfPage, Math.max(pageCount, 1));
|
|
420
|
+
const pageEntries = pagination && pagination.total === void 0 ? sortedEntries.slice((page - 1) * pageSize, page * pageSize) : sortedEntries;
|
|
421
|
+
const rows = pageEntries.map((entry) => entry.row);
|
|
422
|
+
const pageKeys = pageEntries.map((entry) => entry.key);
|
|
423
|
+
const sortHandler = (prop) => {
|
|
424
|
+
const next = !sort || sort.prop !== prop ? { prop, direction: "asc" } : sort.direction === "asc" ? { prop, direction: "desc" } : null;
|
|
425
|
+
setSelfSort(next);
|
|
426
|
+
if (onSortChange) onSortChange(next);
|
|
427
|
+
};
|
|
428
|
+
const selectKeys = (next) => {
|
|
429
|
+
setSelfKeys(next);
|
|
430
|
+
if (onSelectionChange)
|
|
431
|
+
onSelectionChange(
|
|
432
|
+
next,
|
|
433
|
+
sortedEntries.filter((entry) => next.includes(entry.key)).map((entry) => entry.row)
|
|
434
|
+
);
|
|
435
|
+
};
|
|
436
|
+
const toggleKey = (key) => selectKeys(
|
|
437
|
+
selectedKeys.includes(key) ? selectedKeys.filter((item) => item !== key) : [...selectedKeys, key]
|
|
438
|
+
);
|
|
439
|
+
const inView = pageKeys.filter((key) => selectedKeys.includes(key)).length;
|
|
440
|
+
const toggleAll = () => selectKeys(
|
|
441
|
+
inView === pageKeys.length ? selectedKeys.filter((key) => !pageKeys.includes(key)) : [
|
|
442
|
+
...selectedKeys,
|
|
443
|
+
...pageKeys.filter((key) => !selectedKeys.includes(key))
|
|
444
|
+
]
|
|
445
|
+
);
|
|
446
|
+
const pageChangeHandler = (next) => {
|
|
447
|
+
if (next === page) return;
|
|
448
|
+
setSelfPage(next);
|
|
449
|
+
if (pagination == null ? void 0 : pagination.onPageChange) pagination.onPageChange(next);
|
|
450
|
+
};
|
|
451
|
+
const tableStyle = {
|
|
452
|
+
"--table-font-size": SCALES.font(1),
|
|
453
|
+
"--table-select-accent": theme.palette.primary,
|
|
454
|
+
"--table-width": SCALES.width(1, "100%"),
|
|
455
|
+
"--table-height": SCALES.height(1, "auto"),
|
|
456
|
+
"--table-padding-top": SCALES.pt(0),
|
|
457
|
+
"--table-padding-right": SCALES.pr(0),
|
|
458
|
+
"--table-padding-bottom": SCALES.pb(0),
|
|
459
|
+
"--table-padding-left": SCALES.pl(0),
|
|
460
|
+
"--table-margin-top": SCALES.mt(0),
|
|
461
|
+
"--table-margin-right": SCALES.mr(0),
|
|
462
|
+
"--table-margin-bottom": SCALES.mb(0),
|
|
463
|
+
"--table-margin-left": SCALES.ml(0),
|
|
464
|
+
...style
|
|
465
|
+
};
|
|
466
|
+
return (
|
|
467
|
+
// the context is typed for any row: each Table provides its own
|
|
468
|
+
/* @__PURE__ */ jsxs3(
|
|
469
|
+
TableContext.Provider,
|
|
470
|
+
{
|
|
471
|
+
value: contextValue,
|
|
472
|
+
children: [
|
|
473
|
+
/* @__PURE__ */ jsxs3(
|
|
474
|
+
"table",
|
|
475
|
+
{
|
|
476
|
+
ref: tableRef,
|
|
477
|
+
className: use_classes_default(Table_module_css_default.table, className),
|
|
478
|
+
...props,
|
|
479
|
+
style: tableStyle,
|
|
480
|
+
children: [
|
|
481
|
+
/* @__PURE__ */ jsx5(
|
|
482
|
+
TableHead_default,
|
|
483
|
+
{
|
|
484
|
+
columns,
|
|
485
|
+
width,
|
|
486
|
+
sort,
|
|
487
|
+
onSort: sortHandler,
|
|
488
|
+
selection: selectable ? {
|
|
489
|
+
checked: pageKeys.length > 0 && inView === pageKeys.length,
|
|
490
|
+
indeterminate: inView > 0 && inView < pageKeys.length,
|
|
491
|
+
label: selectAllLabel,
|
|
492
|
+
onToggle: toggleAll
|
|
493
|
+
} : void 0
|
|
494
|
+
}
|
|
495
|
+
),
|
|
496
|
+
/* @__PURE__ */ jsx5(
|
|
497
|
+
TableBody_default,
|
|
498
|
+
{
|
|
499
|
+
data: rows,
|
|
500
|
+
keys: pageKeys,
|
|
501
|
+
selection: selectable ? {
|
|
502
|
+
keys: selectedKeys,
|
|
503
|
+
label: selectRowLabel,
|
|
504
|
+
onToggle: toggleKey
|
|
505
|
+
} : void 0,
|
|
506
|
+
hover,
|
|
507
|
+
emptyText,
|
|
508
|
+
onRow,
|
|
509
|
+
onCell,
|
|
510
|
+
rowClassName
|
|
511
|
+
}
|
|
512
|
+
),
|
|
513
|
+
children
|
|
514
|
+
]
|
|
515
|
+
}
|
|
516
|
+
),
|
|
517
|
+
pageCount > 1 && /* @__PURE__ */ jsx5("div", { className: Table_module_css_default.footer, children: /* @__PURE__ */ jsx5(
|
|
518
|
+
Pagination_default,
|
|
519
|
+
{
|
|
520
|
+
count: pageCount,
|
|
521
|
+
page,
|
|
522
|
+
onChange: pageChangeHandler
|
|
523
|
+
}
|
|
524
|
+
) })
|
|
525
|
+
]
|
|
526
|
+
}
|
|
527
|
+
)
|
|
528
|
+
);
|
|
529
|
+
}
|
|
530
|
+
TableComponent.displayName = "BolioUITable";
|
|
531
|
+
TableComponent.Column = TableColumn_default;
|
|
532
|
+
var Table = with_scale_default(
|
|
533
|
+
React5.forwardRef(TableComponent)
|
|
534
|
+
);
|
|
535
|
+
Table.Column = TableColumn_default;
|
|
536
|
+
var Table_default = Table;
|
|
537
|
+
|
|
538
|
+
// core/Table/index.ts
|
|
539
|
+
var Table_default2 = Table_default;
|
|
540
|
+
|
|
541
|
+
export {
|
|
542
|
+
Table_default2 as Table_default
|
|
543
|
+
};
|
package/esm/css/ButtonGroup.css
CHANGED
package/esm/css/Calendar.css
CHANGED
package/esm/css/Carousel.css
CHANGED
package/esm/css/ColorInput.css
CHANGED
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
transition:
|
|
23
23
|
border-color 0.15s ease,
|
|
24
24
|
background-color 0.15s ease;
|
|
25
|
-
background-clip: padding-box;
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
.ColorInput-module_field__JQwJJ:hover {
|
|
@@ -91,7 +90,6 @@
|
|
|
91
90
|
border: 1px solid var(--colorinput-popup-border);
|
|
92
91
|
border-radius: var(--colorinput-popup-radius);
|
|
93
92
|
box-shadow: var(--colorinput-shadow);
|
|
94
|
-
background-clip: padding-box;
|
|
95
93
|
}
|
|
96
94
|
|
|
97
95
|
}
|
package/esm/css/ColorPicker.css
CHANGED
|
@@ -82,7 +82,6 @@
|
|
|
82
82
|
box-shadow: 0 0 0 1px rgb(0 0 0 / 40%);
|
|
83
83
|
appearance: none;
|
|
84
84
|
-webkit-appearance: none;
|
|
85
|
-
background-clip: padding-box;
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
.ColorPicker-module_hue__VKHj-::-moz-range-thumb {
|
|
@@ -93,7 +92,6 @@
|
|
|
93
92
|
border: 2px solid #fff;
|
|
94
93
|
border-radius: 50%;
|
|
95
94
|
box-shadow: 0 0 0 1px rgb(0 0 0 / 40%);
|
|
96
|
-
background-clip: padding-box;
|
|
97
95
|
}
|
|
98
96
|
|
|
99
97
|
.ColorPicker-module_hue__VKHj-:focus-visible {
|
|
@@ -112,7 +110,6 @@
|
|
|
112
110
|
border-radius: var(--picker-radius);
|
|
113
111
|
background-color: var(--picker-bg);
|
|
114
112
|
transition: border-color 0.15s ease;
|
|
115
|
-
background-clip: padding-box;
|
|
116
113
|
}
|
|
117
114
|
|
|
118
115
|
.ColorPicker-module_field__v7-7F:hover {
|
package/esm/css/Combobox.css
CHANGED
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
transition:
|
|
27
27
|
border-color 0.15s ease,
|
|
28
28
|
background-color 0.15s ease;
|
|
29
|
-
background-clip: padding-box;
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
.Combobox-module_input__ti3bv::placeholder {
|
|
@@ -58,7 +57,6 @@
|
|
|
58
57
|
border: 1px solid var(--combobox-border-color);
|
|
59
58
|
border-radius: var(--combobox-popup-radius);
|
|
60
59
|
box-shadow: var(--combobox-shadow);
|
|
61
|
-
background-clip: padding-box;
|
|
62
60
|
}
|
|
63
61
|
|
|
64
62
|
.Combobox-module_list__2otmP {
|
package/esm/css/DatePicker.css
CHANGED
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
transition:
|
|
27
27
|
border-color 0.15s ease,
|
|
28
28
|
background-color 0.15s ease;
|
|
29
|
-
background-clip: padding-box;
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
.DatePicker-module_input__e7dhN::placeholder {
|
|
@@ -62,7 +61,6 @@
|
|
|
62
61
|
border-radius: var(--datepicker-radius);
|
|
63
62
|
appearance: none;
|
|
64
63
|
-webkit-appearance: none;
|
|
65
|
-
background-clip: padding-box;
|
|
66
64
|
}
|
|
67
65
|
|
|
68
66
|
.DatePicker-module_toggle__I8ARg:hover:not(:disabled) {
|
|
@@ -89,7 +87,6 @@
|
|
|
89
87
|
border: 1px solid var(--datepicker-border-color);
|
|
90
88
|
border-radius: var(--datepicker-popup-radius);
|
|
91
89
|
box-shadow: var(--datepicker-shadow);
|
|
92
|
-
background-clip: padding-box;
|
|
93
90
|
}
|
|
94
91
|
|
|
95
92
|
}
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
transition:
|
|
25
25
|
border-color 0.15s ease,
|
|
26
26
|
background-color 0.15s ease;
|
|
27
|
-
background-clip: padding-box;
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
.DateRangePicker-module_field__4UZhH:hover {
|
|
@@ -78,7 +77,6 @@
|
|
|
78
77
|
border-radius: var(--daterange-radius);
|
|
79
78
|
appearance: none;
|
|
80
79
|
-webkit-appearance: none;
|
|
81
|
-
background-clip: padding-box;
|
|
82
80
|
}
|
|
83
81
|
|
|
84
82
|
.DateRangePicker-module_toggle__gNukh:hover:not(:disabled) {
|
|
@@ -104,7 +102,12 @@
|
|
|
104
102
|
border: 1px solid var(--daterange-border-color);
|
|
105
103
|
border-radius: var(--daterange-popup-radius);
|
|
106
104
|
box-shadow: var(--daterange-shadow);
|
|
107
|
-
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* a field near the right edge: the popup grows to the left */
|
|
108
|
+
.DateRangePicker-module_alignEnd__DgOia {
|
|
109
|
+
right: 0;
|
|
110
|
+
left: auto;
|
|
108
111
|
}
|
|
109
112
|
|
|
110
113
|
}
|