@dynamic-framework/ui-react 1.8.1 → 1.9.1
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/css/dynamic-ui-non-root.css +8 -2
- package/dist/css/dynamic-ui-non-root.min.css +1 -1
- package/dist/css/dynamic-ui.css +8 -2
- package/dist/css/dynamic-ui.min.css +1 -1
- package/dist/index.esm.js +38 -35
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +38 -35
- package/dist/index.js.map +1 -1
- package/dist/types/hooks/useInputCurrency.d.ts +1 -1
- package/package.json +5 -3
- package/src/style/components/_d-input.scss +7 -0
- package/src/style/components/_d-paginator.scss +1 -1
- package/src/style/components/_d-popover.scss +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -93,12 +93,7 @@ function DSummaryCard({ title, description, icon, iconSize, iconTheme, Summary,
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
function DAlert({ type = 'light', icon, iconFamilyClass, iconFamilyPrefix, showIcon = false, showClose, onClose, children, id, className, style, }) {
|
|
96
|
-
const generateClasses = useMemo(() => ({
|
|
97
|
-
alert: true,
|
|
98
|
-
[`alert-${type}`]: true,
|
|
99
|
-
'fade show': !!showClose,
|
|
100
|
-
className: !!className,
|
|
101
|
-
}), [type, showClose, className]);
|
|
96
|
+
const generateClasses = useMemo(() => (Object.assign({ alert: true, [`alert-${type}`]: true, 'fade show': !!showClose }, className && { [className]: true })), [type, showClose, className]);
|
|
102
97
|
const getIcon = useMemo(() => icon || ALERT_TYPE_ICON[type] || '', [icon, type]);
|
|
103
98
|
const generateStyleVariables = useMemo(() => (Object.assign(Object.assign(Object.assign({}, style), { [`--${PREFIX_BS}alert-component-separator-opacity`]: '0.3' }), type === 'light' && {
|
|
104
99
|
[`--${PREFIX_BS}alert-component-icon-color`]: `var(--${PREFIX_BS}secondary)`,
|
|
@@ -611,37 +606,27 @@ const ForwardedDInputCounter = forwardRef(DInputCounter);
|
|
|
611
606
|
ForwardedDInputCounter.displayName = 'DInputCounter';
|
|
612
607
|
var DInputCounter$1 = ForwardedDInputCounter;
|
|
613
608
|
|
|
609
|
+
function formatValue(value, currencyOptions) {
|
|
610
|
+
if (value === undefined) {
|
|
611
|
+
return '';
|
|
612
|
+
}
|
|
613
|
+
return currency(value, Object.assign(Object.assign({}, currencyOptions), { symbol: '' })).format();
|
|
614
|
+
}
|
|
614
615
|
function useInputCurrency(currencyOptions, value, onFocus, onChange, onBlur, ref) {
|
|
615
616
|
const inputRef = useProvidedRefOrCreate(ref);
|
|
616
|
-
const valueFormatted = useMemo(() => {
|
|
617
|
-
if (value === undefined) {
|
|
618
|
-
return '';
|
|
619
|
-
}
|
|
620
|
-
return currency(value, Object.assign(Object.assign({}, currencyOptions), { symbol: '' })).format();
|
|
621
|
-
}, [currencyOptions, value]);
|
|
622
|
-
const [innerValue, setInnerValue] = useState(valueFormatted);
|
|
623
617
|
const [innerType, setInnerType] = useState('text');
|
|
618
|
+
const [innerNumber, setInnerNumber] = useState(value);
|
|
619
|
+
const [innerString, setInnerString] = useState(formatValue(value, currencyOptions));
|
|
624
620
|
const handleOnFocus = useCallback((event) => {
|
|
625
621
|
event.stopPropagation();
|
|
626
|
-
|
|
627
|
-
if (event.currentTarget.value) {
|
|
628
|
-
const currencyValue = currency(event.currentTarget.value, Object.assign(Object.assign({}, currencyOptions), { symbol: '' }));
|
|
629
|
-
setInnerValue((currencyValue.intValue / 100).toString());
|
|
630
|
-
}
|
|
631
|
-
setInnerType('number');
|
|
632
|
-
}
|
|
622
|
+
setInnerType('number');
|
|
633
623
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
634
|
-
}, [
|
|
624
|
+
}, [onFocus]);
|
|
635
625
|
const handleOnBlur = useCallback((event) => {
|
|
636
626
|
event.stopPropagation();
|
|
637
|
-
|
|
638
|
-
setInnerType('text');
|
|
639
|
-
if (event.currentTarget.value) {
|
|
640
|
-
setInnerValue(currency(event.currentTarget.value, Object.assign(Object.assign({}, currencyOptions), { symbol: '' })).format());
|
|
641
|
-
}
|
|
642
|
-
}
|
|
627
|
+
setInnerType('text');
|
|
643
628
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
644
|
-
}, [
|
|
629
|
+
}, [onBlur]);
|
|
645
630
|
const handleOnWheel = useCallback((event) => {
|
|
646
631
|
var _a;
|
|
647
632
|
event.stopPropagation();
|
|
@@ -655,12 +640,27 @@ function useInputCurrency(currencyOptions, value, onFocus, onChange, onBlur, ref
|
|
|
655
640
|
color: `var(--${PREFIX_BS}m-input-currency-symbol-color)`,
|
|
656
641
|
}), []);
|
|
657
642
|
const handleOnChange = useCallback((newValue) => {
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
643
|
+
const newNumber = (newValue === undefined || newValue === '')
|
|
644
|
+
? undefined
|
|
645
|
+
: Number(newValue);
|
|
646
|
+
setInnerNumber(newNumber);
|
|
647
|
+
setInnerString(formatValue(newNumber, currencyOptions));
|
|
648
|
+
}, [currencyOptions]);
|
|
661
649
|
useEffect(() => {
|
|
662
|
-
|
|
663
|
-
}, [
|
|
650
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(innerNumber);
|
|
651
|
+
}, [onChange, innerNumber]);
|
|
652
|
+
useEffect(() => {
|
|
653
|
+
setInnerNumber(value);
|
|
654
|
+
}, [value]);
|
|
655
|
+
const innerValue = useMemo(() => {
|
|
656
|
+
if (value === undefined || value.toString() === '') {
|
|
657
|
+
return '';
|
|
658
|
+
}
|
|
659
|
+
const valueToUse = innerType === 'number'
|
|
660
|
+
? innerNumber === null || innerNumber === void 0 ? void 0 : innerNumber.toString()
|
|
661
|
+
: innerString;
|
|
662
|
+
return valueToUse !== null && valueToUse !== void 0 ? valueToUse : '';
|
|
663
|
+
}, [value, innerType, innerNumber, innerString]);
|
|
664
664
|
return {
|
|
665
665
|
inputRef,
|
|
666
666
|
innerValue,
|
|
@@ -956,7 +956,7 @@ function DPopover({ children, renderComponent, isOpen, setEventIsOpen, adjustCon
|
|
|
956
956
|
setEventIsOpen(value);
|
|
957
957
|
}
|
|
958
958
|
}, [setEventIsOpen]);
|
|
959
|
-
const { refs, floatingStyles, context } = useFloating({
|
|
959
|
+
const { refs, floatingStyles, context, } = useFloating({
|
|
960
960
|
open: innerIsOpen,
|
|
961
961
|
onOpenChange,
|
|
962
962
|
middleware: [
|
|
@@ -975,7 +975,10 @@ function DPopover({ children, renderComponent, isOpen, setEventIsOpen, adjustCon
|
|
|
975
975
|
role,
|
|
976
976
|
]);
|
|
977
977
|
const headingId = useId();
|
|
978
|
-
|
|
978
|
+
const generateStyleVariables = useMemo(() => (Object.assign(Object.assign({}, style), adjustContentToRender && {
|
|
979
|
+
[`--${PREFIX_BS}popover-component-min-width`]: 'auto',
|
|
980
|
+
})), [style, adjustContentToRender]);
|
|
981
|
+
return (jsxs("div", { className: classNames('d-popover', className), style: generateStyleVariables, children: [jsx("div", Object.assign({ ref: refs.setReference }, getReferenceProps(), { children: renderComponent(innerIsOpen) })), innerIsOpen && (jsx(FloatingFocusManager, { context: context, modal: false, children: jsx("div", Object.assign({ className: classNames('d-popover-content', {
|
|
979
982
|
'w-100': adjustContentToRender,
|
|
980
983
|
}), ref: refs.setFloating, style: floatingStyles, "aria-labelledby": headingId }, getFloatingProps(), { children: children })) }))] }));
|
|
981
984
|
}
|