@ballistix.digital/react-components 0.3.3 → 0.4.0
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.d.ts +8 -2
- package/dist/index.esm.js +47 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +46 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -126,6 +126,7 @@ declare const base$d: {
|
|
|
126
126
|
input: string;
|
|
127
127
|
trailing: string;
|
|
128
128
|
description: string;
|
|
129
|
+
error: string;
|
|
129
130
|
};
|
|
130
131
|
type TInputGroupStyles = DeepPartial$1<typeof base$d>;
|
|
131
132
|
|
|
@@ -138,11 +139,16 @@ type TProps$b = {
|
|
|
138
139
|
leading?: string;
|
|
139
140
|
trailing?: string;
|
|
140
141
|
value: string;
|
|
142
|
+
map?: string;
|
|
143
|
+
error?: string;
|
|
141
144
|
type: 'normal' | 'inset' | 'overlapping' | 'pill' | 'floored';
|
|
142
145
|
isValid?: boolean;
|
|
143
146
|
isDisabled?: boolean;
|
|
144
147
|
isRequired?: boolean;
|
|
148
|
+
isTouched?: boolean;
|
|
149
|
+
isSolo?: boolean;
|
|
145
150
|
onChange: any;
|
|
151
|
+
onBlur: any;
|
|
146
152
|
styles?: TInputGroupStyles;
|
|
147
153
|
};
|
|
148
154
|
declare const InputGroupForm: FC<TProps$b>;
|
|
@@ -547,8 +553,8 @@ type TProps$2 = {
|
|
|
547
553
|
}) => ReactNode;
|
|
548
554
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
549
555
|
styles?: TModalOverlayStyles;
|
|
550
|
-
onOpen
|
|
551
|
-
onClose
|
|
556
|
+
onOpen?: () => void;
|
|
557
|
+
onClose?: () => void;
|
|
552
558
|
};
|
|
553
559
|
declare const ModalOverlay: FC<TProps$2>;
|
|
554
560
|
|
package/dist/index.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
|
2
2
|
import { ArrowPathIcon, ExclamationCircleIcon, CheckIcon, ChevronDownIcon, EllipsisVerticalIcon, ChevronLeftIcon, ChevronRightIcon, HomeIcon, ArrowLongLeftIcon, ArrowLongRightIcon } from '@heroicons/react/20/solid';
|
|
3
3
|
import { set, get } from 'lodash';
|
|
4
4
|
import get$1 from 'lodash/get';
|
|
5
|
-
import React, { Children, Fragment, useState, useCallback, useMemo
|
|
5
|
+
import React, { Children, Fragment, useState, useEffect, useCallback, useMemo } from 'react';
|
|
6
6
|
import { Menu, Transition, Dialog } from '@headlessui/react';
|
|
7
7
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
8
8
|
import { ViewColumnsIcon, ChevronDownIcon as ChevronDownIcon$1, TableCellsIcon } from '@heroicons/react/24/outline';
|
|
@@ -502,8 +502,36 @@ var IconElement = function (props) {
|
|
|
502
502
|
return component;
|
|
503
503
|
};
|
|
504
504
|
|
|
505
|
+
var useMappedValue = function (format) {
|
|
506
|
+
var _a = useState(''), mappedValue = _a[0], setMappedValue = _a[1];
|
|
507
|
+
useEffect(function () {
|
|
508
|
+
setMappedValue('');
|
|
509
|
+
}, [format]);
|
|
510
|
+
var handleMapValue = function (inputValue) {
|
|
511
|
+
var strippedValue = inputValue.replace(/\D/g, ''); // remove all non-numeric characters
|
|
512
|
+
var formattedNumber = '';
|
|
513
|
+
var valueIndex = 0;
|
|
514
|
+
for (var i = 0; i < format.length; i++) {
|
|
515
|
+
if (format[i] === 'X') {
|
|
516
|
+
if (valueIndex >= strippedValue.length) {
|
|
517
|
+
break;
|
|
518
|
+
}
|
|
519
|
+
formattedNumber += strippedValue[valueIndex];
|
|
520
|
+
valueIndex++;
|
|
521
|
+
}
|
|
522
|
+
else {
|
|
523
|
+
formattedNumber += format[i];
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
setMappedValue(formattedNumber);
|
|
527
|
+
};
|
|
528
|
+
return [mappedValue, handleMapValue];
|
|
529
|
+
};
|
|
530
|
+
|
|
505
531
|
var InputGroupForm = function (props) {
|
|
506
|
-
var name = props.name, _a = props.htmlType, htmlType = _a === void 0 ? 'text' : _a, label = props.label, description = props.description, placeholder = props.placeholder, leading = props.leading, trailing = props.trailing, value = props.value, _b = props.type, type = _b === void 0 ? 'normal' : _b, _c = props.
|
|
532
|
+
var name = props.name, _a = props.htmlType, htmlType = _a === void 0 ? 'text' : _a, label = props.label, description = props.description, placeholder = props.placeholder, leading = props.leading, trailing = props.trailing, value = props.value, map = props.map, error = props.error, _b = props.type, type = _b === void 0 ? 'normal' : _b, isDisabled = props.isDisabled, isRequired = props.isRequired, isTouched = props.isTouched, _c = props.isSolo, isSolo = _c === void 0 ? false : _c, onChange = props.onChange, onBlur = props.onBlur, stylesOverrides = props.styles;
|
|
533
|
+
var _d = useMappedValue(map !== null && map !== void 0 ? map : ''), mappedValue = _d[0], setMappedValue = _d[1];
|
|
534
|
+
var isValid = error === undefined;
|
|
507
535
|
var handleGenerateStyle = function () {
|
|
508
536
|
var result = deepCopyObject(styles$e.base);
|
|
509
537
|
var keys = calculateNestedKeys(styles$e.base);
|
|
@@ -514,7 +542,19 @@ var InputGroupForm = function (props) {
|
|
|
514
542
|
};
|
|
515
543
|
var styles = handleGenerateStyle();
|
|
516
544
|
var invalidIcon = (jsx(ExclamationCircleIcon, { className: "h-5 w-5 text-red-500", "aria-hidden": "true" }));
|
|
517
|
-
return (jsxs("div", __assign({ className: styles.container }, { children: [jsxs("div", __assign({ className: styles.head }, { children: [label && (jsx("label", __assign({ htmlFor: name, className: styles.label }, { children: label }))), !isRequired && jsx("span", __assign({ className: styles.hint }, { children: "Optional" }))] })), jsxs("div", __assign({ className: styles.body }, { children: [leading && jsx("div", __assign({ className: styles.leading }, { children: leading })), jsx("input", { type: htmlType, name: name, id: name, className: styles.input, placeholder: placeholder, defaultValue:
|
|
545
|
+
return (jsxs("div", __assign({ className: styles.container }, { children: [jsxs("div", __assign({ className: styles.head }, { children: [label && (jsx("label", __assign({ htmlFor: name, className: styles.label }, { children: label }))), !isRequired && jsx("span", __assign({ className: styles.hint }, { children: "Optional" }))] })), jsxs("div", __assign({ className: styles.body }, { children: [leading && jsx("div", __assign({ className: styles.leading }, { children: leading })), jsx("input", { type: htmlType, name: name, id: name, className: styles.input, placeholder: placeholder, defaultValue: isSolo ? value : undefined, value: isSolo ? undefined : value, disabled: isDisabled, onChange: function (e) {
|
|
546
|
+
if (map) {
|
|
547
|
+
setMappedValue(e.currentTarget.value);
|
|
548
|
+
}
|
|
549
|
+
onChange(e);
|
|
550
|
+
}, onBlur: function (e) {
|
|
551
|
+
if (map) {
|
|
552
|
+
var result = e.currentTarget;
|
|
553
|
+
result.value = mappedValue;
|
|
554
|
+
onChange(result);
|
|
555
|
+
}
|
|
556
|
+
onBlur(e);
|
|
557
|
+
} }), 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", __assign({ className: styles.trailing }, { children: trailing }))), !isValid && jsx("div", __assign({ className: styles.trailing }, { children: invalidIcon }))] })), jsxs("div", __assign({ className: styles.foot }, { children: [description && !error && (jsx("p", __assign({ className: styles.description }, { children: description }))), error && isTouched && jsx("p", __assign({ className: styles.error }, { children: error }))] }))] })));
|
|
518
558
|
};
|
|
519
559
|
|
|
520
560
|
var base$d = {
|
|
@@ -527,7 +567,8 @@ var base$d = {
|
|
|
527
567
|
leading: 'pointer-events-none absolute inset-y-0 left-0 flex items-center',
|
|
528
568
|
input: 'block w-full',
|
|
529
569
|
trailing: 'pointer-events-none absolute inset-y-0 right-0 flex items-center',
|
|
530
|
-
description: 'text-gray-
|
|
570
|
+
description: 'text-gray-400 text-xs mt-1',
|
|
571
|
+
error: 'text-red-500 text-xs ml-5 mt-1',
|
|
531
572
|
};
|
|
532
573
|
var leading = {
|
|
533
574
|
input: 'pl-10',
|
|
@@ -17532,12 +17573,12 @@ var ModalOverlay = function (props) {
|
|
|
17532
17573
|
var styles = handleGenerateStyle();
|
|
17533
17574
|
useEffect(function () {
|
|
17534
17575
|
if (isOpen) {
|
|
17535
|
-
onOpen();
|
|
17576
|
+
onOpen && onOpen();
|
|
17536
17577
|
}
|
|
17537
17578
|
}, [isOpen, onOpen]);
|
|
17538
17579
|
useEffect(function () {
|
|
17539
17580
|
if (!isOpen) {
|
|
17540
|
-
onClose();
|
|
17581
|
+
onClose && onClose();
|
|
17541
17582
|
}
|
|
17542
17583
|
}, [isOpen, onClose]);
|
|
17543
17584
|
return (jsxs(Fragment$1, { children: [jsx(Transition.Root, __assign({ show: isOpen, as: Fragment }, { children: jsxs(Dialog, __assign({ as: "div", className: styles.container, onClose: setIsOpen }, { children: [jsx(Transition.Child, __assign({ as: Fragment, enter: styles.background.transition.enter, enterFrom: styles.background.transition.enterFrom, enterTo: styles.background.transition.enterTo, leave: styles.background.transition.leave, leaveFrom: styles.background.transition.leaveFrom, leaveTo: styles.background.transition.leaveTo }, { children: jsx("div", { className: styles.background.container }) })), jsx("div", __assign({ className: styles.layout.container }, { children: jsx("div", __assign({ className: styles.layout.content }, { children: jsx(Transition.Child, __assign({ as: Fragment, enter: styles.panel.transition.enter, enterFrom: styles.panel.transition.enterFrom, enterTo: styles.panel.transition.enterTo, leave: styles.panel.transition.leave, leaveFrom: styles.panel.transition.leaveFrom, leaveTo: styles.panel.transition.leaveTo }, { children: jsx(Dialog.Panel, __assign({ className: styles.panel.container }, { children: children(options) })) })) })) }))] })) })), trigger && trigger(options)] }));
|