@star-insure/sdk 2.0.0 → 2.0.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/components/common/SimplePagination.d.ts +9 -0
- package/dist/components/common/index.d.ts +2 -1
- package/dist/components/tables/TableCell.d.ts +2 -1
- package/dist/components/tables/TableHeader.d.ts +2 -1
- package/dist/sdk.cjs.development.js +106 -6
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +106 -7
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/common/SimplePagination.tsx +78 -0
- package/src/components/common/index.ts +2 -0
- package/src/components/tables/TableCell.tsx +6 -2
- package/src/components/tables/TableHeader.tsx +6 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Meta } from "../../types";
|
|
3
|
+
interface Props {
|
|
4
|
+
className?: string;
|
|
5
|
+
meta: Meta;
|
|
6
|
+
showPerPageSelector?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export default function SimplePagination({ meta, className, showPerPageSelector }: Props): JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import Button from './Button';
|
|
2
2
|
import Card from './Card';
|
|
3
3
|
import Pagination from './Pagination';
|
|
4
|
+
import SimplePagination from './SimplePagination';
|
|
4
5
|
import ToastItem from './ToastItem';
|
|
5
6
|
import Toasts from './Toasts';
|
|
6
7
|
import Modal from './Modal';
|
|
7
|
-
export { Button, Card, Pagination, ToastItem, Toasts, Modal, };
|
|
8
|
+
export { Button, Card, Pagination, SimplePagination, ToastItem, Toasts, Modal, };
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
interface Props {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
className?: string;
|
|
5
|
+
condensed?: true;
|
|
5
6
|
}
|
|
6
|
-
export default function TableCell({ children, className }: Props): JSX.Element;
|
|
7
|
+
export default function TableCell({ children, className, condensed }: Props): JSX.Element;
|
|
7
8
|
export {};
|
|
@@ -4,6 +4,7 @@ interface Props {
|
|
|
4
4
|
className?: string;
|
|
5
5
|
textAlign?: 'left' | 'right' | 'center';
|
|
6
6
|
sort?: string;
|
|
7
|
+
condensed?: true;
|
|
7
8
|
}
|
|
8
|
-
export default function TableHeader({ children, className, sort, textAlign, }: Props): JSX.Element;
|
|
9
|
+
export default function TableHeader({ children, className, sort, textAlign, condensed, }: Props): JSX.Element;
|
|
9
10
|
export {};
|
|
@@ -10,8 +10,8 @@ var React = require('react');
|
|
|
10
10
|
var React__default = _interopDefault(React);
|
|
11
11
|
var uuid = require('uuid');
|
|
12
12
|
var react$1 = require('@headlessui/react');
|
|
13
|
-
var lodash = require('lodash');
|
|
14
13
|
var cn = _interopDefault(require('classnames'));
|
|
14
|
+
var lodash = require('lodash');
|
|
15
15
|
|
|
16
16
|
function parseDate(dateString) {
|
|
17
17
|
// Make sure we've only got 10 characters
|
|
@@ -1245,6 +1245,100 @@ function Pagination(_ref) {
|
|
|
1245
1245
|
})))));
|
|
1246
1246
|
}
|
|
1247
1247
|
|
|
1248
|
+
function SimplePagination(_ref) {
|
|
1249
|
+
var meta = _ref.meta,
|
|
1250
|
+
className = _ref.className,
|
|
1251
|
+
_ref$showPerPageSelec = _ref.showPerPageSelector,
|
|
1252
|
+
showPerPageSelector = _ref$showPerPageSelec === void 0 ? false : _ref$showPerPageSelec;
|
|
1253
|
+
var current_page = meta.current_page,
|
|
1254
|
+
per_page = meta.per_page,
|
|
1255
|
+
to = meta.to,
|
|
1256
|
+
from = meta.from;
|
|
1257
|
+
var results_on_page = to - from + 1;
|
|
1258
|
+
var has_more_pages = results_on_page === per_page;
|
|
1259
|
+
|
|
1260
|
+
function getNextPageLink() {
|
|
1261
|
+
if (typeof window !== 'undefined') {
|
|
1262
|
+
var search = new URLSearchParams(window.location.search);
|
|
1263
|
+
search.set('page', String(current_page + 1));
|
|
1264
|
+
return "?" + search.toString();
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
return '';
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
function getPrevPageLink() {
|
|
1271
|
+
if (typeof window !== 'undefined') {
|
|
1272
|
+
var search = new URLSearchParams(window.location.search);
|
|
1273
|
+
search.set('page', String(current_page - 1));
|
|
1274
|
+
return "?" + search.toString();
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
return '';
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
var nextPageLink = getNextPageLink();
|
|
1281
|
+
var prevPageLink = getPrevPageLink();
|
|
1282
|
+
|
|
1283
|
+
function handlePerPageChange(e) {
|
|
1284
|
+
var _window;
|
|
1285
|
+
|
|
1286
|
+
var search = new URLSearchParams((_window = window) == null ? void 0 : _window.location.search);
|
|
1287
|
+
search.set('limit', e.currentTarget.value);
|
|
1288
|
+
search.set('page', '1');
|
|
1289
|
+
window.location.href = "?" + search.toString();
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
return React__default.createElement("div", {
|
|
1293
|
+
className: "" + (className != null ? className : '')
|
|
1294
|
+
}, React__default.createElement("nav", {
|
|
1295
|
+
className: "font-bold flex justify-between items-center gap-6"
|
|
1296
|
+
}, React__default.createElement(react.Link, {
|
|
1297
|
+
href: prevPageLink,
|
|
1298
|
+
className: "flex items-center gap-2",
|
|
1299
|
+
disabled: current_page === 1
|
|
1300
|
+
}, React__default.createElement("svg", {
|
|
1301
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1302
|
+
className: "h-4 w-4",
|
|
1303
|
+
fill: "none",
|
|
1304
|
+
viewBox: "0 0 24 24",
|
|
1305
|
+
stroke: "currentColor",
|
|
1306
|
+
strokeWidth: "2"
|
|
1307
|
+
}, React__default.createElement("path", {
|
|
1308
|
+
strokeLinecap: "round",
|
|
1309
|
+
strokeLinejoin: "round",
|
|
1310
|
+
d: "M10 19l-7-7m0 0l7-7m-7 7h18"
|
|
1311
|
+
})), "Prev"), React__default.createElement("div", {
|
|
1312
|
+
className: "flex gap-6 items-center"
|
|
1313
|
+
}, React__default.createElement("p", null, "Page ", current_page), showPerPageSelector ? React__default.createElement("select", {
|
|
1314
|
+
value: per_page,
|
|
1315
|
+
onChange: handlePerPageChange
|
|
1316
|
+
}, React__default.createElement("option", {
|
|
1317
|
+
value: "10"
|
|
1318
|
+
}, "10 per page"), React__default.createElement("option", {
|
|
1319
|
+
value: "25"
|
|
1320
|
+
}, "25 per page"), React__default.createElement("option", {
|
|
1321
|
+
value: "50"
|
|
1322
|
+
}, "50 per page"), React__default.createElement("option", {
|
|
1323
|
+
value: "100"
|
|
1324
|
+
}, "100 per page")) : ''), React__default.createElement(react.Link, {
|
|
1325
|
+
href: nextPageLink,
|
|
1326
|
+
className: "flex items-center gap-2",
|
|
1327
|
+
disabled: !has_more_pages
|
|
1328
|
+
}, "Next", React__default.createElement("svg", {
|
|
1329
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1330
|
+
className: "h-4 w-4",
|
|
1331
|
+
fill: "none",
|
|
1332
|
+
viewBox: "0 0 24 24",
|
|
1333
|
+
stroke: "currentColor",
|
|
1334
|
+
strokeWidth: "2"
|
|
1335
|
+
}, React__default.createElement("path", {
|
|
1336
|
+
strokeLinecap: "round",
|
|
1337
|
+
strokeLinejoin: "round",
|
|
1338
|
+
d: "M14 5l7 7m0 0l-7 7m7-7H3"
|
|
1339
|
+
})))));
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1248
1342
|
function ToastItem(_ref) {
|
|
1249
1343
|
var _ref$_id = _ref._id,
|
|
1250
1344
|
_id = _ref$_id === void 0 ? '' : _ref$_id,
|
|
@@ -1395,10 +1489,12 @@ function TableBody(_ref) {
|
|
|
1395
1489
|
|
|
1396
1490
|
function TableCell(_ref) {
|
|
1397
1491
|
var children = _ref.children,
|
|
1398
|
-
|
|
1399
|
-
|
|
1492
|
+
className = _ref.className,
|
|
1493
|
+
condensed = _ref.condensed;
|
|
1400
1494
|
return React__default.createElement("td", {
|
|
1401
|
-
className: className
|
|
1495
|
+
className: cn(className, 'px-3 py-3 text-sm text-gray-500', {
|
|
1496
|
+
'w-0 whitespace-nowrap': condensed
|
|
1497
|
+
})
|
|
1402
1498
|
}, children);
|
|
1403
1499
|
}
|
|
1404
1500
|
|
|
@@ -1417,7 +1513,8 @@ function TableHeader(_ref) {
|
|
|
1417
1513
|
className = _ref$className === void 0 ? '' : _ref$className,
|
|
1418
1514
|
sort = _ref.sort,
|
|
1419
1515
|
_ref$textAlign = _ref.textAlign,
|
|
1420
|
-
textAlign = _ref$textAlign === void 0 ? 'left' : _ref$textAlign
|
|
1516
|
+
textAlign = _ref$textAlign === void 0 ? 'left' : _ref$textAlign,
|
|
1517
|
+
condensed = _ref.condensed;
|
|
1421
1518
|
|
|
1422
1519
|
var _React$useState = React__default.useState(''),
|
|
1423
1520
|
sortLink = _React$useState[0],
|
|
@@ -1441,7 +1538,9 @@ function TableHeader(_ref) {
|
|
|
1441
1538
|
}, []);
|
|
1442
1539
|
var textAlignClass = textAlign === 'center' && 'text-center justify-center' || textAlign === 'right' && 'text-right justify-end' || 'text-left justify-between';
|
|
1443
1540
|
return React__default.createElement("th", {
|
|
1444
|
-
className: className
|
|
1541
|
+
className: cn(className, 'py-3.5 px-3 text-sm font-semibold text-left', {
|
|
1542
|
+
'w-0 whitespace-nowrap': condensed
|
|
1543
|
+
})
|
|
1445
1544
|
}, React__default.createElement("div", {
|
|
1446
1545
|
className: "flex items-center gap-3 " + textAlignClass
|
|
1447
1546
|
}, children, sort && React__default.createElement(react.Link, {
|
|
@@ -2076,6 +2175,7 @@ exports.QuoteRequestFormContext = QuoteRequestFormContext;
|
|
|
2076
2175
|
exports.QuoteRequestFormProvider = QuoteRequestFormProvider;
|
|
2077
2176
|
exports.QuoteRequestOptionsProvider = QuoteRequestOptionsProvider;
|
|
2078
2177
|
exports.RegistrationSearchField = RegistrationSearchField;
|
|
2178
|
+
exports.SimplePagination = SimplePagination;
|
|
2079
2179
|
exports.Table = Table;
|
|
2080
2180
|
exports.TableActions = TableActions;
|
|
2081
2181
|
exports.TableBody = TableBody;
|