@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.js
CHANGED
|
@@ -140,11 +140,13 @@ var toClassName = function () {
|
|
|
140
140
|
}
|
|
141
141
|
return values.filter(Boolean).join(' ');
|
|
142
142
|
};
|
|
143
|
-
var fromSelectMenuOptionToStringValue = function (
|
|
144
|
-
if (
|
|
145
|
-
return
|
|
143
|
+
var fromSelectMenuOptionToStringValue = function (value) {
|
|
144
|
+
if (value === null)
|
|
145
|
+
return null;
|
|
146
|
+
if (lodash.isArray(value)) {
|
|
147
|
+
return lodash.map(value, 'value');
|
|
146
148
|
}
|
|
147
|
-
return
|
|
149
|
+
return value === null || value === void 0 ? void 0 : value.value;
|
|
148
150
|
};
|
|
149
151
|
|
|
150
152
|
var deepCopyObject = function (object) {
|
|
@@ -715,8 +717,9 @@ var InputGroupForm = function (props) {
|
|
|
715
717
|
};
|
|
716
718
|
var styles = handleGenerateStyle();
|
|
717
719
|
var invalidIcon = (jsxRuntime.jsx(solid.ExclamationCircleIcon, { className: "h-5 w-5 text-red-500", "aria-hidden": "true" }));
|
|
720
|
+
var isClearable = !trailing && isValid && onClear && value !== '' && value;
|
|
718
721
|
return (jsxRuntime.jsxs("div", { className: styles.container, children: [jsxRuntime.jsxs("div", { className: styles.head, children: [label && (jsxRuntime.jsx("label", { htmlFor: name, className: styles.label, children: label })), !required && !isRequired && typeof label === 'string' && (jsxRuntime.jsx("span", { className: styles.hint, children: "Optional" })), required && required({ isRequired: isRequired })] }), jsxRuntime.jsxs("div", { className: styles.body, children: [leading && jsxRuntime.jsx("div", { className: styles.leading, children: leading }), !htmlType ||
|
|
719
|
-
(htmlType !== 'area' && (jsxRuntime.jsxs("div", { className: "flex items-center", children: [jsxRuntime.jsx("input", { type: mask$1 !== undefined ? 'text' : htmlType, ref: mask$1 && 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' &&
|
|
722
|
+
(htmlType !== 'area' && (jsxRuntime.jsxs("div", { className: "flex items-center", children: [jsxRuntime.jsx("input", { type: mask$1 !== undefined ? 'text' : htmlType, ref: mask$1 && 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 && (jsxRuntime.jsx("div", { className: "right-5 px-2 absolute cursor-pointer hover:opacity-60", onClick: onClear, children: jsxRuntime.jsx(IconElement, { accessor: "times", className: "text-gray-500" }) })), htmlType === 'date' && isClearable && (jsxRuntime.jsx("div", { className: "right-10 px-2 absolute cursor-pointer hover:opacity-60", onClick: onClear, children: jsxRuntime.jsx(IconElement, { accessor: "times", className: "text-gray-500" }) }))] }))), htmlType === 'area' && (jsxRuntime.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' && (jsxRuntime.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 && (jsxRuntime.jsx("div", { className: styles.trailing, children: trailing })), isTouched && !isValid && (jsxRuntime.jsx("div", { className: styles.trailing, children: invalidIcon }))] }), jsxRuntime.jsxs("div", { className: styles.foot, children: [description && !(error && isTouched) && (jsxRuntime.jsx("p", { className: styles.description, children: description })), error && isTouched && jsxRuntime.jsx("p", { className: styles.error, children: error })] })] }));
|
|
720
723
|
};
|
|
721
724
|
|
|
722
725
|
var base$k = {
|
|
@@ -1205,13 +1208,13 @@ var PanelPaginationNavigation = function (props) {
|
|
|
1205
1208
|
}, [onChange]);
|
|
1206
1209
|
var pageType = React.useMemo(function () {
|
|
1207
1210
|
var result = 'center';
|
|
1208
|
-
if (current < min +
|
|
1211
|
+
if (current < min + 2) {
|
|
1209
1212
|
result = 'first';
|
|
1210
1213
|
}
|
|
1211
|
-
if (current > max -
|
|
1214
|
+
if (current > max - 2) {
|
|
1212
1215
|
result = 'last';
|
|
1213
1216
|
}
|
|
1214
|
-
if (max <=
|
|
1217
|
+
if (max <= 4) {
|
|
1215
1218
|
result = 'simple';
|
|
1216
1219
|
}
|
|
1217
1220
|
return result;
|
|
@@ -1222,13 +1225,13 @@ var PanelPaginationNavigation = function (props) {
|
|
|
1222
1225
|
component = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === min && styles.button.active), onClick: function () { return handleChangeCurrent(min); }, children: min }), jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === min + 1 && styles.button.active), onClick: function () { return handleChangeCurrent(min + 1); }, children: min + 1 }), jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === min + 2 && styles.button.active), onClick: function () { return handleChangeCurrent(min + 2); }, children: min + 2 }), jsxRuntime.jsx("span", { className: styles.divider, children: "..." }), jsxRuntime.jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(max); }, children: max })] }));
|
|
1223
1226
|
break;
|
|
1224
1227
|
case 'center':
|
|
1225
|
-
component = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(min); }, children: min }), jsxRuntime.jsx("span", { className: styles.divider, children: "..." }), jsxRuntime.jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(current - 1); }, children: current - 1 }), jsxRuntime.jsx("button", { className: toClassName(styles.button.default, styles.button.active), onClick: function () { return handleChangeCurrent(current); }, children: current }), jsxRuntime.jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(current + 1); }, children: current + 1 }), jsxRuntime.jsx("span", { className: styles.divider, children: "..." }), jsxRuntime.jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(max); }, children: max })] }));
|
|
1228
|
+
component = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(min); }, children: min }), current - 2 !== min && jsxRuntime.jsx("span", { className: styles.divider, children: "..." }), jsxRuntime.jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(current - 1); }, children: current - 1 }), jsxRuntime.jsx("button", { className: toClassName(styles.button.default, styles.button.active), onClick: function () { return handleChangeCurrent(current); }, children: current }), jsxRuntime.jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(current + 1); }, children: current + 1 }), current + 2 !== max && jsxRuntime.jsx("span", { className: styles.divider, children: "..." }), jsxRuntime.jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(max); }, children: max })] }));
|
|
1226
1229
|
break;
|
|
1227
1230
|
case 'last':
|
|
1228
1231
|
component = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { className: styles.button.default, onClick: function () { return handleChangeCurrent(min); }, children: min }), jsxRuntime.jsx("span", { className: styles.divider, children: "..." }), jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === max - 2 && styles.button.active), onClick: function () { return handleChangeCurrent(max - 2); }, children: max - 2 }), jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === max - 1 && styles.button.active), onClick: function () { return handleChangeCurrent(max - 1); }, children: max - 1 }), jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === max && styles.button.active), onClick: function () { return handleChangeCurrent(max); }, children: max })] }));
|
|
1229
1232
|
break;
|
|
1230
1233
|
case 'simple':
|
|
1231
|
-
component = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === min && styles.button.active), onClick: function () { return handleChangeCurrent(min); }, children: min }), max >= min + 1 && (jsxRuntime.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 && (jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === min + 2 && styles.button.active), onClick: function () { return handleChangeCurrent(min + 2); }, children: min + 2 }))] }));
|
|
1234
|
+
component = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === min && styles.button.active), onClick: function () { return handleChangeCurrent(min); }, children: min }), max >= min + 1 && (jsxRuntime.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 && (jsxRuntime.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 && (jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === min + 3 && styles.button.active), onClick: function () { return handleChangeCurrent(min + 3); }, children: min + 3 }))] }));
|
|
1232
1235
|
break;
|
|
1233
1236
|
}
|
|
1234
1237
|
return (jsxRuntime.jsxs("div", { className: styles.container, children: [jsxRuntime.jsxs("div", { className: "flex flex-1 justify-between sm:hidden", children: [jsxRuntime.jsx("button", { className: toClassName(styles.mobile.button, current === min && styles.button.disabled), disabled: current === min, onClick: function () { return handleChangeCurrent(current - 1); }, children: "Previous" }), jsxRuntime.jsx("button", { className: toClassName(styles.mobile.button, current === max && styles.button.disabled), disabled: current === max, onClick: function () { return handleChangeCurrent(current + 1); }, children: "Next" })] }), jsxRuntime.jsxs("div", { className: styles.desktop.container, children: [jsxRuntime.jsx("div", { children: jsxRuntime.jsx("div", { className: "text-sm text-gray-700", children: children && children({ min: min, max: max, current: current }) }) }), jsxRuntime.jsx("div", { children: jsxRuntime.jsxs("nav", { className: styles.desktop.navigation, "aria-label": "Pagination", children: [jsxRuntime.jsxs("button", { className: toClassName(styles.desktop.leftButton, current === min && styles.button.disabled), disabled: current === min, onClick: function () { return handleChangeCurrent(current - 1); }, children: [jsxRuntime.jsx("span", { className: styles.label, children: "Previous" }), jsxRuntime.jsx(solid.ChevronLeftIcon, { className: styles.icon, "aria-hidden": "true" })] }), component, jsxRuntime.jsxs("button", { className: toClassName(styles.desktop.rightButton, current === max && styles.button.disabled), disabled: current === max, onClick: function () { return handleChangeCurrent(current + 1); }, children: [jsxRuntime.jsx("span", { className: styles.label, children: "Next" }), jsxRuntime.jsx(solid.ChevronRightIcon, { className: styles.icon, "aria-hidden": "true" })] })] }) })] })] }));
|
|
@@ -1881,12 +1884,15 @@ var PagePaginationNavigation = function (props) {
|
|
|
1881
1884
|
var styles = handleGenerateStyle();
|
|
1882
1885
|
var pageType = React.useMemo(function () {
|
|
1883
1886
|
var result = 'center';
|
|
1884
|
-
if (current < min +
|
|
1887
|
+
if (current < min + 2) {
|
|
1885
1888
|
result = 'first';
|
|
1886
1889
|
}
|
|
1887
|
-
if (current > max -
|
|
1890
|
+
if (current > max - 2) {
|
|
1888
1891
|
result = 'last';
|
|
1889
1892
|
}
|
|
1893
|
+
if (max <= 4) {
|
|
1894
|
+
result = 'simple';
|
|
1895
|
+
}
|
|
1890
1896
|
return result;
|
|
1891
1897
|
}, [current, min, max]);
|
|
1892
1898
|
var component;
|
|
@@ -1895,11 +1901,14 @@ var PagePaginationNavigation = function (props) {
|
|
|
1895
1901
|
component = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === min && styles.button.active), onClick: function () { return setCurrent(min); }, children: min }), jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === min + 1 && styles.button.active), onClick: function () { return setCurrent(min + 1); }, children: min + 1 }), jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === min + 2 && styles.button.active), onClick: function () { return setCurrent(min + 2); }, children: min + 2 }), jsxRuntime.jsx("span", { className: styles.divider, children: "..." }), jsxRuntime.jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(max); }, children: max })] }));
|
|
1896
1902
|
break;
|
|
1897
1903
|
case 'center':
|
|
1898
|
-
component = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(min); }, children: min }), jsxRuntime.jsx("span", { className: styles.divider, children: "..." }), jsxRuntime.jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(current - 1); }, children: current - 1 }), jsxRuntime.jsx("button", { className: toClassName(styles.button.default, styles.button.active), onClick: function () { return setCurrent(current); }, children: current }), jsxRuntime.jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(current + 1); }, children: current + 1 }), jsxRuntime.jsx("span", { className: styles.divider, children: "..." }), jsxRuntime.jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(max); }, children: max })] }));
|
|
1904
|
+
component = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(min); }, children: min }), current - 2 !== min && jsxRuntime.jsx("span", { className: styles.divider, children: "..." }), jsxRuntime.jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(current - 1); }, children: current - 1 }), jsxRuntime.jsx("button", { className: toClassName(styles.button.default, styles.button.active), onClick: function () { return setCurrent(current); }, children: current }), jsxRuntime.jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(current + 1); }, children: current + 1 }), current + 2 !== max && jsxRuntime.jsx("span", { className: styles.divider, children: "..." }), jsxRuntime.jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(max); }, children: max })] }));
|
|
1899
1905
|
break;
|
|
1900
1906
|
case 'last':
|
|
1901
1907
|
component = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { className: styles.button.default, onClick: function () { return setCurrent(min); }, children: min }), jsxRuntime.jsx("span", { className: styles.divider, children: "..." }), jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === max - 2 && styles.button.active), onClick: function () { return setCurrent(max - 2); }, children: max - 2 }), jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === max - 1 && styles.button.active), onClick: function () { return setCurrent(max - 1); }, children: max - 1 }), jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === max && styles.button.active), onClick: function () { return setCurrent(max); }, children: max })] }));
|
|
1902
1908
|
break;
|
|
1909
|
+
case 'simple':
|
|
1910
|
+
component = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === min && styles.button.active), onClick: function () { return setCurrent(min); }, children: min }), max >= min + 1 && (jsxRuntime.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 && (jsxRuntime.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 && (jsxRuntime.jsx("button", { className: toClassName(styles.button.default, current === min + 3 && styles.button.active), onClick: function () { return setCurrent(min + 3); }, children: min + 3 }))] }));
|
|
1911
|
+
break;
|
|
1903
1912
|
}
|
|
1904
1913
|
React.useEffect(function () {
|
|
1905
1914
|
if (current) {
|
|
@@ -2616,15 +2625,16 @@ var DateMenuForm = function (props) {
|
|
|
2616
2625
|
return isEmpty ? (jsxRuntime.jsx(IconElement, { accessor: "calendar" })) : (jsxRuntime.jsx(IconElement, { accessor: "xmark", className: "text-black" }));
|
|
2617
2626
|
} : _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;
|
|
2618
2627
|
var isValid = error === undefined;
|
|
2619
|
-
var _p = React.useState(
|
|
2620
|
-
var _q = React.useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : {
|
|
2628
|
+
var _p = React.useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : {
|
|
2621
2629
|
startDate: null,
|
|
2622
2630
|
endDate: null,
|
|
2623
|
-
}), state =
|
|
2631
|
+
}), state = _p[0], setState = _p[1];
|
|
2624
2632
|
var handleValueChange = function (newValue) {
|
|
2625
2633
|
setState(newValue);
|
|
2626
2634
|
onChange && onChange(newValue);
|
|
2627
|
-
|
|
2635
|
+
setTimeout(function () {
|
|
2636
|
+
onBlur && onBlur();
|
|
2637
|
+
}, 50);
|
|
2628
2638
|
};
|
|
2629
2639
|
var handleGenerateStyle = function () {
|
|
2630
2640
|
var result = deepCopyObject(styles$5.base);
|
|
@@ -2642,13 +2652,6 @@ var DateMenuForm = function (props) {
|
|
|
2642
2652
|
}
|
|
2643
2653
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2644
2654
|
}, [state]);
|
|
2645
|
-
// Simulate onBlur event.
|
|
2646
|
-
React.useEffect(function () {
|
|
2647
|
-
if (!isFocus) {
|
|
2648
|
-
onBlur && onBlur();
|
|
2649
|
-
}
|
|
2650
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2651
|
-
}, [isFocus]);
|
|
2652
2655
|
return (jsxRuntime.jsxs("div", { className: styles.container, children: [jsxRuntime.jsxs("div", { className: styles.head, children: [label && (jsxRuntime.jsx("label", { htmlFor: name, className: styles.label, children: label })), !required && !isRequired && typeof label === 'string' && (jsxRuntime.jsx("span", { className: styles.hint, children: "Optional" })), required && required({ isRequired: isRequired })] }), jsxRuntime.jsxs("div", { className: styles.container, children: [jsxRuntime.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,
|
|
2653
2656
|
//
|
|
2654
2657
|
value: state,
|