@algolia/satellite 1.0.0-beta.136 → 1.0.0-beta.137
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/cjs/Avatars/ApplicationAvatar.js +2 -0
- package/cjs/Avatars/UserAvatar.js +6 -3
- package/cjs/Avatars/utils.js +3 -3
- package/cjs/Badge/Badge.js +5 -5
- package/cjs/Button/Button.tailwind.js +7 -7
- package/cjs/Insert/Insert.js +3 -0
- package/cjs/Tables/DataTable/DataTable.js +30 -21
- package/cjs/Tables/DataTable/DataTable.tailwind.js +3 -0
- package/cjs/Tables/DataTable/components/HeaderCell.d.ts +1 -0
- package/cjs/Tables/DataTable/components/HeaderCell.js +19 -9
- package/cjs/Tag/Tag.js +2 -3
- package/cjs/utils/onlyText.d.ts +3 -0
- package/cjs/utils/onlyText.js +49 -0
- package/esm/Avatars/ApplicationAvatar.js +2 -0
- package/esm/Avatars/UserAvatar.js +6 -3
- package/esm/Avatars/utils.js +3 -3
- package/esm/Badge/Badge.js +5 -5
- package/esm/Button/Button.tailwind.js +7 -7
- package/esm/Insert/Insert.js +2 -0
- package/esm/Tables/DataTable/DataTable.js +29 -21
- package/esm/Tables/DataTable/DataTable.tailwind.js +3 -0
- package/esm/Tables/DataTable/components/HeaderCell.d.ts +1 -0
- package/esm/Tables/DataTable/components/HeaderCell.js +19 -9
- package/esm/Tag/Tag.js +2 -3
- package/esm/utils/onlyText.d.ts +3 -0
- package/esm/utils/onlyText.js +41 -0
- package/package.json +4 -3
- package/satellite.min.css +1 -1
@@ -27,14 +27,14 @@ var buttonPlugin = plugin(function (_ref) {
|
|
27
27
|
".btn-subtle": {
|
28
28
|
color: theme("colors.grey.600"),
|
29
29
|
"&:hover": {
|
30
|
-
|
30
|
+
backgroundColor: rgba(theme("colors.grey.300"), 0.15)
|
31
31
|
},
|
32
32
|
"&:focus": {
|
33
33
|
boxShadow: "0 0 0 1px ".concat(theme("colors.accent.600"))
|
34
34
|
},
|
35
35
|
"&:active, &.btn-active": {
|
36
36
|
color: theme("colors.accent.600"),
|
37
|
-
|
37
|
+
backgroundColor: theme("colors.accent.100"),
|
38
38
|
boxShadow: "none"
|
39
39
|
},
|
40
40
|
"&:disabled, &.btn-disabled": {
|
@@ -50,8 +50,8 @@ var buttonPlugin = plugin(function (_ref) {
|
|
50
50
|
border: "1px solid ".concat(theme("colors.grey.200")),
|
51
51
|
boxShadow: "0 1px 0 0 ".concat(theme("colors.shadow.5")),
|
52
52
|
"&:hover": {
|
53
|
-
|
54
|
-
|
53
|
+
backgroundImage: "linear-gradient(-180deg, ".concat(theme("colors.white"), " 0%, ").concat(theme("colors.grey.100"), " 100%)"),
|
54
|
+
borderColor: theme("colors.grey.200")
|
55
55
|
},
|
56
56
|
"&:focus": {
|
57
57
|
backgroundImage: "linear-gradient(-180deg, ".concat(theme("colors.white"), " 0%, ").concat(theme("colors.grey.100"), " 100%)"),
|
@@ -59,8 +59,8 @@ var buttonPlugin = plugin(function (_ref) {
|
|
59
59
|
boxShadow: "\n 0 0 0 1px ".concat(theme("colors.accent.600"), ",\n 0 2px 0 1px ").concat(theme("colors.shadow.5"), "\n ")
|
60
60
|
},
|
61
61
|
"&:active, &.btn-active": {
|
62
|
-
backgroundImage: theme("color.grey.100"),
|
63
62
|
borderColor: theme("colors.grey.200"),
|
63
|
+
backgroundImage: theme("color.grey.100"),
|
64
64
|
boxShadow: "\n inset 0 1px 4px 0 ".concat(rgba(theme("colors.grey.500"), 0.4), ",\n inset 0 1px 1px 0 ").concat(rgba(theme("colors.grey.500"), 0.4), ",\n 0 1px 0 0 ").concat(theme("colors.shadow.5"), "\n ")
|
65
65
|
},
|
66
66
|
"&:disabled, &.btn-disabled": {
|
@@ -77,8 +77,8 @@ var buttonPlugin = plugin(function (_ref) {
|
|
77
77
|
border: "1px solid ".concat(theme("colors.accent.700")),
|
78
78
|
boxShadow: "\n inset 0 1px 0 0 ".concat(rgba(theme("colors.white"), 0.06), ",\n 0 1px 0 0 ").concat(theme("colors.shadow.10"), "\n "),
|
79
79
|
"&:hover": {
|
80
|
-
backgroundImage: "linear-gradient(0deg, ".concat(theme("colors.accent.800"), " 0%, ").concat(theme("colors.accent.700"), " 100%)"),
|
81
80
|
borderColor: theme("colors.accent.800"),
|
81
|
+
backgroundImage: "linear-gradient(0deg, ".concat(theme("colors.accent.800"), " 0%, ").concat(theme("colors.accent.700"), " 100%)"),
|
82
82
|
boxShadow: "\n inset 0 1px 0 0 ".concat(rgba(theme("colors.white"), 0.06), ",\n 0 1px 0 0 ").concat(theme("colors.shadow.10"), "\n ")
|
83
83
|
},
|
84
84
|
"&:focus": {
|
@@ -87,7 +87,7 @@ var buttonPlugin = plugin(function (_ref) {
|
|
87
87
|
boxShadow: "\n inset 0 1px 0 0 ".concat(rgba(theme("colors.white"), 0.06), ",\n 0 0 0 1px ").concat(theme("colors.accent.800"), ",\n 0 2px 0 1px ").concat(theme("colors.shadow.10"), "\n ")
|
88
88
|
},
|
89
89
|
"&:active, &.btn-active": {
|
90
|
-
|
90
|
+
backgroundColor: theme("colors.accent.700"),
|
91
91
|
borderColor: theme("colors.accent.800"),
|
92
92
|
boxShadow: "\n inset 0 1px 4px 0 ".concat(rgba(theme("colors.accent.900"), 0.4), ",\n inset 0 1px 1px 0 ").concat(rgba(theme("colors.accent.900"), 0.6), ",\n 0 1px 0 0 ").concat(theme("colors.shadow.5"), "\n ")
|
93
93
|
},
|
package/esm/Insert/Insert.js
CHANGED
@@ -4,6 +4,7 @@ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
4
4
|
|
5
5
|
import Badge from "../Badge";
|
6
6
|
import stl from "../styles/helpers/satellitePrefixer";
|
7
|
+
import onlyText from "../utils/onlyText";
|
7
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
8
9
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
9
10
|
|
@@ -43,6 +44,7 @@ export var Insert = function Insert(_ref) {
|
|
43
44
|
contexts = _ref.contexts,
|
44
45
|
children = _ref.children;
|
45
46
|
return /*#__PURE__*/_jsxs("aside", {
|
47
|
+
"aria-label": onlyText(title),
|
46
48
|
className: stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["inline-flex flex-col self-start p-4 bg-grey-100 rounded"]))),
|
47
49
|
children: [contexts ? /*#__PURE__*/_jsx("span", {
|
48
50
|
className: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["block space-x-2 mb-4"]))),
|
@@ -3,7 +3,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
4
4
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
5
5
|
|
6
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
6
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12;
|
7
7
|
|
8
8
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
9
9
|
|
@@ -22,6 +22,7 @@ import DataTableBody from "./components/Body";
|
|
22
22
|
import DataTableFooter from "./components/Footer";
|
23
23
|
import DataTableHeader from "./components/Header";
|
24
24
|
import DataTableLoader from "./components/Loader";
|
25
|
+
import { isDeterminatePagination, isIndeterminatePagination } from "./utils";
|
25
26
|
import { jsx as _jsx } from "react/jsx-runtime";
|
26
27
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
27
28
|
var DEFAULT_DATATABLE_LOCALE = {
|
@@ -86,17 +87,13 @@ export var DataTable = function DataTable(_ref) {
|
|
86
87
|
if (process.env.NODE_ENV !== "production") {
|
87
88
|
var _selection$length;
|
88
89
|
|
89
|
-
if (itemId === undefined && (sorting.length > 0 || selectMode !==
|
90
|
+
if (itemId === undefined && (sorting.length > 0 || selectMode !== "none")) {
|
90
91
|
console.warn("You did not provide a custom `itemId` function, but you have defined `sorting` and/or `selectMode`. This can lead to unexpected results.");
|
91
92
|
}
|
92
93
|
|
93
94
|
if (selectMode === "single" && ((_selection$length = selection === null || selection === void 0 ? void 0 : selection.length) !== null && _selection$length !== void 0 ? _selection$length : 0) > 1) {
|
94
95
|
console.warn("You can only have one selected item at a time in single `selectMode`.");
|
95
96
|
}
|
96
|
-
|
97
|
-
if (pagination && data.length > pagination.itemsPerPage) {
|
98
|
-
console.warn("`pagination.itemsPerPage` (".concat(pagination.itemsPerPage, ") doesn't match `data.length` (").concat(data.length, ")."));
|
99
|
-
}
|
100
97
|
}
|
101
98
|
|
102
99
|
var _useState = useState(),
|
@@ -111,19 +108,24 @@ export var DataTable = function DataTable(_ref) {
|
|
111
108
|
var computedColumns = compact([selectMode === "single" && {
|
112
109
|
id: "_internal_singleSelect",
|
113
110
|
accessor: "_internal_singleSelect",
|
114
|
-
Header:
|
111
|
+
Header: function Header() {
|
112
|
+
return /*#__PURE__*/_jsx("span", {
|
113
|
+
className: stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["sr-only"]))),
|
114
|
+
children: "Selected row"
|
115
|
+
});
|
116
|
+
},
|
115
117
|
Cell: function Cell(_ref2) {
|
116
118
|
var row = _ref2.row;
|
117
119
|
return /*#__PURE__*/_jsx("div", {
|
118
|
-
className: stl(
|
120
|
+
className: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["flex"]))),
|
119
121
|
children: /*#__PURE__*/_jsx(RadioButton, {
|
120
122
|
defaultChecked: row.selected,
|
121
123
|
disabled: !row.selectable,
|
122
|
-
className: stl(
|
124
|
+
className: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", ""])), row.hovered || row.selected ? "opacity-100" : "opacity-0 select-none")
|
123
125
|
})
|
124
126
|
});
|
125
127
|
},
|
126
|
-
className: stl(
|
128
|
+
className: stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["w-3"])))
|
127
129
|
}, selectMode === "multi" && {
|
128
130
|
id: "_internal_multiSelect",
|
129
131
|
accessor: "_internal_multiSelect",
|
@@ -145,7 +147,7 @@ export var DataTable = function DataTable(_ref) {
|
|
145
147
|
return /*#__PURE__*/_jsx(Checkbox, {
|
146
148
|
"aria-label": locale.selectAllButton // Small hack to position the checkbox in the center of the header
|
147
149
|
,
|
148
|
-
className: stl(
|
150
|
+
className: stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["absolute mb-2.5"]))),
|
149
151
|
checked: isChecked,
|
150
152
|
indeterminate: isIndeterminate,
|
151
153
|
onClick: function onClick() {
|
@@ -156,15 +158,15 @@ export var DataTable = function DataTable(_ref) {
|
|
156
158
|
Cell: function Cell(_ref3) {
|
157
159
|
var row = _ref3.row;
|
158
160
|
return /*#__PURE__*/_jsx("div", {
|
159
|
-
className: stl(
|
161
|
+
className: stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["flex"]))),
|
160
162
|
children: /*#__PURE__*/_jsx(Checkbox, {
|
161
163
|
checked: row.selected,
|
162
164
|
disabled: !row.selectable,
|
163
|
-
className: stl(
|
165
|
+
className: stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["", ""])), row.hovered || row.selected ? "opacity-100" : "opacity-0 select-none")
|
164
166
|
})
|
165
167
|
});
|
166
168
|
},
|
167
|
-
className: stl(
|
169
|
+
className: stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["w-3"])))
|
168
170
|
}].concat(_toConsumableArray(columns.map(function (c) {
|
169
171
|
var _c$Header;
|
170
172
|
|
@@ -204,12 +206,18 @@ export var DataTable = function DataTable(_ref) {
|
|
204
206
|
})) === null || _sorting$find === void 0 ? void 0 : _sorting$find[1]) !== null && _sorting$find$ !== void 0 ? _sorting$find$ : "desc" : "none"];
|
205
207
|
});
|
206
208
|
|
209
|
+
var shouldRenderPagination = function shouldRenderPagination() {
|
210
|
+
if (isDeterminatePagination(pagination)) return pagination && pagination.totalItemsCount > 0;
|
211
|
+
if (isIndeterminatePagination(pagination)) return pagination && data.length > 0;
|
212
|
+
return false;
|
213
|
+
};
|
214
|
+
|
207
215
|
var onRowHoverChange = function onRowHoverChange(row) {
|
208
216
|
setHoveredRowId(row === null || row === void 0 ? void 0 : row.id);
|
209
217
|
onRowHoveredChanged === null || onRowHoveredChanged === void 0 ? void 0 : onRowHoveredChanged(row);
|
210
218
|
};
|
211
219
|
|
212
|
-
var
|
220
|
+
var onToggleSort = function onToggleSort(columnId, direction) {
|
213
221
|
var newSorting = internalSorting.map(function (_ref7) {
|
214
222
|
var _ref8 = _slicedToArray(_ref7, 2),
|
215
223
|
colId = _ref8[0],
|
@@ -228,24 +236,24 @@ export var DataTable = function DataTable(_ref) {
|
|
228
236
|
};
|
229
237
|
|
230
238
|
return /*#__PURE__*/_jsxs("div", {
|
231
|
-
className: stl(
|
239
|
+
className: stl(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["relative"]))),
|
232
240
|
children: [status === "loading" && /*#__PURE__*/_jsx("div", {
|
233
|
-
className: stl(
|
241
|
+
className: stl(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["absolute bg-white/50 z-10 w-full h-full flex items-center justify-center"]))),
|
234
242
|
children: /*#__PURE__*/_jsx(DataTableLoader, {
|
235
|
-
className: stl(
|
243
|
+
className: stl(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["-mt-12"]))),
|
236
244
|
locale: locale
|
237
245
|
})
|
238
246
|
}), /*#__PURE__*/_jsxs(Table, {
|
239
|
-
className: stl(
|
247
|
+
className: stl(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["datatable ", " ", ""])), status === "loading" && "pointer-events-none select-none", status === "loading" && data.length === 0 && "h-48"),
|
240
248
|
highlight: false,
|
241
|
-
footer:
|
249
|
+
footer: shouldRenderPagination() && /*#__PURE__*/_jsx(DataTableFooter, {
|
242
250
|
pagination: pagination,
|
243
251
|
onChange: handlePaginationChange
|
244
252
|
}),
|
245
253
|
children: [/*#__PURE__*/_jsx(DataTableHeader, {
|
246
254
|
disabled: status !== "success" || rows.length === 0,
|
247
255
|
columns: computedColumns,
|
248
|
-
onToggleSort:
|
256
|
+
onToggleSort: onToggleSort,
|
249
257
|
sorting: internalSorting
|
250
258
|
}), /*#__PURE__*/_jsx(DataTableBody, {
|
251
259
|
rows: rows,
|
@@ -3,6 +3,7 @@ import type { AdvancedColumnDefinition, SortingDirection } from "../types";
|
|
3
3
|
export interface HeaderCellProps<Item> extends HTMLAttributes<HTMLTableCellElement> {
|
4
4
|
column: AdvancedColumnDefinition<Item>;
|
5
5
|
disabled?: boolean;
|
6
|
+
isSortingEnabled?: boolean;
|
6
7
|
sortingDirection?: SortingDirection;
|
7
8
|
onToggleSort: (columnId: string, sortingDirection: SortingDirection) => void;
|
8
9
|
children: ReactNode;
|
@@ -3,7 +3,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
|
|
3
3
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
4
4
|
var _excluded = ["sortingDirection", "onToggleSort", "column", "disabled", "children"];
|
5
5
|
|
6
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
6
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
7
7
|
|
8
8
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
9
9
|
|
@@ -28,22 +28,32 @@ export var HeaderCell = function HeaderCell(_ref) {
|
|
28
28
|
children = _ref.children,
|
29
29
|
props = _objectWithoutProperties(_ref, _excluded);
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
var InternalCellComponent = sort && !disabled ? "button" : "span";
|
32
|
+
|
33
|
+
var handleSorting = function handleSorting() {
|
34
|
+
if (disabled) return;
|
35
|
+
onToggleSort(id, sortingDirection === "desc" ? "asc" : sortingDirection === "asc" ? "none" : "desc");
|
36
|
+
};
|
37
|
+
|
38
|
+
var sortButtonProps = sort ? {
|
33
39
|
onClick: function onClick() {
|
34
|
-
return
|
40
|
+
return handleSorting();
|
35
41
|
},
|
36
|
-
className:
|
37
|
-
|
38
|
-
|
42
|
+
className: disabled ? stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["cursor-not-allowed"]))) : stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["cursor-pointer"])))
|
43
|
+
} : {};
|
44
|
+
return /*#__PURE__*/_jsx("th", _objectSpread(_objectSpread({}, props), {}, {
|
45
|
+
"aria-sort": sortingDirection === "desc" ? "descending" : sortingDirection === "asc" ? "ascending" : "none",
|
46
|
+
className: className,
|
47
|
+
children: /*#__PURE__*/_jsxs(InternalCellComponent, _objectSpread(_objectSpread({}, sortButtonProps), {}, {
|
48
|
+
className: cx(stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["px-4 py-[14px] inline-flex items-center focus:outline-none focus:text-accent-600"]))), sortButtonProps.className),
|
39
49
|
children: [children, sort ? sortingDirection === "desc" ? /*#__PURE__*/_jsx(ChevronDown, {
|
40
50
|
className: iconClassName
|
41
51
|
}) : sortingDirection === "asc" ? /*#__PURE__*/_jsx(ChevronUp, {
|
42
52
|
className: iconClassName
|
43
53
|
}) : /*#__PURE__*/_jsx(ChevronDown, {
|
44
|
-
className: cx(iconClassName, stl(
|
54
|
+
className: cx(iconClassName, stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["text-grey-300"]))))
|
45
55
|
}) : null]
|
46
|
-
})
|
56
|
+
}))
|
47
57
|
}));
|
48
58
|
};
|
49
59
|
export default HeaderCell;
|
package/esm/Tag/Tag.js
CHANGED
@@ -24,8 +24,8 @@ var DEFAULT_TAG_LOCALE = {
|
|
24
24
|
var VARIANT_CLASSNAMES = {
|
25
25
|
accent: stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["bg-accent-100 border-accent-200 text-accent-700"]))),
|
26
26
|
grey: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["bg-grey-100 border-grey-200 text-grey-700"]))),
|
27
|
-
blue: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["bg-blue-100 border-blue-200 text-blue-
|
28
|
-
green: stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["bg-green-100 border-green-300 text-green-
|
27
|
+
blue: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["bg-blue-100 border-blue-200 text-blue-800"]))),
|
28
|
+
green: stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["bg-green-100 border-green-300 text-green-900"]))),
|
29
29
|
orange: stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["bg-orange-100 border-orange-300 text-orange-800"]))),
|
30
30
|
red: stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["bg-red-100 border-red-200 text-red-700"]))),
|
31
31
|
pink: stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["bg-pink-100 border-pink-200 text-pink-700"])))
|
@@ -85,7 +85,6 @@ export var Tag = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
85
85
|
|
86
86
|
return /*#__PURE__*/_jsxs("span", _objectSpread(_objectSpread({}, props), {}, {
|
87
87
|
className: tagClassName,
|
88
|
-
"aria-label": title,
|
89
88
|
ref: ref,
|
90
89
|
children: [/*#__PURE__*/_jsx("span", {
|
91
90
|
className: stl(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["truncate flex-1"]))),
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { Children, isValidElement } from "react";
|
2
|
+
|
3
|
+
var hasChildren = function hasChildren(element) {
|
4
|
+
return /*#__PURE__*/isValidElement(element) && Boolean(element.props.children);
|
5
|
+
};
|
6
|
+
|
7
|
+
var childToString = function childToString(child) {
|
8
|
+
if (typeof child === "undefined" || child === null || typeof child === "boolean") {
|
9
|
+
return "";
|
10
|
+
}
|
11
|
+
|
12
|
+
if (JSON.stringify(child) === "{}") {
|
13
|
+
return "";
|
14
|
+
}
|
15
|
+
|
16
|
+
return child.toString();
|
17
|
+
}; // Code stolen from `react-children-utils`
|
18
|
+
// @see https://github.com/fernandopasik/react-children-utilities/blob/main/src/lib/onlyText.ts
|
19
|
+
|
20
|
+
|
21
|
+
var onlyText = function onlyText(children) {
|
22
|
+
if (!(children instanceof Array) && ! /*#__PURE__*/isValidElement(children)) {
|
23
|
+
return childToString(children);
|
24
|
+
}
|
25
|
+
|
26
|
+
return Children.toArray(children).reduce(function (text, child) {
|
27
|
+
var newText = "";
|
28
|
+
|
29
|
+
if ( /*#__PURE__*/isValidElement(child) && hasChildren(child)) {
|
30
|
+
newText = onlyText(child.props.children);
|
31
|
+
} else if ( /*#__PURE__*/isValidElement(child) && !hasChildren(child)) {
|
32
|
+
newText = "";
|
33
|
+
} else {
|
34
|
+
newText = childToString(child);
|
35
|
+
}
|
36
|
+
|
37
|
+
return text.concat(newText);
|
38
|
+
}, "");
|
39
|
+
};
|
40
|
+
|
41
|
+
export default onlyText;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@algolia/satellite",
|
3
|
-
"version": "1.0.0-beta.
|
3
|
+
"version": "1.0.0-beta.137",
|
4
4
|
"description": "Algolia design system React components",
|
5
5
|
"scripts": {
|
6
6
|
"clean": "rimraf dist",
|
@@ -17,11 +17,12 @@
|
|
17
17
|
"build:storybook": "yarn build-storybook -o .storybook-static",
|
18
18
|
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path ./",
|
19
19
|
"dev": "start-storybook -p 6060",
|
20
|
-
"test:
|
20
|
+
"test:accessibility": "test-storybook --url https://algolia-satellite.netlify.app/ --no-stories-json",
|
21
|
+
"test:jest": "jest --config jest.config.js",
|
21
22
|
"quality": "run-s quality:test quality:types quality:lint",
|
22
23
|
"quality:lint": "eslint 'src/**/*.{ts,tsx}'",
|
23
24
|
"quality:types": "tsc",
|
24
|
-
"quality:test": "
|
25
|
+
"quality:test": "run-p test:jest",
|
25
26
|
"preversion": "yarn quality",
|
26
27
|
"version": "yarn changelog && git add CHANGELOG.md",
|
27
28
|
"postversion": "git push && git push --tags",
|