@dynamic-framework/ui-react 2.0.0-dev.3 → 2.0.0-dev.5
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 +294 -46
- package/dist/css/dynamic-ui-non-root.min.css +3 -3
- package/dist/css/dynamic-ui-root.css +2 -2
- package/dist/css/dynamic-ui-root.min.css +2 -2
- package/dist/css/dynamic-ui.css +294 -46
- package/dist/css/dynamic-ui.min.css +3 -3
- package/dist/index.esm.js +234 -25
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +268 -57
- package/dist/index.js.map +1 -1
- package/dist/types/components/DButton/DButton.d.ts +7 -17
- package/dist/types/components/DInputCheck/DInputCheck.d.ts +2 -1
- package/dist/types/components/DInputMask/DInputMask.d.ts +7 -17
- package/dist/types/components/DInputSwitch/DInputSwitch.d.ts +2 -1
- package/dist/types/components/DLayout/DLayout.d.ts +2 -1
- package/dist/types/components/DPasswordStrengthMeter/DPasswordStrengthMeter.d.ts +23 -0
- package/dist/types/components/DPasswordStrengthMeter/PasswordCheckItem.d.ts +7 -0
- package/dist/types/components/DPasswordStrengthMeter/PasswordCheckList.d.ts +14 -0
- package/dist/types/components/DPasswordStrengthMeter/PasswordStrength.d.ts +6 -0
- package/dist/types/components/DPasswordStrengthMeter/index.d.ts +3 -0
- package/dist/types/components/DVoucher/DVoucher.d.ts +14 -0
- package/dist/types/components/DVoucher/hooks/useScreenshot.d.ts +5 -0
- package/dist/types/components/DVoucher/hooks/useScreenshotDownload.d.ts +5 -0
- package/dist/types/components/DVoucher/hooks/useScreenshotWebShare.d.ts +5 -0
- package/dist/types/components/DVoucher/index.d.ts +2 -0
- package/dist/types/components/index.d.ts +3 -0
- package/jest/setup.js +0 -2
- package/package.json +35 -29
- package/src/style/abstracts/_utilities.scss +19 -0
- package/src/style/abstracts/variables/_buttons.scss +2 -0
- package/src/style/base/_buttons.scss +56 -65
- package/src/style/components/_+import.scss +1 -0
- package/src/style/components/_d-voucher.scss +30 -0
package/dist/index.js
CHANGED
|
@@ -18,6 +18,7 @@ var react = require('@floating-ui/react');
|
|
|
18
18
|
var reactHotToast = require('react-hot-toast');
|
|
19
19
|
var reactInternationalPhone = require('react-international-phone');
|
|
20
20
|
var googleLibphonenumber = require('google-libphonenumber');
|
|
21
|
+
var html2canvas = require('html2canvas');
|
|
21
22
|
var i18n = require('i18next');
|
|
22
23
|
var reactI18next = require('react-i18next');
|
|
23
24
|
|
|
@@ -889,26 +890,59 @@ function DBoxFile(_a) {
|
|
|
889
890
|
: children })] })) })), !!files.length && (jsxRuntime.jsx("ul", { className: "d-box-files", children: files.map((file, index) => (jsxRuntime.jsx(ForwardedDInput, { value: file.name, iconStart: "paperclip", iconEnd: "trash", readOnly: true, onIconEndClick: () => handleRemoveFile(index) }, `${file.name} ${index}`))) }))] }));
|
|
890
891
|
}
|
|
891
892
|
|
|
892
|
-
|
|
893
|
-
const
|
|
893
|
+
const DButton = React.forwardRef((props, ref) => {
|
|
894
|
+
const { color = 'primary', size, variant, text, children, iconStart, iconStartFamilyClass, iconStartFamilyPrefix, iconStartMaterialStyle, iconEnd, iconEndFamilyClass, iconEndFamilyPrefix, iconEndMaterialStyle, loading = false, loadingText, loadingAriaLabel, disabled = false, className, style, dataAttributes, onClick, type = 'button' } = props, rest = tslib.__rest(props, ["color", "size", "variant", "text", "children", "iconStart", "iconStartFamilyClass", "iconStartFamilyPrefix", "iconStartMaterialStyle", "iconEnd", "iconEndFamilyClass", "iconEndFamilyPrefix", "iconEndMaterialStyle", "loading", "loadingText", "loadingAriaLabel", "disabled", "className", "style", "dataAttributes", "onClick", "type"]);
|
|
895
|
+
const [buttonWidth, setButtonWidth] = React.useState();
|
|
896
|
+
const buttonRef = React.useRef(null);
|
|
897
|
+
const isDisabled = React.useMemo(() => disabled || loading, [disabled, loading]);
|
|
898
|
+
const content = React.useMemo(() => children || text, [children, text]);
|
|
899
|
+
const classes = React.useMemo(() => {
|
|
894
900
|
const variantClass = variant
|
|
895
901
|
? `btn-${variant}-${color}`
|
|
896
902
|
: `btn-${color}`;
|
|
897
|
-
return
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
903
|
+
return {
|
|
904
|
+
btn: true,
|
|
905
|
+
[variantClass]: true,
|
|
906
|
+
[`btn-${size}`]: !!size,
|
|
907
|
+
loading,
|
|
908
|
+
};
|
|
909
|
+
}, [variant, color, size, loading]);
|
|
910
|
+
const ariaLabel = React.useMemo(() => {
|
|
911
|
+
const ariaLabelProp = rest['aria-label'];
|
|
912
|
+
return loading
|
|
913
|
+
? loadingAriaLabel || ariaLabelProp || text
|
|
914
|
+
: ariaLabelProp || text;
|
|
915
|
+
}, [loading, loadingAriaLabel, rest, text]);
|
|
916
|
+
const handleClick = React.useCallback((event) => {
|
|
917
|
+
if (disabled || loading) {
|
|
918
|
+
event.preventDefault();
|
|
919
|
+
return;
|
|
902
920
|
}
|
|
903
921
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
904
|
-
}, [
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
922
|
+
}, [disabled, loading, onClick]);
|
|
923
|
+
React.useEffect(() => {
|
|
924
|
+
if (!loading && buttonRef.current) {
|
|
925
|
+
const width = buttonRef.current.offsetWidth;
|
|
926
|
+
if (width > 0)
|
|
927
|
+
setButtonWidth(width);
|
|
928
|
+
}
|
|
929
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
930
|
+
}, [content, iconEnd, iconStart]);
|
|
931
|
+
return (jsxRuntime.jsxs("button", Object.assign({ ref: (node) => {
|
|
932
|
+
buttonRef.current = node;
|
|
933
|
+
if (typeof ref === 'function')
|
|
934
|
+
ref(node);
|
|
935
|
+
// eslint-disable-next-line max-len
|
|
936
|
+
// eslint-disable-next-line no-param-reassign, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
|
|
937
|
+
else if (ref)
|
|
938
|
+
ref.current = node;
|
|
939
|
+
},
|
|
940
|
+
// eslint-disable-next-line react/button-has-type
|
|
941
|
+
type: type, className: classNames(classes, className), style: Object.assign(Object.assign({}, style), (loading && buttonWidth
|
|
942
|
+
? { minWidth: `${buttonWidth}px` }
|
|
943
|
+
: undefined)), disabled: isDisabled, "aria-label": ariaLabel, "aria-busy": loading, "aria-disabled": isDisabled, onClick: handleClick }, dataAttributes, rest, { children: [loading && (jsxRuntime.jsxs("span", { className: "btn-loading", children: [jsxRuntime.jsx("span", { className: "spinner-border spinner-border-sm", "aria-hidden": "true" }), loadingText && jsxRuntime.jsx("span", { role: "status", children: loadingText })] })), !loading && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [iconStart && (jsxRuntime.jsx(DIcon, { icon: iconStart, familyClass: iconStartFamilyClass, familyPrefix: iconStartFamilyPrefix, materialStyle: iconStartMaterialStyle })), content, iconEnd && (jsxRuntime.jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix, materialStyle: iconEndMaterialStyle }))] }))] })));
|
|
944
|
+
});
|
|
945
|
+
DButton.displayName = 'DButton';
|
|
912
946
|
|
|
913
947
|
function DButtonIcon({ id, icon, size, className, variant, state, loadingAriaLabel, iconMaterialStyle, ariaLabel, color = 'primary', type = 'button', loading = false, disabled = false, stopPropagationEnabled = true, style, iconFamilyClass, iconFamilyPrefix, dataAttributes, onClick, }) {
|
|
914
948
|
const generateClasses = React.useMemo(() => {
|
|
@@ -944,10 +978,10 @@ function DCardFooter({ className, style, children, }) {
|
|
|
944
978
|
return (jsxRuntime.jsx("div", { className: classNames('card-footer', className), style: style, children: children }));
|
|
945
979
|
}
|
|
946
980
|
|
|
947
|
-
function DCard({ className, style, children, dataAttributes, }) {
|
|
981
|
+
function DCard$1({ className, style, children, dataAttributes, }) {
|
|
948
982
|
return (jsxRuntime.jsx("div", Object.assign({ style: style, className: classNames('card', className) }, dataAttributes, { children: children })));
|
|
949
983
|
}
|
|
950
|
-
var DCard
|
|
984
|
+
var DCard = Object.assign(DCard$1, {
|
|
951
985
|
Header: DCardHeader,
|
|
952
986
|
Body: DCardBody,
|
|
953
987
|
Footer: DCardFooter,
|
|
@@ -958,7 +992,7 @@ function DCarouselSlide(_a) {
|
|
|
958
992
|
return (jsxRuntime.jsx(reactSplide.SplideSlide, Object.assign({ className: classNames('d-carousel-slide', className) }, props)));
|
|
959
993
|
}
|
|
960
994
|
|
|
961
|
-
function DCarousel(_a, ref) {
|
|
995
|
+
function DCarousel$1(_a, ref) {
|
|
962
996
|
var { children, className, style, options, dataAttributes } = _a, props = tslib.__rest(_a, ["children", "className", "style", "options", "dataAttributes"]);
|
|
963
997
|
return (jsxRuntime.jsx(reactSplide.Splide, Object.assign({ className: classNames('d-carousel', className), style: style, ref: ref, options: Object.assign(Object.assign({}, options), { classes: {
|
|
964
998
|
// Arrows
|
|
@@ -971,9 +1005,9 @@ function DCarousel(_a, ref) {
|
|
|
971
1005
|
page: 'splide__pagination__page d-carousel-pagination-page',
|
|
972
1006
|
} }) }, dataAttributes, props, { children: children })));
|
|
973
1007
|
}
|
|
974
|
-
const ForwardedDCarousel = React.forwardRef(DCarousel);
|
|
1008
|
+
const ForwardedDCarousel = React.forwardRef(DCarousel$1);
|
|
975
1009
|
ForwardedDCarousel.displayName = 'DCarousel';
|
|
976
|
-
var DCarousel
|
|
1010
|
+
var DCarousel = Object.assign(ForwardedDCarousel, {
|
|
977
1011
|
Slide: DCarouselSlide,
|
|
978
1012
|
});
|
|
979
1013
|
|
|
@@ -1043,7 +1077,7 @@ const ForwardedDDatePickerInput = React.forwardRef(DDatePickerInput);
|
|
|
1043
1077
|
ForwardedDDatePickerInput.displayName = 'DDatePickerInput';
|
|
1044
1078
|
|
|
1045
1079
|
function DInputCheck(_a) {
|
|
1046
|
-
var { id: idProp, type, name, label, ariaLabel, checked = false, disabled = false, invalid = false, valid = false, indeterminate, value, hint, onChange, className, style, dataAttributes } = _a, props = tslib.__rest(_a, ["id", "type", "name", "label", "ariaLabel", "checked", "disabled", "invalid", "valid", "indeterminate", "value", "hint", "onChange", "className", "style", "dataAttributes"]);
|
|
1080
|
+
var { id: idProp, type, name, label, ariaLabel, checked = false, disabled = false, invalid = false, valid = false, indeterminate, inputClassName, value, hint, onChange, className, style, dataAttributes } = _a, props = tslib.__rest(_a, ["id", "type", "name", "label", "ariaLabel", "checked", "disabled", "invalid", "valid", "indeterminate", "inputClassName", "value", "hint", "onChange", "className", "style", "dataAttributes"]);
|
|
1047
1081
|
const innerRef = React.useRef(null);
|
|
1048
1082
|
const innerId = React.useId();
|
|
1049
1083
|
const id = React.useMemo(() => idProp || innerId, [idProp, innerId]);
|
|
@@ -1071,11 +1105,11 @@ function DInputCheck(_a) {
|
|
|
1071
1105
|
const inputComponent = React.useMemo(() => (jsxRuntime.jsx("input", Object.assign({ ref: innerRef, onChange: handleChange, className: classNames('form-check-input', {
|
|
1072
1106
|
'is-invalid': invalid,
|
|
1073
1107
|
'is-valid': valid,
|
|
1074
|
-
},
|
|
1108
|
+
}, inputClassName), style: style, id: id, disabled: disabled, type: type, name: name, value: value, "aria-label": ariaLabel }, ariaDescribedby && { 'aria-describedby': ariaDescribedby }, props))), [
|
|
1075
1109
|
handleChange,
|
|
1076
1110
|
invalid,
|
|
1077
1111
|
valid,
|
|
1078
|
-
|
|
1112
|
+
inputClassName,
|
|
1079
1113
|
style,
|
|
1080
1114
|
id,
|
|
1081
1115
|
disabled,
|
|
@@ -1089,7 +1123,7 @@ function DInputCheck(_a) {
|
|
|
1089
1123
|
if (!label) {
|
|
1090
1124
|
return inputComponent;
|
|
1091
1125
|
}
|
|
1092
|
-
return (jsxRuntime.jsxs("div", Object.assign({ className:
|
|
1126
|
+
return (jsxRuntime.jsxs("div", Object.assign({ className: classNames('form-check', className) }, dataAttributes, { children: [inputComponent, jsxRuntime.jsx("label", { className: "form-check-label", htmlFor: id, children: label }), hint && (jsxRuntime.jsx("div", { className: "form-text", id: `${id}Hint`, children: hint }))] })));
|
|
1093
1127
|
}
|
|
1094
1128
|
|
|
1095
1129
|
function DSelectOptionCheck(_a) {
|
|
@@ -1167,7 +1201,7 @@ function DSelectPlaceholder(_a) {
|
|
|
1167
1201
|
return (jsxRuntime.jsx(Select.components.Placeholder, Object.assign({ innerProps: innerProps, selectProps: selectProps }, props, { children: children })));
|
|
1168
1202
|
}
|
|
1169
1203
|
|
|
1170
|
-
function DSelect(_a) {
|
|
1204
|
+
function DSelect$1(_a) {
|
|
1171
1205
|
var { id: idProp, className, style, label, hint, iconFamilyClass, iconFamilyPrefix, iconStart, iconStartFamilyClass, iconStartFamilyPrefix, iconStartAriaLabel, iconStartTabIndex, iconEnd, iconEndFamilyClass, iconEndFamilyPrefix, iconEndAriaLabel, iconEndTabIndex, invalid, valid, menuWithMaxContent = false, disabled, clearable, loading, floatingLabel = false, rtl, searchable, multi, components, defaultValue, placeholder, onIconStartClick, onIconEndClick, dataAttributes } = _a, props = tslib.__rest(_a, ["id", "className", "style", "label", "hint", "iconFamilyClass", "iconFamilyPrefix", "iconStart", "iconStartFamilyClass", "iconStartFamilyPrefix", "iconStartAriaLabel", "iconStartTabIndex", "iconEnd", "iconEndFamilyClass", "iconEndFamilyPrefix", "iconEndAriaLabel", "iconEndTabIndex", "invalid", "valid", "menuWithMaxContent", "disabled", "clearable", "loading", "floatingLabel", "rtl", "searchable", "multi", "components", "defaultValue", "placeholder", "onIconStartClick", "onIconEndClick", "dataAttributes"]);
|
|
1172
1206
|
const innerId = React.useId();
|
|
1173
1207
|
const id = React.useMemo(() => idProp || innerId, [idProp, innerId]);
|
|
@@ -1193,7 +1227,7 @@ function DSelect(_a) {
|
|
|
1193
1227
|
'is-valid': valid,
|
|
1194
1228
|
}), classNamePrefix: "d-select", isDisabled: disabled || loading, isClearable: clearable, isLoading: loading, isRtl: rtl, isSearchable: searchable, isMulti: multi, defaultValue: defaultValue, placeholder: floatingLabel ? '' : placeholder, unstyled: true, components: Object.assign({ Placeholder: DSelectPlaceholder, DropdownIndicator: DSelectDropdownIndicator, ClearIndicator: DSelectClearIndicator, MultiValueRemove: DSelectMultiValueRemove, LoadingIndicator: DSelectLoadingIndicator }, components) }, props)), (iconEnd && !loading) && (jsxRuntime.jsx("button", { type: "button", className: "input-group-text", id: `${id}End`, onClick: handleOnIconEndClick, disabled: disabled || loading, "aria-label": iconEndAriaLabel, tabIndex: iconEndTabIndex, children: iconEnd && (jsxRuntime.jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix })) }))] }), hint && (jsxRuntime.jsx("div", { className: "form-text", id: `${id}Hint`, children: hint }))] })));
|
|
1195
1229
|
}
|
|
1196
|
-
var DSelect
|
|
1230
|
+
var DSelect = Object.assign(DSelect$1, {
|
|
1197
1231
|
OptionCheck: DSelectOptionCheck,
|
|
1198
1232
|
OptionIcon: DSelectOptionIcon,
|
|
1199
1233
|
SingleValueIconText: DSelectSingleValueIconText,
|
|
@@ -1242,9 +1276,9 @@ function DDatePickerHeaderSelector({ date, changeYear, changeMonth, decreaseMont
|
|
|
1242
1276
|
return (jsxRuntime.jsxs("div", { className: classNames('react-datepicker__header-selector react-datepicker__header-year-selector', className), style: style, children: [jsxRuntime.jsx(DButtonIcon, { icon: iconPrev || chevronLeft, size: iconSize, variant: "link", onClick: decreaseYear, disabled: prevYearButtonDisabled, ariaLabel: prevYearAriaLabel, className: "header-button" }), jsxRuntime.jsx("p", { children: `${startYear} - ${endYear}` }), jsxRuntime.jsx(DButtonIcon, { icon: iconNext || chevronRight, size: iconSize, variant: "link", onClick: increaseYear, disabled: nextYearButtonDisabled, ariaLabel: nextYearAriaLabel, className: "header-button" })] }));
|
|
1243
1277
|
}
|
|
1244
1278
|
if (pickerType === PickerType.Quarter || pickerType === PickerType.Month) {
|
|
1245
|
-
return (jsxRuntime.jsxs("div", { className: classNames(`react-datepicker__header-selector react-datepicker__header-${pickerType}-selector`, className), style: style, children: [jsxRuntime.jsx(DButtonIcon, { icon: iconPrev || chevronLeft, size: iconSize, variant: "link", onClick: decreaseYear, disabled: prevMonthButtonDisabled, ariaLabel: prevMonthAriaLabel, className: "header-button", style: { visibility: customHeaderCount === 0 ? 'visible' : 'hidden' } }), jsxRuntime.jsx("div", { className: "d-flex justify-content-center flex-grow-1", children: showHeaderSelectors ? (jsxRuntime.jsx(DSelect
|
|
1279
|
+
return (jsxRuntime.jsxs("div", { className: classNames(`react-datepicker__header-selector react-datepicker__header-${pickerType}-selector`, className), style: style, children: [jsxRuntime.jsx(DButtonIcon, { icon: iconPrev || chevronLeft, size: iconSize, variant: "link", onClick: decreaseYear, disabled: prevMonthButtonDisabled, ariaLabel: prevMonthAriaLabel, className: "header-button", style: { visibility: customHeaderCount === 0 ? 'visible' : 'hidden' } }), jsxRuntime.jsx("div", { className: "d-flex justify-content-center flex-grow-1", children: showHeaderSelectors ? (jsxRuntime.jsx(DSelect, { options: years, value: defaultYear, defaultValue: defaultYear, onChange: (year) => changeYear(Number(year === null || year === void 0 ? void 0 : year.value)), searchable: false })) : (jsxRuntime.jsx("p", { children: defaultYear === null || defaultYear === void 0 ? void 0 : defaultYear.label })) }), jsxRuntime.jsx(DButtonIcon, { icon: iconNext || chevronRight, size: iconSize, variant: "link", onClick: increaseYear, disabled: nextMonthButtonDisabled, ariaLabel: nextMonthAriaLabel, className: "header-button", style: { visibility: customHeaderCount === monthsShown - 1 ? 'visible' : 'hidden' } })] }));
|
|
1246
1280
|
}
|
|
1247
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: "datepicker-top-header", children: [showHeaderSelectors && (jsxRuntime.jsx("select", { value: defaultYear === null || defaultYear === void 0 ? void 0 : defaultYear.value, onChange: (e) => changeYear(Number(e.target.value)), className: "custom-year-selector", children: years.map((year) => (jsxRuntime.jsx("option", { value: year.value, children: year.label }, year.value))) })), jsxRuntime.jsx("h4", { className: "mb-0 fw-normal", children: dateFns.format(monthDate, 'LLLL, dd', { locale }) })] }), jsxRuntime.jsxs("div", { className: classNames('react-datepicker__header-selector react-datepicker__header-day-selector', className), style: style, children: [jsxRuntime.jsx(DButtonIcon, { icon: iconPrev || chevronLeft, size: iconSize, variant: "link", onClick: decreaseMonth, disabled: prevMonthButtonDisabled, ariaLabel: prevMonthAriaLabel, className: "header-button", style: { visibility: customHeaderCount === 0 ? 'visible' : 'hidden' } }), showHeaderSelectors ? (jsxRuntime.jsx(DSelect
|
|
1281
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: "datepicker-top-header", children: [showHeaderSelectors && (jsxRuntime.jsx("select", { value: defaultYear === null || defaultYear === void 0 ? void 0 : defaultYear.value, onChange: (e) => changeYear(Number(e.target.value)), className: "custom-year-selector", children: years.map((year) => (jsxRuntime.jsx("option", { value: year.value, children: year.label }, year.value))) })), jsxRuntime.jsx("h4", { className: "mb-0 fw-normal", children: dateFns.format(monthDate, 'LLLL, dd', { locale }) })] }), jsxRuntime.jsxs("div", { className: classNames('react-datepicker__header-selector react-datepicker__header-day-selector', className), style: style, children: [jsxRuntime.jsx(DButtonIcon, { icon: iconPrev || chevronLeft, size: iconSize, variant: "link", onClick: decreaseMonth, disabled: prevMonthButtonDisabled, ariaLabel: prevMonthAriaLabel, className: "header-button", style: { visibility: customHeaderCount === 0 ? 'visible' : 'hidden' } }), showHeaderSelectors ? (jsxRuntime.jsx(DSelect, { options: months, value: defaultMonth, defaultValue: defaultMonth, onChange: (month) => changeMonth((month === null || month === void 0 ? void 0 : month.value) || 0), searchable: false, className: "custom-month-selector" })) : (jsxRuntime.jsx("p", { children: `${defaultMonth.label} ${defaultYear === null || defaultYear === void 0 ? void 0 : defaultYear.label}` })), jsxRuntime.jsx(DButtonIcon, { icon: iconNext || chevronRight, size: iconSize, variant: "link", onClick: increaseMonth, disabled: nextMonthButtonDisabled, ariaLabel: nextMonthAriaLabel, className: "header-button", style: { visibility: customHeaderCount === monthsShown - 1 ? 'visible' : 'hidden' } })] })] }));
|
|
1248
1282
|
}
|
|
1249
1283
|
|
|
1250
1284
|
function DDatePicker(_a) {
|
|
@@ -1289,7 +1323,7 @@ function DLayoutPane({ className, style, children, cols, colsXs, colsSm, colsMd,
|
|
|
1289
1323
|
return (jsxRuntime.jsx("div", Object.assign({ className: classNames(colsClass, colsXsClass, colsSmClass, colsMdClass, colsLgClass, colsXlClass, colsXxlClass, className), style: style }, dataAttributes, { children: children })));
|
|
1290
1324
|
}
|
|
1291
1325
|
|
|
1292
|
-
function DLayout({ className, style, children, gap, gapSm, gapMd, gapLg, gapXl, gapXxl, dataAttributes, }) {
|
|
1326
|
+
function DLayout$1({ className, style, children, gap, columns, gapSm, gapMd, gapLg, gapXl, gapXxl, dataAttributes, }) {
|
|
1293
1327
|
const gapClasses = classNames({
|
|
1294
1328
|
[`gap-${gap}`]: gap !== undefined,
|
|
1295
1329
|
[`gap-sm-${gapSm}`]: gapSm !== undefined,
|
|
@@ -1298,9 +1332,10 @@ function DLayout({ className, style, children, gap, gapSm, gapMd, gapLg, gapXl,
|
|
|
1298
1332
|
[`gap-xl-${gapXl}`]: gapXl !== undefined,
|
|
1299
1333
|
[`gap-xxl-${gapXxl}`]: gapXxl !== undefined,
|
|
1300
1334
|
});
|
|
1301
|
-
|
|
1335
|
+
const styleWithColumns = Object.assign(Object.assign({}, style), { '--bs-columns': columns });
|
|
1336
|
+
return (jsxRuntime.jsx("div", Object.assign({ style: styleWithColumns, className: classNames('grid', gapClasses, className) }, dataAttributes, { children: children })));
|
|
1302
1337
|
}
|
|
1303
|
-
var DLayout
|
|
1338
|
+
var DLayout = Object.assign(DLayout$1, {
|
|
1304
1339
|
Pane: DLayoutPane,
|
|
1305
1340
|
});
|
|
1306
1341
|
|
|
@@ -1512,6 +1547,86 @@ function DInputPassword(_a, ref) {
|
|
|
1512
1547
|
const ForwardedDInputPassword = React.forwardRef(DInputPassword);
|
|
1513
1548
|
ForwardedDInputPassword.displayName = 'DInputPassword';
|
|
1514
1549
|
|
|
1550
|
+
function PasswordCheckItem({ password, regex, text, }) {
|
|
1551
|
+
const isValid = regex.test(password);
|
|
1552
|
+
return (jsxRuntime.jsxs("li", { className: "d-flex gap-2 align-items-start small text-gray-600", children: [jsxRuntime.jsx(DIcon, { className: classNames('flex-shrink-0', isValid ? 'text-success' : 'text-gray-300'), icon: isValid ? 'CircleCheck' : 'Circle', size: "16px" }), jsxRuntime.jsx("span", { className: classNames({ 'text-success': isValid }), children: text })] }));
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
const getColorClass = (strength, total) => {
|
|
1556
|
+
const percentage = total > 0 ? strength / total : 0;
|
|
1557
|
+
if (percentage === 0)
|
|
1558
|
+
return 'bg-gray-200';
|
|
1559
|
+
if (percentage <= 0.25)
|
|
1560
|
+
return 'bg-danger';
|
|
1561
|
+
if (percentage <= 0.5)
|
|
1562
|
+
return 'bg-warning';
|
|
1563
|
+
if (percentage <= 0.75)
|
|
1564
|
+
return 'bg-info';
|
|
1565
|
+
return 'bg-success';
|
|
1566
|
+
};
|
|
1567
|
+
function PasswordStrengthBar({ strength, total }) {
|
|
1568
|
+
const percentage = total > 0 ? (strength / total) * 100 : 0;
|
|
1569
|
+
return (jsxRuntime.jsx("div", { className: "w-100 rounded-3 overflow-hidden bg-gray-100 mb-2", style: { height: '8px' }, children: jsxRuntime.jsx("div", { className: `h-100 ${getColorClass(strength, total)}`, style: {
|
|
1570
|
+
width: `${percentage}%`,
|
|
1571
|
+
transition: 'width 0.3s ease-in-out',
|
|
1572
|
+
} }) }));
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
const CHECK_REGEX = {
|
|
1576
|
+
uppercase: /[A-Z]/,
|
|
1577
|
+
lowercase: /[a-z]/,
|
|
1578
|
+
number: /\d/,
|
|
1579
|
+
specialChar: /[~!@#$^*\-_=[\]{}|;,.?]/,
|
|
1580
|
+
};
|
|
1581
|
+
function PasswordChecksList({ password, validationMessages, enabledChecks, }) {
|
|
1582
|
+
const allChecks = [
|
|
1583
|
+
{
|
|
1584
|
+
key: 'uppercase',
|
|
1585
|
+
regex: CHECK_REGEX.uppercase,
|
|
1586
|
+
text: validationMessages.uppercaseLetter,
|
|
1587
|
+
},
|
|
1588
|
+
{
|
|
1589
|
+
key: 'lowercase',
|
|
1590
|
+
regex: CHECK_REGEX.lowercase,
|
|
1591
|
+
text: validationMessages.lowercaseLetter,
|
|
1592
|
+
},
|
|
1593
|
+
{
|
|
1594
|
+
key: 'number',
|
|
1595
|
+
regex: CHECK_REGEX.number,
|
|
1596
|
+
text: validationMessages.number,
|
|
1597
|
+
},
|
|
1598
|
+
{
|
|
1599
|
+
key: 'specialChar',
|
|
1600
|
+
regex: CHECK_REGEX.specialChar,
|
|
1601
|
+
text: validationMessages.especialChar,
|
|
1602
|
+
},
|
|
1603
|
+
];
|
|
1604
|
+
const passwordChecks = allChecks.filter((check) => enabledChecks.includes(check.key));
|
|
1605
|
+
const passed = passwordChecks.filter((r) => r.regex.test(password)).length;
|
|
1606
|
+
const total = passwordChecks.length;
|
|
1607
|
+
return (jsxRuntime.jsxs("div", { className: "mt-2", children: [jsxRuntime.jsx(PasswordStrengthBar, { strength: passed, total: total }), jsxRuntime.jsx("ul", { className: "list-unstyled m-0 d-flex flex-column gap-2", children: passwordChecks.map(({ key, regex, text }) => (jsxRuntime.jsx(PasswordCheckItem, { password: password, regex: regex, text: text }, key))) })] }));
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
const DEFAULT_VALIDATION_MESSAGES = {
|
|
1611
|
+
number: 'At least one number',
|
|
1612
|
+
lowercaseLetter: 'At least one lowercase letter',
|
|
1613
|
+
uppercaseLetter: 'At least one uppercase letter',
|
|
1614
|
+
especialChar: 'At least one of these special characters: ~!@#$^*-_=[]{}|;,.?',
|
|
1615
|
+
notMatch: 'The password confirmation and the new password do not match.',
|
|
1616
|
+
};
|
|
1617
|
+
const DEFAULT_ENABLED_CHECKS = ['uppercase', 'lowercase', 'number', 'specialChar'];
|
|
1618
|
+
function DPasswordStrengthMeter({ id, label = 'Password', placeholder, value = '', name, disabled = false, invalid = false, validationMessages = DEFAULT_VALIDATION_MESSAGES, enabledChecks = DEFAULT_ENABLED_CHECKS, className, style, dataAttributes, onChange, }) {
|
|
1619
|
+
const [password, setPassword] = React.useState(value);
|
|
1620
|
+
React.useEffect(() => {
|
|
1621
|
+
setPassword(value);
|
|
1622
|
+
}, [value]);
|
|
1623
|
+
const handleChange = (newValue) => {
|
|
1624
|
+
setPassword(newValue);
|
|
1625
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
1626
|
+
};
|
|
1627
|
+
return (jsxRuntime.jsxs("div", Object.assign({ className: className, style: style }, dataAttributes, { children: [jsxRuntime.jsx(ForwardedDInputPassword, { id: id, label: label, placeholder: placeholder, value: password, name: name, disabled: disabled, invalid: invalid, onChange: handleChange }), jsxRuntime.jsx(PasswordChecksList, { password: password, validationMessages: validationMessages, enabledChecks: enabledChecks })] })));
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1515
1630
|
function DInputPin({ id: idProp, label = '', placeholder, type = 'text', disabled = false, loading = false, secret = false, characters = 4, innerInputMode = 'text', hint, invalid = false, valid = false, className, style, dataAttributes, onChange, }) {
|
|
1516
1631
|
const innerId = React.useId();
|
|
1517
1632
|
const id = React.useMemo(() => idProp || innerId, [idProp, innerId]);
|
|
@@ -1675,7 +1790,7 @@ function DInputSelect({ id: idProp, name, label = '', className, style, options
|
|
|
1675
1790
|
}), children: [iconStart && (jsxRuntime.jsx("button", { type: "button", className: "input-group-text", id: `${id}Start`, onClick: iconStartClickHandler, disabled: disabled || loading, "aria-label": iconStartAriaLabel, children: iconStart && (jsxRuntime.jsx(DIcon, { icon: iconStart, familyClass: iconStartFamilyClass, familyPrefix: iconStartFamilyPrefix })) })), dynamicComponent, iconEnd && !loading && (jsxRuntime.jsx("button", { type: "button", className: "input-group-text", id: `${id}End`, onClick: iconEndClickHandler, disabled: disabled || loading, "aria-label": iconEndAriaLabel, children: iconEnd && (jsxRuntime.jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix })) })), loading && (jsxRuntime.jsx("div", { className: "input-group-text form-control-icon loading", children: jsxRuntime.jsx("span", { className: "spinner-border spinner-border-sm", role: "status", "aria-hidden": "true", children: jsxRuntime.jsx("span", { className: "visually-hidden", children: "Loading..." }) }) }))] }), hint && (jsxRuntime.jsx("div", { className: "form-text", id: `${id}Hint`, children: hint }))] })));
|
|
1676
1791
|
}
|
|
1677
1792
|
|
|
1678
|
-
function DInputSwitch({ id: idProp, label, ariaLabel, name, checked, disabled, invalid = false, valid = false, readonly, className, style, dataAttributes, onChange, }) {
|
|
1793
|
+
function DInputSwitch({ id: idProp, label, ariaLabel, name, checked, disabled, invalid = false, valid = false, readonly, className, style, dataAttributes, inputClassName, onChange, }) {
|
|
1679
1794
|
const innerId = React.useId();
|
|
1680
1795
|
const id = React.useMemo(() => idProp || innerId, [idProp, innerId]);
|
|
1681
1796
|
const [internalIsChecked, setInternalIsChecked] = React.useState(checked);
|
|
@@ -1687,10 +1802,10 @@ function DInputSwitch({ id: idProp, label, ariaLabel, name, checked, disabled, i
|
|
|
1687
1802
|
setInternalIsChecked(value);
|
|
1688
1803
|
onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
1689
1804
|
}, [onChange]);
|
|
1690
|
-
return (jsxRuntime.jsxs("div", Object.assign({ className:
|
|
1805
|
+
return (jsxRuntime.jsxs("div", Object.assign({ className: classNames('form-check', className) }, dataAttributes, { children: [jsxRuntime.jsx("input", { id: id, name: name, onChange: readonly ? () => false : changeHandler, className: classNames('form-check-input', {
|
|
1691
1806
|
'is-invalid': invalid,
|
|
1692
1807
|
'is-valid': valid,
|
|
1693
|
-
},
|
|
1808
|
+
}, inputClassName), style: style, type: "checkbox", role: "switch", checked: internalIsChecked, disabled: disabled, "aria-label": ariaLabel }), label && (jsxRuntime.jsx("label", { className: "form-check-label", htmlFor: id, children: label }))] })));
|
|
1694
1809
|
}
|
|
1695
1810
|
|
|
1696
1811
|
function DInputRange(_a, ref) {
|
|
@@ -1762,7 +1877,7 @@ function DListGroupItem({ as = 'li', action: actionProp, active, disabled, href,
|
|
|
1762
1877
|
return (jsxRuntime.jsxs(Tag, Object.assign({ className: classNames(generateClasses, className), style: style }, Tag === 'a' && href && { href }, onClick && { onClick }, ariaAttributes, dataAttributes, Tag === 'button' && { type: 'button' }, { children: [iconStart && (jsxRuntime.jsx(DIcon, { icon: iconStart, familyClass: iconStartFamilyClass, familyPrefix: iconStartFamilyPrefix, materialStyle: iconStartMaterialStyle })), jsxRuntime.jsx("div", { className: "w-100", children: children }), iconEnd && (jsxRuntime.jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix, materialStyle: iconEndMaterialStyle, className: "ms-auto" }))] })));
|
|
1763
1878
|
}
|
|
1764
1879
|
|
|
1765
|
-
function DListGroup({ as = 'ul', numbered, flush, horizontal, children, className, style, dataAttributes, }) {
|
|
1880
|
+
function DListGroup$1({ as = 'ul', numbered, flush, horizontal, children, className, style, dataAttributes, }) {
|
|
1766
1881
|
const Tag = React.useMemo(() => {
|
|
1767
1882
|
if (numbered) {
|
|
1768
1883
|
return 'ol';
|
|
@@ -1782,7 +1897,7 @@ function DListGroup({ as = 'ul', numbered, flush, horizontal, children, classNam
|
|
|
1782
1897
|
}, [flush, horizontal, numbered]);
|
|
1783
1898
|
return (jsxRuntime.jsx(Tag, Object.assign({ className: classNames(generateClasses, className), style: style }, dataAttributes, { children: children })));
|
|
1784
1899
|
}
|
|
1785
|
-
var DListGroup
|
|
1900
|
+
var DListGroup = Object.assign(DListGroup$1, {
|
|
1786
1901
|
Item: DListGroupItem,
|
|
1787
1902
|
});
|
|
1788
1903
|
|
|
@@ -1804,7 +1919,7 @@ function DModalFooter({ className, style, actionPlacement, children, }) {
|
|
|
1804
1919
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "d-modal-separator" }), jsxRuntime.jsx("div", { className: classNames(generateClasses, className), style: style, children: children })] }));
|
|
1805
1920
|
}
|
|
1806
1921
|
|
|
1807
|
-
function DModal({ name, className, style, staticBackdrop, scrollable, centered, fullScreen, fullScreenFrom, size, children, dataAttributes, }) {
|
|
1922
|
+
function DModal$1({ name, className, style, staticBackdrop, scrollable, centered, fullScreen, fullScreenFrom, size, children, dataAttributes, }) {
|
|
1808
1923
|
const fullScreenClass = React.useMemo(() => {
|
|
1809
1924
|
if (fullScreen) {
|
|
1810
1925
|
if (fullScreenFrom) {
|
|
@@ -1820,7 +1935,7 @@ function DModal({ name, className, style, staticBackdrop, scrollable, centered,
|
|
|
1820
1935
|
[`data-${PREFIX_BS}keyboard`]: 'false',
|
|
1821
1936
|
}), dataAttributes, { children: jsxRuntime.jsx("div", { className: classNames(generateModalDialogClasses), children: jsxRuntime.jsx("div", { className: "modal-content", children: children }) }) })));
|
|
1822
1937
|
}
|
|
1823
|
-
var DModal
|
|
1938
|
+
var DModal = Object.assign(DModal$1, {
|
|
1824
1939
|
Header: DModalHeader,
|
|
1825
1940
|
Body: DModalBody,
|
|
1826
1941
|
Footer: DModalFooter,
|
|
@@ -1844,7 +1959,7 @@ function DOffcanvasFooter({ actionPlacement, children, className, style, }) {
|
|
|
1844
1959
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "d-offcanvas-separator" }), jsxRuntime.jsx("div", { className: classNames(generateClasses, className), style: style, children: children })] }));
|
|
1845
1960
|
}
|
|
1846
1961
|
|
|
1847
|
-
function DOffcanvas({ name, className, style, staticBackdrop, scrollable, openFrom = 'end', children, dataAttributes, }) {
|
|
1962
|
+
function DOffcanvas$1({ name, className, style, staticBackdrop, scrollable, openFrom = 'end', children, dataAttributes, }) {
|
|
1848
1963
|
return (jsxRuntime.jsx("div", Object.assign({ className: classNames('offcanvas portal show', {
|
|
1849
1964
|
[`offcanvas-${openFrom}`]: openFrom,
|
|
1850
1965
|
}, className), style: style, id: name, tabIndex: -1, "aria-labelledby": `${name}Label`, "aria-hidden": "false" }, staticBackdrop && ({
|
|
@@ -1855,7 +1970,7 @@ function DOffcanvas({ name, className, style, staticBackdrop, scrollable, openFr
|
|
|
1855
1970
|
[`data-${PREFIX_BS}keyboard`]: 'false',
|
|
1856
1971
|
}), dataAttributes, { children: children })));
|
|
1857
1972
|
}
|
|
1858
|
-
var DOffcanvas
|
|
1973
|
+
var DOffcanvas = Object.assign(DOffcanvas$1, {
|
|
1859
1974
|
Header: DOffcanvasHeader,
|
|
1860
1975
|
Body: DOffcanvasBody,
|
|
1861
1976
|
Footer: DOffcanvasFooter,
|
|
@@ -2028,7 +2143,7 @@ function DTabContent({ tab, children, className, style, }) {
|
|
|
2028
2143
|
return (jsxRuntime.jsx("div", { className: classNames('tab-pane fade show active', className), id: `${tab}Pane`, role: "tabpanel", tabIndex: 0, "aria-labelledby": `${tab}Tab`, style: style, children: children }));
|
|
2029
2144
|
}
|
|
2030
2145
|
|
|
2031
|
-
function DTabs({ children, defaultSelected, onChange, options, className, classNameTab, style, vertical, variant = 'underline', dataAttributes, }) {
|
|
2146
|
+
function DTabs$1({ children, defaultSelected, onChange, options, className, classNameTab, style, vertical, variant = 'underline', dataAttributes, }) {
|
|
2032
2147
|
const [selected, setSelected] = React.useState(defaultSelected);
|
|
2033
2148
|
const onSelect = React.useCallback((option) => {
|
|
2034
2149
|
if (option.tab) {
|
|
@@ -2051,7 +2166,7 @@ function DTabs({ children, defaultSelected, onChange, options, className, classN
|
|
|
2051
2166
|
active: option.tab === selected,
|
|
2052
2167
|
}, classNameTab), type: "button", role: "tab", "aria-controls": `${option.tab}Pane`, "aria-selected": option.tab === selected, disabled: option.disabled, onClick: () => onSelect(option), children: option.label }, option.tab))) }), jsxRuntime.jsx("div", { className: "tab-content w-100", children: children })] })) }));
|
|
2053
2168
|
}
|
|
2054
|
-
var DTabs
|
|
2169
|
+
var DTabs = Object.assign(DTabs$1, {
|
|
2055
2170
|
Tab: DTabContent,
|
|
2056
2171
|
});
|
|
2057
2172
|
|
|
@@ -2063,10 +2178,10 @@ function DToastBody({ children, className, style }) {
|
|
|
2063
2178
|
return (jsxRuntime.jsx("div", { className: classNames('toast-body', className), style: style, children: children }));
|
|
2064
2179
|
}
|
|
2065
2180
|
|
|
2066
|
-
function DToast({ children, className, style, dataAttributes, }) {
|
|
2181
|
+
function DToast$1({ children, className, style, dataAttributes, }) {
|
|
2067
2182
|
return (jsxRuntime.jsx("div", Object.assign({ className: classNames('toast', className), role: "alert", "aria-live": "assertive", "aria-atomic": "true", style: style }, dataAttributes, { children: children })));
|
|
2068
2183
|
}
|
|
2069
|
-
var DToast
|
|
2184
|
+
var DToast = Object.assign(DToast$1, {
|
|
2070
2185
|
Header: DToastHeader,
|
|
2071
2186
|
Body: DToastBody,
|
|
2072
2187
|
});
|
|
@@ -2087,13 +2202,13 @@ function useDToast() {
|
|
|
2087
2202
|
return null;
|
|
2088
2203
|
}
|
|
2089
2204
|
if (!description) {
|
|
2090
|
-
return (jsxRuntime.jsx(DToast
|
|
2205
|
+
return (jsxRuntime.jsx(DToast, { className: classNames({
|
|
2091
2206
|
[`toast-${color}`]: !!color,
|
|
2092
|
-
}, 'show'), children: jsxRuntime.jsxs(DToast
|
|
2207
|
+
}, 'show'), children: jsxRuntime.jsxs(DToast.Body, { children: [icon && (jsxRuntime.jsx(DIcon, { className: "toast-icon", icon: icon })), jsxRuntime.jsx("p", { className: "toast-title", children: title }), jsxRuntime.jsx("button", { type: "button", className: "d-close align-self-center", "aria-label": "Close", onClick: () => reactHotToast.toast.dismiss(id), children: jsxRuntime.jsx(DIcon, { icon: closeIcon || xLg }) })] }) }));
|
|
2093
2208
|
}
|
|
2094
|
-
return (jsxRuntime.jsxs(DToast
|
|
2209
|
+
return (jsxRuntime.jsxs(DToast, { className: classNames({
|
|
2095
2210
|
[`toast-${color}`]: !!color,
|
|
2096
|
-
}, 'show'), children: [jsxRuntime.jsxs(DToast
|
|
2211
|
+
}, 'show'), children: [jsxRuntime.jsxs(DToast.Header, { children: [icon && (jsxRuntime.jsx(DIcon, { className: "toast-icon", icon: icon })), jsxRuntime.jsx("p", { className: "toast-title", children: title }), timestamp && (jsxRuntime.jsx("small", { className: "toast-timestamp", children: timestamp })), jsxRuntime.jsx("button", { type: "button", className: "d-close align-self-center", "aria-label": "Close", onClick: () => reactHotToast.toast.dismiss(id), children: jsxRuntime.jsx(DIcon, { icon: closeIcon || xLg }) })] }), jsxRuntime.jsx(DToast.Body, { children: jsxRuntime.jsx("span", { children: description }) })] }));
|
|
2097
2212
|
}, toastProps);
|
|
2098
2213
|
}, [xLg]);
|
|
2099
2214
|
return {
|
|
@@ -2327,6 +2442,100 @@ function DDropdown({ actions, dropdownToggle, className, }) {
|
|
|
2327
2442
|
}) })] }));
|
|
2328
2443
|
}
|
|
2329
2444
|
|
|
2445
|
+
function useScreenshot() {
|
|
2446
|
+
const clipRef = React.useRef(null);
|
|
2447
|
+
const takeBlob = React.useCallback(async (type) => {
|
|
2448
|
+
if (!clipRef.current) {
|
|
2449
|
+
throw new Error('set the clipRef');
|
|
2450
|
+
}
|
|
2451
|
+
const canvas = await html2canvas(clipRef === null || clipRef === void 0 ? void 0 : clipRef.current, {
|
|
2452
|
+
allowTaint: true,
|
|
2453
|
+
useCORS: true,
|
|
2454
|
+
});
|
|
2455
|
+
return (new Promise((resolve, reject) => {
|
|
2456
|
+
canvas.toBlob((innerBlob) => {
|
|
2457
|
+
if (!innerBlob) {
|
|
2458
|
+
return reject();
|
|
2459
|
+
}
|
|
2460
|
+
return resolve(innerBlob);
|
|
2461
|
+
}, type);
|
|
2462
|
+
}));
|
|
2463
|
+
}, []);
|
|
2464
|
+
return {
|
|
2465
|
+
clipRef,
|
|
2466
|
+
takeBlob,
|
|
2467
|
+
};
|
|
2468
|
+
}
|
|
2469
|
+
|
|
2470
|
+
function useScreenshotDownload() {
|
|
2471
|
+
const { clipRef, takeBlob } = useScreenshot();
|
|
2472
|
+
const download = React.useCallback(async () => {
|
|
2473
|
+
const blob = await takeBlob();
|
|
2474
|
+
const url = window.URL.createObjectURL(blob);
|
|
2475
|
+
const link = window.document.createElement('a');
|
|
2476
|
+
link.style.display = 'none';
|
|
2477
|
+
link.href = url;
|
|
2478
|
+
link.download = 'voucher.jpg';
|
|
2479
|
+
document.body.appendChild(link);
|
|
2480
|
+
link.click();
|
|
2481
|
+
document.body.removeChild(link);
|
|
2482
|
+
window.URL.revokeObjectURL(url);
|
|
2483
|
+
}, [takeBlob]);
|
|
2484
|
+
return {
|
|
2485
|
+
download,
|
|
2486
|
+
downloadRef: clipRef,
|
|
2487
|
+
};
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
function useScreenshotWebShare() {
|
|
2491
|
+
const { takeBlob, clipRef } = useScreenshot();
|
|
2492
|
+
const share = React.useCallback(async () => {
|
|
2493
|
+
const blob = await takeBlob();
|
|
2494
|
+
const image = new File([blob], 'voucher.jpeg', { type: 'image/jpeg' });
|
|
2495
|
+
if (!navigator.canShare
|
|
2496
|
+
&& (navigator.canShare && !navigator.canShare({ files: [image] }))) {
|
|
2497
|
+
window.print();
|
|
2498
|
+
return;
|
|
2499
|
+
}
|
|
2500
|
+
await navigator.share({ files: [image] });
|
|
2501
|
+
}, [takeBlob]);
|
|
2502
|
+
return {
|
|
2503
|
+
share,
|
|
2504
|
+
shareRef: clipRef,
|
|
2505
|
+
};
|
|
2506
|
+
}
|
|
2507
|
+
|
|
2508
|
+
function DVoucher({ amount, amountDetails, icon = 'CircleCheckBig', color = 'success', title, onError, message, downloadText = 'Download', shareText = 'Share', children, }) {
|
|
2509
|
+
const { shareRef, share } = useScreenshotWebShare();
|
|
2510
|
+
const { downloadRef, download } = useScreenshotDownload();
|
|
2511
|
+
const handleShare = () => {
|
|
2512
|
+
share()
|
|
2513
|
+
.catch(async (err) => {
|
|
2514
|
+
if (onError) {
|
|
2515
|
+
await onError(err);
|
|
2516
|
+
}
|
|
2517
|
+
})
|
|
2518
|
+
.catch(() => {
|
|
2519
|
+
// Error already handled by onError
|
|
2520
|
+
});
|
|
2521
|
+
};
|
|
2522
|
+
const handleDownload = () => {
|
|
2523
|
+
download()
|
|
2524
|
+
.catch(async (err) => {
|
|
2525
|
+
if (onError) {
|
|
2526
|
+
await onError(err);
|
|
2527
|
+
}
|
|
2528
|
+
})
|
|
2529
|
+
.catch(() => {
|
|
2530
|
+
// Error already handled by onError
|
|
2531
|
+
});
|
|
2532
|
+
};
|
|
2533
|
+
return (jsxRuntime.jsx("div", { className: "d-voucher", ref: (el) => {
|
|
2534
|
+
shareRef.current = el;
|
|
2535
|
+
downloadRef.current = el;
|
|
2536
|
+
}, children: jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs("div", { className: "d-voucher-header", children: [jsxRuntime.jsx(DIcon, { icon: icon, color: color }), jsxRuntime.jsxs("div", { className: "text-center", children: [jsxRuntime.jsx("h3", { className: "mb-2", children: title }), jsxRuntime.jsx("p", { className: "m-0", children: message })] })] }), amount && (jsxRuntime.jsxs("div", { className: "d-voucher-amount", children: [jsxRuntime.jsx("div", { className: classNames('text-center fw-bold fs-3', amountDetails ? 'mb-1' : 'm-0'), children: amount }), amountDetails] })), jsxRuntime.jsx("hr", { className: "my-4" }), children, jsxRuntime.jsx("hr", { className: "my-4" }), jsxRuntime.jsxs("div", { className: "d-voucher-footer", children: [jsxRuntime.jsx(DButton, { onClick: handleShare, iconStart: "Share2", text: shareText, variant: "outline", size: "sm" }), jsxRuntime.jsx(DButton, { onClick: handleDownload, iconStart: "Download", text: downloadText, variant: "outline", size: "sm" })] })] }) }));
|
|
2537
|
+
}
|
|
2538
|
+
|
|
2330
2539
|
exports.DAlert = DAlert;
|
|
2331
2540
|
exports.DAvatar = DAvatar;
|
|
2332
2541
|
exports.DBadge = DBadge;
|
|
@@ -2334,11 +2543,11 @@ exports.DBox = DBox;
|
|
|
2334
2543
|
exports.DBoxFile = DBoxFile;
|
|
2335
2544
|
exports.DButton = DButton;
|
|
2336
2545
|
exports.DButtonIcon = DButtonIcon;
|
|
2337
|
-
exports.DCard = DCard
|
|
2546
|
+
exports.DCard = DCard;
|
|
2338
2547
|
exports.DCardBody = DCardBody;
|
|
2339
2548
|
exports.DCardFooter = DCardFooter;
|
|
2340
2549
|
exports.DCardHeader = DCardHeader;
|
|
2341
|
-
exports.DCarousel = DCarousel
|
|
2550
|
+
exports.DCarousel = DCarousel;
|
|
2342
2551
|
exports.DCarouselSlide = DCarouselSlide;
|
|
2343
2552
|
exports.DChip = DChip;
|
|
2344
2553
|
exports.DCollapse = DCollapse;
|
|
@@ -2361,32 +2570,34 @@ exports.DInputPin = DInputPin;
|
|
|
2361
2570
|
exports.DInputRange = ForwardedDInputRange;
|
|
2362
2571
|
exports.DInputSelect = DInputSelect;
|
|
2363
2572
|
exports.DInputSwitch = DInputSwitch;
|
|
2364
|
-
exports.DLayout = DLayout
|
|
2573
|
+
exports.DLayout = DLayout;
|
|
2365
2574
|
exports.DLayoutPane = DLayoutPane;
|
|
2366
|
-
exports.DListGroup = DListGroup
|
|
2575
|
+
exports.DListGroup = DListGroup;
|
|
2367
2576
|
exports.DListGroupItem = DListGroupItem;
|
|
2368
|
-
exports.DModal = DModal
|
|
2577
|
+
exports.DModal = DModal;
|
|
2369
2578
|
exports.DModalBody = DModalBody;
|
|
2370
2579
|
exports.DModalFooter = DModalFooter;
|
|
2371
2580
|
exports.DModalHeader = DModalHeader;
|
|
2372
|
-
exports.DOffcanvas = DOffcanvas
|
|
2581
|
+
exports.DOffcanvas = DOffcanvas;
|
|
2373
2582
|
exports.DOffcanvasBody = DOffcanvasBody;
|
|
2374
2583
|
exports.DOffcanvasFooter = DOffcanvasFooter;
|
|
2375
2584
|
exports.DOffcanvasHeader = DOffcanvasHeader;
|
|
2376
2585
|
exports.DPaginator = DPaginator;
|
|
2586
|
+
exports.DPasswordStrengthMeter = DPasswordStrengthMeter;
|
|
2377
2587
|
exports.DPopover = DPopover;
|
|
2378
2588
|
exports.DProgress = DProgress;
|
|
2379
|
-
exports.DSelect = DSelect
|
|
2589
|
+
exports.DSelect = DSelect;
|
|
2380
2590
|
exports.DStepper = DStepper;
|
|
2381
2591
|
exports.DStepperDesktop = DStepper$2;
|
|
2382
2592
|
exports.DStepperMobile = DStepper$1;
|
|
2383
2593
|
exports.DTabContent = DTabContent;
|
|
2384
2594
|
exports.DTableHead = DTableHead;
|
|
2385
|
-
exports.DTabs = DTabs
|
|
2595
|
+
exports.DTabs = DTabs;
|
|
2386
2596
|
exports.DTimeline = DTimeline;
|
|
2387
|
-
exports.DToast = DToast
|
|
2597
|
+
exports.DToast = DToast;
|
|
2388
2598
|
exports.DToastContainer = DToastContainer;
|
|
2389
2599
|
exports.DTooltip = DTooltip;
|
|
2600
|
+
exports.DVoucher = DVoucher;
|
|
2390
2601
|
exports.changeQueryString = changeQueryString;
|
|
2391
2602
|
exports.checkMediaQuery = checkMediaQuery;
|
|
2392
2603
|
exports.configureI18n = configureI8n;
|