@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.js
CHANGED
|
@@ -202,7 +202,12 @@ function useDPortalContext() {
|
|
|
202
202
|
return context;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
|
|
205
|
+
function getCssVariable(variable) {
|
|
206
|
+
const computedStyle = getComputedStyle(document.documentElement);
|
|
207
|
+
return computedStyle.getPropertyValue(variable).trim();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const DEFAULT_STATE = {
|
|
206
211
|
language: 'en',
|
|
207
212
|
currency: {
|
|
208
213
|
symbol: '$',
|
|
@@ -245,18 +250,40 @@ const defaultState = {
|
|
|
245
250
|
decrease: 'dash-square',
|
|
246
251
|
},
|
|
247
252
|
},
|
|
253
|
+
breakpoints: {
|
|
254
|
+
xs: '',
|
|
255
|
+
sm: '',
|
|
256
|
+
md: '',
|
|
257
|
+
lg: '',
|
|
258
|
+
xl: '',
|
|
259
|
+
xxl: '',
|
|
260
|
+
},
|
|
248
261
|
setContext: () => { },
|
|
249
262
|
portalName: 'd-portal',
|
|
250
263
|
};
|
|
251
|
-
const DContext = React.createContext(
|
|
252
|
-
function DContextProvider({ language =
|
|
264
|
+
const DContext = React.createContext(DEFAULT_STATE);
|
|
265
|
+
function DContextProvider({ language = DEFAULT_STATE.language, currency = DEFAULT_STATE.currency, icon = DEFAULT_STATE.icon, iconMap = DEFAULT_STATE.iconMap, portalName = DEFAULT_STATE.portalName, availablePortals, children, }) {
|
|
253
266
|
const [internalContext, setInternalContext,] = React.useState({
|
|
254
267
|
language,
|
|
255
268
|
currency,
|
|
256
269
|
icon,
|
|
257
270
|
iconMap,
|
|
271
|
+
breakpoints: DEFAULT_STATE.breakpoints,
|
|
258
272
|
});
|
|
259
273
|
const setContext = React.useCallback((newValue) => (setInternalContext((prevInternalContext) => (Object.assign(Object.assign({}, prevInternalContext), newValue)))), []);
|
|
274
|
+
React.useLayoutEffect(() => {
|
|
275
|
+
console.log('context');
|
|
276
|
+
setContext({
|
|
277
|
+
breakpoints: {
|
|
278
|
+
xs: getCssVariable(`--${PREFIX_BS}breakpoint-xs`),
|
|
279
|
+
sm: getCssVariable(`--${PREFIX_BS}breakpoint-sm`),
|
|
280
|
+
md: getCssVariable(`--${PREFIX_BS}breakpoint-md`),
|
|
281
|
+
lg: getCssVariable(`--${PREFIX_BS}breakpoint-lg`),
|
|
282
|
+
xl: getCssVariable(`--${PREFIX_BS}breakpoint-xl`),
|
|
283
|
+
xxl: getCssVariable(`--${PREFIX_BS}breakpoint-xxl`),
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
}, [setContext]);
|
|
260
287
|
const value = React.useMemo(() => (Object.assign(Object.assign({}, internalContext), { setContext })), [internalContext, setContext]);
|
|
261
288
|
return (jsxRuntime.jsx(DContext.Provider, { value: value, children: jsxRuntime.jsx(DPortalContextProvider, { portalName: portalName, availablePortals: availablePortals, children: children }) }));
|
|
262
289
|
}
|
|
@@ -895,6 +922,47 @@ function useItemSelection({ getItemIdentifier: getItemIdentifierProp, previousSe
|
|
|
895
922
|
};
|
|
896
923
|
}
|
|
897
924
|
|
|
925
|
+
function subscribeToMediaQuery(query, callback) {
|
|
926
|
+
const mediaQueryList = window.matchMedia(query);
|
|
927
|
+
mediaQueryList.addEventListener('change', callback);
|
|
928
|
+
return () => {
|
|
929
|
+
mediaQueryList.removeEventListener('change', callback);
|
|
930
|
+
};
|
|
931
|
+
}
|
|
932
|
+
function checkMediaQuery(query) {
|
|
933
|
+
return window.matchMedia(query).matches;
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
function useMediaQuery(mediaQuery, useListener = false) {
|
|
937
|
+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
938
|
+
const noop = (_) => () => { };
|
|
939
|
+
return React.useSyncExternalStore(useListener ? (cb) => subscribeToMediaQuery(mediaQuery, cb) : noop, () => (mediaQuery ? checkMediaQuery(mediaQuery) : true), () => false);
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
function useMediaBreakpointUp(breakpoint, useListener = false) {
|
|
943
|
+
const { breakpoints } = useDContext();
|
|
944
|
+
const mediaQuery = React.useMemo(() => (`(min-width: ${breakpoints[breakpoint]})`), [breakpoint, breakpoints]);
|
|
945
|
+
return useMediaQuery(mediaQuery, useListener);
|
|
946
|
+
}
|
|
947
|
+
function useMediaBreakpointUpXs(useListener = false) {
|
|
948
|
+
return useMediaBreakpointUp('xs', useListener);
|
|
949
|
+
}
|
|
950
|
+
function useMediaBreakpointUpSm(useListener = false) {
|
|
951
|
+
return useMediaBreakpointUp('sm', useListener);
|
|
952
|
+
}
|
|
953
|
+
function useMediaBreakpointUpMd(useListener = false) {
|
|
954
|
+
return useMediaBreakpointUp('md', useListener);
|
|
955
|
+
}
|
|
956
|
+
function useMediaBreakpointUpLg(useListener = false) {
|
|
957
|
+
return useMediaBreakpointUp('lg', useListener);
|
|
958
|
+
}
|
|
959
|
+
function useMediaBreakpointUpXl(useListener = false) {
|
|
960
|
+
return useMediaBreakpointUp('xl', useListener);
|
|
961
|
+
}
|
|
962
|
+
function useMediaBreakpointUpXxl(useListener = false) {
|
|
963
|
+
return useMediaBreakpointUp('xxl', useListener);
|
|
964
|
+
}
|
|
965
|
+
|
|
898
966
|
function DInputCounter(_a, ref) {
|
|
899
967
|
var { minValue, maxValue, value = minValue, invalid, iconStart: iconStartProp, iconEnd: iconEndProp, iconStartAriaLabel = 'decrease action', iconEndAriaLabel = 'increase action', style, onChange } = _a, props = tslib.__rest(_a, ["minValue", "maxValue", "value", "invalid", "iconStart", "iconEnd", "iconStartAriaLabel", "iconEndAriaLabel", "style", "onChange"]);
|
|
900
968
|
const { handleOnWheel, } = useDisableInputWheel(ref);
|
|
@@ -1417,29 +1485,42 @@ function DProgress({ className, style, currentValue, minValue = 0, maxValue = 10
|
|
|
1417
1485
|
return (jsxRuntime.jsx("div", Object.assign({ className: classNames('progress', className) }, dataAttributes, { children: jsxRuntime.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 }) })));
|
|
1418
1486
|
}
|
|
1419
1487
|
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
const globalClickHandler = React.useCallback(() => {
|
|
1425
|
-
if (actionLinkText) {
|
|
1426
|
-
return;
|
|
1488
|
+
function DQuickActionButton({ line1, line2, className, actionIcon, actionIconFamilyClass, actionIconFamilyPrefix, actionIconTheme, representativeImage, representativeIcon, representativeIconTheme = 'secondary', representativeIconHasCircle = false, representativeIconFamilyClass, representativeIconFamilyPrefix, onClick, href, hrefTarget, style, dataAttributes, }) {
|
|
1489
|
+
const Tag = React.useMemo(() => {
|
|
1490
|
+
if (href) {
|
|
1491
|
+
return 'a';
|
|
1427
1492
|
}
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
const actionLinkClickHandler = React.useCallback(() => {
|
|
1431
|
-
if (!actionLinkText) {
|
|
1432
|
-
return;
|
|
1493
|
+
if (onClick) {
|
|
1494
|
+
return 'button';
|
|
1433
1495
|
}
|
|
1434
|
-
|
|
1435
|
-
}, [
|
|
1436
|
-
const
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1496
|
+
return 'div';
|
|
1497
|
+
}, [href, onClick]);
|
|
1498
|
+
const tagProps = React.useMemo(() => {
|
|
1499
|
+
if (href) {
|
|
1500
|
+
return {
|
|
1501
|
+
className: classNames('d-quick-action-button', 'd-quick-action-button-feedback', className),
|
|
1502
|
+
href,
|
|
1503
|
+
target: hrefTarget,
|
|
1504
|
+
};
|
|
1505
|
+
}
|
|
1506
|
+
if (onClick) {
|
|
1507
|
+
return {
|
|
1508
|
+
className: classNames('d-quick-action-button', 'd-quick-action-button-feedback', className),
|
|
1509
|
+
onClick,
|
|
1510
|
+
};
|
|
1511
|
+
}
|
|
1512
|
+
return {
|
|
1513
|
+
className: classNames('d-quick-action-button', className),
|
|
1514
|
+
};
|
|
1515
|
+
}, [
|
|
1516
|
+
className,
|
|
1517
|
+
href,
|
|
1518
|
+
hrefTarget,
|
|
1519
|
+
onClick,
|
|
1520
|
+
]);
|
|
1521
|
+
return (jsxRuntime.jsxs(Tag, Object.assign({ style: style }, tagProps, dataAttributes, { children: [representativeIcon && (jsxRuntime.jsx(DIcon, { className: "d-quick-action-button-representative-icon", size: representativeIconHasCircle
|
|
1441
1522
|
? `var(--${PREFIX_BS}quick-action-button-representative-icon-size)`
|
|
1442
|
-
: `var(--${PREFIX_BS}quick-action-button-representative-image-size)`, icon: representativeIcon, hasCircle: representativeIconHasCircle, theme: representativeIconTheme, familyClass: representativeIconFamilyClass, familyPrefix: representativeIconFamilyPrefix })), representativeImage && (jsxRuntime.jsx("img", { className: "d-quick-action-button-representative-image", src: representativeImage, alt: "" })), jsxRuntime.jsx("div", { className: "d-quick-action-button-content", children: jsxRuntime.jsxs("div", { className: "d-quick-action-button-text", children: [jsxRuntime.jsx("span", { className: "d-quick-action-button-line1", children: line1 }), jsxRuntime.jsx("small", { className: "d-quick-action-button-line2", children: line2 })] }) }),
|
|
1523
|
+
: `var(--${PREFIX_BS}quick-action-button-representative-image-size)`, icon: representativeIcon, hasCircle: representativeIconHasCircle, theme: representativeIconTheme, familyClass: representativeIconFamilyClass, familyPrefix: representativeIconFamilyPrefix })), representativeImage && (jsxRuntime.jsx("img", { className: "d-quick-action-button-representative-image", src: representativeImage, alt: "" })), jsxRuntime.jsx("div", { className: "d-quick-action-button-content", children: jsxRuntime.jsxs("div", { className: "d-quick-action-button-text", children: [jsxRuntime.jsx("span", { className: "d-quick-action-button-line1", children: line1 }), jsxRuntime.jsx("small", { className: "d-quick-action-button-line2", children: line2 })] }) }), actionIcon && (jsxRuntime.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 }))] })));
|
|
1443
1524
|
}
|
|
1444
1525
|
|
|
1445
1526
|
/**
|
|
@@ -1802,9 +1883,12 @@ exports.DToast = DToast$1;
|
|
|
1802
1883
|
exports.DToastContainer = DToastContainer;
|
|
1803
1884
|
exports.DTooltip = DTooltip;
|
|
1804
1885
|
exports.changeQueryString = changeQueryString;
|
|
1886
|
+
exports.checkMediaQuery = checkMediaQuery;
|
|
1805
1887
|
exports.configureI18n = configureI8n;
|
|
1806
1888
|
exports.formatCurrency = formatCurrency;
|
|
1889
|
+
exports.getCssVariable = getCssVariable;
|
|
1807
1890
|
exports.getQueryString = getQueryString;
|
|
1891
|
+
exports.subscribeToMediaQuery = subscribeToMediaQuery;
|
|
1808
1892
|
exports.useDContext = useDContext;
|
|
1809
1893
|
exports.useDPortalContext = useDPortalContext;
|
|
1810
1894
|
exports.useDToast = useDToast;
|
|
@@ -1813,6 +1897,13 @@ exports.useDisableInputWheel = useDisableInputWheel;
|
|
|
1813
1897
|
exports.useFormatCurrency = useFormatCurrency;
|
|
1814
1898
|
exports.useInputCurrency = useInputCurrency;
|
|
1815
1899
|
exports.useItemSelection = useItemSelection;
|
|
1900
|
+
exports.useMediaBreakpointUpLg = useMediaBreakpointUpLg;
|
|
1901
|
+
exports.useMediaBreakpointUpMd = useMediaBreakpointUpMd;
|
|
1902
|
+
exports.useMediaBreakpointUpSm = useMediaBreakpointUpSm;
|
|
1903
|
+
exports.useMediaBreakpointUpXl = useMediaBreakpointUpXl;
|
|
1904
|
+
exports.useMediaBreakpointUpXs = useMediaBreakpointUpXs;
|
|
1905
|
+
exports.useMediaBreakpointUpXxl = useMediaBreakpointUpXxl;
|
|
1906
|
+
exports.useMediaQuery = useMediaQuery;
|
|
1816
1907
|
exports.usePortal = usePortal;
|
|
1817
1908
|
exports.useProvidedRefOrCreate = useProvidedRefOrCreate;
|
|
1818
1909
|
exports.useStackState = useStackState;
|