@dynamic-framework/ui-react 1.11.0 → 1.12.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/css/dynamic-ui-non-root.css +784 -17
- package/dist/css/dynamic-ui-non-root.min.css +1 -1
- package/dist/css/dynamic-ui.css +784 -17
- package/dist/css/dynamic-ui.min.css +1 -1
- package/dist/index.esm.js +83 -159
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +92 -166
- package/dist/index.js.map +1 -1
- package/dist/types/components/DAlert/DAlert.d.ts +15 -0
- package/dist/types/components/DAlert/index.d.ts +2 -0
- package/dist/types/components/DButton/DButton.d.ts +2 -1
- package/dist/types/components/DInputMask/DInputMask.d.ts +16 -0
- package/dist/types/components/DInputMask/index.d.ts +2 -0
- package/dist/types/components/DModal/DModal.d.ts +2 -2
- package/dist/types/components/DToastContainer/useToast.d.ts +2 -2
- package/dist/types/components/DTooltip/DTooltip.d.ts +3 -2
- package/dist/types/components/config.d.ts +2 -2
- package/dist/types/components/index.d.ts +2 -2
- package/dist/types/components/interface.d.ts +3 -4
- package/dist/types/contexts/DModalContext.d.ts +31 -0
- package/dist/types/contexts/DOffcanvasContext.d.ts +31 -0
- package/dist/types/contexts/index.d.ts +2 -2
- package/dist/types/hooks/index.d.ts +2 -0
- package/dist/types/hooks/useDisableBodyScrollEffect.d.ts +1 -0
- package/dist/types/hooks/usePortal.d.ts +3 -0
- package/package.json +3 -2
- package/src/style/abstracts/_maps.scss +1 -1
- package/src/style/abstracts/_utilities.scss +2 -5
- package/src/style/abstracts/variables/_box-file.scss +1 -0
- package/src/style/abstracts/variables/_modals.scss +4 -0
- package/src/style/abstracts/variables/_offcanvas.scss +1 -0
- package/src/style/abstracts/variables/_typography.scss +1 -0
- package/src/style/components/_+import.scss +2 -1
- package/src/style/components/{_d-toast.scss → _d-alert.scss} +12 -11
- package/src/style/components/_d-box-file.scss +2 -0
- package/src/style/components/_d-button.scss +67 -3
- package/src/style/components/_d-modal.scss +16 -4
- package/src/style/components/_d-offcanvas.scss +4 -0
- package/src/style/components/_d-tooltip.scss +35 -0
- package/dist/types/components/DAlertBox/DAlertBox.d.ts +0 -9
- package/dist/types/components/DAlertBox/index.d.ts +0 -2
- package/dist/types/components/DToast/DToast.d.ts +0 -14
- package/dist/types/components/DToast/index.d.ts +0 -2
- package/dist/types/contexts/ModalContext.d.ts +0 -44
- package/dist/types/contexts/OffcanvasContext.d.ts +0 -44
package/dist/index.esm.js
CHANGED
|
@@ -7,6 +7,7 @@ import { SplideSlide, Splide } from '@splidejs/react-splide';
|
|
|
7
7
|
import currency from 'currency.js';
|
|
8
8
|
import DatePicker from 'react-datepicker';
|
|
9
9
|
import { parseISO, format, getMonth, getYear } from 'date-fns';
|
|
10
|
+
import { InputMask } from '@react-input/mask';
|
|
10
11
|
import ResponsivePagination from 'react-responsive-pagination';
|
|
11
12
|
import { useFloating, offset, flip, shift, autoUpdate, useClick, useDismiss, useRole, useInteractions, useId, FloatingFocusManager, arrow, useHover, useFocus, FloatingPortal, FloatingArrow } from '@floating-ui/react';
|
|
12
13
|
import ContentLoader from 'react-content-loader';
|
|
@@ -53,6 +54,8 @@ const ALERT_TYPE_ICON = {
|
|
|
53
54
|
info: 'info-circle',
|
|
54
55
|
dark: 'info-circle',
|
|
55
56
|
light: 'info-circle',
|
|
57
|
+
primary: 'info-circle',
|
|
58
|
+
secondary: 'info-circle',
|
|
56
59
|
};
|
|
57
60
|
|
|
58
61
|
function DIcon({ icon, theme, style, className, size = '1.5rem', loading = false, loadingDuration = 1.8, hasCircle = false, circleSize = `calc(var(--${PREFIX_BS}icon-component-size) * 1)`, color, backgroundColor, familyClass = 'bi', familyPrefix = 'bi-', }) {
|
|
@@ -92,18 +95,13 @@ function DSummaryCard({ title, description, icon, iconSize, iconTheme, Summary,
|
|
|
92
95
|
return (jsxs("div", { children: [jsx("h6", { className: "fw-bold fs-6", children: title }), jsx("p", { className: "fs-8", children: description }), jsxs("div", { className: "bg-white rounded p-4 d-flex gap-3 shadow-sm text-gray-700 fs-8", children: [jsx(DIcon, { icon: icon, theme: iconTheme, size: iconSize }), Summary] })] }));
|
|
93
96
|
}
|
|
94
97
|
|
|
95
|
-
function
|
|
96
|
-
const generateClasses = useMemo(() => (Object.assign({ alert: true, [`alert-${type}`]: true, 'fade show': !!showClose }, className && { [className]: true })), [type, showClose, className]);
|
|
98
|
+
function DAlert({ type = 'success', icon, iconFamilyClass, iconFamilyPrefix, showIcon = true, soft = false, showClose, onClose, children, id, className, style, }) {
|
|
99
|
+
const generateClasses = useMemo(() => (Object.assign({ alert: true, [`alert-${type}`]: true, 'fade show': !!showClose, 'alert-soft': soft }, className && { [className]: true })), [type, showClose, soft, className]);
|
|
97
100
|
const getIcon = useMemo(() => icon || ALERT_TYPE_ICON[type] || '', [icon, type]);
|
|
98
101
|
const generateStyleVariables = useMemo(() => (Object.assign(Object.assign({}, style), { [`--${PREFIX_BS}alert-component-separator-opacity`]: '0.3' })), [style]);
|
|
99
102
|
return (jsxs("div", { className: classNames(generateClasses), style: generateStyleVariables, role: "alert", id: id, children: [(showIcon || icon) && (jsx(DIcon, Object.assign({ className: "alert-icon", icon: getIcon }, iconFamilyClass && { familyClass: iconFamilyClass }, iconFamilyPrefix && { familyPrefix: iconFamilyPrefix }))), jsx("div", { className: "alert-text", children: children }), showClose && (jsx("div", { className: "alert-separator" })), showClose && (jsx("button", { type: "button", className: "btn-close", "aria-label": "Close", onClick: onClose, children: jsx(DIcon, { className: "alert-close-icon", icon: "x-lg", familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix }) }))] }));
|
|
100
103
|
}
|
|
101
104
|
|
|
102
|
-
function DAlertBox({ theme = 'box-secondary', icon = 'info-circle', iconFamilyClass, iconFamilyPrefix, children, id, className, style, }) {
|
|
103
|
-
const generateClasses = useMemo(() => (Object.assign({ 'alert alert-box': true, [`alert-${theme}`]: true }, className && { [className]: true })), [theme, className]);
|
|
104
|
-
return (jsxs("div", { className: classNames(generateClasses), style: style, role: "alert", id: id, children: [jsx(DIcon, Object.assign({ className: "alert-icon", icon: icon }, iconFamilyClass && { familyClass: iconFamilyClass }, iconFamilyPrefix && { familyPrefix: iconFamilyPrefix })), jsx("div", { className: "alert-text", children: children })] }));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
105
|
function DBoxFile(_a) {
|
|
108
106
|
var { icon = 'cloud-upload', iconFamilyClass, iconFamilyPrefix, disabled = false, children, className, style } = _a, dropzoneOptions = __rest(_a, ["icon", "iconFamilyClass", "iconFamilyPrefix", "disabled", "children", "className", "style"]);
|
|
109
107
|
const { acceptedFiles, getRootProps, getInputProps, } = useDropzone(Object.assign({ disabled }, dropzoneOptions));
|
|
@@ -116,7 +114,7 @@ function DBoxFile(_a) {
|
|
|
116
114
|
}), { children: [jsx("input", Object.assign({}, getInputProps())), jsx(DIcon, { icon: icon, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix }), jsx("div", { className: "d-box-content", children: children })] })), !!acceptedFiles.length && (jsx("aside", { className: "d-box-files", children: acceptedFiles.map((file) => (jsx("div", { className: "d-box-files-text", children: `${file.name} - ${file.size} bytes` }, file.name))) }))] }));
|
|
117
115
|
}
|
|
118
116
|
|
|
119
|
-
function DButton({ theme = 'primary', size, variant, state, text = '', ariaLabel, iconStart, iconStartFamilyClass, iconStartFamilyPrefix, iconEnd, iconEndFamilyClass, iconEndFamilyPrefix, value, type = 'button', pill = false, loading = false, loadingAriaLabel, disabled = false, stopPropagationEnabled = true, className, onClick, }) {
|
|
117
|
+
function DButton({ theme = 'primary', size, variant, state, text = '', ariaLabel, iconStart, iconStartFamilyClass, iconStartFamilyPrefix, iconEnd, iconEndFamilyClass, iconEndFamilyPrefix, value, type = 'button', pill = false, loading = false, loadingAriaLabel, disabled = false, stopPropagationEnabled = true, className, form, onClick, }) {
|
|
120
118
|
const generateClasses = useMemo(() => {
|
|
121
119
|
const variantClass = variant
|
|
122
120
|
? `btn-${variant}-${theme}`
|
|
@@ -143,7 +141,7 @@ function DButton({ theme = 'primary', size, variant, state, text = '', ariaLabel
|
|
|
143
141
|
const newAriaLabel = useMemo(() => (loading
|
|
144
142
|
? (loadingAriaLabel || ariaLabel || text)
|
|
145
143
|
: (ariaLabel || text)), [loading, loadingAriaLabel, ariaLabel, text]);
|
|
146
|
-
return (jsxs("button", Object.assign({ className: classNames(generateClasses, className), style: generateStyleVariables, type: type, disabled: isDisabled, onClick: clickHandler, "aria-label": newAriaLabel }, value && { value }, { children: [iconStart && (jsx(DIcon, { icon: iconStart, familyClass: iconStartFamilyClass, familyPrefix: iconStartFamilyPrefix })), (text && !loading) && (jsx("span", { children: text })), loading && (jsx("span", { className: "spinner-border spinner-border-sm", role: "status", "aria-hidden": "true", children: jsx("span", { className: "visually-hidden", children: "Loading..." }) })), iconEnd && (jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix }))] })));
|
|
144
|
+
return (jsxs("button", Object.assign({ className: classNames(generateClasses, className), style: generateStyleVariables, type: type, disabled: isDisabled, onClick: clickHandler, "aria-label": newAriaLabel, form: form }, value && { value }, { children: [iconStart && (jsx(DIcon, { icon: iconStart, familyClass: iconStartFamilyClass, familyPrefix: iconStartFamilyPrefix })), (text && !loading) && (jsx("span", { children: text })), loading && (jsx("span", { className: "spinner-border spinner-border-sm", role: "status", "aria-hidden": "true", children: jsx("span", { className: "visually-hidden", children: "Loading..." }) })), iconEnd && (jsx(DIcon, { icon: iconEnd, familyClass: iconEndFamilyClass, familyPrefix: iconEndFamilyPrefix }))] })));
|
|
147
145
|
}
|
|
148
146
|
|
|
149
147
|
function DCardHeader({ className, style, children, }) {
|
|
@@ -249,6 +247,35 @@ function useDContext() {
|
|
|
249
247
|
return context;
|
|
250
248
|
}
|
|
251
249
|
|
|
250
|
+
function useDisableBodyScrollEffect(disable) {
|
|
251
|
+
useEffect(() => {
|
|
252
|
+
if (disable) {
|
|
253
|
+
document.body.style.overflow = 'hidden';
|
|
254
|
+
document.body.style.paddingRight = '0';
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
document.body.style.overflow = 'unset';
|
|
258
|
+
document.body.style.paddingRight = 'unset';
|
|
259
|
+
}
|
|
260
|
+
}, [disable]);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function usePortal(portalName) {
|
|
264
|
+
const [hasPortal, setHasPortal] = useState(false);
|
|
265
|
+
useEffect(() => {
|
|
266
|
+
const previousPortal = document.querySelector(`#${portalName}`);
|
|
267
|
+
if (previousPortal) {
|
|
268
|
+
previousPortal.remove();
|
|
269
|
+
}
|
|
270
|
+
const portal = document.createElement('div');
|
|
271
|
+
portal.id = portalName;
|
|
272
|
+
portal.className = 'd-portal';
|
|
273
|
+
document.body.appendChild(portal);
|
|
274
|
+
setHasPortal(true);
|
|
275
|
+
}, [portalName]);
|
|
276
|
+
return { created: hasPortal };
|
|
277
|
+
}
|
|
278
|
+
|
|
252
279
|
/**
|
|
253
280
|
* useStackState inspired from rooks
|
|
254
281
|
* @see https://github.com/imbhargav5/rooks/blob/main/packages/rooks/src/hooks/useStackState.ts
|
|
@@ -294,73 +321,27 @@ function useStackState(initialList) {
|
|
|
294
321
|
return [list, controls];
|
|
295
322
|
}
|
|
296
323
|
|
|
297
|
-
const
|
|
298
|
-
function
|
|
299
|
-
|
|
300
|
-
var { name, payload } = _a, otherProps = __rest(_a, ["name", "payload"]);
|
|
301
|
-
useEffect(() => {
|
|
302
|
-
if (callbacks === null || callbacks === void 0 ? void 0 : callbacks.onAfterOpen) {
|
|
303
|
-
callbacks.onAfterOpen(payload);
|
|
304
|
-
}
|
|
305
|
-
return () => {
|
|
306
|
-
if (callbacks === null || callbacks === void 0 ? void 0 : callbacks.onAfterClose) {
|
|
307
|
-
callbacks.onAfterClose({ fromModal: false }, payload);
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
}, [payload]);
|
|
311
|
-
return (
|
|
312
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
313
|
-
jsx(Modal, Object.assign({ name: name, payload: payload }, otherProps)));
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
function ModalContextProvider({ portalName, children, availableModals, }) {
|
|
317
|
-
const [hasPortal, setHasPortal] = useState(false);
|
|
318
|
-
useEffect(() => {
|
|
319
|
-
const previousPortal = document.querySelector(`#${portalName}`);
|
|
320
|
-
if (previousPortal) {
|
|
321
|
-
previousPortal.remove();
|
|
322
|
-
}
|
|
323
|
-
const portal = document.createElement('div');
|
|
324
|
-
portal.id = portalName;
|
|
325
|
-
document.body.appendChild(portal);
|
|
326
|
-
setHasPortal(true);
|
|
327
|
-
}, [portalName]);
|
|
324
|
+
const DModalContext = createContext(undefined);
|
|
325
|
+
function DModalContextProvider({ portalName, children, availableModals, }) {
|
|
326
|
+
const { created } = usePortal(portalName);
|
|
328
327
|
const [stack, { push, pop, peek }] = useStackState([]);
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
document.body.style.overflow = 'hidden';
|
|
332
|
-
document.body.style.paddingRight = '0';
|
|
333
|
-
}
|
|
334
|
-
else {
|
|
335
|
-
document.body.style.overflow = 'unset';
|
|
336
|
-
document.body.style.paddingRight = 'unset';
|
|
337
|
-
}
|
|
338
|
-
}, [stack.length]);
|
|
339
|
-
const openModal = useCallback((modalName, { payload, callbacks } = { payload: {} }) => {
|
|
328
|
+
useDisableBodyScrollEffect(Boolean(stack.length));
|
|
329
|
+
const openModal = useCallback((modalName, payload) => {
|
|
340
330
|
const Component = availableModals[modalName];
|
|
341
331
|
if (!Component) {
|
|
342
|
-
throw new Error(`there is no component for modal ${modalName}`);
|
|
332
|
+
throw new Error(`there is no component for modal ${modalName.toString()}`);
|
|
343
333
|
}
|
|
344
|
-
|
|
334
|
+
push({
|
|
345
335
|
modalName,
|
|
346
336
|
Component,
|
|
347
337
|
payload,
|
|
348
|
-
|
|
349
|
-
};
|
|
350
|
-
if (callbacks === null || callbacks === void 0 ? void 0 : callbacks.onBeforeOpen) {
|
|
351
|
-
callbacks.onBeforeOpen(payload);
|
|
352
|
-
}
|
|
353
|
-
push(stackItem);
|
|
338
|
+
});
|
|
354
339
|
}, [availableModals, push]);
|
|
355
|
-
const closeModal = useCallback((
|
|
356
|
-
var _a;
|
|
340
|
+
const closeModal = useCallback(() => {
|
|
357
341
|
const stackItem = peek();
|
|
358
342
|
if (!stackItem) {
|
|
359
343
|
return;
|
|
360
344
|
}
|
|
361
|
-
if ((_a = stackItem.callbacks) === null || _a === void 0 ? void 0 : _a.onBeforeClose) {
|
|
362
|
-
stackItem.callbacks.onBeforeClose(context, stackItem.payload);
|
|
363
|
-
}
|
|
364
345
|
pop();
|
|
365
346
|
}, [peek, pop]);
|
|
366
347
|
const value = useMemo(() => ({
|
|
@@ -368,86 +349,37 @@ function ModalContextProvider({ portalName, children, availableModals, }) {
|
|
|
368
349
|
openModal,
|
|
369
350
|
closeModal,
|
|
370
351
|
}), [stack, openModal, closeModal]);
|
|
371
|
-
return (jsxs(
|
|
372
|
-
const EnhancedComponent = enhanceModal(Component, callbacks);
|
|
373
|
-
return (jsx(EnhancedComponent, { name: modalName, payload: payload, openModal: openModal, closeModal: closeModal }, modalName));
|
|
374
|
-
}), !!stack.length && jsx("div", { className: "modal-backdrop fade show" })] }), document.getElementById(portalName))] }));
|
|
352
|
+
return (jsxs(DModalContext.Provider, { value: value, children: [children, created && createPortal(jsxs(Fragment, { children: [stack.map(({ Component, modalName, payload, }) => (jsx(Component, { name: modalName, payload: payload, openModal: openModal, closeModal: closeModal }, modalName))), !!stack.length && jsx("div", { className: "modal-backdrop fade show" })] }), document.getElementById(portalName))] }));
|
|
375
353
|
}
|
|
376
|
-
function
|
|
377
|
-
const context = useContext(
|
|
354
|
+
function useDModalContext() {
|
|
355
|
+
const context = useContext(DModalContext);
|
|
378
356
|
if (context === undefined) {
|
|
379
357
|
throw new Error('useModalContext was used outside of ModalContextProvider');
|
|
380
358
|
}
|
|
381
359
|
return context;
|
|
382
360
|
}
|
|
383
361
|
|
|
384
|
-
const
|
|
385
|
-
function
|
|
386
|
-
|
|
387
|
-
var { name, payload } = _a, otherProps = __rest(_a, ["name", "payload"]);
|
|
388
|
-
useEffect(() => {
|
|
389
|
-
if (callbacks === null || callbacks === void 0 ? void 0 : callbacks.onAfterOpen) {
|
|
390
|
-
callbacks.onAfterOpen(payload);
|
|
391
|
-
}
|
|
392
|
-
return () => {
|
|
393
|
-
if (callbacks === null || callbacks === void 0 ? void 0 : callbacks.onAfterClose) {
|
|
394
|
-
callbacks.onAfterClose({ fromOffcanvas: false }, payload);
|
|
395
|
-
}
|
|
396
|
-
};
|
|
397
|
-
}, [payload]);
|
|
398
|
-
return (
|
|
399
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
400
|
-
jsx(Offcanvas, Object.assign({ name: name, payload: payload }, otherProps)));
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
function OffcanvasContextProvider({ portalName, children, availableOffcanvas, }) {
|
|
404
|
-
const [hasPortal, setHasPortal] = useState(false);
|
|
405
|
-
useEffect(() => {
|
|
406
|
-
const previousPortal = document.querySelector(`#${portalName}`);
|
|
407
|
-
if (previousPortal) {
|
|
408
|
-
previousPortal.remove();
|
|
409
|
-
}
|
|
410
|
-
const portal = document.createElement('div');
|
|
411
|
-
portal.id = portalName;
|
|
412
|
-
document.body.appendChild(portal);
|
|
413
|
-
setHasPortal(true);
|
|
414
|
-
}, [portalName]);
|
|
362
|
+
const DOffcanvasContext = createContext(undefined);
|
|
363
|
+
function DOffcanvasContextProvider({ portalName, children, availableOffcanvas, }) {
|
|
364
|
+
const { created } = usePortal(portalName);
|
|
415
365
|
const [stack, { push, pop, peek }] = useStackState([]);
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
document.body.style.overflow = 'hidden';
|
|
419
|
-
document.body.style.paddingRight = '0';
|
|
420
|
-
}
|
|
421
|
-
else {
|
|
422
|
-
document.body.style.overflow = 'unset';
|
|
423
|
-
document.body.style.paddingRight = 'unset';
|
|
424
|
-
}
|
|
425
|
-
}, [stack.length]);
|
|
426
|
-
const openOffcanvas = useCallback((offcanvasName, { payload, callbacks } = { payload: {} }) => {
|
|
366
|
+
useDisableBodyScrollEffect(Boolean(stack.length));
|
|
367
|
+
const openOffcanvas = useCallback((offcanvasName, payload) => {
|
|
427
368
|
const Component = availableOffcanvas[offcanvasName];
|
|
428
369
|
if (!Component) {
|
|
429
370
|
throw new Error(`there is no component for offcanvas ${offcanvasName}`);
|
|
430
371
|
}
|
|
431
|
-
|
|
372
|
+
push({
|
|
432
373
|
offcanvasName,
|
|
433
374
|
Component,
|
|
434
375
|
payload,
|
|
435
|
-
|
|
436
|
-
};
|
|
437
|
-
if (callbacks === null || callbacks === void 0 ? void 0 : callbacks.onBeforeOpen) {
|
|
438
|
-
callbacks.onBeforeOpen(payload);
|
|
439
|
-
}
|
|
440
|
-
push(stackItem);
|
|
376
|
+
});
|
|
441
377
|
}, [availableOffcanvas, push]);
|
|
442
|
-
const closeOffcanvas = useCallback((
|
|
443
|
-
var _a;
|
|
378
|
+
const closeOffcanvas = useCallback(() => {
|
|
444
379
|
const stackItem = peek();
|
|
445
380
|
if (!stackItem) {
|
|
446
381
|
return;
|
|
447
382
|
}
|
|
448
|
-
if ((_a = stackItem.callbacks) === null || _a === void 0 ? void 0 : _a.onBeforeClose) {
|
|
449
|
-
stackItem.callbacks.onBeforeClose(context, stackItem.payload);
|
|
450
|
-
}
|
|
451
383
|
pop();
|
|
452
384
|
}, [peek, pop]);
|
|
453
385
|
const value = useMemo(() => ({
|
|
@@ -455,13 +387,10 @@ function OffcanvasContextProvider({ portalName, children, availableOffcanvas, })
|
|
|
455
387
|
openOffcanvas,
|
|
456
388
|
closeOffcanvas,
|
|
457
389
|
}), [stack, openOffcanvas, closeOffcanvas]);
|
|
458
|
-
return (jsxs(
|
|
459
|
-
const EnhancedComponent = enhanceOffcanvas(Component, callbacks);
|
|
460
|
-
return (jsx(EnhancedComponent, { name: offcanvasName, payload: payload, openOffcanvas: openOffcanvas, closeOffcanvas: closeOffcanvas }, offcanvasName));
|
|
461
|
-
}), !!stack.length && jsx("div", { className: "offcanvas-backdrop fade show" })] }), document.getElementById(portalName))] }));
|
|
390
|
+
return (jsxs(DOffcanvasContext.Provider, { value: value, children: [children, created && createPortal(jsxs(Fragment, { children: [stack.map(({ Component, offcanvasName, payload, }) => (jsx(Component, { name: offcanvasName, payload: payload, openOffcanvas: openOffcanvas, closeOffcanvas: closeOffcanvas }, offcanvasName))), !!stack.length && jsx("div", { className: "offcanvas-backdrop fade show" })] }), document.getElementById(portalName))] }));
|
|
462
391
|
}
|
|
463
|
-
function
|
|
464
|
-
const context = useContext(
|
|
392
|
+
function useDOffcanvasContext() {
|
|
393
|
+
const context = useContext(DOffcanvasContext);
|
|
465
394
|
if (context === undefined) {
|
|
466
395
|
throw new Error('useOffcanvasContext was used outside of OffcanvasContextProvider');
|
|
467
396
|
}
|
|
@@ -508,7 +437,7 @@ function useProvidedRefOrCreate(providedRef) {
|
|
|
508
437
|
}
|
|
509
438
|
|
|
510
439
|
function DInput(_a, ref) {
|
|
511
|
-
var { id, style, className, label = '', labelIcon, labelIconFamilyClass, labelIconFamilyPrefix, disabled = false, readOnly = false, loading = false, iconFamilyClass, iconFamilyPrefix, iconStart, iconStartFamilyClass, iconStartFamilyPrefix, iconStartAriaLabel, iconStartTabIndex, iconEnd, iconEndFamilyClass, iconEndFamilyPrefix, iconEndAriaLabel, iconEndTabIndex, hint, invalid = false, valid = false, floatingLabel = false, inputStart, value, onChange, onIconStartClick, onIconEndClick } = _a, inputProps = __rest(_a, ["id", "style", "className", "label", "labelIcon", "labelIconFamilyClass", "labelIconFamilyPrefix", "disabled", "readOnly", "loading", "iconFamilyClass", "iconFamilyPrefix", "iconStart", "iconStartFamilyClass", "iconStartFamilyPrefix", "iconStartAriaLabel", "iconStartTabIndex", "iconEnd", "iconEndFamilyClass", "iconEndFamilyPrefix", "iconEndAriaLabel", "iconEndTabIndex", "hint", "invalid", "valid", "floatingLabel", "inputStart", "value", "onChange", "onIconStartClick", "onIconEndClick"]);
|
|
440
|
+
var { id, style, className, label = '', labelIcon, labelIconFamilyClass, labelIconFamilyPrefix, disabled = false, readOnly = false, loading = false, iconFamilyClass, iconFamilyPrefix, iconStart, iconStartFamilyClass, iconStartFamilyPrefix, iconStartAriaLabel, iconStartTabIndex, iconEnd, iconEndFamilyClass, iconEndFamilyPrefix, iconEndAriaLabel, iconEndTabIndex, hint, invalid = false, valid = false, floatingLabel = false, inputStart, value, placeholder = '', onChange, onIconStartClick, onIconEndClick } = _a, inputProps = __rest(_a, ["id", "style", "className", "label", "labelIcon", "labelIconFamilyClass", "labelIconFamilyPrefix", "disabled", "readOnly", "loading", "iconFamilyClass", "iconFamilyPrefix", "iconStart", "iconStartFamilyClass", "iconStartFamilyPrefix", "iconStartAriaLabel", "iconStartTabIndex", "iconEnd", "iconEndFamilyClass", "iconEndFamilyPrefix", "iconEndAriaLabel", "iconEndTabIndex", "hint", "invalid", "valid", "floatingLabel", "inputStart", "value", "placeholder", "onChange", "onIconStartClick", "onIconEndClick"]);
|
|
512
441
|
const inputRef = useProvidedRefOrCreate(ref);
|
|
513
442
|
const handleOnChange = useCallback((event) => {
|
|
514
443
|
onChange === null || onChange === void 0 ? void 0 : onChange(event.currentTarget.value);
|
|
@@ -529,7 +458,7 @@ function DInput(_a, ref) {
|
|
|
529
458
|
const inputComponent = useMemo(() => (jsx("input", Object.assign({ ref: inputRef, id: id, className: classNames('form-control', {
|
|
530
459
|
'is-invalid': invalid,
|
|
531
460
|
'is-valid': valid,
|
|
532
|
-
}), disabled: disabled || loading, readOnly: readOnly, value: value, onChange: handleOnChange }, ariaDescribedby && { 'aria-describedby': ariaDescribedby }, inputProps))), [
|
|
461
|
+
}), disabled: disabled || loading, readOnly: readOnly, value: value, onChange: handleOnChange }, (floatingLabel || placeholder) && { placeholder: floatingLabel ? '' : placeholder }, ariaDescribedby && { 'aria-describedby': ariaDescribedby }, inputProps))), [
|
|
533
462
|
ariaDescribedby,
|
|
534
463
|
disabled,
|
|
535
464
|
handleOnChange,
|
|
@@ -538,6 +467,8 @@ function DInput(_a, ref) {
|
|
|
538
467
|
inputRef,
|
|
539
468
|
invalid,
|
|
540
469
|
loading,
|
|
470
|
+
placeholder,
|
|
471
|
+
floatingLabel,
|
|
541
472
|
readOnly,
|
|
542
473
|
valid,
|
|
543
474
|
value,
|
|
@@ -555,10 +486,7 @@ function DInput(_a, ref) {
|
|
|
555
486
|
}
|
|
556
487
|
return inputComponent;
|
|
557
488
|
}, [floatingLabel, inputComponent, labelComponent]);
|
|
558
|
-
return (jsxs("div", { className: classNames({
|
|
559
|
-
'd-input': true,
|
|
560
|
-
className: !!className,
|
|
561
|
-
}), style: style, children: [label && !floatingLabel && (labelComponent), jsxs("div", { className: "d-input-control", children: [jsxs("div", { className: classNames({
|
|
489
|
+
return (jsxs("div", { className: classNames(Object.assign({ 'd-input': true }, className && { [className]: true })), style: style, children: [label && !floatingLabel && (labelComponent), jsxs("div", { className: "d-input-control", children: [jsxs("div", { className: classNames({
|
|
562
490
|
'input-group': true,
|
|
563
491
|
'has-validation': invalid,
|
|
564
492
|
disabled: disabled || loading,
|
|
@@ -617,6 +545,13 @@ function DDatePicker(_a) {
|
|
|
617
545
|
return (jsx(DatePicker, Object.assign({ selected: selected, calendarClassName: "d-date-picker", renderCustomHeader: (headerProps) => jsx(DatePickerHeader, Object.assign({}, headerProps)), customInput: (jsx(DDatePickerInput$1, { id: inputId, "aria-label": inputAriaLabel, iconEndAriaLabel: inputActionAriaLabel, iconEnd: inputIcon, className: className, style: style })), customTimeInput: jsx(DDatePickerTime, { id: timeId, label: timeLabel }), selectsRange: selectsRange }, locale && { locale }, props)));
|
|
618
546
|
}
|
|
619
547
|
|
|
548
|
+
function DInputMask(props, ref) {
|
|
549
|
+
return (jsx(InputMask, Object.assign({ ref: ref, component: DInput$1 }, props)));
|
|
550
|
+
}
|
|
551
|
+
const ForwardedDInputMask = forwardRef(DInputMask);
|
|
552
|
+
ForwardedDInputMask.displayName = 'DInputMask';
|
|
553
|
+
var DInputMask$1 = ForwardedDInputMask;
|
|
554
|
+
|
|
620
555
|
function DInputCounter(_a, ref) {
|
|
621
556
|
var { minValue, maxValue, value = minValue, invalid, iconStart = 'dash-square', iconEnd = 'plus-square', iconStartAriaLabel = 'decrease action', iconEndAriaLabel = 'increase action', style, onChange } = _a, props = __rest(_a, ["minValue", "maxValue", "value", "invalid", "iconStart", "iconEnd", "iconStartAriaLabel", "iconEndAriaLabel", "style", "onChange"]);
|
|
622
557
|
const inputRef = useProvidedRefOrCreate(ref);
|
|
@@ -835,7 +770,7 @@ function DInputPin({ id, label = '', labelIcon, labelIconFamilyClass, labelIconF
|
|
|
835
770
|
}), type: secret ? 'password' : type, "aria-describedby": `${id}State`, inputMode: innerInputMode, id: `pinIndex${index}`, name: `pin-${index}`, maxLength: 1, onChange: nextInput, onKeyDown: prevInput, onFocus: focusInput, onWheel: wheelInput, onClick: preventDefaultEvent, autoComplete: "off", placeholder: placeholder, disabled: disabled || loading, required: true }, type === 'number' && ({ min: 0, max: 9 })), index))), (invalid || valid) && !loading && (jsx("span", { className: "input-group-text", id: `${id}State`, children: jsx(DIcon, { className: "d-input-pin-validation-icon", icon: invalid ? 'exclamation-circle' : 'check', familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix }) })), loading && (jsx("div", { className: "input-group-text d-input-pin-icon", children: jsx("span", { className: "spinner-border spinner-border-sm", role: "status", "aria-hidden": "true", children: jsx("span", { className: "visually-hidden", children: "Loading..." }) }) }))] }), hint && (jsx("div", { className: "form-text", id: `${id}Hint`, children: hint }))] }));
|
|
836
771
|
}
|
|
837
772
|
|
|
838
|
-
function DInputSelect({ id, name, label = '', className, style, options, labelIcon, labelIconFamilyClass, labelIconFamilyPrefix, disabled = false, loading = false, iconStart, iconStartFamilyClass, iconStartFamilyPrefix, iconStartAriaLabel, iconEnd, iconEndFamilyClass, iconEndFamilyPrefix, iconEndAriaLabel, hint, value, floatingLabel = false, valueExtractor, labelExtractor, onChange, onBlur, onIconStartClick, onIconEndClick, }) {
|
|
773
|
+
function DInputSelect({ id, name, label = '', className, style, options = [], labelIcon, labelIconFamilyClass, labelIconFamilyPrefix, disabled = false, loading = false, iconStart, iconStartFamilyClass, iconStartFamilyPrefix, iconStartAriaLabel, iconEnd, iconEndFamilyClass, iconEndFamilyPrefix, iconEndAriaLabel, hint, value, floatingLabel = false, valueExtractor, labelExtractor, onChange, onBlur, onIconStartClick, onIconEndClick, }) {
|
|
839
774
|
const internalValueExtractor = useCallback((option) => {
|
|
840
775
|
if (valueExtractor) {
|
|
841
776
|
return valueExtractor(option);
|
|
@@ -959,7 +894,7 @@ function DListItemMovement(_a) {
|
|
|
959
894
|
}
|
|
960
895
|
|
|
961
896
|
function DModalHeader({ showCloseButton, onClose, children, className, style, }) {
|
|
962
|
-
return (jsxs("div", { className: classNames('modal-header', className), style: style, children: [showCloseButton && (jsx("button", { type: "button", className: "d-modal-close", "aria-label": "Close", onClick: onClose, children: jsx(DIcon, { icon: "x-lg" }) }))
|
|
897
|
+
return (jsxs("div", { className: classNames('modal-header', className), style: style, children: [jsx("div", { className: "d-modal-slot", children: children }), showCloseButton && (jsx("button", { type: "button", className: "d-modal-close", "aria-label": "Close", onClick: onClose, children: jsx(DIcon, { icon: "x-lg" }) }))] }));
|
|
963
898
|
}
|
|
964
899
|
|
|
965
900
|
function DModalBody({ children, className, style, }) {
|
|
@@ -970,7 +905,7 @@ function DModalFooter({ className, style, actionPlacement = 'fill', children, })
|
|
|
970
905
|
return (jsxs(Fragment, { children: [jsx("div", { className: "d-modal-separator" }), jsx("div", { className: classNames(`d-modal-slot modal-footer d-modal-action-${actionPlacement}`, className), style: style, children: children })] }));
|
|
971
906
|
}
|
|
972
907
|
|
|
973
|
-
function DModal({ name, className, style, staticBackdrop, scrollable, centered, fullScreen, fullScreenFrom,
|
|
908
|
+
function DModal({ name, className, style, staticBackdrop, scrollable, centered, fullScreen, fullScreenFrom, size, children, }) {
|
|
974
909
|
const fullScreenClass = useMemo(() => {
|
|
975
910
|
if (fullScreen) {
|
|
976
911
|
if (fullScreenFrom) {
|
|
@@ -981,7 +916,7 @@ function DModal({ name, className, style, staticBackdrop, scrollable, centered,
|
|
|
981
916
|
return '';
|
|
982
917
|
}, [fullScreenFrom, fullScreen]);
|
|
983
918
|
const generateClasses = useMemo(() => (Object.assign({ 'modal fade show': true }, className && { [className]: true })), [className]);
|
|
984
|
-
const generateModalDialogClasses = useMemo(() => (Object.assign({ 'modal-dialog': true, 'modal-dialog-centered': !!centered, 'modal-dialog-scrollable': !!scrollable, [fullScreenClass]: !!fullScreen },
|
|
919
|
+
const generateModalDialogClasses = useMemo(() => (Object.assign({ 'modal-dialog': true, 'modal-dialog-centered': !!centered, 'modal-dialog-scrollable': !!scrollable, [fullScreenClass]: !!fullScreen }, size && { [`modal-${size}`]: true })), [fullScreenClass, centered, fullScreen, scrollable, size]);
|
|
985
920
|
return (jsx("div", Object.assign({ className: classNames(generateClasses), id: name, tabIndex: -1, "aria-labelledby": `${name}Label`, "aria-hidden": "false", style: style }, staticBackdrop && ({
|
|
986
921
|
[`data-${PREFIX_BS}backdrop`]: 'static',
|
|
987
922
|
[`data-${PREFIX_BS}keyboard`]: 'false',
|
|
@@ -1066,12 +1001,13 @@ function DPopover({ children, renderComponent, open, setOpen, adjustContentToRen
|
|
|
1066
1001
|
}
|
|
1067
1002
|
|
|
1068
1003
|
function DProgress({ className, style, currentValue, minValue = 0, maxValue = 100, hideCurrentValue = false, enableStripedAnimation = false, }) {
|
|
1069
|
-
const
|
|
1004
|
+
const percentage = useMemo(() => (Math.round((currentValue * 100) / maxValue)), [currentValue, maxValue]);
|
|
1005
|
+
const formatProgress = useMemo(() => `${percentage}%`, [percentage]);
|
|
1070
1006
|
const generateClasses = useMemo(() => ({
|
|
1071
1007
|
'progress-bar': true,
|
|
1072
1008
|
'progress-bar-striped progress-bar-animated': enableStripedAnimation,
|
|
1073
1009
|
}), [enableStripedAnimation]);
|
|
1074
|
-
return (jsx("div", { className:
|
|
1010
|
+
return (jsx("div", { className: classNames('progress', className), children: jsx("div", { className: classNames(generateClasses), role: "progressbar", "aria-label": "Progress bar", style: Object.assign({ width: formatProgress }, style), "aria-valuenow": currentValue, "aria-valuemin": minValue, "aria-valuemax": maxValue, children: !hideCurrentValue && formatProgress }) }));
|
|
1075
1011
|
}
|
|
1076
1012
|
|
|
1077
1013
|
function DQuickActionButton({ line1, line2, className, actionLinkText, actionLinkTheme = 'secondary', actionIcon, secondaryActionIcon, secondaryActionAriaLabel, actionIconFamilyClass, actionIconFamilyPrefix, representativeImage, representativeIcon, representativeIconTheme = 'secondary', representativeIconHasCircle = false, representativeIconFamilyClass, representativeIconFamilyPrefix, onClick, onClickSecondary, style, }) {
|
|
@@ -1194,22 +1130,11 @@ function DStepper({ options, currentStep, successIcon = 'check', vertical = fals
|
|
|
1194
1130
|
return (jsxs("div", { className: className, style: style, children: [jsx("div", { className: `d-block d-${breakpoint}-none`, children: jsx(DStepper$1, { options: options, currentStep: currentStep }) }), jsx("div", { className: `d-none d-${breakpoint}-block`, children: jsx(DStepper$2, { options: options, currentStep: currentStep, successIcon: successIcon, vertical: vertical }) })] }));
|
|
1195
1131
|
}
|
|
1196
1132
|
|
|
1197
|
-
const TOOLTIP_FONT_SIZE_BY_SIZE = {
|
|
1198
|
-
sm: `var(--${PREFIX_BS}ref-fs-small)`,
|
|
1199
|
-
default: `var(--${PREFIX_BS}body-font-size)`,
|
|
1200
|
-
lg: `var(--${PREFIX_BS}ref-fs-6)`,
|
|
1201
|
-
};
|
|
1202
1133
|
const ARROW_WIDTH = 8;
|
|
1203
1134
|
const ARROW_HEIGHT = 4;
|
|
1204
1135
|
const GAP = 2;
|
|
1205
|
-
function DTooltip({
|
|
1136
|
+
function DTooltip({ className, childrenClassName, style, offSet = ARROW_HEIGHT + GAP, padding, withFocus = false, withClick = false, withHover = true, open = false, theme = 'primary', placement = 'top', size, Component, children, }) {
|
|
1206
1137
|
const [isOpen, setIsOpen] = useState(open);
|
|
1207
|
-
const styleVariables = useMemo(() => {
|
|
1208
|
-
const defaultFontSize = size
|
|
1209
|
-
? TOOLTIP_FONT_SIZE_BY_SIZE[size]
|
|
1210
|
-
: TOOLTIP_FONT_SIZE_BY_SIZE.default;
|
|
1211
|
-
return Object.assign(Object.assign({}, style), { background: `var(--${PREFIX_BS}tooltip-bg, var(--${PREFIX_BS}tooltip-component-bg, var(--${PREFIX_BS}secondary)))`, borderRadius: `var(--${PREFIX_BS}tooltip-border-radius, var(--${PREFIX_BS}tooltip-component-border-radius, var(--${PREFIX_BS}border-radius)))`, color: `var(--${PREFIX_BS}tooltip-color, var(--${PREFIX_BS}tooltip-component-color, var(--${PREFIX_BS}white)))`, fontSize: `var(--${PREFIX_BS}tooltip-font-size, var(--${PREFIX_BS}tooltip-component-font-size, ${defaultFontSize}))`, padding: `var(--${PREFIX_BS}tooltip-padding, var(--${PREFIX_BS}tooltip-component-padding, var(--${PREFIX_BS}ref-spacer-2)))`, maxWidth: `var(--${PREFIX_BS}tooltip-max-width, var(--${PREFIX_BS}tooltip-component-max-width, 300px))` });
|
|
1212
|
-
}, [size, style]);
|
|
1213
1138
|
const arrowRef = useRef(null);
|
|
1214
1139
|
const { refs, context, floatingStyles, } = useFloating({
|
|
1215
1140
|
open: isOpen,
|
|
@@ -1239,9 +1164,8 @@ function DTooltip({ classNameContainer, className, style, offSet = ARROW_HEIGHT
|
|
|
1239
1164
|
dismiss,
|
|
1240
1165
|
role,
|
|
1241
1166
|
]);
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
}, width: ARROW_WIDTH, height: ARROW_HEIGHT }), children] }))) })] }));
|
|
1167
|
+
const generateClasses = useMemo(() => (Object.assign({ 'd-tooltip': true, [`d-tooltip-${size}`]: !!size, [`d-tooltip-${theme}`]: !!theme }, className && { [className]: true })), [size, theme, className]);
|
|
1168
|
+
return (jsxs(Fragment, { children: [jsx("div", Object.assign({ className: childrenClassName, ref: refs.setReference }, getReferenceProps(), { children: Component })), jsx(FloatingPortal, { children: isOpen && (jsxs("div", Object.assign({ className: classNames(generateClasses), ref: refs.setFloating, style: Object.assign(Object.assign({}, floatingStyles), style) }, getFloatingProps(), { children: [jsx(FloatingArrow, { ref: arrowRef, context: context, width: ARROW_WIDTH, height: ARROW_HEIGHT }), children] }))) })] }));
|
|
1245
1169
|
}
|
|
1246
1170
|
|
|
1247
1171
|
const TabContext = createContext(undefined);
|
|
@@ -1293,7 +1217,7 @@ function DToastContainer({ style, position = 'top-right', className, }) {
|
|
|
1293
1217
|
|
|
1294
1218
|
function useToast() {
|
|
1295
1219
|
const toast$1 = useCallback((message, { position = 'top-right', type = 'info', showClose = true, autoClose = false, } = {}) => {
|
|
1296
|
-
toast(({ closeToast }) => (jsx(
|
|
1220
|
+
toast(({ closeToast }) => (jsx(DAlert, { type: type, showClose: showClose, onClose: closeToast, id: "alertID", children: message })), {
|
|
1297
1221
|
transition: Slide,
|
|
1298
1222
|
position,
|
|
1299
1223
|
autoClose,
|
|
@@ -1318,5 +1242,5 @@ async function configureI8n(resources, _a = {}) {
|
|
|
1318
1242
|
.then((t) => t);
|
|
1319
1243
|
}
|
|
1320
1244
|
|
|
1321
|
-
export {
|
|
1245
|
+
export { DAlert, DBadge, DBoxFile, DButton, DCard$1 as DCard, DCardAccount, DCardBody, DCardFooter, DCardHeader, DCarousel$1 as DCarousel, DCarouselSlide, DChip, DCollapse, DCollapseIconText, DContext, DContextProvider, DCurrencyText, DDatePicker, DIcon, DInput$1 as DInput, DInputCheck, DInputCounter$1 as DInputCounter, DInputCurrency$1 as DInputCurrency, DInputCurrencyBase$1 as DInputCurrencyBase, DInputMask$1 as DInputMask, DInputPassword$1 as DInputPassword, DInputPin, DInputSearch$1 as DInputSearch, DInputSelect, DInputSwitch, DList$1 as DList, DListItem, DListItemMovement, DModal$1 as DModal, DModalBody, DModalContext, DModalContextProvider, DModalFooter, DModalHeader, DOffcanvas$1 as DOffcanvas, DOffcanvasBody, DOffcanvasContext, DOffcanvasContextProvider, DOffcanvasFooter, DOffcanvasHeader, DPaginator, DPermissionGroup, DPermissionItem, DPopover, DProgress, DQuickActionButton, DQuickActionCheck, DQuickActionSelect, DQuickActionSwitch, DSkeleton, DStepper, DStepper$2 as DStepperDesktop, DStepper$1 as DStepperMobile, DSummaryCard, DTabContent, DTabs$1 as DTabs, DToastContainer, DTooltip, configureI8n as configureI18n, formatCurrency, useDContext, useDModalContext, useDOffcanvasContext, useDisableBodyScrollEffect, useFormatCurrency, useInputCurrency, usePortal, useProvidedRefOrCreate, useStackState, useTabContext, useToast };
|
|
1322
1246
|
//# sourceMappingURL=index.esm.js.map
|