@bolio-ui/core 1.0.1 → 1.0.3

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.
@@ -0,0 +1,115 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
+ var _excluded = ["children", "data", "initialData", "hover", "emptyText", "onRow", "onCell", "onChange", "className", "rowClassName"];
6
+ import _JSXStyle from "../styled-jsx.es.js";
7
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
8
+ import TableHead from './table-head';
9
+ import TableBody from './table-body';
10
+ import useRealShape from '../utils/use-real-shape';
11
+ import useResize from '../utils/use-resize';
12
+ import { TableContext } from './table-context';
13
+ import useScale, { withScale } from '../use-scale';
14
+ import TableColumn from './table-column';
15
+ var defaultProps = {
16
+ hover: true,
17
+ initialData: [],
18
+ emptyText: '',
19
+ className: '',
20
+ rowClassName: function rowClassName() {
21
+ return '';
22
+ }
23
+ };
24
+
25
+ function TableComponent(tableProps) {
26
+ /* eslint-disable @typescript-eslint/no-unused-vars */
27
+ var _ref = tableProps,
28
+ children = _ref.children,
29
+ customData = _ref.data,
30
+ initialData = _ref.initialData,
31
+ hover = _ref.hover,
32
+ emptyText = _ref.emptyText,
33
+ onRow = _ref.onRow,
34
+ onCell = _ref.onCell,
35
+ onChange = _ref.onChange,
36
+ className = _ref.className,
37
+ rowClassName = _ref.rowClassName,
38
+ props = _objectWithoutProperties(_ref, _excluded);
39
+ /* eslint-enable @typescript-eslint/no-unused-vars */
40
+
41
+
42
+ var _useScale = useScale(),
43
+ SCALES = _useScale.SCALES;
44
+
45
+ var ref = useRef(null);
46
+
47
+ var _useRealShape = useRealShape(ref),
48
+ _useRealShape2 = _slicedToArray(_useRealShape, 2),
49
+ width = _useRealShape2[0].width,
50
+ updateShape = _useRealShape2[1];
51
+
52
+ var _useState = useState([]),
53
+ _useState2 = _slicedToArray(_useState, 2),
54
+ columns = _useState2[0],
55
+ setColumns = _useState2[1];
56
+
57
+ var _useState3 = useState(initialData),
58
+ _useState4 = _slicedToArray(_useState3, 2),
59
+ data = _useState4[0],
60
+ setData = _useState4[1];
61
+
62
+ var updateColumn = function updateColumn(column) {
63
+ setColumns(function (last) {
64
+ var hasColumn = last.find(function (item) {
65
+ return item.prop === column.prop;
66
+ });
67
+ if (!hasColumn) return [].concat(_toConsumableArray(last), [column]);
68
+ return last.map(function (item) {
69
+ if (item.prop !== column.prop) return item;
70
+ return column;
71
+ });
72
+ });
73
+ };
74
+
75
+ var contextValue = useMemo(function () {
76
+ return {
77
+ columns: columns,
78
+ updateColumn: updateColumn
79
+ };
80
+ }, [columns]);
81
+ useEffect(function () {
82
+ if (typeof customData === 'undefined') return;
83
+ setData(customData);
84
+ }, [customData]);
85
+ useResize(function () {
86
+ return updateShape();
87
+ });
88
+ return /*#__PURE__*/React.createElement(TableContext.Provider, {
89
+ value: contextValue
90
+ }, /*#__PURE__*/React.createElement("table", _extends({
91
+ ref: ref
92
+ }, props, {
93
+ className: _JSXStyle.dynamic([["2991182230", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, 'auto'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0)]]]) + " " + (props && props.className != null && props.className || className || "")
94
+ }), /*#__PURE__*/React.createElement(TableHead, {
95
+ columns: columns,
96
+ width: width
97
+ }), /*#__PURE__*/React.createElement(TableBody, {
98
+ data: data,
99
+ hover: hover,
100
+ emptyText: emptyText,
101
+ onRow: onRow,
102
+ onCell: onCell,
103
+ rowClassName: rowClassName
104
+ }), children, /*#__PURE__*/React.createElement(_JSXStyle, {
105
+ id: "2991182230",
106
+ dynamic: [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, 'auto'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0)]
107
+ }, "table.__jsx-style-dynamic-selector{border-collapse:separate;border-spacing:0;--table-font-size:".concat(SCALES.font(1), ";font-size:var(--table-font-size);width:").concat(SCALES.width(1, '100%'), ";height:").concat(SCALES.height(1, 'auto'), ";padding:").concat(SCALES.pt(0), " ").concat(SCALES.pr(0), " ").concat(SCALES.pb(0), " ").concat(SCALES.pl(0), ";margin:").concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";}"))));
108
+ }
109
+
110
+ TableComponent.defaultProps = defaultProps;
111
+ TableComponent.displayName = 'BolioUITable';
112
+ TableComponent.Column = TableColumn;
113
+ var Table = withScale(TableComponent);
114
+ Table.Column = TableColumn;
115
+ export default Table;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bolio-ui/core",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "license": "MIT",
5
5
  "description": "Amazing, modern and creative tools for React UI. 🥷🏼",
6
6
  "homepage": "https://bolio-ui.com/",
@@ -72,14 +72,14 @@
72
72
  "gray-matter": "^4.0.3",
73
73
  "jest-styled-components": "^7.0.5",
74
74
  "kbar": "0.1.0-beta.6",
75
- "next": "11.0.1",
75
+ "next": "12.3.1",
76
76
  "next-pwa": "^5.2.24",
77
77
  "next-seo": "^5.5.0",
78
78
  "prism-react-renderer": "^1.2.1",
79
- "react": "17.0.2",
79
+ "react": "^18.2.0",
80
80
  "react-autosuggest": "^10.1.0",
81
81
  "react-device-detect": "^1.17.0",
82
- "react-dom": "^17.0.2",
82
+ "react-dom": "^18.2.0",
83
83
  "react-instantsearch-dom": "^6.12.0",
84
84
  "react-live": "^2.2.3",
85
85
  "react-syntax-highlighter": "^15.5.0",