@helpdice/ui 1.3.4 → 1.3.6

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.
@@ -20599,247 +20599,6 @@ function Placeholder(_ref) {
20599
20599
  }, msg));
20600
20600
  }
20601
20601
 
20602
- var TableBody = function TableBody(_ref) {
20603
- var data = _ref.data,
20604
- emptyText = _ref.emptyText,
20605
- onRow = _ref.onRow,
20606
- onCell = _ref.onCell,
20607
- rowClassName = _ref.rowClassName,
20608
- _ref$rowDraggable = _ref.rowDraggable,
20609
- rowDraggable = _ref$rowDraggable === undefined ? false : _ref$rowDraggable,
20610
- _ref$readOnly = _ref.readOnly,
20611
- readOnly = _ref$readOnly === undefined ? false : _ref$readOnly,
20612
- onSelected = _ref.onSelected;
20613
- var theme = useTheme();
20614
- var _useState = React.useState([]),
20615
- _useState2 = _slicedToArray(_useState, 2),
20616
- selected = _useState2[0],
20617
- setSelected = _useState2[1];
20618
- var _useTableContext = useTableContext(),
20619
- columns = _useTableContext.columns;
20620
- // const rowClickHandler = (row: TableDataItem, index: number) => {
20621
- // onRow && onRow(row, index)
20622
- // }
20623
-
20624
- var handleClick = function handleClick(_event, id) {
20625
- if (readOnly) {
20626
- return true;
20627
- }
20628
- var selectedIndex = selected.indexOf(id);
20629
- var newSelected = [];
20630
- if (selectedIndex === -1) {
20631
- newSelected = newSelected.concat(selected, id);
20632
- } else if (selectedIndex === 0) {
20633
- newSelected = newSelected.concat(selected.slice(1));
20634
- } else if (selectedIndex === selected.length - 1) {
20635
- newSelected = newSelected.concat(selected.slice(0, -1));
20636
- } else if (selectedIndex > 0) {
20637
- newSelected = newSelected.concat(selected.slice(0, selectedIndex), selected.slice(selectedIndex + 1));
20638
- }
20639
- setSelected(newSelected);
20640
- };
20641
-
20642
- // const handleSelectAllClick = (event: { target: { checked: any } }) => {
20643
- // if (event.target.checked) {
20644
- // const newSelecteds = data.map((n: any) => n._id);
20645
- // setSelected(newSelecteds as never[]);
20646
- // return;
20647
- // }
20648
- // setSelected([]);
20649
- // };
20650
-
20651
- // Push Selected Rows
20652
- React.useEffect(function () {
20653
- if (selected.length > 0 && onSelected) {
20654
- onSelected(selected);
20655
- }
20656
- }, [selected]);
20657
- function renderRow(cols, row, index) {
20658
- var _row$style;
20659
- var urid = _.uniqueId();
20660
- var className = rowClassName(row, index);
20661
- var rw = _objectSpread2({}, row);
20662
- var rowStyle = (_row$style = row === null || row === undefined ? undefined : row.style) !== null && _row$style !== undefined ? _row$style : {};
20663
- var onDragStart = row === null || row === undefined ? undefined : row.onDragStart;
20664
- delete rw.table;
20665
- delete rw.style;
20666
- delete rw.onDragStart;
20667
- // console.log(row);
20668
- // const frow = Object.fromEntries(
20669
- // Object.entries(row).filter(([ky, _]) => ky !== '_id' && cols.map((col: any) => col.id).includes(ky))
20670
- // ) as unknown as TableDataItem
20671
- // console.log(frow);
20672
- var isRowSelected = selected.indexOf(row) !== -1;
20673
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("tr", {
20674
- draggable: rowDraggable,
20675
- role: "checkbox",
20676
- onDragStart: onDragStart,
20677
- "aria-checked": selected.indexOf(row) !== -1,
20678
- tabIndex: -1,
20679
- key: urid,
20680
- style: _objectSpread2({
20681
- cursor: 'pointer',
20682
- backgroundColor: isRowSelected ? '#efefef' : ''
20683
- }, rowStyle),
20684
- onClick: function onClick(e) {
20685
- if (!rowDraggable) {
20686
- if (onRow) {
20687
- onRow(row, index);
20688
- } else {
20689
- handleClick(e, row);
20690
- }
20691
- }
20692
- },
20693
- className: _JSXStyle.dynamic([["2019708038", [theme.palette.accents_1, theme.palette.border, theme.palette.accents_6]]]) + " " + (useClasses("".concat(rowDraggable ? 'draggable' : 'hover', " ").concat(className)) || "")
20694
- }, /*#__PURE__*/React.createElement(TableCell, {
20695
- columns: cols,
20696
- row: rw,
20697
- rowIndex: index,
20698
- emptyText: emptyText,
20699
- onCellClick: onCell
20700
- })), /*#__PURE__*/React.createElement(_JSXStyle, {
20701
- id: "2019708038",
20702
- dynamic: [theme.palette.accents_1, theme.palette.border, theme.palette.accents_6]
20703
- }, "tr.__jsx-style-dynamic-selector{-webkit-transition:background-color 0.25s ease;transition:background-color 0.25s ease;font-size:inherit;}tr.hover.__jsx-style-dynamic-selector:hover{background-color:".concat(theme.palette.accents_1, ";}tr.draggable.__jsx-style-dynamic-selector:hover{border:2px dashed #dfdfdf;margin:3px;}tr.__jsx-style-dynamic-selector td{padding:0 0.5em;border-bottom:1px solid ").concat(theme.palette.border, ";color:").concat(theme.palette.accents_6, ";font-size:calc(0.875 * var(--table-font-size));text-align:left;}tr.__jsx-style-dynamic-selector .cell{min-height:calc(3.125 * var(--table-font-size));display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-flex-flow:row wrap;-ms-flex-flow:row wrap;flex-flow:row wrap;}")));
20704
- }
20705
- if ((data === null || data === undefined ? undefined : data.length) === 0) {
20706
- return /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
20707
- colSpan: columns === null || columns === undefined ? undefined : columns.length
20708
- }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Placeholder, {
20709
- empty: true,
20710
- msg: "No Entries Found"
20711
- })))));
20712
- }
20713
- return /*#__PURE__*/React.createElement("tbody", {
20714
- className: _JSXStyle.dynamic([["1422656197", [theme.palette.accents_1, theme.palette.border, theme.palette.accents_6]]])
20715
- }, data.map(function (row, index) {
20716
- var qid = _.uniqueId();
20717
- if (row === null || row === undefined) {
20718
- var uid = _.uniqueId();
20719
- return /*#__PURE__*/React.createElement("tr", {
20720
- key: uid,
20721
- className: _JSXStyle.dynamic([["1422656197", [theme.palette.accents_1, theme.palette.border, theme.palette.accents_6]]])
20722
- }, /*#__PURE__*/React.createElement("td", {
20723
- colSpan: columns.length,
20724
- className: _JSXStyle.dynamic([["1422656197", [theme.palette.accents_1, theme.palette.border, theme.palette.accents_6]]])
20725
- }, "\u2003"));
20726
- }
20727
- return /*#__PURE__*/React.createElement(React.Fragment, null, renderRow(columns, row, index), (row === null || row === undefined ? undefined : row.table) && /*#__PURE__*/React.createElement("tr", {
20728
- key: qid,
20729
- className: _JSXStyle.dynamic([["1422656197", [theme.palette.accents_1, theme.palette.border, theme.palette.accents_6]]])
20730
- }, /*#__PURE__*/React.createElement("td", {
20731
- style: {
20732
- padding: '1rem'
20733
- },
20734
- colSpan: columns.length,
20735
- className: _JSXStyle.dynamic([["1422656197", [theme.palette.accents_1, theme.palette.border, theme.palette.accents_6]]])
20736
- })));
20737
-
20738
- // return (
20739
- // <tr
20740
- // key={`tbody-row-${index}`}
20741
- // className={useClasses({ hover }, className)}
20742
- // onClick={() => rowClickHandler(row, index)}>
20743
- // <TableCell<TableDataItem>
20744
- // columns={columns}
20745
- // row={row}
20746
- // rowIndex={index}
20747
- // emptyText={emptyText}
20748
- // onCellClick={onCell}
20749
- // />
20750
- // </tr>
20751
- // )
20752
- }), /*#__PURE__*/React.createElement(_JSXStyle, {
20753
- id: "1422656197",
20754
- dynamic: [theme.palette.accents_1, theme.palette.border, theme.palette.accents_6]
20755
- }, "tr.__jsx-style-dynamic-selector{-webkit-transition:background-color 0.25s ease;transition:background-color 0.25s ease;font-size:inherit;}tr.hover.__jsx-style-dynamic-selector:hover{background-color:".concat(theme.palette.accents_1, ";}tr.draggable.__jsx-style-dynamic-selector:hover{border:2px dashed #dfdfdf;margin:3px;}tr.__jsx-style-dynamic-selector td{padding:0 0.5em;border-bottom:1px solid ").concat(theme.palette.border, ";color:").concat(theme.palette.accents_6, ";font-size:calc(0.875 * var(--table-font-size));text-align:left;}tr.__jsx-style-dynamic-selector .cell{min-height:calc(3.125 * var(--table-font-size));display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-flex-flow:row wrap;-ms-flex-flow:row wrap;flex-flow:row wrap;}")));
20756
- };
20757
- TableBody.displayName = 'TableBody';
20758
-
20759
- var getRealShape = function getRealShape(el) {
20760
- var defaultShape = {
20761
- width: 0,
20762
- height: 0
20763
- };
20764
- if (!el || typeof window === 'undefined') return defaultShape;
20765
- var rect = el.getBoundingClientRect();
20766
- var _window$getComputedSt = window.getComputedStyle(el),
20767
- width = _window$getComputedSt.width,
20768
- height = _window$getComputedSt.height;
20769
- var getCSSStyleVal = function getCSSStyleVal(str, parentNum) {
20770
- if (!str) return 0;
20771
- var strVal = str.includes('px') ? +str.split('px')[0] : str.includes('%') ? +str.split('%')[0] * parentNum * 0.01 : str;
20772
- return Number.isNaN(+strVal) ? 0 : +strVal;
20773
- };
20774
- return {
20775
- width: getCSSStyleVal("".concat(width), rect.width),
20776
- height: getCSSStyleVal("".concat(height), rect.height)
20777
- };
20778
- };
20779
- var useRealShape = function useRealShape(ref) {
20780
- var _useState = React.useState({
20781
- width: 0,
20782
- height: 0
20783
- }),
20784
- _useState2 = _slicedToArray(_useState, 2),
20785
- state = _useState2[0],
20786
- setState = _useState2[1];
20787
- var update = function update() {
20788
- var _getRealShape = getRealShape(ref.current),
20789
- width = _getRealShape.width,
20790
- height = _getRealShape.height;
20791
- setState({
20792
- width: width,
20793
- height: height
20794
- });
20795
- };
20796
- React.useEffect(function () {
20797
- return update();
20798
- }, [ref.current]);
20799
- return [state, update];
20800
- };
20801
-
20802
- /* "use client" */
20803
-
20804
- var TableColumn = function TableColumn(columnProps) {
20805
- var _ref = columnProps,
20806
- children = _ref.children,
20807
- prop = _ref.prop,
20808
- label = _ref.label,
20809
- width = _ref.width,
20810
- filter = _ref.filter,
20811
- options = _ref.options,
20812
- noWrap = _ref.noWrap,
20813
- align = _ref.align,
20814
- _ref$fontSize = _ref.fontSize,
20815
- fontSize = _ref$fontSize === undefined ? 'smaller' : _ref$fontSize,
20816
- _ref$className = _ref.className,
20817
- className = _ref$className === undefined ? '' : _ref$className,
20818
- renderHandler = _ref.render;
20819
- var _useTableContext = useTableContext(),
20820
- updateColumn = _useTableContext.updateColumn;
20821
- var safeProp = "".concat(prop.toString()).trim();
20822
- if (!safeProp) {
20823
- useWarning('The props "prop" is required.', 'Table.Column');
20824
- }
20825
- React.useEffect(function () {
20826
- updateColumn({
20827
- label: children || label,
20828
- filter: filter,
20829
- noWrap: noWrap,
20830
- options: options,
20831
- prop: safeProp,
20832
- width: width,
20833
- align: align,
20834
- fontSize: fontSize,
20835
- className: className,
20836
- renderHandler: function renderHandler() {}
20837
- });
20838
- }, [children, noWrap, fontSize, align, filter, options, label, prop, width, className, renderHandler]);
20839
- return null;
20840
- };
20841
- TableColumn.displayName = 'TableColumn';
20842
-
20843
20602
  // import { IconContext } from "./context.js";
20844
20603
  const createIcon = (Component) => {
20845
20604
  const IconWrapper = React.forwardRef(({ color = "#001A72", strokeWidth = "1.5", size = "24", set = "outline", style, ...props }, ref) => {
@@ -30716,22 +30475,204 @@ const HelpCircle = ({ color, strokeWidth, set }) => {
30716
30475
  HelpCircle.displayName = "HelpCircle";
30717
30476
  createIcon(HelpCircle);
30718
30477
 
30719
- var hexToRgb = function hexToRgb(color) {
30720
- var fullReg = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
30721
- var full = color.replace(fullReg, function (_, r, g, b) {
30722
- return "".concat(r).concat(r).concat(g).concat(g).concat(b).concat(b);
30723
- });
30724
- var values = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(full);
30725
- if (!values) {
30726
- throw new Error("Helpdice UI: Unsupported ".concat(color, " color."));
30727
- }
30728
- return [Number.parseInt(values[1], 16), Number.parseInt(values[2], 16), Number.parseInt(values[3], 16)];
30729
- };
30730
- var colorToRgbValues = function colorToRgbValues(color) {
30731
- if (color.charAt(0) === '#') return hexToRgb(color);
30732
- var safeColor = color.replace(/ /g, '');
30733
- var colorType = color.substr(0, 4);
30734
- var regArray = safeColor.match(/\((.+)\)/);
30478
+ var ButtonDrip = function ButtonDrip(_ref) {
30479
+ var _ref$x = _ref.x,
30480
+ x = _ref$x === undefined ? 0 : _ref$x,
30481
+ _ref$y = _ref.y,
30482
+ y = _ref$y === undefined ? 0 : _ref$y,
30483
+ color = _ref.color,
30484
+ onCompleted = _ref.onCompleted;
30485
+ var dripRef = React.useRef(null);
30486
+ /* istanbul ignore next */
30487
+ var top = Number.isNaN(+y) ? 0 : y - 10;
30488
+ /* istanbul ignore next */
30489
+ var left = Number.isNaN(+x) ? 0 : x - 10;
30490
+ React.useEffect(function () {
30491
+ /* istanbul ignore next */
30492
+ if (!dripRef.current) return;
30493
+ dripRef.current.addEventListener('animationend', onCompleted);
30494
+ return function () {
30495
+ /* istanbul ignore next */
30496
+ if (!dripRef.current) return;
30497
+ dripRef.current.removeEventListener('animationend', onCompleted);
30498
+ };
30499
+ });
30500
+ return /*#__PURE__*/React.createElement("div", {
30501
+ ref: dripRef,
30502
+ className: "jsx-3424889537" + " " + "drip"
30503
+ }, /*#__PURE__*/React.createElement("svg", {
30504
+ width: "20",
30505
+ height: "20",
30506
+ viewBox: "0 0 20 20",
30507
+ style: {
30508
+ top: top,
30509
+ left: left
30510
+ },
30511
+ className: "jsx-3424889537"
30512
+ }, /*#__PURE__*/React.createElement("g", {
30513
+ stroke: "none",
30514
+ strokeWidth: "1",
30515
+ fill: "none",
30516
+ fillRule: "evenodd",
30517
+ className: "jsx-3424889537"
30518
+ }, /*#__PURE__*/React.createElement("g", {
30519
+ fill: color,
30520
+ className: "jsx-3424889537"
30521
+ }, /*#__PURE__*/React.createElement("rect", {
30522
+ width: "100%",
30523
+ height: "100%",
30524
+ rx: "10",
30525
+ className: "jsx-3424889537"
30526
+ })))), /*#__PURE__*/React.createElement(_JSXStyle, {
30527
+ id: "3424889537"
30528
+ }, ".drip.jsx-3424889537{position:absolute;left:0;right:0;top:0;bottom:0;}svg.jsx-3424889537{position:absolute;-webkit-animation:350ms ease-in expand-jsx-3424889537;animation:350ms ease-in expand-jsx-3424889537;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;width:1rem;height:1rem;}@-webkit-keyframes expand-jsx-3424889537{0%{opacity:0;-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1);}30%{opacity:1;}80%{opacity:0.5;}100%{-webkit-transform:scale(28);-ms-transform:scale(28);transform:scale(28);opacity:0;}}@keyframes expand-jsx-3424889537{0%{opacity:0;-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1);}30%{opacity:1;}80%{opacity:0.5;}100%{-webkit-transform:scale(28);-ms-transform:scale(28);transform:scale(28);opacity:0;}}"));
30529
+ };
30530
+ ButtonDrip.displayName = 'ButtonDrip';
30531
+
30532
+ var _excluded$a = ["children", "type", "color", "className", "spaceRatio"];
30533
+ var getIconBgColor = function getIconBgColor(type, palette, color) {
30534
+ var colors = {
30535
+ "default": palette.accents_6,
30536
+ secondary: palette.secondary,
30537
+ success: palette.success,
30538
+ warning: palette.warning,
30539
+ error: palette.error
30540
+ };
30541
+ return color ? color : colors[type];
30542
+ };
30543
+ var LoadingComponent = function LoadingComponent(_ref) {
30544
+ var children = _ref.children,
30545
+ _ref$type = _ref.type,
30546
+ type = _ref$type === undefined ? 'default' : _ref$type,
30547
+ color = _ref.color,
30548
+ _ref$className = _ref.className,
30549
+ className = _ref$className === undefined ? '' : _ref$className,
30550
+ _ref$spaceRatio = _ref.spaceRatio,
30551
+ spaceRatio = _ref$spaceRatio === undefined ? 1 : _ref$spaceRatio,
30552
+ props = _objectWithoutProperties(_ref, _excluded$a);
30553
+ var theme = useTheme();
30554
+ var _useScale = useScale(),
30555
+ SCALES = _useScale.SCALES;
30556
+ var classes = useClasses('loading-container', className);
30557
+ var bgColor = React.useMemo(function () {
30558
+ return getIconBgColor(type, theme.palette, color);
30559
+ }, [type, theme.palette, color]);
30560
+ return /*#__PURE__*/React.createElement("div", _extends({}, props, {
30561
+ className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.accents_5, bgColor, spaceRatio]]]) + " " + (props && props.className != null && props.className || classes || "")
30562
+ }), /*#__PURE__*/React.createElement("span", {
30563
+ className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.accents_5, bgColor, spaceRatio]]]) + " " + "loading"
30564
+ }, children && /*#__PURE__*/React.createElement("label", {
30565
+ className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.accents_5, bgColor, spaceRatio]]])
30566
+ }, children), /*#__PURE__*/React.createElement("i", {
30567
+ className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.accents_5, bgColor, spaceRatio]]])
30568
+ }), /*#__PURE__*/React.createElement("i", {
30569
+ className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.accents_5, bgColor, spaceRatio]]])
30570
+ }), /*#__PURE__*/React.createElement("i", {
30571
+ className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.accents_5, bgColor, spaceRatio]]])
30572
+ })), /*#__PURE__*/React.createElement(_JSXStyle, {
30573
+ id: "2201634259",
30574
+ dynamic: [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.accents_5, bgColor, spaceRatio]
30575
+ }, ".loading-container.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;position:relative;font-size:".concat(SCALES.font(1), ";width:").concat(SCALES.width(1, '100%'), ";height:").concat(SCALES.height(1, '100%'), ";min-height:1em;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), ";}label.__jsx-style-dynamic-selector{margin-right:0.5em;color:").concat(theme.palette.accents_5, ";line-height:1;}label.__jsx-style-dynamic-selector *{margin:0;}.loading.__jsx-style-dynamic-selector{position:absolute;top:50%;left:50%;width:100%;height:100%;-webkit-transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);transform:translate(-50%,-50%);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;background-color:transparent;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}i.__jsx-style-dynamic-selector{width:0.25em;height:0.25em;border-radius:50%;background-color:").concat(bgColor, ";margin:0 calc(0.25em / 2 * ").concat(spaceRatio, ");display:inline-block;-webkit-animation:loading-blink-__jsx-style-dynamic-selector 1.4s infinite both;animation:loading-blink-__jsx-style-dynamic-selector 1.4s infinite both;}i.__jsx-style-dynamic-selector:nth-child(2){-webkit-animation-delay:0.2s;animation-delay:0.2s;}i.__jsx-style-dynamic-selector:nth-child(3){-webkit-animation-delay:0.4s;animation-delay:0.4s;}@-webkit-keyframes loading-blink-__jsx-style-dynamic-selector{0%{opacity:0.2;}20%{opacity:1;}100%{opacity:0.2;}}@keyframes loading-blink-__jsx-style-dynamic-selector{0%{opacity:0.2;}20%{opacity:1;}100%{opacity:0.2;}}")));
30576
+ };
30577
+ LoadingComponent.displayName = 'Loading';
30578
+ var Loading = withScale(LoadingComponent);
30579
+
30580
+ var ButtonLoading = function ButtonLoading(_ref) {
30581
+ var color = _ref.color;
30582
+ return /*#__PURE__*/React.createElement("div", {
30583
+ className: "jsx-212623367" + " " + "btn-loading"
30584
+ }, /*#__PURE__*/React.createElement(Loading, {
30585
+ color: color
30586
+ }), /*#__PURE__*/React.createElement(_JSXStyle, {
30587
+ id: "212623367"
30588
+ }, ".btn-loading.jsx-212623367{position:absolute;top:0;left:0;right:0;bottom:0;z-index:2;background-color:var(--helpdice-ui-button-bg);}"));
30589
+ };
30590
+ ButtonLoading.displayName = 'GeistButtonLoading';
30591
+
30592
+ var _excluded$9 = ["isRight", "isSingle", "children", "className"];
30593
+ var ButtonIcon = function ButtonIcon(_ref) {
30594
+ var _ref$isRight = _ref.isRight,
30595
+ isRight = _ref$isRight === undefined ? false : _ref$isRight,
30596
+ isSingle = _ref.isSingle,
30597
+ children = _ref.children,
30598
+ _ref$className = _ref.className,
30599
+ className = _ref$className === undefined ? '' : _ref$className,
30600
+ props = _objectWithoutProperties(_ref, _excluded$9);
30601
+ var classes = useClasses('icon', {
30602
+ right: isRight,
30603
+ single: isSingle
30604
+ }, className);
30605
+ return /*#__PURE__*/React.createElement("span", _extends({}, props, {
30606
+ className: "jsx-2467502931" + " " + (props && props.className != null && props.className || classes || "")
30607
+ }), children, /*#__PURE__*/React.createElement(_JSXStyle, {
30608
+ id: "2467502931"
30609
+ }, ".icon.jsx-2467502931{position:absolute;left:var(--helpdice-ui-button-icon-padding);right:auto;top:50%;-webkit-transform:translateY(-50%);-ms-transform:translateY(-50%);transform:translateY(-50%);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:var(--helpdice-ui-button-color);z-index:1;}.right.jsx-2467502931{right:var(--helpdice-ui-button-icon-padding);left:auto;}.icon.jsx-2467502931 svg{background:transparent;height:calc(var(--helpdice-ui-button-height) / 2.35);width:calc(var(--helpdice-ui-button-height) / 2.35);}.single.jsx-2467502931{position:static;-webkit-transform:none;-ms-transform:none;transform:none;}"));
30610
+ };
30611
+ ButtonIcon.displayName = 'ButtonIcon';
30612
+
30613
+ var getButtonChildrenWithIcon = function getButtonChildrenWithIcon(auto, children, icons) {
30614
+ var icon = icons.icon,
30615
+ iconRight = icons.iconRight;
30616
+ var hasIcon = icon || iconRight;
30617
+ var isRight = Boolean(iconRight);
30618
+ var paddingForAutoMode = auto ? "calc(var(--helpdice-ui-button-height) / 2 + var(--helpdice-ui-button-icon-padding) * .5)" : 0;
30619
+ var classes = useClasses('text', isRight ? 'right' : 'left');
30620
+ if (!hasIcon) return /*#__PURE__*/React.createElement("div", {
30621
+ className: "text"
30622
+ }, children);
30623
+ if (React.Children.count(children) === 0) {
30624
+ return /*#__PURE__*/React.createElement(ButtonIcon, {
30625
+ isRight: isRight,
30626
+ isSingle: true
30627
+ }, hasIcon);
30628
+ }
30629
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ButtonIcon, {
30630
+ isRight: isRight
30631
+ }, hasIcon), /*#__PURE__*/React.createElement("div", {
30632
+ className: _JSXStyle.dynamic([["3568181479", [paddingForAutoMode, paddingForAutoMode]]]) + " " + (classes || "")
30633
+ }, children, /*#__PURE__*/React.createElement(_JSXStyle, {
30634
+ id: "3568181479",
30635
+ dynamic: [paddingForAutoMode, paddingForAutoMode]
30636
+ }, ".left.__jsx-style-dynamic-selector{padding-left:".concat(paddingForAutoMode, ";}.right.__jsx-style-dynamic-selector{padding-right:").concat(paddingForAutoMode, ";}"))));
30637
+ };
30638
+ var filterPropsWithGroup = function filterPropsWithGroup(props, config) {
30639
+ if (!config.isButtonGroup) return props;
30640
+ return _objectSpread2(_objectSpread2({}, props), {}, {
30641
+ auto: true,
30642
+ shadow: false,
30643
+ ghost: config.ghost || props.ghost,
30644
+ type: config.type || props.type,
30645
+ disabled: config.disabled || props.disabled
30646
+ });
30647
+ };
30648
+
30649
+ /* "use client" */
30650
+
30651
+ var defaultContext$2 = {
30652
+ isButtonGroup: false,
30653
+ disabled: false
30654
+ };
30655
+ var ButtonGroupContext = /*#__PURE__*/React.createContext(defaultContext$2);
30656
+ var useButtonGroupContext = function useButtonGroupContext() {
30657
+ return React.useContext(ButtonGroupContext);
30658
+ };
30659
+
30660
+ var hexToRgb = function hexToRgb(color) {
30661
+ var fullReg = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
30662
+ var full = color.replace(fullReg, function (_, r, g, b) {
30663
+ return "".concat(r).concat(r).concat(g).concat(g).concat(b).concat(b);
30664
+ });
30665
+ var values = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(full);
30666
+ if (!values) {
30667
+ throw new Error("Helpdice UI: Unsupported ".concat(color, " color."));
30668
+ }
30669
+ return [Number.parseInt(values[1], 16), Number.parseInt(values[2], 16), Number.parseInt(values[3], 16)];
30670
+ };
30671
+ var colorToRgbValues = function colorToRgbValues(color) {
30672
+ if (color.charAt(0) === '#') return hexToRgb(color);
30673
+ var safeColor = color.replace(/ /g, '');
30674
+ var colorType = color.substr(0, 4);
30675
+ var regArray = safeColor.match(/\((.+)\)/);
30735
30676
  if (!colorType.startsWith('rgb') || !regArray) {
30736
30677
  console.log(color);
30737
30678
  throw new Error("Helpdice UI: Only support [\"RGB\", \"RGBA\", \"HEX\"] color.");
@@ -30751,1093 +30692,474 @@ var addColorAlpha = function addColorAlpha(color, alpha) {
30751
30692
  return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(safeAlpha, ")");
30752
30693
  };
30753
30694
 
30754
- var _excluded$a = ["active", "children", "disabled", "onClick"];
30755
- var PaginationItem = function PaginationItem(_ref) {
30756
- var active = _ref.active,
30757
- children = _ref.children,
30758
- disabled = _ref.disabled,
30759
- onClick = _ref.onClick,
30760
- props = _objectWithoutProperties(_ref, _excluded$a);
30761
- var theme = useTheme();
30762
- var _useMemo = React.useMemo(function () {
30763
- return [addColorAlpha(theme.palette.success, 0.1), addColorAlpha(theme.palette.success, 0.8)];
30764
- }, [theme.palette.success]),
30765
- _useMemo2 = _slicedToArray(_useMemo, 2),
30766
- hover = _useMemo2[0],
30767
- activeHover = _useMemo2[1];
30768
- var classes = useClasses({
30769
- active: active,
30770
- disabled: disabled
30771
- });
30772
- var clickHandler = function clickHandler(event) {
30773
- if (disabled) return;
30774
- onClick && onClick(event);
30695
+ var getButtonGhostColors = function getButtonGhostColors(palette, type) {
30696
+ var colors = {
30697
+ secondary: {
30698
+ bg: palette.background,
30699
+ border: palette.foreground,
30700
+ color: palette.foreground
30701
+ },
30702
+ success: {
30703
+ bg: palette.background,
30704
+ border: palette.success,
30705
+ color: palette.success
30706
+ },
30707
+ warning: {
30708
+ bg: palette.background,
30709
+ border: palette.warning,
30710
+ color: palette.warning
30711
+ },
30712
+ error: {
30713
+ bg: palette.background,
30714
+ border: palette.error,
30715
+ color: palette.error
30716
+ }
30775
30717
  };
30776
- return /*#__PURE__*/React.createElement("li", {
30777
- className: _JSXStyle.dynamic([["1657796974", [theme.palette.success, theme.layout.radius, theme.palette.background, hover, theme.palette.success, theme.palette.background, theme.expressiveness.shadowSmall, activeHover, theme.expressiveness.shadowMedium, theme.palette.accents_4, theme.palette.accents_2]]])
30778
- }, /*#__PURE__*/React.createElement("button", _extends({
30779
- onClick: clickHandler
30780
- }, props, {
30781
- className: _JSXStyle.dynamic([["1657796974", [theme.palette.success, theme.layout.radius, theme.palette.background, hover, theme.palette.success, theme.palette.background, theme.expressiveness.shadowSmall, activeHover, theme.expressiveness.shadowMedium, theme.palette.accents_4, theme.palette.accents_2]]]) + " " + (props && props.className != null && props.className || classes || "")
30782
- }), children), /*#__PURE__*/React.createElement(_JSXStyle, {
30783
- id: "1657796974",
30784
- dynamic: [theme.palette.success, theme.layout.radius, theme.palette.background, hover, theme.palette.success, theme.palette.background, theme.expressiveness.shadowSmall, activeHover, theme.expressiveness.shadowMedium, theme.palette.accents_4, theme.palette.accents_2]
30785
- }, "li.__jsx-style-dynamic-selector{margin-right:0.428em;display:inline-block;}button.__jsx-style-dynamic-selector{border:none;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;box-sizing:border-box;text-transform:capitalize;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;white-space:nowrap;text-align:center;vertical-align:middle;box-shadow:none;outline:none;height:var(--pagination-size);min-width:var(--pagination-size);font-size:inherit;cursor:pointer;color:".concat(theme.palette.success, ";border-radius:").concat(theme.layout.radius, ";background-color:").concat(theme.palette.background, ";-webkit-transition:all linear 200ms 0ms;transition:all linear 200ms 0ms;}button.__jsx-style-dynamic-selector:hover{background-color:").concat(hover, ";}.active.__jsx-style-dynamic-selector{font-weight:bold;background-color:").concat(theme.palette.success, ";color:").concat(theme.palette.background, ";box-shadow:").concat(theme.expressiveness.shadowSmall, ";}.active.__jsx-style-dynamic-selector:hover{background-color:").concat(activeHover, ";box-shadow:").concat(theme.expressiveness.shadowMedium, ";}.disabled.__jsx-style-dynamic-selector{color:").concat(theme.palette.accents_4, ";cursor:not-allowed;}.disabled.__jsx-style-dynamic-selector:hover{background-color:").concat(theme.palette.accents_2, ";}button.__jsx-style-dynamic-selector svg{width:1.3em;height:1.3em;}")));
30786
- };
30787
- PaginationItem.displayName = 'GeistPaginationItem';
30788
-
30789
- /* "use client" */
30790
-
30791
- tuple('prev', 'next', 'click');
30792
- var defaultContext$2 = {};
30793
- var PaginationContext = /*#__PURE__*/React.createContext(defaultContext$2);
30794
- var usePaginationContext = function usePaginationContext() {
30795
- return React.useContext(PaginationContext);
30718
+ return colors[type] || null;
30796
30719
  };
30797
-
30798
- var _excluded$9 = ["children"];
30799
- var PaginationPrevious = function PaginationPrevious(_ref) {
30800
- var children = _ref.children,
30801
- props = _objectWithoutProperties(_ref, _excluded$9);
30802
- var _usePaginationContext = usePaginationContext(),
30803
- update = _usePaginationContext.update,
30804
- isFirst = _usePaginationContext.isFirst;
30805
- return /*#__PURE__*/React.createElement(PaginationItem, _extends({
30806
- onClick: function onClick() {
30807
- return update && update('prev');
30720
+ var getButtonColors = function getButtonColors(palette, props) {
30721
+ var type = props.type,
30722
+ disabled = props.disabled,
30723
+ ghost = props.ghost;
30724
+ var colors = {
30725
+ "default": {
30726
+ bg: palette.background,
30727
+ border: palette.border,
30728
+ color: palette.accents_5
30808
30729
  },
30809
- disabled: isFirst
30810
- }, props), children);
30811
- };
30812
- PaginationPrevious.displayName = 'GeistPaginationPrevious';
30813
-
30814
- var _excluded$8 = ["children"];
30815
- var PaginationNext = function PaginationNext(_ref) {
30816
- var children = _ref.children,
30817
- props = _objectWithoutProperties(_ref, _excluded$8);
30818
- var _usePaginationContext = usePaginationContext(),
30819
- update = _usePaginationContext.update,
30820
- isLast = _usePaginationContext.isLast;
30821
- return /*#__PURE__*/React.createElement(PaginationItem, _extends({
30822
- onClick: function onClick() {
30823
- return update && update('next');
30730
+ secondary: {
30731
+ bg: palette.foreground,
30732
+ border: palette.foreground,
30733
+ color: palette.background
30824
30734
  },
30825
- disabled: isLast
30826
- }, props), children);
30827
- };
30828
- PaginationNext.displayName = 'GeistPaginationNext';
30829
-
30830
- var PaginationEllipsis = function PaginationEllipsis(_ref) {
30831
- var isBefore = _ref.isBefore,
30832
- _onClick = _ref.onClick;
30833
- var _useState = React.useState(false),
30834
- _useState2 = _slicedToArray(_useState, 2),
30835
- showMore = _useState2[0],
30836
- setShowMore = _useState2[1];
30837
- return /*#__PURE__*/React.createElement(PaginationItem, {
30838
- onClick: function onClick(e) {
30839
- return _onClick && _onClick(e);
30735
+ success: {
30736
+ bg: palette.success,
30737
+ border: palette.success,
30738
+ color: '#fff'
30840
30739
  },
30841
- onMouseEnter: function onMouseEnter() {
30842
- return setShowMore(true);
30740
+ warning: {
30741
+ bg: palette.warning,
30742
+ border: palette.warning,
30743
+ color: '#fff'
30843
30744
  },
30844
- onMouseLeave: function onMouseLeave() {
30845
- return setShowMore(false);
30745
+ error: {
30746
+ bg: palette.error,
30747
+ border: palette.error,
30748
+ color: '#fff'
30749
+ },
30750
+ abort: {
30751
+ bg: 'transparent',
30752
+ border: 'transparent',
30753
+ color: palette.accents_5
30846
30754
  }
30847
- }, showMore ? /*#__PURE__*/React.createElement("svg", {
30848
- viewBox: "0 0 24 24",
30849
- stroke: "currentColor",
30850
- strokeWidth: "1.5",
30851
- strokeLinecap: "round",
30852
- strokeLinejoin: "round",
30853
- fill: "none",
30854
- shapeRendering: "geometricPrecision",
30855
- className: _JSXStyle.dynamic([["2928474255", [isBefore ? '180deg' : '0deg']]]) + " " + "more"
30856
- }, /*#__PURE__*/React.createElement("path", {
30857
- d: "M13 17l5-5-5-5",
30858
- className: _JSXStyle.dynamic([["2928474255", [isBefore ? '180deg' : '0deg']]])
30859
- }), /*#__PURE__*/React.createElement("path", {
30860
- d: "M6 17l5-5-5-5",
30861
- className: _JSXStyle.dynamic([["2928474255", [isBefore ? '180deg' : '0deg']]])
30862
- })) : /*#__PURE__*/React.createElement("svg", {
30863
- viewBox: "0 0 24 24",
30864
- strokeWidth: "1.5",
30865
- strokeLinecap: "round",
30866
- strokeLinejoin: "round",
30867
- fill: "none",
30868
- shapeRendering: "geometricPrecision",
30869
- className: _JSXStyle.dynamic([["2928474255", [isBefore ? '180deg' : '0deg']]])
30870
- }, /*#__PURE__*/React.createElement("circle", {
30871
- cx: "12",
30872
- cy: "12",
30873
- r: "1",
30874
- fill: "currentColor",
30875
- className: _JSXStyle.dynamic([["2928474255", [isBefore ? '180deg' : '0deg']]])
30876
- }), /*#__PURE__*/React.createElement("circle", {
30877
- cx: "19",
30878
- cy: "12",
30879
- r: "1",
30880
- fill: "currentColor",
30881
- className: _JSXStyle.dynamic([["2928474255", [isBefore ? '180deg' : '0deg']]])
30882
- }), /*#__PURE__*/React.createElement("circle", {
30883
- cx: "5",
30884
- cy: "12",
30885
- r: "1",
30886
- fill: "currentColor",
30887
- className: _JSXStyle.dynamic([["2928474255", [isBefore ? '180deg' : '0deg']]])
30888
- })), /*#__PURE__*/React.createElement(_JSXStyle, {
30889
- id: "2928474255",
30890
- dynamic: [isBefore ? '180deg' : '0deg']
30891
- }, "svg.__jsx-style-dynamic-selector{color:currentColor;stroke:currentColor;width:1em;height:1em;}.more.__jsx-style-dynamic-selector{-webkit-transform:rotate(".concat(isBefore ? '180deg' : '0deg', ");-ms-transform:rotate(").concat(isBefore ? '180deg' : '0deg', ");transform:rotate(").concat(isBefore ? '180deg' : '0deg', ");}")));
30892
- };
30893
- PaginationEllipsis.displayName = 'GeistPaginationEllipsis';
30755
+ };
30756
+ if (disabled) return {
30757
+ bg: palette.accents_1,
30758
+ border: palette.accents_2,
30759
+ color: '#ccc'
30760
+ };
30894
30761
 
30895
- var PaginationPages = function PaginationPages(_ref) {
30896
- var limit = _ref.limit,
30897
- count = _ref.count,
30898
- current = _ref.current,
30899
- setPage = _ref.setPage;
30900
- var showPages = React.useMemo(function () {
30901
- var oddLimit = limit % 2 === 0 ? limit - 1 : limit;
30902
- return oddLimit - 2;
30903
- }, [limit]);
30904
- var middleNumber = (showPages + 1) / 2;
30905
- var _useMemo = React.useMemo(function () {
30906
- var showEllipsis = count > limit;
30907
- return [showEllipsis && current > middleNumber + 1, showEllipsis && current < count - middleNumber];
30908
- }, [current, showPages, middleNumber, count, limit]),
30909
- _useMemo2 = _slicedToArray(_useMemo, 2),
30910
- showBeforeEllipsis = _useMemo2[0],
30911
- showAfterEllipsis = _useMemo2[1];
30912
- var pagesArray = React.useMemo(function () {
30913
- return _toConsumableArray(new Array(showPages));
30914
- }, [showPages]);
30915
- var renderItem = React.useCallback(function (value, active) {
30916
- return /*#__PURE__*/React.createElement(PaginationItem, {
30917
- key: "pagination-item-".concat(value),
30918
- active: value === active,
30919
- onClick: function onClick() {
30920
- return setPage(value);
30921
- }
30922
- }, value);
30923
- }, []);
30924
- var startPages = pagesArray.map(function (_, index) {
30925
- var value = index + 2;
30926
- return renderItem(value, current);
30927
- });
30928
- var middlePages = pagesArray.map(function (_, index) {
30929
- var middleIndexNumber = middleNumber - (index + 1);
30930
- var value = current - middleIndexNumber;
30931
- return /*#__PURE__*/React.createElement(PaginationItem, {
30932
- key: "pagination-middle-".concat(index),
30933
- active: index + 1 === middleNumber,
30934
- onClick: function onClick() {
30935
- return setPage(value);
30936
- }
30937
- }, value);
30938
- });
30939
- var endPages = pagesArray.map(function (_, index) {
30940
- var value = count - (showPages - index);
30941
- return renderItem(value, current);
30942
- });
30943
- if (count <= limit) {
30944
- /* eslint-disable react/jsx-no-useless-fragment */
30945
- return /*#__PURE__*/React.createElement(React.Fragment, null, _toConsumableArray(new Array(count)).map(function (_, index) {
30946
- var value = index + 1;
30947
- return /*#__PURE__*/React.createElement(PaginationItem, {
30948
- key: "pagination-item-".concat(value),
30949
- active: value === current,
30950
- onClick: function onClick() {
30951
- return setPage(value);
30952
- }
30953
- }, value);
30954
- }));
30955
- /* eslint-enable */
30956
- }
30957
- return /*#__PURE__*/React.createElement(React.Fragment, null, renderItem(1, current), showBeforeEllipsis && /*#__PURE__*/React.createElement(PaginationEllipsis, {
30958
- key: "pagination-ellipsis-before",
30959
- isBefore: true,
30960
- onClick: function onClick() {
30961
- return setPage(function (last) {
30962
- return last - 5 >= 1 ? last - 5 : 1;
30963
- });
30964
- }
30965
- }), showBeforeEllipsis && showAfterEllipsis ? middlePages : showBeforeEllipsis ? endPages : startPages, showAfterEllipsis && /*#__PURE__*/React.createElement(PaginationEllipsis, {
30966
- key: "pagination-ellipsis-after",
30967
- onClick: function onClick() {
30968
- return setPage(function (last) {
30969
- return last + 5 <= count ? last + 5 : count;
30970
- });
30762
+ /**
30763
+ * The '-light' type is the same color as the common type,
30764
+ * only hover's color is different.
30765
+ * e.g.
30766
+ * Color['success'] === Color['success-light']
30767
+ * Color['warning'] === Color['warning-light']
30768
+ */
30769
+ var withoutLightType = type === null || type === undefined ? undefined : type.replace('-light', '');
30770
+ var defaultColor = colors["default"];
30771
+ if (ghost) return getButtonGhostColors(palette, withoutLightType) || defaultColor;
30772
+ return colors[withoutLightType] || defaultColor;
30773
+ };
30774
+ var getButtonGhostHoverColors = function getButtonGhostHoverColors(palette, type) {
30775
+ var colors = {
30776
+ secondary: {
30777
+ bg: palette.foreground,
30778
+ border: palette.background,
30779
+ color: palette.background
30780
+ },
30781
+ success: {
30782
+ bg: palette.success,
30783
+ border: palette.background,
30784
+ color: 'white'
30785
+ },
30786
+ warning: {
30787
+ bg: palette.warning,
30788
+ border: palette.background,
30789
+ color: 'white'
30790
+ },
30791
+ error: {
30792
+ bg: palette.error,
30793
+ border: palette.background,
30794
+ color: 'white'
30971
30795
  }
30972
- }), renderItem(count, current));
30796
+ };
30797
+ var withoutLightType = type.replace('-light', '');
30798
+ return colors[withoutLightType] || null;
30973
30799
  };
30974
- PaginationPages.displayName = 'GeistPaginationPages';
30975
-
30976
- var _excluded$7 = ["page", "initialPage", "count", "limit", "children", "onChange", "className"];
30977
- var PaginationComponent = function PaginationComponent(_ref) {
30978
- var customPage = _ref.page,
30979
- _ref$initialPage = _ref.initialPage,
30980
- initialPage = _ref$initialPage === undefined ? 1 : _ref$initialPage,
30981
- _ref$count = _ref.count,
30982
- count = _ref$count === undefined ? 1 : _ref$count,
30983
- _ref$limit = _ref.limit,
30984
- limit = _ref$limit === undefined ? 7 : _ref$limit,
30985
- children = _ref.children,
30986
- onChange = _ref.onChange,
30987
- _ref$className = _ref.className,
30988
- className = _ref$className === undefined ? '' : _ref$className,
30989
- props = _objectWithoutProperties(_ref, _excluded$7);
30990
- var _useScale = useScale(),
30991
- SCALES = _useScale.SCALES;
30992
- var _useCurrentState = useCurrentState(initialPage),
30993
- _useCurrentState2 = _slicedToArray(_useCurrentState, 3),
30994
- page = _useCurrentState2[0],
30995
- setPage = _useCurrentState2[1],
30996
- pageRef = _useCurrentState2[2];
30997
- var _pickChild = pickChild(children, PaginationPrevious),
30998
- _pickChild2 = _slicedToArray(_pickChild, 2),
30999
- prevChildren = _pickChild2[1];
31000
- var _pickChild3 = pickChild(children, PaginationNext),
31001
- _pickChild4 = _slicedToArray(_pickChild3, 2),
31002
- nextChildren = _pickChild4[1];
31003
- var _useMemo = React.useMemo(function () {
31004
- var hasChildren = function hasChildren(c) {
31005
- return React.Children.count(c) > 0;
31006
- };
31007
- var prevDefault = /*#__PURE__*/React.createElement(PaginationPrevious, null, "prev");
31008
- var nextDefault = /*#__PURE__*/React.createElement(PaginationNext, null, "next");
31009
- return [hasChildren(prevChildren) ? prevChildren : prevDefault, hasChildren(nextChildren) ? nextChildren : nextDefault];
31010
- }, [prevChildren, nextChildren]),
31011
- _useMemo2 = _slicedToArray(_useMemo, 2),
31012
- prevItem = _useMemo2[0],
31013
- nextItem = _useMemo2[1];
31014
- var update = function update(type) {
31015
- if (type === 'prev' && pageRef.current > 1) {
31016
- setPage(function (last) {
31017
- return last - 1;
31018
- });
31019
- }
31020
- if (type === 'next' && pageRef.current < count) {
31021
- setPage(function (last) {
31022
- return last + 1;
31023
- });
31024
- }
30800
+ var getButtonHoverColors = function getButtonHoverColors(palette, props) {
30801
+ var type = props.type,
30802
+ disabled = props.disabled,
30803
+ loading = props.loading,
30804
+ shadow = props.shadow,
30805
+ ghost = props.ghost;
30806
+ var defaultColor = getButtonColors(palette, props);
30807
+ var alphaBackground = addColorAlpha(defaultColor.bg, 0.85);
30808
+ var colors = {
30809
+ "default": {
30810
+ bg: palette.background,
30811
+ border: palette.foreground
30812
+ },
30813
+ secondary: {
30814
+ bg: palette.background,
30815
+ border: palette.foreground
30816
+ },
30817
+ success: {
30818
+ bg: palette.background,
30819
+ border: palette.success
30820
+ },
30821
+ warning: {
30822
+ bg: palette.background,
30823
+ border: palette.warning
30824
+ },
30825
+ error: {
30826
+ bg: palette.background,
30827
+ border: palette.error
30828
+ },
30829
+ abort: {
30830
+ bg: 'transparent',
30831
+ border: 'transparent',
30832
+ color: palette.accents_5
30833
+ },
30834
+ 'secondary-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
30835
+ bg: alphaBackground
30836
+ }),
30837
+ 'success-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
30838
+ bg: alphaBackground
30839
+ }),
30840
+ 'warning-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
30841
+ bg: alphaBackground
30842
+ }),
30843
+ 'error-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
30844
+ bg: alphaBackground
30845
+ })
31025
30846
  };
31026
- var values = React.useMemo(function () {
31027
- return {
31028
- isFirst: page <= 1,
31029
- isLast: page >= count,
31030
- update: update
31031
- };
31032
- }, [page, count]);
31033
- React.useEffect(function () {
31034
- onChange && onChange(page);
31035
- }, [page]);
31036
- React.useEffect(function () {
31037
- if (customPage !== undefined) {
31038
- setPage(customPage);
31039
- }
31040
- }, [customPage]);
31041
- return /*#__PURE__*/React.createElement(PaginationContext.Provider, {
31042
- value: values
31043
- }, /*#__PURE__*/React.createElement("nav", _extends({}, props, {
31044
- className: _JSXStyle.dynamic([["3826701357", [SCALES.font(2), SCALES.font(0.875), SCALES.width(1, 'auto'), 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 || "")
31045
- }), prevItem, /*#__PURE__*/React.createElement(PaginationPages, {
31046
- count: count,
31047
- current: page,
31048
- limit: limit,
31049
- setPage: setPage
31050
- }), nextItem), /*#__PURE__*/React.createElement(_JSXStyle, {
31051
- id: "3826701357",
31052
- dynamic: [SCALES.font(2), SCALES.font(0.875), SCALES.width(1, 'auto'), 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)]
31053
- }, "nav.__jsx-style-dynamic-selector{font-variant:tabular-nums;font-feature-settings:'tnum';--pagination-size:".concat(SCALES.font(2), ";font-size:").concat(SCALES.font(0.875), ";width:").concat(SCALES.width(1, 'auto'), ";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), ";}nav.__jsx-style-dynamic-selector button:last-of-type{margin-right:0;}")));
30847
+ if (disabled) return {
30848
+ bg: palette.accents_1,
30849
+ border: palette.accents_2,
30850
+ color: '#ccc'
30851
+ };
30852
+ if (loading) return _objectSpread2(_objectSpread2({}, defaultColor), {}, {
30853
+ color: 'transparent'
30854
+ });
30855
+ if (shadow) return defaultColor;
30856
+ var hoverColor = (ghost ? getButtonGhostHoverColors(palette, type) : colors[type]) || colors["default"];
30857
+ return _objectSpread2(_objectSpread2({}, hoverColor), {}, {
30858
+ color: hoverColor.color || hoverColor.border
30859
+ });
30860
+ };
30861
+ var getButtonCursor = function getButtonCursor(disabled, loading) {
30862
+ if (disabled) return {
30863
+ cursor: 'not-allowed',
30864
+ events: 'auto'
30865
+ };
30866
+ if (loading) return {
30867
+ cursor: 'default',
30868
+ events: 'none'
30869
+ };
30870
+ return {
30871
+ cursor: 'pointer',
30872
+ events: 'auto'
30873
+ };
30874
+ };
30875
+ var getButtonDripColor = function getButtonDripColor(palette, props) {
30876
+ var type = props.type;
30877
+ var isLightHover = type ? type.endsWith('light') : false;
30878
+ var hoverColors = getButtonHoverColors(palette, props);
30879
+ return isLightHover ? addColorAlpha(hoverColors.bg, 0.65) : addColorAlpha(palette.accents_2, 0.65);
31054
30880
  };
31055
- PaginationComponent.displayName = 'Pagination';
31056
- var Pagination = withScale(PaginationComponent);
31057
-
31058
- Pagination.Previous = PaginationPrevious;
31059
- Pagination.Next = PaginationNext;
31060
30881
 
31061
- var _excluded$6 = ["children", "data", "initialData", "hover", "emptyText", "rowDraggable", "readOnly", "onRow", "onCell", "onChange", "onFilters", "onPageChange", "showFilters", "stickyHeader", "onSelected", "dataLength", "viewLength", "className", "rowClassName"];
31062
- function TableComponent(tableProps) {
31063
- /* eslint-disable @typescript-eslint/no-unused-vars */
31064
- var _ref = tableProps,
31065
- children = _ref.children,
31066
- customData = _ref.data,
31067
- _ref$initialData = _ref.initialData,
31068
- initialData = _ref$initialData === undefined ? [] : _ref$initialData,
31069
- _ref$hover = _ref.hover,
31070
- hover = _ref$hover === undefined ? true : _ref$hover,
31071
- _ref$emptyText = _ref.emptyText,
31072
- emptyText = _ref$emptyText === undefined ? '' : _ref$emptyText,
31073
- _ref$rowDraggable = _ref.rowDraggable,
31074
- rowDraggable = _ref$rowDraggable === undefined ? false : _ref$rowDraggable,
31075
- _ref$readOnly = _ref.readOnly,
31076
- readOnly = _ref$readOnly === undefined ? false : _ref$readOnly,
31077
- onRow = _ref.onRow,
31078
- onCell = _ref.onCell;
31079
- _ref.onChange;
31080
- var onFilters = _ref.onFilters,
31081
- onPageChange = _ref.onPageChange,
31082
- _ref$showFilters = _ref.showFilters,
31083
- showFilters = _ref$showFilters === undefined ? false : _ref$showFilters,
31084
- _ref$stickyHeader = _ref.stickyHeader,
31085
- stickyHeader = _ref$stickyHeader === undefined ? false : _ref$stickyHeader,
31086
- onSelected = _ref.onSelected,
31087
- dataLength = _ref.dataLength,
31088
- viewLength = _ref.viewLength,
31089
- _ref$className = _ref.className,
31090
- className = _ref$className === undefined ? '' : _ref$className,
31091
- _ref$rowClassName = _ref.rowClassName,
31092
- rowClassName = _ref$rowClassName === undefined ? function () {
31093
- return '';
31094
- } : _ref$rowClassName,
31095
- props = _objectWithoutProperties(_ref, _excluded$6);
31096
- /* eslint-enable @typescript-eslint/no-unused-vars */
30882
+ var _excluded$8 = ["children", "disabled", "type", "loading", "shadow", "ghost", "effect", "onClick", "auto", "icon", "htmlType", "iconRight", "className", "crossOrigin"];
30883
+ var ButtonComponent = /*#__PURE__*/React.forwardRef(function (btnProps, ref) {
30884
+ var theme = useTheme();
31097
30885
  var _useScale = useScale(),
31098
30886
  SCALES = _useScale.SCALES;
31099
- var ref = React.useRef(null);
31100
- var _useRealShape = useRealShape(ref),
31101
- _useRealShape2 = _slicedToArray(_useRealShape, 2),
31102
- width = _useRealShape2[0].width,
31103
- updateShape = _useRealShape2[1];
31104
- var _useState = React.useState([]),
30887
+ var buttonRef = React.useRef(null);
30888
+ React.useImperativeHandle(ref, function () {
30889
+ return buttonRef.current;
30890
+ });
30891
+ var _useState = React.useState(false),
31105
30892
  _useState2 = _slicedToArray(_useState, 2),
31106
- columns = _useState2[0],
31107
- setColumns = _useState2[1];
31108
- var _useState3 = React.useState(initialData),
30893
+ dripShow = _useState2[0],
30894
+ setDripShow = _useState2[1];
30895
+ var _useState3 = React.useState(0),
31109
30896
  _useState4 = _slicedToArray(_useState3, 2),
31110
- data = _useState4[0],
31111
- setData = _useState4[1];
31112
- var updateColumn = function updateColumn(column) {
31113
- setColumns(function (last) {
31114
- var hasColumn = last.find(function (item) {
31115
- return item.prop === column.prop;
31116
- });
31117
- if (!hasColumn) return [].concat(_toConsumableArray(last), [column]);
31118
- return last.map(function (item) {
31119
- if (item.prop !== column.prop) return item;
31120
- return column;
31121
- });
31122
- });
31123
- };
31124
- var contextValue = React.useMemo(function () {
31125
- return {
31126
- columns: columns,
31127
- updateColumn: updateColumn
31128
- };
31129
- }, [columns]);
31130
- React.useEffect(function () {
31131
- if (typeof customData === 'undefined') return;
31132
- setData(customData);
31133
- }, [customData]);
31134
- useResize(function () {
31135
- return updateShape();
31136
- });
30897
+ dripX = _useState4[0],
30898
+ setDripX = _useState4[1];
30899
+ var _useState5 = React.useState(0),
30900
+ _useState6 = _slicedToArray(_useState5, 2),
30901
+ dripY = _useState6[0],
30902
+ setDripY = _useState6[1];
30903
+ var groupConfig = useButtonGroupContext();
30904
+ var filteredProps = filterPropsWithGroup(btnProps, groupConfig);
30905
+ /* eslint-disable @typescript-eslint/no-unused-vars */
30906
+ var children = filteredProps.children,
30907
+ _filteredProps$disabl = filteredProps.disabled,
30908
+ disabled = _filteredProps$disabl === undefined ? false : _filteredProps$disabl;
30909
+ filteredProps.type;
30910
+ var _filteredProps$loadin = filteredProps.loading,
30911
+ loading = _filteredProps$loadin === undefined ? false : _filteredProps$loadin,
30912
+ _filteredProps$shadow = filteredProps.shadow,
30913
+ shadow = _filteredProps$shadow === undefined ? false : _filteredProps$shadow,
30914
+ _filteredProps$ghost = filteredProps.ghost,
30915
+ ghost = _filteredProps$ghost === undefined ? false : _filteredProps$ghost,
30916
+ _filteredProps$effect = filteredProps.effect,
30917
+ effect = _filteredProps$effect === undefined ? true : _filteredProps$effect,
30918
+ onClick = filteredProps.onClick,
30919
+ _filteredProps$auto = filteredProps.auto,
30920
+ auto = _filteredProps$auto === undefined ? false : _filteredProps$auto,
30921
+ icon = filteredProps.icon,
30922
+ _filteredProps$htmlTy = filteredProps.htmlType,
30923
+ htmlType = _filteredProps$htmlTy === undefined ? 'button' : _filteredProps$htmlTy,
30924
+ iconRight = filteredProps.iconRight,
30925
+ _filteredProps$classN = filteredProps.className,
30926
+ className = _filteredProps$classN === undefined ? '' : _filteredProps$classN;
30927
+ filteredProps.crossOrigin;
30928
+ var props = _objectWithoutProperties(filteredProps, _excluded$8);
30929
+ /* eslint-enable @typescript-eslint/no-unused-vars */
31137
30930
 
31138
- // Function to calculate start and end index for a given page
31139
- var getDataRange = function getDataRange(pageNumber, itemsPerPage, dataLength) {
31140
- var startIndex = (pageNumber - 1) * itemsPerPage;
31141
- var endIndex = Math.min(startIndex + itemsPerPage - 1, dataLength - 1);
31142
- return {
31143
- startIndex: startIndex,
31144
- endIndex: endIndex
31145
- };
31146
- };
31147
- return /*#__PURE__*/React.createElement(TableContext.Provider, {
31148
- value: contextValue
31149
- }, /*#__PURE__*/React.createElement("table", _extends({
31150
- ref: ref
31151
- }, props, {
31152
- className: _JSXStyle.dynamic([["2132340556", [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 || "")
31153
- }), /*#__PURE__*/React.createElement(TableHead, {
31154
- stickyHeader: stickyHeader,
31155
- columns: columns,
31156
- onFilters: onFilters,
31157
- showFilters: showFilters,
31158
- width: width
31159
- }), /*#__PURE__*/React.createElement(TableBody, {
31160
- data: data,
31161
- hover: hover,
31162
- emptyText: emptyText,
31163
- onRow: onRow,
31164
- onCell: onCell,
31165
- rowClassName: rowClassName,
31166
- rowDraggable: rowDraggable,
31167
- readOnly: readOnly,
31168
- onSelected: onSelected
31169
- }), children, /*#__PURE__*/React.createElement(_JSXStyle, {
31170
- id: "2132340556",
31171
- 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)]
31172
- }, "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), ";}")), dataLength && viewLength && onPageChange ? /*#__PURE__*/React.createElement("tfoot", {
31173
- className: _JSXStyle.dynamic([["2132340556", [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)]]])
31174
- }, /*#__PURE__*/React.createElement(Pagination, {
31175
- onChange: function onChange(pageNumber) {
31176
- // Get the range for the current page
31177
- var _getDataRange = getDataRange(pageNumber, viewLength, dataLength),
31178
- startIndex = _getDataRange.startIndex,
31179
- endIndex = _getDataRange.endIndex;
31180
- onPageChange(pageNumber, startIndex, endIndex);
31181
- },
31182
- limit: 5,
31183
- count: Number(dataLength / viewLength)
31184
- }, /*#__PURE__*/React.createElement(Pagination.Next, null, /*#__PURE__*/React.createElement(ChevronRight$1, null)), /*#__PURE__*/React.createElement(Pagination.Previous, null, /*#__PURE__*/React.createElement(ChevronLeft$1, null)))) : null));
31185
- }
31186
- TableComponent.displayName = 'Table';
31187
- TableComponent.Column = TableColumn;
31188
- var Table = withScale(TableComponent);
31189
- Table.Column = TableColumn;
30931
+ var _useMemo = React.useMemo(function () {
30932
+ return getButtonColors(theme.palette, filteredProps);
30933
+ }, [theme.palette, filteredProps]),
30934
+ bg = _useMemo.bg,
30935
+ border = _useMemo.border,
30936
+ color = _useMemo.color;
30937
+ var hover = React.useMemo(function () {
30938
+ return getButtonHoverColors(theme.palette, filteredProps);
30939
+ }, [theme.palette, filteredProps]);
30940
+ var _useMemo2 = React.useMemo(function () {
30941
+ return getButtonCursor(disabled, loading);
30942
+ }, [disabled, loading]),
30943
+ cursor = _useMemo2.cursor,
30944
+ events = _useMemo2.events;
30945
+ var dripColor = React.useMemo(function () {
30946
+ return getButtonDripColor(theme.palette, filteredProps);
30947
+ }, [theme.palette, filteredProps]);
31190
30948
 
31191
- var ButtonDrip = function ButtonDrip(_ref) {
31192
- var _ref$x = _ref.x,
31193
- x = _ref$x === undefined ? 0 : _ref$x,
31194
- _ref$y = _ref.y,
31195
- y = _ref$y === undefined ? 0 : _ref$y,
31196
- color = _ref.color,
31197
- onCompleted = _ref.onCompleted;
31198
- var dripRef = React.useRef(null);
31199
- /* istanbul ignore next */
31200
- var top = Number.isNaN(+y) ? 0 : y - 10;
31201
30949
  /* istanbul ignore next */
31202
- var left = Number.isNaN(+x) ? 0 : x - 10;
31203
- React.useEffect(function () {
30950
+ var dripCompletedHandle = function dripCompletedHandle() {
30951
+ setDripShow(false);
30952
+ setDripX(0);
30953
+ setDripY(0);
30954
+ };
30955
+ var clickHandler = function clickHandler(event) {
30956
+ if (disabled || loading) return;
30957
+ var showDrip = !shadow && !ghost && effect;
31204
30958
  /* istanbul ignore next */
31205
- if (!dripRef.current) return;
31206
- dripRef.current.addEventListener('animationend', onCompleted);
31207
- return function () {
31208
- /* istanbul ignore next */
31209
- if (!dripRef.current) return;
31210
- dripRef.current.removeEventListener('animationend', onCompleted);
31211
- };
31212
- });
31213
- return /*#__PURE__*/React.createElement("div", {
31214
- ref: dripRef,
31215
- className: "jsx-3424889537" + " " + "drip"
31216
- }, /*#__PURE__*/React.createElement("svg", {
31217
- width: "20",
31218
- height: "20",
31219
- viewBox: "0 0 20 20",
31220
- style: {
31221
- top: top,
31222
- left: left
31223
- },
31224
- className: "jsx-3424889537"
31225
- }, /*#__PURE__*/React.createElement("g", {
31226
- stroke: "none",
31227
- strokeWidth: "1",
31228
- fill: "none",
31229
- fillRule: "evenodd",
31230
- className: "jsx-3424889537"
31231
- }, /*#__PURE__*/React.createElement("g", {
31232
- fill: color,
31233
- className: "jsx-3424889537"
31234
- }, /*#__PURE__*/React.createElement("rect", {
31235
- width: "100%",
31236
- height: "100%",
31237
- rx: "10",
31238
- className: "jsx-3424889537"
31239
- })))), /*#__PURE__*/React.createElement(_JSXStyle, {
31240
- id: "3424889537"
31241
- }, ".drip.jsx-3424889537{position:absolute;left:0;right:0;top:0;bottom:0;}svg.jsx-3424889537{position:absolute;-webkit-animation:350ms ease-in expand-jsx-3424889537;animation:350ms ease-in expand-jsx-3424889537;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;width:1rem;height:1rem;}@-webkit-keyframes expand-jsx-3424889537{0%{opacity:0;-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1);}30%{opacity:1;}80%{opacity:0.5;}100%{-webkit-transform:scale(28);-ms-transform:scale(28);transform:scale(28);opacity:0;}}@keyframes expand-jsx-3424889537{0%{opacity:0;-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1);}30%{opacity:1;}80%{opacity:0.5;}100%{-webkit-transform:scale(28);-ms-transform:scale(28);transform:scale(28);opacity:0;}}"));
31242
- };
31243
- ButtonDrip.displayName = 'ButtonDrip';
30959
+ if (showDrip && buttonRef.current) {
30960
+ var rect = buttonRef.current.getBoundingClientRect();
30961
+ setDripShow(true);
30962
+ setDripX(event.clientX - rect.left);
30963
+ setDripY(event.clientY - rect.top);
30964
+ }
30965
+ onClick && onClick(event);
30966
+ };
30967
+ var childrenWithIcon = React.useMemo(function () {
30968
+ return getButtonChildrenWithIcon(auto, children, {
30969
+ icon: icon,
30970
+ iconRight: iconRight
30971
+ });
30972
+ }, [auto, children, icon, iconRight]);
30973
+ var paddingLeft = auto ? SCALES.pl(1.15) : SCALES.pl(1.375),
30974
+ paddingRight = auto ? SCALES.pr(1.15) : SCALES.pr(1.375);
30975
+ return /*#__PURE__*/React.createElement("button", _extends({
30976
+ ref: buttonRef,
30977
+ type: htmlType,
30978
+ disabled: disabled,
30979
+ onClick: clickHandler
30980
+ }, props, {
30981
+ className: _JSXStyle.dynamic([["22324076", [SCALES.height(2.5), theme.layout.radius, SCALES.font(0.875), color, bg, border, cursor, events, shadow ? theme.expressiveness.shadowSmall : 'none', SCALES.pl(0.727), SCALES.height(2.5), color, bg, auto ? 'min-content' : SCALES.width(10.5), auto ? 'auto' : 'initial', SCALES.height(2.5), SCALES.pt(0), paddingRight, SCALES.pb(0), paddingLeft, SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), hover.color, hover.color, hover.bg, hover.border, cursor, events, shadow ? theme.expressiveness.shadowMedium : 'none', shadow ? '-1px' : '0px']]]) + " " + (props && props.className != null && props.className || useClasses('btn', className) || "")
30982
+ }), loading && /*#__PURE__*/React.createElement(ButtonLoading, {
30983
+ color: color
30984
+ }), childrenWithIcon, dripShow && /*#__PURE__*/React.createElement(ButtonDrip, {
30985
+ x: dripX,
30986
+ y: dripY,
30987
+ color: dripColor,
30988
+ onCompleted: dripCompletedHandle
30989
+ }), /*#__PURE__*/React.createElement(_JSXStyle, {
30990
+ id: "22324076",
30991
+ dynamic: [SCALES.height(2.5), theme.layout.radius, SCALES.font(0.875), color, bg, border, cursor, events, shadow ? theme.expressiveness.shadowSmall : 'none', SCALES.pl(0.727), SCALES.height(2.5), color, bg, auto ? 'min-content' : SCALES.width(10.5), auto ? 'auto' : 'initial', SCALES.height(2.5), SCALES.pt(0), paddingRight, SCALES.pb(0), paddingLeft, SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), hover.color, hover.color, hover.bg, hover.border, cursor, events, shadow ? theme.expressiveness.shadowMedium : 'none', shadow ? '-1px' : '0px']
30992
+ }, ".btn.__jsx-style-dynamic-selector{box-sizing:border-box;display:inline-block;line-height:".concat(SCALES.height(2.5), ";border-radius:").concat(theme.layout.radius, ";font-weight:400;font-size:").concat(SCALES.font(0.875), ";-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;outline:none;text-transform:capitalize;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;text-align:center;white-space:nowrap;-webkit-transition:background-color 200ms ease 0ms,box-shadow 200ms ease 0ms, border 200ms ease 0ms,color 200ms ease 0ms;transition:background-color 200ms ease 0ms,box-shadow 200ms ease 0ms, border 200ms ease 0ms,color 200ms ease 0ms;position:relative;overflow:hidden;color:").concat(color, ";background-color:").concat(bg, ";border:1px solid ").concat(border, ";cursor:").concat(cursor, ";pointer-events:").concat(events, ";box-shadow:").concat(shadow ? theme.expressiveness.shadowSmall : 'none', ";--helpdice-ui-button-icon-padding:").concat(SCALES.pl(0.727), ";--helpdice-ui-button-height:").concat(SCALES.height(2.5), ";--helpdice-ui-button-color:").concat(color, ";--helpdice-ui-button-bg:").concat(bg, ";min-width:").concat(auto ? 'min-content' : SCALES.width(10.5), ";width:").concat(auto ? 'auto' : 'initial', ";height:").concat(SCALES.height(2.5), ";padding:").concat(SCALES.pt(0), " ").concat(paddingRight, " ").concat(SCALES.pb(0), " ").concat(paddingLeft, ";margin:").concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";}.btn.__jsx-style-dynamic-selector:hover,.btn.__jsx-style-dynamic-selector:focus{color:").concat(hover.color, ";--helpdice-ui-button-color:").concat(hover.color, ";background-color:").concat(hover.bg, ";border-color:").concat(hover.border, ";cursor:").concat(cursor, ";pointer-events:").concat(events, ";box-shadow:").concat(shadow ? theme.expressiveness.shadowMedium : 'none', ";-webkit-transform:translate3d(0px,").concat(shadow ? '-1px' : '0px', ",0px);-ms-transform:translate3d(0px,").concat(shadow ? '-1px' : '0px', ",0px);transform:translate3d(0px,").concat(shadow ? '-1px' : '0px', ",0px);}.btn.__jsx-style-dynamic-selector .text{position:relative;z-index:1;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;text-align:center;line-height:inherit;top:-1px;}.btn.__jsx-style-dynamic-selector .text p,.btn.__jsx-style-dynamic-selector .text pre,.btn.__jsx-style-dynamic-selector .text div{margin:0;}")));
30993
+ });
30994
+ ButtonComponent.displayName = 'Button';
30995
+ var Button = withScale(ButtonComponent);
31244
30996
 
31245
- var _excluded$5 = ["children", "type", "color", "className", "spaceRatio"];
31246
- var getIconBgColor = function getIconBgColor(type, palette, color) {
30997
+ var getColors = function getColors(type, palette) {
31247
30998
  var colors = {
31248
- "default": palette.accents_6,
31249
- secondary: palette.secondary,
30999
+ "default": palette.background,
31250
31000
  success: palette.success,
31251
31001
  warning: palette.warning,
31252
- error: palette.error
31002
+ error: palette.error,
31003
+ secondary: palette.secondary,
31004
+ dark: palette.foreground,
31005
+ lite: palette.background
31006
+ };
31007
+ var color = type === 'lite' || type === 'default' ? palette.foreground : palette.background;
31008
+ return {
31009
+ color: color,
31010
+ bgColor: colors[type]
31253
31011
  };
31254
- return color ? color : colors[type];
31255
- };
31256
- var LoadingComponent = function LoadingComponent(_ref) {
31257
- var children = _ref.children,
31258
- _ref$type = _ref.type,
31259
- type = _ref$type === undefined ? 'default' : _ref$type,
31260
- color = _ref.color,
31261
- _ref$className = _ref.className,
31262
- className = _ref$className === undefined ? '' : _ref$className,
31263
- _ref$spaceRatio = _ref.spaceRatio,
31264
- spaceRatio = _ref$spaceRatio === undefined ? 1 : _ref$spaceRatio,
31265
- props = _objectWithoutProperties(_ref, _excluded$5);
31266
- var theme = useTheme();
31267
- var _useScale = useScale(),
31268
- SCALES = _useScale.SCALES;
31269
- var classes = useClasses('loading-container', className);
31270
- var bgColor = React.useMemo(function () {
31271
- return getIconBgColor(type, theme.palette, color);
31272
- }, [type, theme.palette, color]);
31273
- return /*#__PURE__*/React.createElement("div", _extends({}, props, {
31274
- className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.accents_5, bgColor, spaceRatio]]]) + " " + (props && props.className != null && props.className || classes || "")
31275
- }), /*#__PURE__*/React.createElement("span", {
31276
- className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.accents_5, bgColor, spaceRatio]]]) + " " + "loading"
31277
- }, children && /*#__PURE__*/React.createElement("label", {
31278
- className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.accents_5, bgColor, spaceRatio]]])
31279
- }, children), /*#__PURE__*/React.createElement("i", {
31280
- className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.accents_5, bgColor, spaceRatio]]])
31281
- }), /*#__PURE__*/React.createElement("i", {
31282
- className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.accents_5, bgColor, spaceRatio]]])
31283
- }), /*#__PURE__*/React.createElement("i", {
31284
- className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.accents_5, bgColor, spaceRatio]]])
31285
- })), /*#__PURE__*/React.createElement(_JSXStyle, {
31286
- id: "2201634259",
31287
- dynamic: [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme.palette.accents_5, bgColor, spaceRatio]
31288
- }, ".loading-container.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;position:relative;font-size:".concat(SCALES.font(1), ";width:").concat(SCALES.width(1, '100%'), ";height:").concat(SCALES.height(1, '100%'), ";min-height:1em;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), ";}label.__jsx-style-dynamic-selector{margin-right:0.5em;color:").concat(theme.palette.accents_5, ";line-height:1;}label.__jsx-style-dynamic-selector *{margin:0;}.loading.__jsx-style-dynamic-selector{position:absolute;top:50%;left:50%;width:100%;height:100%;-webkit-transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);transform:translate(-50%,-50%);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;background-color:transparent;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}i.__jsx-style-dynamic-selector{width:0.25em;height:0.25em;border-radius:50%;background-color:").concat(bgColor, ";margin:0 calc(0.25em / 2 * ").concat(spaceRatio, ");display:inline-block;-webkit-animation:loading-blink-__jsx-style-dynamic-selector 1.4s infinite both;animation:loading-blink-__jsx-style-dynamic-selector 1.4s infinite both;}i.__jsx-style-dynamic-selector:nth-child(2){-webkit-animation-delay:0.2s;animation-delay:0.2s;}i.__jsx-style-dynamic-selector:nth-child(3){-webkit-animation-delay:0.4s;animation-delay:0.4s;}@-webkit-keyframes loading-blink-__jsx-style-dynamic-selector{0%{opacity:0.2;}20%{opacity:1;}100%{opacity:0.2;}}@keyframes loading-blink-__jsx-style-dynamic-selector{0%{opacity:0.2;}20%{opacity:1;}100%{opacity:0.2;}}")));
31289
- };
31290
- LoadingComponent.displayName = 'Loading';
31291
- var Loading = withScale(LoadingComponent);
31292
-
31293
- var ButtonLoading = function ButtonLoading(_ref) {
31294
- var color = _ref.color;
31295
- return /*#__PURE__*/React.createElement("div", {
31296
- className: "jsx-212623367" + " " + "btn-loading"
31297
- }, /*#__PURE__*/React.createElement(Loading, {
31298
- color: color
31299
- }), /*#__PURE__*/React.createElement(_JSXStyle, {
31300
- id: "212623367"
31301
- }, ".btn-loading.jsx-212623367{position:absolute;top:0;left:0;right:0;bottom:0;z-index:2;background-color:var(--helpdice-ui-button-bg);}"));
31302
31012
  };
31303
- ButtonLoading.displayName = 'GeistButtonLoading';
31304
31013
 
31305
- var _excluded$4 = ["isRight", "isSingle", "children", "className"];
31306
- var ButtonIcon = function ButtonIcon(_ref) {
31307
- var _ref$isRight = _ref.isRight,
31308
- isRight = _ref$isRight === undefined ? false : _ref$isRight,
31309
- isSingle = _ref.isSingle,
31310
- children = _ref.children,
31311
- _ref$className = _ref.className,
31312
- className = _ref$className === undefined ? '' : _ref$className,
31313
- props = _objectWithoutProperties(_ref, _excluded$4);
31314
- var classes = useClasses('icon', {
31315
- right: isRight,
31316
- single: isSingle
31317
- }, className);
31318
- return /*#__PURE__*/React.createElement("span", _extends({}, props, {
31319
- className: "jsx-2467502931" + " " + (props && props.className != null && props.className || classes || "")
31320
- }), children, /*#__PURE__*/React.createElement(_JSXStyle, {
31321
- id: "2467502931"
31322
- }, ".icon.jsx-2467502931{position:absolute;left:var(--helpdice-ui-button-icon-padding);right:auto;top:50%;-webkit-transform:translateY(-50%);-ms-transform:translateY(-50%);transform:translateY(-50%);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:var(--helpdice-ui-button-color);z-index:1;}.right.jsx-2467502931{right:var(--helpdice-ui-button-icon-padding);left:auto;}.icon.jsx-2467502931 svg{background:transparent;height:calc(var(--helpdice-ui-button-height) / 2.35);width:calc(var(--helpdice-ui-button-height) / 2.35);}.single.jsx-2467502931{position:static;-webkit-transform:none;-ms-transform:none;transform:none;}"));
31014
+ var defaultTooltipPosition = {
31015
+ top: '-1000px',
31016
+ left: '-1000px',
31017
+ transform: 'none'
31323
31018
  };
31324
- ButtonIcon.displayName = 'ButtonIcon';
31325
-
31326
- var getButtonChildrenWithIcon = function getButtonChildrenWithIcon(auto, children, icons) {
31327
- var icon = icons.icon,
31328
- iconRight = icons.iconRight;
31329
- var hasIcon = icon || iconRight;
31330
- var isRight = Boolean(iconRight);
31331
- var paddingForAutoMode = auto ? "calc(var(--helpdice-ui-button-height) / 2 + var(--helpdice-ui-button-icon-padding) * .5)" : 0;
31332
- var classes = useClasses('text', isRight ? 'right' : 'left');
31333
- if (!hasIcon) return /*#__PURE__*/React.createElement("div", {
31334
- className: "text"
31335
- }, children);
31336
- if (React.Children.count(children) === 0) {
31337
- return /*#__PURE__*/React.createElement(ButtonIcon, {
31338
- isRight: isRight,
31339
- isSingle: true
31340
- }, hasIcon);
31341
- }
31342
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ButtonIcon, {
31343
- isRight: isRight
31344
- }, hasIcon), /*#__PURE__*/React.createElement("div", {
31345
- className: _JSXStyle.dynamic([["3568181479", [paddingForAutoMode, paddingForAutoMode]]]) + " " + (classes || "")
31346
- }, children, /*#__PURE__*/React.createElement(_JSXStyle, {
31347
- id: "3568181479",
31348
- dynamic: [paddingForAutoMode, paddingForAutoMode]
31349
- }, ".left.__jsx-style-dynamic-selector{padding-left:".concat(paddingForAutoMode, ";}.right.__jsx-style-dynamic-selector{padding-right:").concat(paddingForAutoMode, ";}"))));
31350
- };
31351
- var filterPropsWithGroup = function filterPropsWithGroup(props, config) {
31352
- if (!config.isButtonGroup) return props;
31353
- return _objectSpread2(_objectSpread2({}, props), {}, {
31354
- auto: true,
31355
- shadow: false,
31356
- ghost: config.ghost || props.ghost,
31357
- type: config.type || props.type,
31358
- disabled: config.disabled || props.disabled
31359
- });
31360
- };
31361
-
31362
- /* "use client" */
31363
-
31364
- var defaultContext$1 = {
31365
- isButtonGroup: false,
31366
- disabled: false
31367
- };
31368
- var ButtonGroupContext = /*#__PURE__*/React.createContext(defaultContext$1);
31369
- var useButtonGroupContext = function useButtonGroupContext() {
31370
- return React.useContext(ButtonGroupContext);
31371
- };
31372
-
31373
- var getButtonGhostColors = function getButtonGhostColors(palette, type) {
31374
- var colors = {
31375
- secondary: {
31376
- bg: palette.background,
31377
- border: palette.foreground,
31378
- color: palette.foreground
31019
+ var getPosition = function getPosition(placement, rect, offset) {
31020
+ var positions = {
31021
+ top: {
31022
+ top: "".concat(rect.top - offset, "px"),
31023
+ left: "".concat(rect.left + rect.width / 2, "px"),
31024
+ transform: 'translate(-50%, -100%)'
31379
31025
  },
31380
- success: {
31381
- bg: palette.background,
31382
- border: palette.success,
31383
- color: palette.success
31026
+ topStart: {
31027
+ top: "".concat(rect.top - offset, "px"),
31028
+ left: "".concat(rect.left, "px"),
31029
+ transform: 'translate(0, -100%)'
31384
31030
  },
31385
- warning: {
31386
- bg: palette.background,
31387
- border: palette.warning,
31388
- color: palette.warning
31031
+ topEnd: {
31032
+ top: "".concat(rect.top - offset, "px"),
31033
+ left: "".concat(rect.left + rect.width, "px"),
31034
+ transform: 'translate(-100%, -100%)'
31389
31035
  },
31390
- error: {
31391
- bg: palette.background,
31392
- border: palette.error,
31393
- color: palette.error
31394
- }
31395
- };
31396
- return colors[type] || null;
31397
- };
31398
- var getButtonColors = function getButtonColors(palette, props) {
31399
- var type = props.type,
31400
- disabled = props.disabled,
31401
- ghost = props.ghost;
31402
- var colors = {
31403
- "default": {
31404
- bg: palette.background,
31405
- border: palette.border,
31406
- color: palette.accents_5
31036
+ bottom: {
31037
+ top: "".concat(rect.bottom + offset, "px"),
31038
+ left: "".concat(rect.left + rect.width / 2, "px"),
31039
+ transform: 'translate(-50%, 0)'
31407
31040
  },
31408
- secondary: {
31409
- bg: palette.foreground,
31410
- border: palette.foreground,
31411
- color: palette.background
31041
+ bottomStart: {
31042
+ top: "".concat(rect.bottom + offset, "px"),
31043
+ left: "".concat(rect.left, "px"),
31044
+ transform: 'translate(0, 0)'
31412
31045
  },
31413
- success: {
31414
- bg: palette.success,
31415
- border: palette.success,
31416
- color: '#fff'
31046
+ bottomEnd: {
31047
+ top: "".concat(rect.bottom + offset, "px"),
31048
+ left: "".concat(rect.left + rect.width, "px"),
31049
+ transform: 'translate(-100%, 0)'
31417
31050
  },
31418
- warning: {
31419
- bg: palette.warning,
31420
- border: palette.warning,
31421
- color: '#fff'
31051
+ left: {
31052
+ top: "".concat(rect.top + rect.height / 2, "px"),
31053
+ left: "".concat(rect.left - offset, "px"),
31054
+ transform: 'translate(-100%, -50%)'
31422
31055
  },
31423
- error: {
31424
- bg: palette.error,
31425
- border: palette.error,
31426
- color: '#fff'
31056
+ leftStart: {
31057
+ top: "".concat(rect.top, "px"),
31058
+ left: "".concat(rect.left - offset, "px"),
31059
+ transform: 'translate(-100%, 0)'
31427
31060
  },
31428
- abort: {
31429
- bg: 'transparent',
31430
- border: 'transparent',
31431
- color: palette.accents_5
31432
- }
31433
- };
31434
- if (disabled) return {
31435
- bg: palette.accents_1,
31436
- border: palette.accents_2,
31437
- color: '#ccc'
31438
- };
31439
-
31440
- /**
31441
- * The '-light' type is the same color as the common type,
31442
- * only hover's color is different.
31443
- * e.g.
31444
- * Color['success'] === Color['success-light']
31445
- * Color['warning'] === Color['warning-light']
31446
- */
31447
- var withoutLightType = type === null || type === undefined ? undefined : type.replace('-light', '');
31448
- var defaultColor = colors["default"];
31449
- if (ghost) return getButtonGhostColors(palette, withoutLightType) || defaultColor;
31450
- return colors[withoutLightType] || defaultColor;
31451
- };
31452
- var getButtonGhostHoverColors = function getButtonGhostHoverColors(palette, type) {
31453
- var colors = {
31454
- secondary: {
31455
- bg: palette.foreground,
31456
- border: palette.background,
31457
- color: palette.background
31061
+ leftEnd: {
31062
+ top: "".concat(rect.top + rect.height, "px"),
31063
+ left: "".concat(rect.left - offset, "px"),
31064
+ transform: 'translate(-100%, -100%)'
31458
31065
  },
31459
- success: {
31460
- bg: palette.success,
31461
- border: palette.background,
31462
- color: 'white'
31066
+ right: {
31067
+ top: "".concat(rect.top + rect.height / 2, "px"),
31068
+ left: "".concat(rect.right + offset, "px"),
31069
+ transform: 'translate(0, -50%)'
31463
31070
  },
31464
- warning: {
31465
- bg: palette.warning,
31466
- border: palette.background,
31467
- color: 'white'
31071
+ rightStart: {
31072
+ top: "".concat(rect.top, "px"),
31073
+ left: "".concat(rect.right + offset, "px"),
31074
+ transform: 'translate(0, 0)'
31468
31075
  },
31469
- error: {
31470
- bg: palette.error,
31471
- border: palette.background,
31472
- color: 'white'
31076
+ rightEnd: {
31077
+ top: "".concat(rect.top + rect.height, "px"),
31078
+ left: "".concat(rect.right + offset, "px"),
31079
+ transform: 'translate(0, -100%)'
31473
31080
  }
31474
31081
  };
31475
- var withoutLightType = type.replace('-light', '');
31476
- return colors[withoutLightType] || null;
31082
+ return positions[placement] || positions.top;
31477
31083
  };
31478
- var getButtonHoverColors = function getButtonHoverColors(palette, props) {
31479
- var type = props.type,
31480
- disabled = props.disabled,
31481
- loading = props.loading,
31482
- shadow = props.shadow,
31483
- ghost = props.ghost;
31484
- var defaultColor = getButtonColors(palette, props);
31485
- var alphaBackground = addColorAlpha(defaultColor.bg, 0.85);
31486
- var colors = {
31487
- "default": {
31488
- bg: palette.background,
31489
- border: palette.foreground
31084
+ var getIconPosition = function getIconPosition(placement, offsetX, offsetY) {
31085
+ var offsetAbsolute = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '3px';
31086
+ var positions = {
31087
+ top: {
31088
+ top: 'auto',
31089
+ right: 'auto',
31090
+ left: '50%',
31091
+ bottom: "".concat(offsetAbsolute),
31092
+ transform: 'translate(-50%, 100%) rotate(-90deg)'
31490
31093
  },
31491
- secondary: {
31492
- bg: palette.background,
31493
- border: palette.foreground
31094
+ topStart: {
31095
+ top: 'auto',
31096
+ right: 'auto',
31097
+ left: "".concat(offsetX),
31098
+ bottom: "".concat(offsetAbsolute),
31099
+ transform: 'translate(0, 100%) rotate(-90deg)'
31494
31100
  },
31495
- success: {
31496
- bg: palette.background,
31497
- border: palette.success
31101
+ topEnd: {
31102
+ top: 'auto',
31103
+ right: "".concat(offsetX),
31104
+ left: 'auto',
31105
+ bottom: "".concat(offsetAbsolute),
31106
+ transform: 'translate(0, 100%) rotate(-90deg)'
31498
31107
  },
31499
- warning: {
31500
- bg: palette.background,
31501
- border: palette.warning
31108
+ bottom: {
31109
+ top: "".concat(offsetAbsolute),
31110
+ right: 'auto',
31111
+ left: '50%',
31112
+ bottom: 'auto',
31113
+ transform: 'translate(-50%, -100%) rotate(90deg)'
31502
31114
  },
31503
- error: {
31504
- bg: palette.background,
31505
- border: palette.error
31115
+ bottomStart: {
31116
+ top: "".concat(offsetAbsolute),
31117
+ right: 'auto',
31118
+ left: "".concat(offsetX),
31119
+ bottom: 'auto',
31120
+ transform: 'translate(0, -100%) rotate(90deg)'
31506
31121
  },
31507
- abort: {
31508
- bg: 'transparent',
31509
- border: 'transparent',
31510
- color: palette.accents_5
31511
- },
31512
- 'secondary-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
31513
- bg: alphaBackground
31514
- }),
31515
- 'success-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
31516
- bg: alphaBackground
31517
- }),
31518
- 'warning-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
31519
- bg: alphaBackground
31520
- }),
31521
- 'error-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
31522
- bg: alphaBackground
31523
- })
31524
- };
31525
- if (disabled) return {
31526
- bg: palette.accents_1,
31527
- border: palette.accents_2,
31528
- color: '#ccc'
31529
- };
31530
- if (loading) return _objectSpread2(_objectSpread2({}, defaultColor), {}, {
31531
- color: 'transparent'
31532
- });
31533
- if (shadow) return defaultColor;
31534
- var hoverColor = (ghost ? getButtonGhostHoverColors(palette, type) : colors[type]) || colors["default"];
31535
- return _objectSpread2(_objectSpread2({}, hoverColor), {}, {
31536
- color: hoverColor.color || hoverColor.border
31537
- });
31538
- };
31539
- var getButtonCursor = function getButtonCursor(disabled, loading) {
31540
- if (disabled) return {
31541
- cursor: 'not-allowed',
31542
- events: 'auto'
31543
- };
31544
- if (loading) return {
31545
- cursor: 'default',
31546
- events: 'none'
31547
- };
31548
- return {
31549
- cursor: 'pointer',
31550
- events: 'auto'
31551
- };
31552
- };
31553
- var getButtonDripColor = function getButtonDripColor(palette, props) {
31554
- var type = props.type;
31555
- var isLightHover = type ? type.endsWith('light') : false;
31556
- var hoverColors = getButtonHoverColors(palette, props);
31557
- return isLightHover ? addColorAlpha(hoverColors.bg, 0.65) : addColorAlpha(palette.accents_2, 0.65);
31558
- };
31559
-
31560
- var _excluded$3 = ["children", "disabled", "type", "loading", "shadow", "ghost", "effect", "onClick", "auto", "icon", "htmlType", "iconRight", "className", "crossOrigin"];
31561
- var ButtonComponent = /*#__PURE__*/React.forwardRef(function (btnProps, ref) {
31562
- var theme = useTheme();
31563
- var _useScale = useScale(),
31564
- SCALES = _useScale.SCALES;
31565
- var buttonRef = React.useRef(null);
31566
- React.useImperativeHandle(ref, function () {
31567
- return buttonRef.current;
31568
- });
31569
- var _useState = React.useState(false),
31570
- _useState2 = _slicedToArray(_useState, 2),
31571
- dripShow = _useState2[0],
31572
- setDripShow = _useState2[1];
31573
- var _useState3 = React.useState(0),
31574
- _useState4 = _slicedToArray(_useState3, 2),
31575
- dripX = _useState4[0],
31576
- setDripX = _useState4[1];
31577
- var _useState5 = React.useState(0),
31578
- _useState6 = _slicedToArray(_useState5, 2),
31579
- dripY = _useState6[0],
31580
- setDripY = _useState6[1];
31581
- var groupConfig = useButtonGroupContext();
31582
- var filteredProps = filterPropsWithGroup(btnProps, groupConfig);
31583
- /* eslint-disable @typescript-eslint/no-unused-vars */
31584
- var children = filteredProps.children,
31585
- _filteredProps$disabl = filteredProps.disabled,
31586
- disabled = _filteredProps$disabl === undefined ? false : _filteredProps$disabl;
31587
- filteredProps.type;
31588
- var _filteredProps$loadin = filteredProps.loading,
31589
- loading = _filteredProps$loadin === undefined ? false : _filteredProps$loadin,
31590
- _filteredProps$shadow = filteredProps.shadow,
31591
- shadow = _filteredProps$shadow === undefined ? false : _filteredProps$shadow,
31592
- _filteredProps$ghost = filteredProps.ghost,
31593
- ghost = _filteredProps$ghost === undefined ? false : _filteredProps$ghost,
31594
- _filteredProps$effect = filteredProps.effect,
31595
- effect = _filteredProps$effect === undefined ? true : _filteredProps$effect,
31596
- onClick = filteredProps.onClick,
31597
- _filteredProps$auto = filteredProps.auto,
31598
- auto = _filteredProps$auto === undefined ? false : _filteredProps$auto,
31599
- icon = filteredProps.icon,
31600
- _filteredProps$htmlTy = filteredProps.htmlType,
31601
- htmlType = _filteredProps$htmlTy === undefined ? 'button' : _filteredProps$htmlTy,
31602
- iconRight = filteredProps.iconRight,
31603
- _filteredProps$classN = filteredProps.className,
31604
- className = _filteredProps$classN === undefined ? '' : _filteredProps$classN;
31605
- filteredProps.crossOrigin;
31606
- var props = _objectWithoutProperties(filteredProps, _excluded$3);
31607
- /* eslint-enable @typescript-eslint/no-unused-vars */
31608
-
31609
- var _useMemo = React.useMemo(function () {
31610
- return getButtonColors(theme.palette, filteredProps);
31611
- }, [theme.palette, filteredProps]),
31612
- bg = _useMemo.bg,
31613
- border = _useMemo.border,
31614
- color = _useMemo.color;
31615
- var hover = React.useMemo(function () {
31616
- return getButtonHoverColors(theme.palette, filteredProps);
31617
- }, [theme.palette, filteredProps]);
31618
- var _useMemo2 = React.useMemo(function () {
31619
- return getButtonCursor(disabled, loading);
31620
- }, [disabled, loading]),
31621
- cursor = _useMemo2.cursor,
31622
- events = _useMemo2.events;
31623
- var dripColor = React.useMemo(function () {
31624
- return getButtonDripColor(theme.palette, filteredProps);
31625
- }, [theme.palette, filteredProps]);
31626
-
31627
- /* istanbul ignore next */
31628
- var dripCompletedHandle = function dripCompletedHandle() {
31629
- setDripShow(false);
31630
- setDripX(0);
31631
- setDripY(0);
31632
- };
31633
- var clickHandler = function clickHandler(event) {
31634
- if (disabled || loading) return;
31635
- var showDrip = !shadow && !ghost && effect;
31636
- /* istanbul ignore next */
31637
- if (showDrip && buttonRef.current) {
31638
- var rect = buttonRef.current.getBoundingClientRect();
31639
- setDripShow(true);
31640
- setDripX(event.clientX - rect.left);
31641
- setDripY(event.clientY - rect.top);
31642
- }
31643
- onClick && onClick(event);
31644
- };
31645
- var childrenWithIcon = React.useMemo(function () {
31646
- return getButtonChildrenWithIcon(auto, children, {
31647
- icon: icon,
31648
- iconRight: iconRight
31649
- });
31650
- }, [auto, children, icon, iconRight]);
31651
- var paddingLeft = auto ? SCALES.pl(1.15) : SCALES.pl(1.375),
31652
- paddingRight = auto ? SCALES.pr(1.15) : SCALES.pr(1.375);
31653
- return /*#__PURE__*/React.createElement("button", _extends({
31654
- ref: buttonRef,
31655
- type: htmlType,
31656
- disabled: disabled,
31657
- onClick: clickHandler
31658
- }, props, {
31659
- className: _JSXStyle.dynamic([["22324076", [SCALES.height(2.5), theme.layout.radius, SCALES.font(0.875), color, bg, border, cursor, events, shadow ? theme.expressiveness.shadowSmall : 'none', SCALES.pl(0.727), SCALES.height(2.5), color, bg, auto ? 'min-content' : SCALES.width(10.5), auto ? 'auto' : 'initial', SCALES.height(2.5), SCALES.pt(0), paddingRight, SCALES.pb(0), paddingLeft, SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), hover.color, hover.color, hover.bg, hover.border, cursor, events, shadow ? theme.expressiveness.shadowMedium : 'none', shadow ? '-1px' : '0px']]]) + " " + (props && props.className != null && props.className || useClasses('btn', className) || "")
31660
- }), loading && /*#__PURE__*/React.createElement(ButtonLoading, {
31661
- color: color
31662
- }), childrenWithIcon, dripShow && /*#__PURE__*/React.createElement(ButtonDrip, {
31663
- x: dripX,
31664
- y: dripY,
31665
- color: dripColor,
31666
- onCompleted: dripCompletedHandle
31667
- }), /*#__PURE__*/React.createElement(_JSXStyle, {
31668
- id: "22324076",
31669
- dynamic: [SCALES.height(2.5), theme.layout.radius, SCALES.font(0.875), color, bg, border, cursor, events, shadow ? theme.expressiveness.shadowSmall : 'none', SCALES.pl(0.727), SCALES.height(2.5), color, bg, auto ? 'min-content' : SCALES.width(10.5), auto ? 'auto' : 'initial', SCALES.height(2.5), SCALES.pt(0), paddingRight, SCALES.pb(0), paddingLeft, SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), hover.color, hover.color, hover.bg, hover.border, cursor, events, shadow ? theme.expressiveness.shadowMedium : 'none', shadow ? '-1px' : '0px']
31670
- }, ".btn.__jsx-style-dynamic-selector{box-sizing:border-box;display:inline-block;line-height:".concat(SCALES.height(2.5), ";border-radius:").concat(theme.layout.radius, ";font-weight:400;font-size:").concat(SCALES.font(0.875), ";-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;outline:none;text-transform:capitalize;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;text-align:center;white-space:nowrap;-webkit-transition:background-color 200ms ease 0ms,box-shadow 200ms ease 0ms, border 200ms ease 0ms,color 200ms ease 0ms;transition:background-color 200ms ease 0ms,box-shadow 200ms ease 0ms, border 200ms ease 0ms,color 200ms ease 0ms;position:relative;overflow:hidden;color:").concat(color, ";background-color:").concat(bg, ";border:1px solid ").concat(border, ";cursor:").concat(cursor, ";pointer-events:").concat(events, ";box-shadow:").concat(shadow ? theme.expressiveness.shadowSmall : 'none', ";--helpdice-ui-button-icon-padding:").concat(SCALES.pl(0.727), ";--helpdice-ui-button-height:").concat(SCALES.height(2.5), ";--helpdice-ui-button-color:").concat(color, ";--helpdice-ui-button-bg:").concat(bg, ";min-width:").concat(auto ? 'min-content' : SCALES.width(10.5), ";width:").concat(auto ? 'auto' : 'initial', ";height:").concat(SCALES.height(2.5), ";padding:").concat(SCALES.pt(0), " ").concat(paddingRight, " ").concat(SCALES.pb(0), " ").concat(paddingLeft, ";margin:").concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";}.btn.__jsx-style-dynamic-selector:hover,.btn.__jsx-style-dynamic-selector:focus{color:").concat(hover.color, ";--helpdice-ui-button-color:").concat(hover.color, ";background-color:").concat(hover.bg, ";border-color:").concat(hover.border, ";cursor:").concat(cursor, ";pointer-events:").concat(events, ";box-shadow:").concat(shadow ? theme.expressiveness.shadowMedium : 'none', ";-webkit-transform:translate3d(0px,").concat(shadow ? '-1px' : '0px', ",0px);-ms-transform:translate3d(0px,").concat(shadow ? '-1px' : '0px', ",0px);transform:translate3d(0px,").concat(shadow ? '-1px' : '0px', ",0px);}.btn.__jsx-style-dynamic-selector .text{position:relative;z-index:1;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;text-align:center;line-height:inherit;top:-1px;}.btn.__jsx-style-dynamic-selector .text p,.btn.__jsx-style-dynamic-selector .text pre,.btn.__jsx-style-dynamic-selector .text div{margin:0;}")));
31671
- });
31672
- ButtonComponent.displayName = 'Button';
31673
- var Button = withScale(ButtonComponent);
31674
-
31675
- var getColors = function getColors(type, palette) {
31676
- var colors = {
31677
- "default": palette.background,
31678
- success: palette.success,
31679
- warning: palette.warning,
31680
- error: palette.error,
31681
- secondary: palette.secondary,
31682
- dark: palette.foreground,
31683
- lite: palette.background
31684
- };
31685
- var color = type === 'lite' || type === 'default' ? palette.foreground : palette.background;
31686
- return {
31687
- color: color,
31688
- bgColor: colors[type]
31689
- };
31690
- };
31691
-
31692
- var defaultTooltipPosition = {
31693
- top: '-1000px',
31694
- left: '-1000px',
31695
- transform: 'none'
31696
- };
31697
- var getPosition = function getPosition(placement, rect, offset) {
31698
- var positions = {
31699
- top: {
31700
- top: "".concat(rect.top - offset, "px"),
31701
- left: "".concat(rect.left + rect.width / 2, "px"),
31702
- transform: 'translate(-50%, -100%)'
31703
- },
31704
- topStart: {
31705
- top: "".concat(rect.top - offset, "px"),
31706
- left: "".concat(rect.left, "px"),
31707
- transform: 'translate(0, -100%)'
31708
- },
31709
- topEnd: {
31710
- top: "".concat(rect.top - offset, "px"),
31711
- left: "".concat(rect.left + rect.width, "px"),
31712
- transform: 'translate(-100%, -100%)'
31713
- },
31714
- bottom: {
31715
- top: "".concat(rect.bottom + offset, "px"),
31716
- left: "".concat(rect.left + rect.width / 2, "px"),
31717
- transform: 'translate(-50%, 0)'
31718
- },
31719
- bottomStart: {
31720
- top: "".concat(rect.bottom + offset, "px"),
31721
- left: "".concat(rect.left, "px"),
31722
- transform: 'translate(0, 0)'
31723
- },
31724
- bottomEnd: {
31725
- top: "".concat(rect.bottom + offset, "px"),
31726
- left: "".concat(rect.left + rect.width, "px"),
31727
- transform: 'translate(-100%, 0)'
31122
+ bottomEnd: {
31123
+ top: "".concat(offsetAbsolute),
31124
+ right: "".concat(offsetX),
31125
+ left: 'auto',
31126
+ bottom: 'auto',
31127
+ transform: 'translate(0, -100%) rotate(90deg)'
31728
31128
  },
31729
31129
  left: {
31730
- top: "".concat(rect.top + rect.height / 2, "px"),
31731
- left: "".concat(rect.left - offset, "px"),
31732
- transform: 'translate(-100%, -50%)'
31130
+ top: '50%',
31131
+ right: '0',
31132
+ left: 'auto',
31133
+ bottom: 'auto',
31134
+ transform: 'translate(100%, -50%) rotate(180deg)'
31733
31135
  },
31734
31136
  leftStart: {
31735
- top: "".concat(rect.top, "px"),
31736
- left: "".concat(rect.left - offset, "px"),
31737
- transform: 'translate(-100%, 0)'
31137
+ top: "".concat(offsetY),
31138
+ right: '0',
31139
+ left: 'auto',
31140
+ bottom: 'auto',
31141
+ transform: 'translate(100%, -50%) rotate(180deg)'
31738
31142
  },
31739
31143
  leftEnd: {
31740
- top: "".concat(rect.top + rect.height, "px"),
31741
- left: "".concat(rect.left - offset, "px"),
31742
- transform: 'translate(-100%, -100%)'
31144
+ top: 'auto',
31145
+ right: '0',
31146
+ left: 'auto',
31147
+ bottom: "".concat(offsetY),
31148
+ transform: 'translate(100%, 50%) rotate(180deg)'
31743
31149
  },
31744
31150
  right: {
31745
- top: "".concat(rect.top + rect.height / 2, "px"),
31746
- left: "".concat(rect.right + offset, "px"),
31747
- transform: 'translate(0, -50%)'
31151
+ top: '50%',
31152
+ right: 'auto',
31153
+ left: '0',
31154
+ bottom: 'auto',
31155
+ transform: 'translate(-100%, -50%) rotate(0deg)'
31748
31156
  },
31749
31157
  rightStart: {
31750
- top: "".concat(rect.top, "px"),
31751
- left: "".concat(rect.right + offset, "px"),
31752
- transform: 'translate(0, 0)'
31753
- },
31754
- rightEnd: {
31755
- top: "".concat(rect.top + rect.height, "px"),
31756
- left: "".concat(rect.right + offset, "px"),
31757
- transform: 'translate(0, -100%)'
31758
- }
31759
- };
31760
- return positions[placement] || positions.top;
31761
- };
31762
- var getIconPosition = function getIconPosition(placement, offsetX, offsetY) {
31763
- var offsetAbsolute = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '3px';
31764
- var positions = {
31765
- top: {
31766
- top: 'auto',
31767
- right: 'auto',
31768
- left: '50%',
31769
- bottom: "".concat(offsetAbsolute),
31770
- transform: 'translate(-50%, 100%) rotate(-90deg)'
31771
- },
31772
- topStart: {
31773
- top: 'auto',
31774
- right: 'auto',
31775
- left: "".concat(offsetX),
31776
- bottom: "".concat(offsetAbsolute),
31777
- transform: 'translate(0, 100%) rotate(-90deg)'
31778
- },
31779
- topEnd: {
31780
- top: 'auto',
31781
- right: "".concat(offsetX),
31782
- left: 'auto',
31783
- bottom: "".concat(offsetAbsolute),
31784
- transform: 'translate(0, 100%) rotate(-90deg)'
31785
- },
31786
- bottom: {
31787
- top: "".concat(offsetAbsolute),
31788
- right: 'auto',
31789
- left: '50%',
31790
- bottom: 'auto',
31791
- transform: 'translate(-50%, -100%) rotate(90deg)'
31792
- },
31793
- bottomStart: {
31794
- top: "".concat(offsetAbsolute),
31795
- right: 'auto',
31796
- left: "".concat(offsetX),
31797
- bottom: 'auto',
31798
- transform: 'translate(0, -100%) rotate(90deg)'
31799
- },
31800
- bottomEnd: {
31801
- top: "".concat(offsetAbsolute),
31802
- right: "".concat(offsetX),
31803
- left: 'auto',
31804
- bottom: 'auto',
31805
- transform: 'translate(0, -100%) rotate(90deg)'
31806
- },
31807
- left: {
31808
- top: '50%',
31809
- right: '0',
31810
- left: 'auto',
31811
- bottom: 'auto',
31812
- transform: 'translate(100%, -50%) rotate(180deg)'
31813
- },
31814
- leftStart: {
31815
- top: "".concat(offsetY),
31816
- right: '0',
31817
- left: 'auto',
31818
- bottom: 'auto',
31819
- transform: 'translate(100%, -50%) rotate(180deg)'
31820
- },
31821
- leftEnd: {
31822
- top: 'auto',
31823
- right: '0',
31824
- left: 'auto',
31825
- bottom: "".concat(offsetY),
31826
- transform: 'translate(100%, 50%) rotate(180deg)'
31827
- },
31828
- right: {
31829
- top: '50%',
31830
- right: 'auto',
31831
- left: '0',
31832
- bottom: 'auto',
31833
- transform: 'translate(-100%, -50%) rotate(0deg)'
31834
- },
31835
- rightStart: {
31836
- top: "".concat(offsetY),
31837
- right: 'auto',
31838
- left: '0',
31839
- bottom: 'auto',
31840
- transform: 'translate(-100%, -50%) rotate(0deg)'
31158
+ top: "".concat(offsetY),
31159
+ right: 'auto',
31160
+ left: '0',
31161
+ bottom: 'auto',
31162
+ transform: 'translate(-100%, -50%) rotate(0deg)'
31841
31163
  },
31842
31164
  rightEnd: {
31843
31165
  top: 'auto',
@@ -31973,7 +31295,7 @@ var useClickAway = function useClickAway(ref, handler) {
31973
31295
  }, [ref]);
31974
31296
  };
31975
31297
 
31976
- var _excluded$2 = ["children", "initialVisible", "text", "offset", "placement", "portalClassName", "enterDelay", "leaveDelay", "trigger", "type", "className", "onVisibleChange", "hideArrow", "visible"];
31298
+ var _excluded$7 = ["children", "initialVisible", "text", "offset", "placement", "portalClassName", "enterDelay", "leaveDelay", "trigger", "type", "className", "onVisibleChange", "hideArrow", "visible"];
31977
31299
  var TooltipComponent = function TooltipComponent(_ref) {
31978
31300
  var children = _ref.children,
31979
31301
  _ref$initialVisible = _ref.initialVisible,
@@ -32000,7 +31322,7 @@ var TooltipComponent = function TooltipComponent(_ref) {
32000
31322
  _ref$hideArrow = _ref.hideArrow,
32001
31323
  hideArrow = _ref$hideArrow === undefined ? false : _ref$hideArrow,
32002
31324
  customVisible = _ref.visible,
32003
- props = _objectWithoutProperties(_ref, _excluded$2);
31325
+ props = _objectWithoutProperties(_ref, _excluded$7);
32004
31326
  var timer = React.useRef();
32005
31327
  var ref = React.useRef(null);
32006
31328
  var _useState = React.useState(initialVisible),
@@ -32083,16 +31405,16 @@ var Tooltip = withScale(TooltipComponent);
32083
31405
 
32084
31406
  /* "use client" */
32085
31407
 
32086
- var defaultContext = {
31408
+ var defaultContext$1 = {
32087
31409
  disableItemsAutoClose: false,
32088
31410
  onItemClick: function onItemClick() {}
32089
31411
  };
32090
- var PopoverContext = /*#__PURE__*/React.createContext(defaultContext);
31412
+ var PopoverContext = /*#__PURE__*/React.createContext(defaultContext$1);
32091
31413
  var usePopoverContext = function usePopoverContext() {
32092
31414
  return React.useContext(PopoverContext);
32093
31415
  };
32094
31416
 
32095
- var _excluded$1 = ["child", "children", "enterDelay", "leaveDelay", "offset", "type", "trigger", "placement", "initialVisible", "portalClassName", "disableItemsAutoClose", "onVisibleChange", "visible"];
31417
+ var _excluded$6 = ["child", "children", "enterDelay", "leaveDelay", "offset", "type", "trigger", "placement", "initialVisible", "portalClassName", "disableItemsAutoClose", "onVisibleChange", "visible"];
32096
31418
  var PopoverComponent = function PopoverComponent(_ref) {
32097
31419
  var child = _ref.child,
32098
31420
  children = _ref.children,
@@ -32117,7 +31439,7 @@ var PopoverComponent = function PopoverComponent(_ref) {
32117
31439
  _ref$onVisibleChange = _ref.onVisibleChange,
32118
31440
  onVisibleChange = _ref$onVisibleChange === undefined ? function () {} : _ref$onVisibleChange,
32119
31441
  customVisible = _ref.visible,
32120
- props = _objectWithoutProperties(_ref, _excluded$1);
31442
+ props = _objectWithoutProperties(_ref, _excluded$6);
32121
31443
  var _useScale = useScale(),
32122
31444
  SCALES = _useScale.SCALES;
32123
31445
  var _useState = React.useState(initialVisible),
@@ -32166,7 +31488,7 @@ var PopoverComponent = function PopoverComponent(_ref) {
32166
31488
  PopoverComponent.displayName = 'Popover';
32167
31489
  var Popover = withScale(PopoverComponent);
32168
31490
 
32169
- var _excluded = ["children", "line", "showTitle", "className", "onClick", "disableAutoClose"];
31491
+ var _excluded$5 = ["children", "line", "showTitle", "className", "onClick", "disableAutoClose"];
32170
31492
  var PopoverItemComponent = function PopoverItemComponent(_ref) {
32171
31493
  var children = _ref.children,
32172
31494
  _ref$line = _ref.line,
@@ -32178,7 +31500,7 @@ var PopoverItemComponent = function PopoverItemComponent(_ref) {
32178
31500
  onClick = _ref.onClick,
32179
31501
  _ref$disableAutoClose = _ref.disableAutoClose,
32180
31502
  disableAutoClose = _ref$disableAutoClose === undefined ? false : _ref$disableAutoClose,
32181
- props = _objectWithoutProperties(_ref, _excluded);
31503
+ props = _objectWithoutProperties(_ref, _excluded$5);
32182
31504
  var theme = useTheme();
32183
31505
  var _useScale = useScale(),
32184
31506
  SCALES = _useScale.SCALES;
@@ -32301,34 +31623,6 @@ function DataTable(_ref) {
32301
31623
  }
32302
31624
  });
32303
31625
  }, [hideColumn, cols, rows]);
32304
-
32305
- // const handleClick = (event: React.MouseEvent<HTMLTableRowElement, MouseEvent>, id: any) => {
32306
- // if (readOnly) {
32307
- // return true;
32308
- // }
32309
- // const selectedIndex = selected.indexOf(id as never);
32310
- // let newSelected: never[] | ((prevState: never[]) => never[]) = [];
32311
- // if (selectedIndex === -1) {
32312
- // newSelected = newSelected.concat(selected, id);
32313
- // } else if (selectedIndex === 0) {
32314
- // newSelected = newSelected.concat(selected.slice(1));
32315
- // } else if (selectedIndex === selected.length - 1) {
32316
- // newSelected = newSelected.concat(selected.slice(0, -1));
32317
- // } else if (selectedIndex > 0) {
32318
- // newSelected = newSelected.concat(selected.slice(0, selectedIndex), selected.slice(selectedIndex + 1));
32319
- // }
32320
- // setSelected(newSelected);
32321
- // };
32322
-
32323
- // const handleSelectAllClick = (event: { target: { checked: any } }) => {
32324
- // if (event.target.checked) {
32325
- // const newSelecteds = rows.map((n: { _id: any }) => n._id);
32326
- // setSelected(newSelecteds as never[]);
32327
- // return;
32328
- // }
32329
- // setSelected([]);
32330
- // };
32331
-
32332
31626
  var handleHideColumnClick = function handleHideColumnClick(_event, id) {
32333
31627
  var selectedIndex = hideColumn.indexOf(id);
32334
31628
  var newSelected = [];
@@ -32427,7 +31721,7 @@ function DataTable(_ref) {
32427
31721
  },
32428
31722
  justify: "flex-end",
32429
31723
  alignContent: "center"
32430
- }, menu, !children && !readOnly ? /*#__PURE__*/React.createElement(React.Fragment, null, selected.length > 0 && /*#__PURE__*/React.createElement(React.Fragment, null, onSelectedEdit && selected.length === 1 ? /*#__PURE__*/React.createElement(Tooltip, {
31724
+ }, menu, !children && !readOnly ? /*#__PURE__*/React.createElement(React.Fragment, null, onSelectedEdit && selected.length === 1 ? /*#__PURE__*/React.createElement(Tooltip, {
32431
31725
  text: "Edit Selected",
32432
31726
  placement: "bottom",
32433
31727
  font: 0.8,
@@ -32442,7 +31736,7 @@ function DataTable(_ref) {
32442
31736
  auto: true,
32443
31737
  scale: 2 / 3,
32444
31738
  px: 0.6
32445
- })) : null, onSelectedDelete ? /*#__PURE__*/React.createElement(Tooltip, {
31739
+ })) : null, onSelectedDelete && selected.length > 1 ? /*#__PURE__*/React.createElement(Tooltip, {
32446
31740
  text: "Delete Selected",
32447
31741
  placement: "bottom",
32448
31742
  font: 0.8,
@@ -32457,7 +31751,7 @@ function DataTable(_ref) {
32457
31751
  scale: 2 / 3,
32458
31752
  px: 0.6,
32459
31753
  iconRight: /*#__PURE__*/React.createElement(Delete$1, null)
32460
- })) : null), onRefresh ? /*#__PURE__*/React.createElement(Tooltip, {
31754
+ })) : null, onRefresh ? /*#__PURE__*/React.createElement(Tooltip, {
32461
31755
  text: "Refresh",
32462
31756
  placement: "bottom",
32463
31757
  font: 0.8,
@@ -32566,7 +31860,700 @@ function DataTable(_ref) {
32566
31860
  });
32567
31861
  })))));
32568
31862
  }
32569
- var dataTable = /*#__PURE__*/React.memo(DataTable);
31863
+ var DataTable$1 = /*#__PURE__*/React.memo(DataTable);
31864
+
31865
+ var TableBody = function TableBody(_ref) {
31866
+ var data = _ref.data,
31867
+ emptyText = _ref.emptyText,
31868
+ onRow = _ref.onRow,
31869
+ onCell = _ref.onCell,
31870
+ rowClassName = _ref.rowClassName,
31871
+ _ref$rowDraggable = _ref.rowDraggable,
31872
+ rowDraggable = _ref$rowDraggable === undefined ? false : _ref$rowDraggable,
31873
+ _ref$readOnly = _ref.readOnly,
31874
+ readOnly = _ref$readOnly === undefined ? false : _ref$readOnly,
31875
+ onSelected = _ref.onSelected;
31876
+ var theme = useTheme();
31877
+ var _useState = React.useState([]),
31878
+ _useState2 = _slicedToArray(_useState, 2),
31879
+ selected = _useState2[0],
31880
+ setSelected = _useState2[1];
31881
+ var _useTableContext = useTableContext(),
31882
+ columns = _useTableContext.columns;
31883
+ // const rowClickHandler = (row: TableDataItem, index: number) => {
31884
+ // onRow && onRow(row, index)
31885
+ // }
31886
+
31887
+ var handleClick = function handleClick(_event, id) {
31888
+ if (readOnly) {
31889
+ return true;
31890
+ }
31891
+ var selectedIndex = selected.indexOf(id);
31892
+ var newSelected = [];
31893
+ if (selectedIndex === -1) {
31894
+ newSelected = newSelected.concat(selected, id);
31895
+ } else if (selectedIndex === 0) {
31896
+ newSelected = newSelected.concat(selected.slice(1));
31897
+ } else if (selectedIndex === selected.length - 1) {
31898
+ newSelected = newSelected.concat(selected.slice(0, -1));
31899
+ } else if (selectedIndex > 0) {
31900
+ newSelected = newSelected.concat(selected.slice(0, selectedIndex), selected.slice(selectedIndex + 1));
31901
+ }
31902
+ setSelected(newSelected);
31903
+ if (newSelected.length > 0 && onSelected) {
31904
+ onSelected(newSelected);
31905
+ }
31906
+ };
31907
+
31908
+ // const handleSelectAllClick = (event: { target: { checked: any } }) => {
31909
+ // if (event.target.checked) {
31910
+ // const newSelecteds = data.map((n: any) => n._id);
31911
+ // setSelected(newSelecteds as never[]);
31912
+ // return;
31913
+ // }
31914
+ // setSelected([]);
31915
+ // };
31916
+
31917
+ // Push Selected Rows
31918
+ // useEffect(() => {
31919
+ // if (selected.length > 0 && onSelected) {
31920
+ // onSelected(selected);
31921
+ // }
31922
+ // }, [selected]);
31923
+
31924
+ function renderRow(cols, row, index) {
31925
+ var _row$style;
31926
+ var urid = _.uniqueId();
31927
+ var className = rowClassName(row, index);
31928
+ var rw = _objectSpread2({}, row);
31929
+ var rowStyle = (_row$style = row === null || row === undefined ? undefined : row.style) !== null && _row$style !== undefined ? _row$style : {};
31930
+ var onDragStart = row === null || row === undefined ? undefined : row.onDragStart;
31931
+ delete rw.table;
31932
+ delete rw.style;
31933
+ delete rw.onDragStart;
31934
+ // console.log(row);
31935
+ // const frow = Object.fromEntries(
31936
+ // Object.entries(row).filter(([ky, _]) => ky !== '_id' && cols.map((col: any) => col.id).includes(ky))
31937
+ // ) as unknown as TableDataItem
31938
+ // console.log(frow);
31939
+ var isRowSelected = selected.indexOf(row) !== -1;
31940
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("tr", {
31941
+ draggable: rowDraggable,
31942
+ role: "checkbox",
31943
+ onDragStart: onDragStart,
31944
+ "aria-checked": selected.indexOf(row) !== -1,
31945
+ tabIndex: -1,
31946
+ key: urid,
31947
+ style: _objectSpread2({
31948
+ cursor: 'pointer',
31949
+ backgroundColor: isRowSelected ? '#efefef' : ''
31950
+ }, rowStyle),
31951
+ onClick: function onClick(e) {
31952
+ if (!rowDraggable) {
31953
+ if (onRow) {
31954
+ onRow(row, index);
31955
+ } else {
31956
+ handleClick(e, row);
31957
+ }
31958
+ }
31959
+ },
31960
+ className: _JSXStyle.dynamic([["2019708038", [theme.palette.accents_1, theme.palette.border, theme.palette.accents_6]]]) + " " + (useClasses("".concat(rowDraggable ? 'draggable' : 'hover', " ").concat(className)) || "")
31961
+ }, /*#__PURE__*/React.createElement(TableCell, {
31962
+ columns: cols,
31963
+ row: rw,
31964
+ rowIndex: index,
31965
+ emptyText: emptyText,
31966
+ onCellClick: onCell
31967
+ })), /*#__PURE__*/React.createElement(_JSXStyle, {
31968
+ id: "2019708038",
31969
+ dynamic: [theme.palette.accents_1, theme.palette.border, theme.palette.accents_6]
31970
+ }, "tr.__jsx-style-dynamic-selector{-webkit-transition:background-color 0.25s ease;transition:background-color 0.25s ease;font-size:inherit;}tr.hover.__jsx-style-dynamic-selector:hover{background-color:".concat(theme.palette.accents_1, ";}tr.draggable.__jsx-style-dynamic-selector:hover{border:2px dashed #dfdfdf;margin:3px;}tr.__jsx-style-dynamic-selector td{padding:0 0.5em;border-bottom:1px solid ").concat(theme.palette.border, ";color:").concat(theme.palette.accents_6, ";font-size:calc(0.875 * var(--table-font-size));text-align:left;}tr.__jsx-style-dynamic-selector .cell{min-height:calc(3.125 * var(--table-font-size));display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-flex-flow:row wrap;-ms-flex-flow:row wrap;flex-flow:row wrap;}")));
31971
+ }
31972
+ if ((data === null || data === undefined ? undefined : data.length) === 0) {
31973
+ return /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
31974
+ colSpan: columns === null || columns === undefined ? undefined : columns.length
31975
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Placeholder, {
31976
+ empty: true,
31977
+ msg: "No Entries Found"
31978
+ })))));
31979
+ }
31980
+ return /*#__PURE__*/React.createElement("tbody", {
31981
+ className: _JSXStyle.dynamic([["1422656197", [theme.palette.accents_1, theme.palette.border, theme.palette.accents_6]]])
31982
+ }, data.map(function (row, index) {
31983
+ var _row$table, _row$table2, _row$table3, _row$table4, _row$table5;
31984
+ var qid = _.uniqueId();
31985
+ if (row === null || row === undefined) {
31986
+ var uid = _.uniqueId();
31987
+ return /*#__PURE__*/React.createElement("tr", {
31988
+ key: uid,
31989
+ className: _JSXStyle.dynamic([["1422656197", [theme.palette.accents_1, theme.palette.border, theme.palette.accents_6]]])
31990
+ }, /*#__PURE__*/React.createElement("td", {
31991
+ colSpan: columns.length,
31992
+ className: _JSXStyle.dynamic([["1422656197", [theme.palette.accents_1, theme.palette.border, theme.palette.accents_6]]])
31993
+ }, "\u2003"));
31994
+ }
31995
+ return /*#__PURE__*/React.createElement(React.Fragment, null, renderRow(columns, row, index), (row === null || row === undefined ? undefined : row.table) && /*#__PURE__*/React.createElement("tr", {
31996
+ key: qid,
31997
+ className: _JSXStyle.dynamic([["1422656197", [theme.palette.accents_1, theme.palette.border, theme.palette.accents_6]]])
31998
+ }, /*#__PURE__*/React.createElement("td", {
31999
+ style: {
32000
+ padding: '1rem'
32001
+ },
32002
+ colSpan: columns.length,
32003
+ className: _JSXStyle.dynamic([["1422656197", [theme.palette.accents_1, theme.palette.border, theme.palette.accents_6]]])
32004
+ }, /*#__PURE__*/React.createElement(DataTable$1, {
32005
+ readOnly: true,
32006
+ stickyHeader: false,
32007
+ style: _objectSpread2({
32008
+ height: 'auto !important'
32009
+ }, row === null || row === undefined || (_row$table = row.table) === null || _row$table === undefined ? undefined : _row$table.style),
32010
+ menu: (_row$table2 = row.table) === null || _row$table2 === undefined ? undefined : _row$table2.menu,
32011
+ rows: (_row$table3 = row.table) === null || _row$table3 === undefined ? undefined : _row$table3.rows,
32012
+ heading: (_row$table4 = row.table) === null || _row$table4 === undefined ? undefined : _row$table4.heading,
32013
+ cols: (_row$table5 = row.table) === null || _row$table5 === undefined ? undefined : _row$table5.cols
32014
+ }))));
32015
+
32016
+ // return (
32017
+ // <tr
32018
+ // key={`tbody-row-${index}`}
32019
+ // className={useClasses({ hover }, className)}
32020
+ // onClick={() => rowClickHandler(row, index)}>
32021
+ // <TableCell<TableDataItem>
32022
+ // columns={columns}
32023
+ // row={row}
32024
+ // rowIndex={index}
32025
+ // emptyText={emptyText}
32026
+ // onCellClick={onCell}
32027
+ // />
32028
+ // </tr>
32029
+ // )
32030
+ }), /*#__PURE__*/React.createElement(_JSXStyle, {
32031
+ id: "1422656197",
32032
+ dynamic: [theme.palette.accents_1, theme.palette.border, theme.palette.accents_6]
32033
+ }, "tr.__jsx-style-dynamic-selector{-webkit-transition:background-color 0.25s ease;transition:background-color 0.25s ease;font-size:inherit;}tr.hover.__jsx-style-dynamic-selector:hover{background-color:".concat(theme.palette.accents_1, ";}tr.draggable.__jsx-style-dynamic-selector:hover{border:2px dashed #dfdfdf;margin:3px;}tr.__jsx-style-dynamic-selector td{padding:0 0.5em;border-bottom:1px solid ").concat(theme.palette.border, ";color:").concat(theme.palette.accents_6, ";font-size:calc(0.875 * var(--table-font-size));text-align:left;}tr.__jsx-style-dynamic-selector .cell{min-height:calc(3.125 * var(--table-font-size));display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-flex-flow:row wrap;-ms-flex-flow:row wrap;flex-flow:row wrap;}")));
32034
+ };
32035
+ TableBody.displayName = 'TableBody';
32036
+
32037
+ var getRealShape = function getRealShape(el) {
32038
+ var defaultShape = {
32039
+ width: 0,
32040
+ height: 0
32041
+ };
32042
+ if (!el || typeof window === 'undefined') return defaultShape;
32043
+ var rect = el.getBoundingClientRect();
32044
+ var _window$getComputedSt = window.getComputedStyle(el),
32045
+ width = _window$getComputedSt.width,
32046
+ height = _window$getComputedSt.height;
32047
+ var getCSSStyleVal = function getCSSStyleVal(str, parentNum) {
32048
+ if (!str) return 0;
32049
+ var strVal = str.includes('px') ? +str.split('px')[0] : str.includes('%') ? +str.split('%')[0] * parentNum * 0.01 : str;
32050
+ return Number.isNaN(+strVal) ? 0 : +strVal;
32051
+ };
32052
+ return {
32053
+ width: getCSSStyleVal("".concat(width), rect.width),
32054
+ height: getCSSStyleVal("".concat(height), rect.height)
32055
+ };
32056
+ };
32057
+ var useRealShape = function useRealShape(ref) {
32058
+ var _useState = React.useState({
32059
+ width: 0,
32060
+ height: 0
32061
+ }),
32062
+ _useState2 = _slicedToArray(_useState, 2),
32063
+ state = _useState2[0],
32064
+ setState = _useState2[1];
32065
+ var update = function update() {
32066
+ var _getRealShape = getRealShape(ref.current),
32067
+ width = _getRealShape.width,
32068
+ height = _getRealShape.height;
32069
+ setState({
32070
+ width: width,
32071
+ height: height
32072
+ });
32073
+ };
32074
+ React.useEffect(function () {
32075
+ return update();
32076
+ }, [ref.current]);
32077
+ return [state, update];
32078
+ };
32079
+
32080
+ /* "use client" */
32081
+
32082
+ var TableColumn = function TableColumn(columnProps) {
32083
+ var _ref = columnProps,
32084
+ children = _ref.children,
32085
+ prop = _ref.prop,
32086
+ label = _ref.label,
32087
+ width = _ref.width,
32088
+ filter = _ref.filter,
32089
+ options = _ref.options,
32090
+ noWrap = _ref.noWrap,
32091
+ align = _ref.align,
32092
+ _ref$fontSize = _ref.fontSize,
32093
+ fontSize = _ref$fontSize === undefined ? 'smaller' : _ref$fontSize,
32094
+ _ref$className = _ref.className,
32095
+ className = _ref$className === undefined ? '' : _ref$className,
32096
+ renderHandler = _ref.render;
32097
+ var _useTableContext = useTableContext(),
32098
+ updateColumn = _useTableContext.updateColumn;
32099
+ var safeProp = "".concat(prop.toString()).trim();
32100
+ if (!safeProp) {
32101
+ useWarning('The props "prop" is required.', 'Table.Column');
32102
+ }
32103
+ React.useEffect(function () {
32104
+ updateColumn({
32105
+ label: children || label,
32106
+ filter: filter,
32107
+ noWrap: noWrap,
32108
+ options: options,
32109
+ prop: safeProp,
32110
+ width: width,
32111
+ align: align,
32112
+ fontSize: fontSize,
32113
+ className: className,
32114
+ renderHandler: function renderHandler() {}
32115
+ });
32116
+ }, [children, noWrap, fontSize, align, filter, options, label, prop, width, className, renderHandler]);
32117
+ return null;
32118
+ };
32119
+ TableColumn.displayName = 'TableColumn';
32120
+
32121
+ var _excluded$4 = ["active", "children", "disabled", "onClick"];
32122
+ var PaginationItem = function PaginationItem(_ref) {
32123
+ var active = _ref.active,
32124
+ children = _ref.children,
32125
+ disabled = _ref.disabled,
32126
+ onClick = _ref.onClick,
32127
+ props = _objectWithoutProperties(_ref, _excluded$4);
32128
+ var theme = useTheme();
32129
+ var _useMemo = React.useMemo(function () {
32130
+ return [addColorAlpha(theme.palette.success, 0.1), addColorAlpha(theme.palette.success, 0.8)];
32131
+ }, [theme.palette.success]),
32132
+ _useMemo2 = _slicedToArray(_useMemo, 2),
32133
+ hover = _useMemo2[0],
32134
+ activeHover = _useMemo2[1];
32135
+ var classes = useClasses({
32136
+ active: active,
32137
+ disabled: disabled
32138
+ });
32139
+ var clickHandler = function clickHandler(event) {
32140
+ if (disabled) return;
32141
+ onClick && onClick(event);
32142
+ };
32143
+ return /*#__PURE__*/React.createElement("li", {
32144
+ className: _JSXStyle.dynamic([["1657796974", [theme.palette.success, theme.layout.radius, theme.palette.background, hover, theme.palette.success, theme.palette.background, theme.expressiveness.shadowSmall, activeHover, theme.expressiveness.shadowMedium, theme.palette.accents_4, theme.palette.accents_2]]])
32145
+ }, /*#__PURE__*/React.createElement("button", _extends({
32146
+ onClick: clickHandler
32147
+ }, props, {
32148
+ className: _JSXStyle.dynamic([["1657796974", [theme.palette.success, theme.layout.radius, theme.palette.background, hover, theme.palette.success, theme.palette.background, theme.expressiveness.shadowSmall, activeHover, theme.expressiveness.shadowMedium, theme.palette.accents_4, theme.palette.accents_2]]]) + " " + (props && props.className != null && props.className || classes || "")
32149
+ }), children), /*#__PURE__*/React.createElement(_JSXStyle, {
32150
+ id: "1657796974",
32151
+ dynamic: [theme.palette.success, theme.layout.radius, theme.palette.background, hover, theme.palette.success, theme.palette.background, theme.expressiveness.shadowSmall, activeHover, theme.expressiveness.shadowMedium, theme.palette.accents_4, theme.palette.accents_2]
32152
+ }, "li.__jsx-style-dynamic-selector{margin-right:0.428em;display:inline-block;}button.__jsx-style-dynamic-selector{border:none;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;box-sizing:border-box;text-transform:capitalize;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;white-space:nowrap;text-align:center;vertical-align:middle;box-shadow:none;outline:none;height:var(--pagination-size);min-width:var(--pagination-size);font-size:inherit;cursor:pointer;color:".concat(theme.palette.success, ";border-radius:").concat(theme.layout.radius, ";background-color:").concat(theme.palette.background, ";-webkit-transition:all linear 200ms 0ms;transition:all linear 200ms 0ms;}button.__jsx-style-dynamic-selector:hover{background-color:").concat(hover, ";}.active.__jsx-style-dynamic-selector{font-weight:bold;background-color:").concat(theme.palette.success, ";color:").concat(theme.palette.background, ";box-shadow:").concat(theme.expressiveness.shadowSmall, ";}.active.__jsx-style-dynamic-selector:hover{background-color:").concat(activeHover, ";box-shadow:").concat(theme.expressiveness.shadowMedium, ";}.disabled.__jsx-style-dynamic-selector{color:").concat(theme.palette.accents_4, ";cursor:not-allowed;}.disabled.__jsx-style-dynamic-selector:hover{background-color:").concat(theme.palette.accents_2, ";}button.__jsx-style-dynamic-selector svg{width:1.3em;height:1.3em;}")));
32153
+ };
32154
+ PaginationItem.displayName = 'GeistPaginationItem';
32155
+
32156
+ /* "use client" */
32157
+
32158
+ tuple('prev', 'next', 'click');
32159
+ var defaultContext = {};
32160
+ var PaginationContext = /*#__PURE__*/React.createContext(defaultContext);
32161
+ var usePaginationContext = function usePaginationContext() {
32162
+ return React.useContext(PaginationContext);
32163
+ };
32164
+
32165
+ var _excluded$3 = ["children"];
32166
+ var PaginationPrevious = function PaginationPrevious(_ref) {
32167
+ var children = _ref.children,
32168
+ props = _objectWithoutProperties(_ref, _excluded$3);
32169
+ var _usePaginationContext = usePaginationContext(),
32170
+ update = _usePaginationContext.update,
32171
+ isFirst = _usePaginationContext.isFirst;
32172
+ return /*#__PURE__*/React.createElement(PaginationItem, _extends({
32173
+ onClick: function onClick() {
32174
+ return update && update('prev');
32175
+ },
32176
+ disabled: isFirst
32177
+ }, props), children);
32178
+ };
32179
+ PaginationPrevious.displayName = 'GeistPaginationPrevious';
32180
+
32181
+ var _excluded$2 = ["children"];
32182
+ var PaginationNext = function PaginationNext(_ref) {
32183
+ var children = _ref.children,
32184
+ props = _objectWithoutProperties(_ref, _excluded$2);
32185
+ var _usePaginationContext = usePaginationContext(),
32186
+ update = _usePaginationContext.update,
32187
+ isLast = _usePaginationContext.isLast;
32188
+ return /*#__PURE__*/React.createElement(PaginationItem, _extends({
32189
+ onClick: function onClick() {
32190
+ return update && update('next');
32191
+ },
32192
+ disabled: isLast
32193
+ }, props), children);
32194
+ };
32195
+ PaginationNext.displayName = 'GeistPaginationNext';
32196
+
32197
+ var PaginationEllipsis = function PaginationEllipsis(_ref) {
32198
+ var isBefore = _ref.isBefore,
32199
+ _onClick = _ref.onClick;
32200
+ var _useState = React.useState(false),
32201
+ _useState2 = _slicedToArray(_useState, 2),
32202
+ showMore = _useState2[0],
32203
+ setShowMore = _useState2[1];
32204
+ return /*#__PURE__*/React.createElement(PaginationItem, {
32205
+ onClick: function onClick(e) {
32206
+ return _onClick && _onClick(e);
32207
+ },
32208
+ onMouseEnter: function onMouseEnter() {
32209
+ return setShowMore(true);
32210
+ },
32211
+ onMouseLeave: function onMouseLeave() {
32212
+ return setShowMore(false);
32213
+ }
32214
+ }, showMore ? /*#__PURE__*/React.createElement("svg", {
32215
+ viewBox: "0 0 24 24",
32216
+ stroke: "currentColor",
32217
+ strokeWidth: "1.5",
32218
+ strokeLinecap: "round",
32219
+ strokeLinejoin: "round",
32220
+ fill: "none",
32221
+ shapeRendering: "geometricPrecision",
32222
+ className: _JSXStyle.dynamic([["2928474255", [isBefore ? '180deg' : '0deg']]]) + " " + "more"
32223
+ }, /*#__PURE__*/React.createElement("path", {
32224
+ d: "M13 17l5-5-5-5",
32225
+ className: _JSXStyle.dynamic([["2928474255", [isBefore ? '180deg' : '0deg']]])
32226
+ }), /*#__PURE__*/React.createElement("path", {
32227
+ d: "M6 17l5-5-5-5",
32228
+ className: _JSXStyle.dynamic([["2928474255", [isBefore ? '180deg' : '0deg']]])
32229
+ })) : /*#__PURE__*/React.createElement("svg", {
32230
+ viewBox: "0 0 24 24",
32231
+ strokeWidth: "1.5",
32232
+ strokeLinecap: "round",
32233
+ strokeLinejoin: "round",
32234
+ fill: "none",
32235
+ shapeRendering: "geometricPrecision",
32236
+ className: _JSXStyle.dynamic([["2928474255", [isBefore ? '180deg' : '0deg']]])
32237
+ }, /*#__PURE__*/React.createElement("circle", {
32238
+ cx: "12",
32239
+ cy: "12",
32240
+ r: "1",
32241
+ fill: "currentColor",
32242
+ className: _JSXStyle.dynamic([["2928474255", [isBefore ? '180deg' : '0deg']]])
32243
+ }), /*#__PURE__*/React.createElement("circle", {
32244
+ cx: "19",
32245
+ cy: "12",
32246
+ r: "1",
32247
+ fill: "currentColor",
32248
+ className: _JSXStyle.dynamic([["2928474255", [isBefore ? '180deg' : '0deg']]])
32249
+ }), /*#__PURE__*/React.createElement("circle", {
32250
+ cx: "5",
32251
+ cy: "12",
32252
+ r: "1",
32253
+ fill: "currentColor",
32254
+ className: _JSXStyle.dynamic([["2928474255", [isBefore ? '180deg' : '0deg']]])
32255
+ })), /*#__PURE__*/React.createElement(_JSXStyle, {
32256
+ id: "2928474255",
32257
+ dynamic: [isBefore ? '180deg' : '0deg']
32258
+ }, "svg.__jsx-style-dynamic-selector{color:currentColor;stroke:currentColor;width:1em;height:1em;}.more.__jsx-style-dynamic-selector{-webkit-transform:rotate(".concat(isBefore ? '180deg' : '0deg', ");-ms-transform:rotate(").concat(isBefore ? '180deg' : '0deg', ");transform:rotate(").concat(isBefore ? '180deg' : '0deg', ");}")));
32259
+ };
32260
+ PaginationEllipsis.displayName = 'GeistPaginationEllipsis';
32261
+
32262
+ var PaginationPages = function PaginationPages(_ref) {
32263
+ var limit = _ref.limit,
32264
+ count = _ref.count,
32265
+ current = _ref.current,
32266
+ setPage = _ref.setPage;
32267
+ var showPages = React.useMemo(function () {
32268
+ var oddLimit = limit % 2 === 0 ? limit - 1 : limit;
32269
+ return oddLimit - 2;
32270
+ }, [limit]);
32271
+ var middleNumber = (showPages + 1) / 2;
32272
+ var _useMemo = React.useMemo(function () {
32273
+ var showEllipsis = count > limit;
32274
+ return [showEllipsis && current > middleNumber + 1, showEllipsis && current < count - middleNumber];
32275
+ }, [current, showPages, middleNumber, count, limit]),
32276
+ _useMemo2 = _slicedToArray(_useMemo, 2),
32277
+ showBeforeEllipsis = _useMemo2[0],
32278
+ showAfterEllipsis = _useMemo2[1];
32279
+ var pagesArray = React.useMemo(function () {
32280
+ return _toConsumableArray(new Array(showPages));
32281
+ }, [showPages]);
32282
+ var renderItem = React.useCallback(function (value, active) {
32283
+ return /*#__PURE__*/React.createElement(PaginationItem, {
32284
+ key: "pagination-item-".concat(value),
32285
+ active: value === active,
32286
+ onClick: function onClick() {
32287
+ return setPage(value);
32288
+ }
32289
+ }, value);
32290
+ }, []);
32291
+ var startPages = pagesArray.map(function (_, index) {
32292
+ var value = index + 2;
32293
+ return renderItem(value, current);
32294
+ });
32295
+ var middlePages = pagesArray.map(function (_, index) {
32296
+ var middleIndexNumber = middleNumber - (index + 1);
32297
+ var value = current - middleIndexNumber;
32298
+ return /*#__PURE__*/React.createElement(PaginationItem, {
32299
+ key: "pagination-middle-".concat(index),
32300
+ active: index + 1 === middleNumber,
32301
+ onClick: function onClick() {
32302
+ return setPage(value);
32303
+ }
32304
+ }, value);
32305
+ });
32306
+ var endPages = pagesArray.map(function (_, index) {
32307
+ var value = count - (showPages - index);
32308
+ return renderItem(value, current);
32309
+ });
32310
+ if (count <= limit) {
32311
+ /* eslint-disable react/jsx-no-useless-fragment */
32312
+ return /*#__PURE__*/React.createElement(React.Fragment, null, _toConsumableArray(new Array(count)).map(function (_, index) {
32313
+ var value = index + 1;
32314
+ return /*#__PURE__*/React.createElement(PaginationItem, {
32315
+ key: "pagination-item-".concat(value),
32316
+ active: value === current,
32317
+ onClick: function onClick() {
32318
+ return setPage(value);
32319
+ }
32320
+ }, value);
32321
+ }));
32322
+ /* eslint-enable */
32323
+ }
32324
+ return /*#__PURE__*/React.createElement(React.Fragment, null, renderItem(1, current), showBeforeEllipsis && /*#__PURE__*/React.createElement(PaginationEllipsis, {
32325
+ key: "pagination-ellipsis-before",
32326
+ isBefore: true,
32327
+ onClick: function onClick() {
32328
+ return setPage(function (last) {
32329
+ return last - 5 >= 1 ? last - 5 : 1;
32330
+ });
32331
+ }
32332
+ }), showBeforeEllipsis && showAfterEllipsis ? middlePages : showBeforeEllipsis ? endPages : startPages, showAfterEllipsis && /*#__PURE__*/React.createElement(PaginationEllipsis, {
32333
+ key: "pagination-ellipsis-after",
32334
+ onClick: function onClick() {
32335
+ return setPage(function (last) {
32336
+ return last + 5 <= count ? last + 5 : count;
32337
+ });
32338
+ }
32339
+ }), renderItem(count, current));
32340
+ };
32341
+ PaginationPages.displayName = 'GeistPaginationPages';
32342
+
32343
+ var _excluded$1 = ["page", "initialPage", "count", "limit", "children", "onChange", "className"];
32344
+ var PaginationComponent = function PaginationComponent(_ref) {
32345
+ var customPage = _ref.page,
32346
+ _ref$initialPage = _ref.initialPage,
32347
+ initialPage = _ref$initialPage === undefined ? 1 : _ref$initialPage,
32348
+ _ref$count = _ref.count,
32349
+ count = _ref$count === undefined ? 1 : _ref$count,
32350
+ _ref$limit = _ref.limit,
32351
+ limit = _ref$limit === undefined ? 7 : _ref$limit,
32352
+ children = _ref.children,
32353
+ onChange = _ref.onChange,
32354
+ _ref$className = _ref.className,
32355
+ className = _ref$className === undefined ? '' : _ref$className,
32356
+ props = _objectWithoutProperties(_ref, _excluded$1);
32357
+ var _useScale = useScale(),
32358
+ SCALES = _useScale.SCALES;
32359
+ var _useCurrentState = useCurrentState(initialPage),
32360
+ _useCurrentState2 = _slicedToArray(_useCurrentState, 3),
32361
+ page = _useCurrentState2[0],
32362
+ setPage = _useCurrentState2[1],
32363
+ pageRef = _useCurrentState2[2];
32364
+ var _pickChild = pickChild(children, PaginationPrevious),
32365
+ _pickChild2 = _slicedToArray(_pickChild, 2),
32366
+ prevChildren = _pickChild2[1];
32367
+ var _pickChild3 = pickChild(children, PaginationNext),
32368
+ _pickChild4 = _slicedToArray(_pickChild3, 2),
32369
+ nextChildren = _pickChild4[1];
32370
+ var _useMemo = React.useMemo(function () {
32371
+ var hasChildren = function hasChildren(c) {
32372
+ return React.Children.count(c) > 0;
32373
+ };
32374
+ var prevDefault = /*#__PURE__*/React.createElement(PaginationPrevious, null, "prev");
32375
+ var nextDefault = /*#__PURE__*/React.createElement(PaginationNext, null, "next");
32376
+ return [hasChildren(prevChildren) ? prevChildren : prevDefault, hasChildren(nextChildren) ? nextChildren : nextDefault];
32377
+ }, [prevChildren, nextChildren]),
32378
+ _useMemo2 = _slicedToArray(_useMemo, 2),
32379
+ prevItem = _useMemo2[0],
32380
+ nextItem = _useMemo2[1];
32381
+ var update = function update(type) {
32382
+ if (type === 'prev' && pageRef.current > 1) {
32383
+ setPage(function (last) {
32384
+ return last - 1;
32385
+ });
32386
+ }
32387
+ if (type === 'next' && pageRef.current < count) {
32388
+ setPage(function (last) {
32389
+ return last + 1;
32390
+ });
32391
+ }
32392
+ };
32393
+ var values = React.useMemo(function () {
32394
+ return {
32395
+ isFirst: page <= 1,
32396
+ isLast: page >= count,
32397
+ update: update
32398
+ };
32399
+ }, [page, count]);
32400
+ React.useEffect(function () {
32401
+ onChange && onChange(page);
32402
+ }, [page]);
32403
+ React.useEffect(function () {
32404
+ if (customPage !== undefined) {
32405
+ setPage(customPage);
32406
+ }
32407
+ }, [customPage]);
32408
+ return /*#__PURE__*/React.createElement(PaginationContext.Provider, {
32409
+ value: values
32410
+ }, /*#__PURE__*/React.createElement("nav", _extends({}, props, {
32411
+ className: _JSXStyle.dynamic([["3826701357", [SCALES.font(2), SCALES.font(0.875), SCALES.width(1, 'auto'), 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 || "")
32412
+ }), prevItem, /*#__PURE__*/React.createElement(PaginationPages, {
32413
+ count: count,
32414
+ current: page,
32415
+ limit: limit,
32416
+ setPage: setPage
32417
+ }), nextItem), /*#__PURE__*/React.createElement(_JSXStyle, {
32418
+ id: "3826701357",
32419
+ dynamic: [SCALES.font(2), SCALES.font(0.875), SCALES.width(1, 'auto'), 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)]
32420
+ }, "nav.__jsx-style-dynamic-selector{font-variant:tabular-nums;font-feature-settings:'tnum';--pagination-size:".concat(SCALES.font(2), ";font-size:").concat(SCALES.font(0.875), ";width:").concat(SCALES.width(1, 'auto'), ";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), ";}nav.__jsx-style-dynamic-selector button:last-of-type{margin-right:0;}")));
32421
+ };
32422
+ PaginationComponent.displayName = 'Pagination';
32423
+ var Pagination = withScale(PaginationComponent);
32424
+
32425
+ Pagination.Previous = PaginationPrevious;
32426
+ Pagination.Next = PaginationNext;
32427
+
32428
+ var _excluded = ["children", "data", "initialData", "hover", "emptyText", "rowDraggable", "readOnly", "onRow", "onCell", "onChange", "onFilters", "onPageChange", "showFilters", "stickyHeader", "onSelected", "dataLength", "viewLength", "className", "rowClassName"];
32429
+ function TableComponent(tableProps) {
32430
+ /* eslint-disable @typescript-eslint/no-unused-vars */
32431
+ var _ref = tableProps,
32432
+ children = _ref.children,
32433
+ customData = _ref.data,
32434
+ _ref$initialData = _ref.initialData,
32435
+ initialData = _ref$initialData === undefined ? [] : _ref$initialData,
32436
+ _ref$hover = _ref.hover,
32437
+ hover = _ref$hover === undefined ? true : _ref$hover,
32438
+ _ref$emptyText = _ref.emptyText,
32439
+ emptyText = _ref$emptyText === undefined ? '' : _ref$emptyText,
32440
+ _ref$rowDraggable = _ref.rowDraggable,
32441
+ rowDraggable = _ref$rowDraggable === undefined ? false : _ref$rowDraggable,
32442
+ _ref$readOnly = _ref.readOnly,
32443
+ readOnly = _ref$readOnly === undefined ? false : _ref$readOnly,
32444
+ onRow = _ref.onRow,
32445
+ onCell = _ref.onCell;
32446
+ _ref.onChange;
32447
+ var onFilters = _ref.onFilters,
32448
+ onPageChange = _ref.onPageChange,
32449
+ _ref$showFilters = _ref.showFilters,
32450
+ showFilters = _ref$showFilters === undefined ? false : _ref$showFilters,
32451
+ _ref$stickyHeader = _ref.stickyHeader,
32452
+ stickyHeader = _ref$stickyHeader === undefined ? false : _ref$stickyHeader,
32453
+ onSelected = _ref.onSelected,
32454
+ dataLength = _ref.dataLength,
32455
+ viewLength = _ref.viewLength,
32456
+ _ref$className = _ref.className,
32457
+ className = _ref$className === undefined ? '' : _ref$className,
32458
+ _ref$rowClassName = _ref.rowClassName,
32459
+ rowClassName = _ref$rowClassName === undefined ? function () {
32460
+ return '';
32461
+ } : _ref$rowClassName,
32462
+ props = _objectWithoutProperties(_ref, _excluded);
32463
+ /* eslint-enable @typescript-eslint/no-unused-vars */
32464
+ var _useScale = useScale(),
32465
+ SCALES = _useScale.SCALES;
32466
+ var ref = React.useRef(null);
32467
+ var _useRealShape = useRealShape(ref),
32468
+ _useRealShape2 = _slicedToArray(_useRealShape, 2),
32469
+ width = _useRealShape2[0].width,
32470
+ updateShape = _useRealShape2[1];
32471
+ var _useState = React.useState([]),
32472
+ _useState2 = _slicedToArray(_useState, 2),
32473
+ columns = _useState2[0],
32474
+ setColumns = _useState2[1];
32475
+ var _useState3 = React.useState(initialData),
32476
+ _useState4 = _slicedToArray(_useState3, 2),
32477
+ data = _useState4[0],
32478
+ setData = _useState4[1];
32479
+ var updateColumn = function updateColumn(column) {
32480
+ setColumns(function (last) {
32481
+ var hasColumn = last.find(function (item) {
32482
+ return item.prop === column.prop;
32483
+ });
32484
+ if (!hasColumn) return [].concat(_toConsumableArray(last), [column]);
32485
+ return last.map(function (item) {
32486
+ if (item.prop !== column.prop) return item;
32487
+ return column;
32488
+ });
32489
+ });
32490
+ };
32491
+ var contextValue = React.useMemo(function () {
32492
+ return {
32493
+ columns: columns,
32494
+ updateColumn: updateColumn
32495
+ };
32496
+ }, [columns]);
32497
+ React.useEffect(function () {
32498
+ if (typeof customData === 'undefined') return;
32499
+ setData(customData);
32500
+ }, [customData]);
32501
+ useResize(function () {
32502
+ return updateShape();
32503
+ });
32504
+
32505
+ // Function to calculate start and end index for a given page
32506
+ var getDataRange = function getDataRange(pageNumber, itemsPerPage, dataLength) {
32507
+ var startIndex = (pageNumber - 1) * itemsPerPage;
32508
+ var endIndex = Math.min(startIndex + itemsPerPage - 1, dataLength - 1);
32509
+ return {
32510
+ startIndex: startIndex,
32511
+ endIndex: endIndex
32512
+ };
32513
+ };
32514
+ return /*#__PURE__*/React.createElement(TableContext.Provider, {
32515
+ value: contextValue
32516
+ }, /*#__PURE__*/React.createElement("table", _extends({
32517
+ ref: ref
32518
+ }, props, {
32519
+ className: _JSXStyle.dynamic([["2132340556", [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 || "")
32520
+ }), /*#__PURE__*/React.createElement(TableHead, {
32521
+ stickyHeader: stickyHeader,
32522
+ columns: columns,
32523
+ onFilters: onFilters,
32524
+ showFilters: showFilters,
32525
+ width: width
32526
+ }), /*#__PURE__*/React.createElement(TableBody, {
32527
+ data: data,
32528
+ hover: hover,
32529
+ emptyText: emptyText,
32530
+ onRow: onRow,
32531
+ onCell: onCell,
32532
+ rowClassName: rowClassName,
32533
+ rowDraggable: rowDraggable,
32534
+ readOnly: readOnly,
32535
+ onSelected: onSelected
32536
+ }), children, /*#__PURE__*/React.createElement(_JSXStyle, {
32537
+ id: "2132340556",
32538
+ 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)]
32539
+ }, "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), ";}")), dataLength && viewLength && onPageChange ? /*#__PURE__*/React.createElement("tfoot", {
32540
+ className: _JSXStyle.dynamic([["2132340556", [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)]]])
32541
+ }, /*#__PURE__*/React.createElement(Pagination, {
32542
+ onChange: function onChange(pageNumber) {
32543
+ // Get the range for the current page
32544
+ var _getDataRange = getDataRange(pageNumber, viewLength, dataLength),
32545
+ startIndex = _getDataRange.startIndex,
32546
+ endIndex = _getDataRange.endIndex;
32547
+ onPageChange(pageNumber, startIndex, endIndex);
32548
+ },
32549
+ limit: 5,
32550
+ count: Number(dataLength / viewLength)
32551
+ }, /*#__PURE__*/React.createElement(Pagination.Next, null, /*#__PURE__*/React.createElement(ChevronRight$1, null)), /*#__PURE__*/React.createElement(Pagination.Previous, null, /*#__PURE__*/React.createElement(ChevronLeft$1, null)))) : null));
32552
+ }
32553
+ TableComponent.displayName = 'Table';
32554
+ TableComponent.Column = TableColumn;
32555
+ var Table = withScale(TableComponent);
32556
+ Table.Column = TableColumn;
32570
32557
 
32571
- exports.DataTable = dataTable;
32558
+ exports.DataTable = DataTable$1;
32572
32559
  exports.default = Table;