@dynamic-framework/ui-react 1.33.0 → 1.34.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 +5 -3
- package/dist/css/dynamic-ui-non-root.min.css +2 -2
- package/dist/css/dynamic-ui-root.css +1 -1
- package/dist/css/dynamic-ui-root.min.css +1 -1
- package/dist/css/dynamic-ui.css +5 -3
- package/dist/css/dynamic-ui.min.css +2 -2
- package/dist/index.esm.js +106 -25
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +114 -23
- package/dist/index.js.map +1 -1
- package/dist/types/components/DQuickActionButton/DQuickActionButton.d.ts +4 -9
- package/dist/types/contexts/DContext.d.ts +9 -0
- package/dist/types/hooks/index.d.ts +2 -0
- package/dist/types/hooks/useMediaBreakpointUp.d.ts +6 -0
- package/dist/types/hooks/useMediaQuery.d.ts +1 -0
- package/dist/types/utils/getCssVariable.d.ts +1 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/mediaQuery.d.ts +2 -0
- package/package.json +1 -1
- package/src/style/components/_d-quick-action-button.scss +4 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
2
|
-
import React, { useMemo, useEffect, useState, useCallback, createContext, useContext, Fragment, forwardRef, useId, useRef } from 'react';
|
|
2
|
+
import React, { useMemo, useEffect, useState, useCallback, createContext, useContext, Fragment, useLayoutEffect, forwardRef, useId, useRef, useSyncExternalStore } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { __rest } from 'tslib';
|
|
5
5
|
import { createPortal } from 'react-dom';
|
|
@@ -200,7 +200,12 @@ function useDPortalContext() {
|
|
|
200
200
|
return context;
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
|
|
203
|
+
function getCssVariable(variable) {
|
|
204
|
+
const computedStyle = getComputedStyle(document.documentElement);
|
|
205
|
+
return computedStyle.getPropertyValue(variable).trim();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const DEFAULT_STATE = {
|
|
204
209
|
language: 'en',
|
|
205
210
|
currency: {
|
|
206
211
|
symbol: '$',
|
|
@@ -243,18 +248,40 @@ const defaultState = {
|
|
|
243
248
|
decrease: 'dash-square',
|
|
244
249
|
},
|
|
245
250
|
},
|
|
251
|
+
breakpoints: {
|
|
252
|
+
xs: '',
|
|
253
|
+
sm: '',
|
|
254
|
+
md: '',
|
|
255
|
+
lg: '',
|
|
256
|
+
xl: '',
|
|
257
|
+
xxl: '',
|
|
258
|
+
},
|
|
246
259
|
setContext: () => { },
|
|
247
260
|
portalName: 'd-portal',
|
|
248
261
|
};
|
|
249
|
-
const DContext = createContext(
|
|
250
|
-
function DContextProvider({ language =
|
|
262
|
+
const DContext = createContext(DEFAULT_STATE);
|
|
263
|
+
function DContextProvider({ language = DEFAULT_STATE.language, currency = DEFAULT_STATE.currency, icon = DEFAULT_STATE.icon, iconMap = DEFAULT_STATE.iconMap, portalName = DEFAULT_STATE.portalName, availablePortals, children, }) {
|
|
251
264
|
const [internalContext, setInternalContext,] = useState({
|
|
252
265
|
language,
|
|
253
266
|
currency,
|
|
254
267
|
icon,
|
|
255
268
|
iconMap,
|
|
269
|
+
breakpoints: DEFAULT_STATE.breakpoints,
|
|
256
270
|
});
|
|
257
271
|
const setContext = useCallback((newValue) => (setInternalContext((prevInternalContext) => (Object.assign(Object.assign({}, prevInternalContext), newValue)))), []);
|
|
272
|
+
useLayoutEffect(() => {
|
|
273
|
+
console.log('context');
|
|
274
|
+
setContext({
|
|
275
|
+
breakpoints: {
|
|
276
|
+
xs: getCssVariable(`--${PREFIX_BS}breakpoint-xs`),
|
|
277
|
+
sm: getCssVariable(`--${PREFIX_BS}breakpoint-sm`),
|
|
278
|
+
md: getCssVariable(`--${PREFIX_BS}breakpoint-md`),
|
|
279
|
+
lg: getCssVariable(`--${PREFIX_BS}breakpoint-lg`),
|
|
280
|
+
xl: getCssVariable(`--${PREFIX_BS}breakpoint-xl`),
|
|
281
|
+
xxl: getCssVariable(`--${PREFIX_BS}breakpoint-xxl`),
|
|
282
|
+
},
|
|
283
|
+
});
|
|
284
|
+
}, [setContext]);
|
|
258
285
|
const value = useMemo(() => (Object.assign(Object.assign({}, internalContext), { setContext })), [internalContext, setContext]);
|
|
259
286
|
return (jsx(DContext.Provider, { value: value, children: jsx(DPortalContextProvider, { portalName: portalName, availablePortals: availablePortals, children: children }) }));
|
|
260
287
|
}
|
|
@@ -893,6 +920,47 @@ function useItemSelection({ getItemIdentifier: getItemIdentifierProp, previousSe
|
|
|
893
920
|
};
|
|
894
921
|
}
|
|
895
922
|
|
|
923
|
+
function subscribeToMediaQuery(query, callback) {
|
|
924
|
+
const mediaQueryList = window.matchMedia(query);
|
|
925
|
+
mediaQueryList.addEventListener('change', callback);
|
|
926
|
+
return () => {
|
|
927
|
+
mediaQueryList.removeEventListener('change', callback);
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
function checkMediaQuery(query) {
|
|
931
|
+
return window.matchMedia(query).matches;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
function useMediaQuery(mediaQuery, useListener = false) {
|
|
935
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
936
|
+
const noop = (_) => () => { };
|
|
937
|
+
return useSyncExternalStore(useListener ? (cb) => subscribeToMediaQuery(mediaQuery, cb) : noop, () => (mediaQuery ? checkMediaQuery(mediaQuery) : true), () => false);
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
function useMediaBreakpointUp(breakpoint, useListener = false) {
|
|
941
|
+
const { breakpoints } = useDContext();
|
|
942
|
+
const mediaQuery = useMemo(() => (`(min-width: ${breakpoints[breakpoint]})`), [breakpoint, breakpoints]);
|
|
943
|
+
return useMediaQuery(mediaQuery, useListener);
|
|
944
|
+
}
|
|
945
|
+
function useMediaBreakpointUpXs(useListener = false) {
|
|
946
|
+
return useMediaBreakpointUp('xs', useListener);
|
|
947
|
+
}
|
|
948
|
+
function useMediaBreakpointUpSm(useListener = false) {
|
|
949
|
+
return useMediaBreakpointUp('sm', useListener);
|
|
950
|
+
}
|
|
951
|
+
function useMediaBreakpointUpMd(useListener = false) {
|
|
952
|
+
return useMediaBreakpointUp('md', useListener);
|
|
953
|
+
}
|
|
954
|
+
function useMediaBreakpointUpLg(useListener = false) {
|
|
955
|
+
return useMediaBreakpointUp('lg', useListener);
|
|
956
|
+
}
|
|
957
|
+
function useMediaBreakpointUpXl(useListener = false) {
|
|
958
|
+
return useMediaBreakpointUp('xl', useListener);
|
|
959
|
+
}
|
|
960
|
+
function useMediaBreakpointUpXxl(useListener = false) {
|
|
961
|
+
return useMediaBreakpointUp('xxl', useListener);
|
|
962
|
+
}
|
|
963
|
+
|
|
896
964
|
function DInputCounter(_a, ref) {
|
|
897
965
|
var { minValue, maxValue, value = minValue, invalid, iconStart: iconStartProp, iconEnd: iconEndProp, iconStartAriaLabel = 'decrease action', iconEndAriaLabel = 'increase action', style, onChange } = _a, props = __rest(_a, ["minValue", "maxValue", "value", "invalid", "iconStart", "iconEnd", "iconStartAriaLabel", "iconEndAriaLabel", "style", "onChange"]);
|
|
898
966
|
const { handleOnWheel, } = useDisableInputWheel(ref);
|
|
@@ -1415,29 +1483,42 @@ function DProgress({ className, style, currentValue, minValue = 0, maxValue = 10
|
|
|
1415
1483
|
return (jsx("div", Object.assign({ className: classNames('progress', className) }, dataAttributes, { 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 }) })));
|
|
1416
1484
|
}
|
|
1417
1485
|
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
const globalClickHandler = useCallback(() => {
|
|
1423
|
-
if (actionLinkText) {
|
|
1424
|
-
return;
|
|
1486
|
+
function DQuickActionButton({ line1, line2, className, actionIcon, actionIconFamilyClass, actionIconFamilyPrefix, actionIconTheme, representativeImage, representativeIcon, representativeIconTheme = 'secondary', representativeIconHasCircle = false, representativeIconFamilyClass, representativeIconFamilyPrefix, onClick, href, hrefTarget, style, dataAttributes, }) {
|
|
1487
|
+
const Tag = useMemo(() => {
|
|
1488
|
+
if (href) {
|
|
1489
|
+
return 'a';
|
|
1425
1490
|
}
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
const actionLinkClickHandler = useCallback(() => {
|
|
1429
|
-
if (!actionLinkText) {
|
|
1430
|
-
return;
|
|
1491
|
+
if (onClick) {
|
|
1492
|
+
return 'button';
|
|
1431
1493
|
}
|
|
1432
|
-
|
|
1433
|
-
}, [
|
|
1434
|
-
const
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1494
|
+
return 'div';
|
|
1495
|
+
}, [href, onClick]);
|
|
1496
|
+
const tagProps = useMemo(() => {
|
|
1497
|
+
if (href) {
|
|
1498
|
+
return {
|
|
1499
|
+
className: classNames('d-quick-action-button', 'd-quick-action-button-feedback', className),
|
|
1500
|
+
href,
|
|
1501
|
+
target: hrefTarget,
|
|
1502
|
+
};
|
|
1503
|
+
}
|
|
1504
|
+
if (onClick) {
|
|
1505
|
+
return {
|
|
1506
|
+
className: classNames('d-quick-action-button', 'd-quick-action-button-feedback', className),
|
|
1507
|
+
onClick,
|
|
1508
|
+
};
|
|
1509
|
+
}
|
|
1510
|
+
return {
|
|
1511
|
+
className: classNames('d-quick-action-button', className),
|
|
1512
|
+
};
|
|
1513
|
+
}, [
|
|
1514
|
+
className,
|
|
1515
|
+
href,
|
|
1516
|
+
hrefTarget,
|
|
1517
|
+
onClick,
|
|
1518
|
+
]);
|
|
1519
|
+
return (jsxs(Tag, Object.assign({ style: style }, tagProps, dataAttributes, { children: [representativeIcon && (jsx(DIcon, { className: "d-quick-action-button-representative-icon", size: representativeIconHasCircle
|
|
1439
1520
|
? `var(--${PREFIX_BS}quick-action-button-representative-icon-size)`
|
|
1440
|
-
: `var(--${PREFIX_BS}quick-action-button-representative-image-size)`, icon: representativeIcon, hasCircle: representativeIconHasCircle, theme: representativeIconTheme, familyClass: representativeIconFamilyClass, familyPrefix: representativeIconFamilyPrefix })), representativeImage && (jsx("img", { className: "d-quick-action-button-representative-image", src: representativeImage, alt: "" })), jsx("div", { className: "d-quick-action-button-content", children: jsxs("div", { className: "d-quick-action-button-text", children: [jsx("span", { className: "d-quick-action-button-line1", children: line1 }), jsx("small", { className: "d-quick-action-button-line2", children: line2 })] }) }),
|
|
1521
|
+
: `var(--${PREFIX_BS}quick-action-button-representative-image-size)`, icon: representativeIcon, hasCircle: representativeIconHasCircle, theme: representativeIconTheme, familyClass: representativeIconFamilyClass, familyPrefix: representativeIconFamilyPrefix })), representativeImage && (jsx("img", { className: "d-quick-action-button-representative-image", src: representativeImage, alt: "" })), jsx("div", { className: "d-quick-action-button-content", children: jsxs("div", { className: "d-quick-action-button-text", children: [jsx("span", { className: "d-quick-action-button-line1", children: line1 }), jsx("small", { className: "d-quick-action-button-line2", children: line2 })] }) }), actionIcon && (jsx(DIcon, { className: "d-quick-action-button-action-icon", icon: actionIcon, size: `var(--${PREFIX_BS}quick-action-button-action-icon-size)`, theme: actionIconTheme, familyClass: actionIconFamilyClass, familyPrefix: actionIconFamilyPrefix }))] })));
|
|
1441
1522
|
}
|
|
1442
1523
|
|
|
1443
1524
|
/**
|
|
@@ -1737,5 +1818,5 @@ function changeQueryString(values, { useSearch = true, pushState = false, } = {}
|
|
|
1737
1818
|
return searchParams.toString();
|
|
1738
1819
|
}
|
|
1739
1820
|
|
|
1740
|
-
export { DAlert, DAvatar, DBadge, DBoxFile, DButton, DButtonIcon, DCard$1 as DCard, DCardBody, DCardFooter, DCardHeader, DCarousel$1 as DCarousel, DCarouselSlide, DChip, DCollapse, DContext, DContextProvider, DCurrencyText, DDatePicker, DIcon, DIconBase, ForwardedDInput as DInput, DInputCheck, ForwardedDInputCounter as DInputCounter, ForwardedDInputCurrencyBase as DInputCurrency, ForwardedDInputCurrencyBase$1 as DInputCurrencyBase, ForwardedDInputMask as DInputMask, ForwardedDInputPassword as DInputPassword, DInputPin, ForwardedDInputRange as DInputRange, ForwardedDInputSearch as DInputSearch, DInputSelect, DInputSwitch, DList$1 as DList, DListGroup$1 as DListGroup, DListGroupItem, DListItem, DModal$1 as DModal, DModalBody, DModalFooter, DModalHeader, DOffcanvas$1 as DOffcanvas, DOffcanvasBody, DOffcanvasFooter, DOffcanvasHeader, DPaginator, DPopover, DProgress, DQuickActionButton, DQuickActionCheck, DQuickActionSelect, DQuickActionSwitch, DSelect$1 as DSelect, DSkeleton, DStepper, DStepper$2 as DStepperDesktop, DStepper$1 as DStepperMobile, DTabContent, DTableHead, DTabs$1 as DTabs, DToast$1 as DToast, DToastContainer, DTooltip, changeQueryString, configureI8n as configureI18n, formatCurrency, getQueryString, useDContext, useDPortalContext, useDToast, useDisableBodyScrollEffect, useDisableInputWheel, useFormatCurrency, useInputCurrency, useItemSelection, usePortal, useProvidedRefOrCreate, useStackState, useTabContext };
|
|
1821
|
+
export { DAlert, DAvatar, DBadge, DBoxFile, DButton, DButtonIcon, DCard$1 as DCard, DCardBody, DCardFooter, DCardHeader, DCarousel$1 as DCarousel, DCarouselSlide, DChip, DCollapse, DContext, DContextProvider, DCurrencyText, DDatePicker, DIcon, DIconBase, ForwardedDInput as DInput, DInputCheck, ForwardedDInputCounter as DInputCounter, ForwardedDInputCurrencyBase as DInputCurrency, ForwardedDInputCurrencyBase$1 as DInputCurrencyBase, ForwardedDInputMask as DInputMask, ForwardedDInputPassword as DInputPassword, DInputPin, ForwardedDInputRange as DInputRange, ForwardedDInputSearch as DInputSearch, DInputSelect, DInputSwitch, DList$1 as DList, DListGroup$1 as DListGroup, DListGroupItem, DListItem, DModal$1 as DModal, DModalBody, DModalFooter, DModalHeader, DOffcanvas$1 as DOffcanvas, DOffcanvasBody, DOffcanvasFooter, DOffcanvasHeader, DPaginator, DPopover, DProgress, DQuickActionButton, DQuickActionCheck, DQuickActionSelect, DQuickActionSwitch, DSelect$1 as DSelect, DSkeleton, DStepper, DStepper$2 as DStepperDesktop, DStepper$1 as DStepperMobile, DTabContent, DTableHead, DTabs$1 as DTabs, DToast$1 as DToast, DToastContainer, DTooltip, changeQueryString, checkMediaQuery, configureI8n as configureI18n, formatCurrency, getCssVariable, getQueryString, subscribeToMediaQuery, useDContext, useDPortalContext, useDToast, useDisableBodyScrollEffect, useDisableInputWheel, useFormatCurrency, useInputCurrency, useItemSelection, useMediaBreakpointUpLg, useMediaBreakpointUpMd, useMediaBreakpointUpSm, useMediaBreakpointUpXl, useMediaBreakpointUpXs, useMediaBreakpointUpXxl, useMediaQuery, usePortal, useProvidedRefOrCreate, useStackState, useTabContext };
|
|
1741
1822
|
//# sourceMappingURL=index.esm.js.map
|