@ballistix.digital/react-components 0.5.4 → 0.5.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.
- package/dist/index.esm.js +28 -25
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +27 -24
- package/dist/index.js.map +1 -1
- package/dist/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
2
2
|
import { ArrowPathIcon, ChevronDownIcon, EllipsisVerticalIcon, ExclamationCircleIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronUpDownIcon, HomeIcon, ArrowLongLeftIcon, ArrowLongRightIcon } from '@heroicons/react/20/solid';
|
|
3
|
-
import { set, get, noop as noop$1, indexOf, pick, isEmpty, some, forEach, assign
|
|
3
|
+
import { isArray, map, set, get, noop as noop$1, indexOf, pick, isEmpty, some, forEach, assign } from 'lodash';
|
|
4
4
|
import get$1 from 'lodash/get';
|
|
5
5
|
import React, { useState, useMemo, Children, Fragment, useEffect, useCallback, forwardRef, useImperativeHandle, useRef, useReducer, createElement, PureComponent, Component } from 'react';
|
|
6
6
|
import { library } from '@fortawesome/fontawesome-svg-core';
|
|
@@ -138,11 +138,13 @@ var toClassName = function () {
|
|
|
138
138
|
}
|
|
139
139
|
return values.filter(Boolean).join(' ');
|
|
140
140
|
};
|
|
141
|
-
var fromSelectMenuOptionToStringValue = function (
|
|
142
|
-
if (
|
|
143
|
-
return
|
|
141
|
+
var fromSelectMenuOptionToStringValue = function (value) {
|
|
142
|
+
if (value === null)
|
|
143
|
+
return null;
|
|
144
|
+
if (isArray(value)) {
|
|
145
|
+
return map(value, 'value');
|
|
144
146
|
}
|
|
145
|
-
return
|
|
147
|
+
return value === null || value === void 0 ? void 0 : value.value;
|
|
146
148
|
};
|
|
147
149
|
|
|
148
150
|
var deepCopyObject = function (object) {
|
|
@@ -713,8 +715,9 @@ var InputGroupForm = function (props) {
|
|
|
713
715
|
};
|
|
714
716
|
var styles = handleGenerateStyle();
|
|
715
717
|
var invalidIcon = (jsx(ExclamationCircleIcon, { className: "h-5 w-5 text-red-500", "aria-hidden": "true" }));
|
|
718
|
+
var isClearable = !trailing && isValid && onClear && value !== '' && value;
|
|
716
719
|
return (jsxs("div", { className: styles.container, children: [jsxs("div", { className: styles.head, children: [label && (jsx("label", { htmlFor: name, className: styles.label, children: label })), !required && !isRequired && typeof label === 'string' && (jsx("span", { className: styles.hint, children: "Optional" })), required && required({ isRequired: isRequired })] }), jsxs("div", { className: styles.body, children: [leading && jsx("div", { className: styles.leading, children: leading }), !htmlType ||
|
|
717
|
-
(htmlType !== 'area' && (jsxs("div", { className: "flex items-center", children: [jsx("input", { type: mask !== undefined ? 'text' : htmlType, ref: mask && ref, name: name, id: name, className: toClassName(styles.input, htmlType === 'color' && '!h-10'), placeholder: placeholder, defaultValue: isSolo ? value : undefined, value: isSolo ? undefined : value, min: min, max: max, maxLength: maxLength, disabled: isDisabled, onChange: onChange, onBlur: onBlur }), htmlType === 'text' &&
|
|
720
|
+
(htmlType !== 'area' && (jsxs("div", { className: "flex items-center", children: [jsx("input", { type: mask !== undefined ? 'text' : htmlType, ref: mask && ref, name: name, id: name, className: toClassName(styles.input, htmlType === 'color' && '!h-10'), placeholder: placeholder, defaultValue: isSolo ? value : undefined, value: isSolo ? undefined : value, min: min, max: max, maxLength: maxLength, disabled: isDisabled, onChange: onChange, onBlur: onBlur }), htmlType === 'text' && isClearable && (jsx("div", { className: "right-5 px-2 absolute cursor-pointer hover:opacity-60", onClick: onClear, children: jsx(IconElement, { accessor: "times", className: "text-gray-500" }) })), htmlType === 'date' && isClearable && (jsx("div", { className: "right-10 px-2 absolute cursor-pointer hover:opacity-60", onClick: onClear, children: jsx(IconElement, { accessor: "times", className: "text-gray-500" }) }))] }))), htmlType === 'area' && (jsx("textarea", { rows: rows, name: name, id: name, className: styles.input, placeholder: placeholder, defaultValue: isSolo ? value : undefined, value: isSolo ? undefined : value, maxLength: maxLength, disabled: isDisabled, onChange: onChange, onBlur: onBlur })), type === 'floored' && (jsx("div", { className: "absolute inset-x-0 bottom-0 border-t border-gray-300 peer-focus:border-t-2 peer-focus:border-primary-600", "aria-hidden": "true" })), trailing && isValid && (jsx("div", { className: styles.trailing, children: trailing })), isTouched && !isValid && (jsx("div", { className: styles.trailing, children: invalidIcon }))] }), jsxs("div", { className: styles.foot, children: [description && !(error && isTouched) && (jsx("p", { className: styles.description, children: description })), error && isTouched && jsx("p", { className: styles.error, children: error })] })] }));
|
|
718
721
|
};
|
|
719
722
|
|
|
720
723
|
var base$k = {
|
|
@@ -1203,13 +1206,13 @@ var PanelPaginationNavigation = function (props) {
|
|
|
1203
1206
|
}, [onChange]);
|
|
1204
1207
|
var pageType = useMemo(function () {
|
|
1205
1208
|
var result = 'center';
|
|
1206
|
-
if (current < min +
|
|
1209
|
+
if (current < min + 2) {
|
|
1207
1210
|
result = 'first';
|
|
1208
1211
|
}
|
|
1209
|
-
if (current > max -
|
|
1212
|
+
if (current > max - 2) {
|
|
1210
1213
|
result = 'last';
|
|
1211
1214
|
}
|
|
1212
|
-
if (max <=
|
|
1215
|
+
if (max <= 4) {
|
|
1213
1216
|
result = 'simple';
|
|
1214
1217
|
}
|
|
1215
1218
|
return result;
|
|
@@ -1220,13 +1223,13 @@ var PanelPaginationNavigation = function (props) {
|
|
|
1220
1223
|
component = (jsxs(Fragment$1, { children: [jsx("button", { className: toClassName(styles.button.default, current === min && styles.button.active), onClick: function () { return handleChangeCurrent(min); }, children: min }), jsx("button", { className: toClassName(styles.button.default, current === min + 1 && styles.button.active), onClick: function () { return handleChangeCurrent(min + 1); }, children: min + 1 }), jsx("button", { className: toClassName(styles.button.default, current === min + 2 && styles.button.active), onClick: function () { return handleChangeCurrent(min + 2); }, children: min + 2 }), jsx("span", { className: styles.divider, children: "..." }), jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(max); }, children: max })] }));
|
|
1221
1224
|
break;
|
|
1222
1225
|
case 'center':
|
|
1223
|
-
component = (jsxs(Fragment$1, { children: [jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(min); }, children: min }), jsx("span", { className: styles.divider, children: "..." }), jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(current - 1); }, children: current - 1 }), jsx("button", { className: toClassName(styles.button.default, styles.button.active), onClick: function () { return handleChangeCurrent(current); }, children: current }), jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(current + 1); }, children: current + 1 }), jsx("span", { className: styles.divider, children: "..." }), jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(max); }, children: max })] }));
|
|
1226
|
+
component = (jsxs(Fragment$1, { children: [jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(min); }, children: min }), current - 2 !== min && jsx("span", { className: styles.divider, children: "..." }), jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(current - 1); }, children: current - 1 }), jsx("button", { className: toClassName(styles.button.default, styles.button.active), onClick: function () { return handleChangeCurrent(current); }, children: current }), jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(current + 1); }, children: current + 1 }), current + 2 !== max && jsx("span", { className: styles.divider, children: "..." }), jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(max); }, children: max })] }));
|
|
1224
1227
|
break;
|
|
1225
1228
|
case 'last':
|
|
1226
1229
|
component = (jsxs(Fragment$1, { children: [jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(min); }, children: min }), jsx("span", { className: styles.divider, children: "..." }), jsx("button", { className: toClassName(styles.button.default, current === max - 2 && styles.button.active), onClick: function () { return handleChangeCurrent(max - 2); }, children: max - 2 }), jsx("button", { className: toClassName(styles.button.default, current === max - 1 && styles.button.active), onClick: function () { return handleChangeCurrent(max - 1); }, children: max - 1 }), jsx("button", { className: toClassName(styles.button.default, current === max && styles.button.active), onClick: function () { return handleChangeCurrent(max); }, children: max })] }));
|
|
1227
1230
|
break;
|
|
1228
1231
|
case 'simple':
|
|
1229
|
-
component = (jsxs(Fragment$1, { children: [jsx("button", { className: toClassName(styles.button.default, current === min && styles.button.active), onClick: function () { return handleChangeCurrent(min); }, children: min }), max >= min + 1 && (jsx("button", { className: toClassName(styles.button.default, current === min + 1 && styles.button.active), onClick: function () { return handleChangeCurrent(min + 1); }, children: min + 1 })), max >= min + 2 && (jsx("button", { className: toClassName(styles.button.default, current === min + 2 && styles.button.active), onClick: function () { return handleChangeCurrent(min + 2); }, children: min + 2 }))] }));
|
|
1232
|
+
component = (jsxs(Fragment$1, { children: [jsx("button", { className: toClassName(styles.button.default, current === min && styles.button.active), onClick: function () { return handleChangeCurrent(min); }, children: min }), max >= min + 1 && (jsx("button", { className: toClassName(styles.button.default, current === min + 1 && styles.button.active), onClick: function () { return handleChangeCurrent(min + 1); }, children: min + 1 })), max >= min + 2 && (jsx("button", { className: toClassName(styles.button.default, current === min + 2 && styles.button.active), onClick: function () { return handleChangeCurrent(min + 2); }, children: min + 2 })), max >= min + 3 && (jsx("button", { className: toClassName(styles.button.default, current === min + 3 && styles.button.active), onClick: function () { return handleChangeCurrent(min + 3); }, children: min + 3 }))] }));
|
|
1230
1233
|
break;
|
|
1231
1234
|
}
|
|
1232
1235
|
return (jsxs("div", { className: styles.container, children: [jsxs("div", { className: "flex flex-1 justify-between sm:hidden", children: [jsx("button", { className: toClassName(styles.mobile.button, current === min && styles.button.disabled), disabled: current === min, onClick: function () { return handleChangeCurrent(current - 1); }, children: "Previous" }), jsx("button", { className: toClassName(styles.mobile.button, current === max && styles.button.disabled), disabled: current === max, onClick: function () { return handleChangeCurrent(current + 1); }, children: "Next" })] }), jsxs("div", { className: styles.desktop.container, children: [jsx("div", { children: jsx("div", { className: "text-sm text-gray-700", children: children && children({ min: min, max: max, current: current }) }) }), jsx("div", { children: jsxs("nav", { className: styles.desktop.navigation, "aria-label": "Pagination", children: [jsxs("button", { className: toClassName(styles.desktop.leftButton, current === min && styles.button.disabled), disabled: current === min, onClick: function () { return handleChangeCurrent(current - 1); }, children: [jsx("span", { className: styles.label, children: "Previous" }), jsx(ChevronLeftIcon, { className: styles.icon, "aria-hidden": "true" })] }), component, jsxs("button", { className: toClassName(styles.desktop.rightButton, current === max && styles.button.disabled), disabled: current === max, onClick: function () { return handleChangeCurrent(current + 1); }, children: [jsx("span", { className: styles.label, children: "Next" }), jsx(ChevronRightIcon, { className: styles.icon, "aria-hidden": "true" })] })] }) })] })] }));
|
|
@@ -1879,12 +1882,15 @@ var PagePaginationNavigation = function (props) {
|
|
|
1879
1882
|
var styles = handleGenerateStyle();
|
|
1880
1883
|
var pageType = useMemo(function () {
|
|
1881
1884
|
var result = 'center';
|
|
1882
|
-
if (current < min +
|
|
1885
|
+
if (current < min + 2) {
|
|
1883
1886
|
result = 'first';
|
|
1884
1887
|
}
|
|
1885
|
-
if (current > max -
|
|
1888
|
+
if (current > max - 2) {
|
|
1886
1889
|
result = 'last';
|
|
1887
1890
|
}
|
|
1891
|
+
if (max <= 4) {
|
|
1892
|
+
result = 'simple';
|
|
1893
|
+
}
|
|
1888
1894
|
return result;
|
|
1889
1895
|
}, [current, min, max]);
|
|
1890
1896
|
var component;
|
|
@@ -1893,11 +1899,14 @@ var PagePaginationNavigation = function (props) {
|
|
|
1893
1899
|
component = (jsxs(Fragment$1, { children: [jsx("button", { className: toClassName(styles.button.default, current === min && styles.button.active), onClick: function () { return setCurrent(min); }, children: min }), jsx("button", { className: toClassName(styles.button.default, current === min + 1 && styles.button.active), onClick: function () { return setCurrent(min + 1); }, children: min + 1 }), jsx("button", { className: toClassName(styles.button.default, current === min + 2 && styles.button.active), onClick: function () { return setCurrent(min + 2); }, children: min + 2 }), jsx("span", { className: styles.divider, children: "..." }), jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(max); }, children: max })] }));
|
|
1894
1900
|
break;
|
|
1895
1901
|
case 'center':
|
|
1896
|
-
component = (jsxs(Fragment$1, { children: [jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(min); }, children: min }), jsx("span", { className: styles.divider, children: "..." }), jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(current - 1); }, children: current - 1 }), jsx("button", { className: toClassName(styles.button.default, styles.button.active), onClick: function () { return setCurrent(current); }, children: current }), jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(current + 1); }, children: current + 1 }), jsx("span", { className: styles.divider, children: "..." }), jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(max); }, children: max })] }));
|
|
1902
|
+
component = (jsxs(Fragment$1, { children: [jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(min); }, children: min }), current - 2 !== min && jsx("span", { className: styles.divider, children: "..." }), jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(current - 1); }, children: current - 1 }), jsx("button", { className: toClassName(styles.button.default, styles.button.active), onClick: function () { return setCurrent(current); }, children: current }), jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(current + 1); }, children: current + 1 }), current + 2 !== max && jsx("span", { className: styles.divider, children: "..." }), jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(max); }, children: max })] }));
|
|
1897
1903
|
break;
|
|
1898
1904
|
case 'last':
|
|
1899
1905
|
component = (jsxs(Fragment$1, { children: [jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(min); }, children: min }), jsx("span", { className: styles.divider, children: "..." }), jsx("button", { className: toClassName(styles.button.default, current === max - 2 && styles.button.active), onClick: function () { return setCurrent(max - 2); }, children: max - 2 }), jsx("button", { className: toClassName(styles.button.default, current === max - 1 && styles.button.active), onClick: function () { return setCurrent(max - 1); }, children: max - 1 }), jsx("button", { className: toClassName(styles.button.default, current === max && styles.button.active), onClick: function () { return setCurrent(max); }, children: max })] }));
|
|
1900
1906
|
break;
|
|
1907
|
+
case 'simple':
|
|
1908
|
+
component = (jsxs(Fragment$1, { children: [jsx("button", { className: toClassName(styles.button.default, current === min && styles.button.active), onClick: function () { return setCurrent(min); }, children: min }), max >= min + 1 && (jsx("button", { className: toClassName(styles.button.default, current === min + 1 && styles.button.active), onClick: function () { return setCurrent(min + 1); }, children: min + 1 })), max >= min + 2 && (jsx("button", { className: toClassName(styles.button.default, current === min + 2 && styles.button.active), onClick: function () { return setCurrent(min + 2); }, children: min + 2 })), max >= min + 3 && (jsx("button", { className: toClassName(styles.button.default, current === min + 3 && styles.button.active), onClick: function () { return setCurrent(min + 3); }, children: min + 3 }))] }));
|
|
1909
|
+
break;
|
|
1901
1910
|
}
|
|
1902
1911
|
useEffect(function () {
|
|
1903
1912
|
if (current) {
|
|
@@ -2614,15 +2623,16 @@ var DateMenuForm = function (props) {
|
|
|
2614
2623
|
return isEmpty ? (jsx(IconElement, { accessor: "calendar" })) : (jsx(IconElement, { accessor: "xmark", className: "text-black" }));
|
|
2615
2624
|
} : _h, required = props.required, defaultValue = props.value, error = props.error, _j = props.type, type = _j === void 0 ? 'normal' : _j, _k = props.isRequired, isRequired = _k === void 0 ? false : _k, _l = props.isTouched, isTouched = _l === void 0 ? false : _l, isDisabled = props.isDisabled, _m = props.isSolo, isSolo = _m === void 0 ? false : _m, _o = props.isRanged, isRanged = _o === void 0 ? false : _o, onChange = props.onChange, onClear = props.onClear, onBlur = props.onBlur, stylesOverrides = props.styles;
|
|
2616
2625
|
var isValid = error === undefined;
|
|
2617
|
-
var _p = useState(
|
|
2618
|
-
var _q = useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : {
|
|
2626
|
+
var _p = useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : {
|
|
2619
2627
|
startDate: null,
|
|
2620
2628
|
endDate: null,
|
|
2621
|
-
}), state =
|
|
2629
|
+
}), state = _p[0], setState = _p[1];
|
|
2622
2630
|
var handleValueChange = function (newValue) {
|
|
2623
2631
|
setState(newValue);
|
|
2624
2632
|
onChange && onChange(newValue);
|
|
2625
|
-
|
|
2633
|
+
setTimeout(function () {
|
|
2634
|
+
onBlur && onBlur();
|
|
2635
|
+
}, 50);
|
|
2626
2636
|
};
|
|
2627
2637
|
var handleGenerateStyle = function () {
|
|
2628
2638
|
var result = deepCopyObject(styles$5.base);
|
|
@@ -2640,13 +2650,6 @@ var DateMenuForm = function (props) {
|
|
|
2640
2650
|
}
|
|
2641
2651
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2642
2652
|
}, [state]);
|
|
2643
|
-
// Simulate onBlur event.
|
|
2644
|
-
useEffect(function () {
|
|
2645
|
-
if (!isFocus) {
|
|
2646
|
-
onBlur && onBlur();
|
|
2647
|
-
}
|
|
2648
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2649
|
-
}, [isFocus]);
|
|
2650
2653
|
return (jsxs("div", { className: styles.container, children: [jsxs("div", { className: styles.head, children: [label && (jsx("label", { htmlFor: name, className: styles.label, children: label })), !required && !isRequired && typeof label === 'string' && (jsx("span", { className: styles.hint, children: "Optional" })), required && required({ isRequired: isRequired })] }), jsxs("div", { className: styles.container, children: [jsx(Datepicker, { inputName: name, inputId: name, i18n: i18n, useRange: size === 'expanded', placeholder: placeholder, asSingle: !isRanged, separator: separator, startFrom: startFrom, displayFormat: displayFormat, disabled: isDisabled, popoverDirection: direction, minDate: minDate, maxDate: maxDate, toggleIcon: icon,
|
|
2651
2654
|
//
|
|
2652
2655
|
value: state,
|