@dynamic-framework/ui-react 2.0.0-dev.5 → 2.0.0-dev.6

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/index.js CHANGED
@@ -6,6 +6,7 @@ var React = require('react');
6
6
  var tslib = require('tslib');
7
7
  var LucideIcons = require('lucide-react');
8
8
  var reactDom = require('react-dom');
9
+ var framerMotion = require('framer-motion');
9
10
  var fileSelector = require('file-selector');
10
11
  var reactSplide = require('@splidejs/react-splide');
11
12
  var currency = require('currency.js');
@@ -43,7 +44,7 @@ var LucideIcons__namespace = /*#__PURE__*/_interopNamespaceDefault(LucideIcons);
43
44
 
44
45
  const PREFIX_BS = 'bs-';
45
46
 
46
- function DIconBase({ icon, color, style, className, size, hasCircle = false, materialStyle = false, familyClass = 'material-symbols-outlined', strokeWidth = 2, dataAttributes, }) {
47
+ function DIconBase({ icon, color, style, className, size, hasCircle = false, materialStyle = false, familyClass, familyPrefix, strokeWidth = 2, dataAttributes, }) {
47
48
  // If materialStyle is true, use Material Design icons (legacy)
48
49
  const useMaterialIcons = materialStyle;
49
50
  // Get Lucide icon component
@@ -70,13 +71,7 @@ function DIconBase({ icon, color, style, className, size, hasCircle = false, mat
70
71
  return {};
71
72
  }, [hasCircle, color]);
72
73
  const generateStyleVariables = React.useMemo(() => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, size && { [`--${PREFIX_BS}icon-component-size`]: size }), colorStyle), backgroundStyle), hasCircle && { [`--${PREFIX_BS}icon-component-padding`]: `calc(var(--${PREFIX_BS}icon-component-size, 24px) * 0.4)` }), style)), [size, colorStyle, backgroundStyle, hasCircle, style]);
73
- const generateClasses = React.useMemo(() => (Object.assign(Object.assign({ 'd-icon': true }, useMaterialIcons && {
74
- [familyClass]: true,
75
- }), className && { [className]: true })), [
76
- className,
77
- useMaterialIcons,
78
- familyClass,
79
- ]);
74
+ const generateClasses = React.useMemo(() => (Object.assign({ 'd-icon': true }, className && { [className]: true })), [className]);
80
75
  const iconSize = React.useMemo(() => {
81
76
  if (size) {
82
77
  const numSize = parseInt(size, 10);
@@ -86,10 +81,13 @@ function DIconBase({ icon, color, style, className, size, hasCircle = false, mat
86
81
  }, [size]);
87
82
  // Render Material Design icon (legacy support)
88
83
  if (useMaterialIcons) {
89
- return (jsxRuntime.jsx("i", Object.assign({ className: classNames(generateClasses), style: generateStyleVariables }, dataAttributes, { children: icon })));
84
+ return (jsxRuntime.jsx("i", Object.assign({ className: classNames(generateClasses, familyClass), style: generateStyleVariables }, dataAttributes, { children: icon })));
90
85
  }
91
86
  // Render Lucide icon
92
87
  if (!LucideIcon) {
88
+ if (familyClass && familyPrefix) {
89
+ return (jsxRuntime.jsx("i", Object.assign({ className: classNames(generateClasses, familyClass, `${familyPrefix}${icon}`), style: generateStyleVariables }, dataAttributes)));
90
+ }
93
91
  // eslint-disable-next-line no-console
94
92
  console.warn(`Icon "${icon}" not found in Lucide. Make sure to use PascalCase names (e.g., "Home", "User", "Settings")`);
95
93
  return (jsxRuntime.jsx("span", Object.assign({ className: classNames(generateClasses), style: generateStyleVariables }, dataAttributes, { children: "?" })));
@@ -253,7 +251,10 @@ function DPortalContextProvider({ portalName, children, availablePortals, }) {
253
251
  return (jsxRuntime.jsxs(DPortalContext.Provider, { value: value, children: [children, created && reactDom.createPortal(
254
252
  // eslint-disable-next-line max-len
255
253
  // eslint-disable-next-line jsx-a11y/no-static-element-interactions
256
- jsxRuntime.jsx("div", { onClick: ({ target }) => handleClose(target), onKeyDown: () => { }, children: stack.map(({ Component, name, payload, }) => (jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsx("div", { className: "backdrop fade show" }), jsxRuntime.jsx(Component, { name: name, payload: payload })] }, name))) }), document.getElementById(portalName))] }));
254
+ jsxRuntime.jsx("div", { onClick: ({ target }) => handleClose(target), onKeyDown: () => { }, children: jsxRuntime.jsx(framerMotion.AnimatePresence, { children: stack.flatMap(({ Component, name, payload, }) => [
255
+ jsxRuntime.jsx(framerMotion.motion.div, { className: "backdrop", initial: { opacity: 0 }, animate: { opacity: 0.5 }, exit: { opacity: 0, transition: { delay: 0.3 } }, transition: { duration: 0.15, ease: 'linear' } }, `${name}-backdrop`),
256
+ jsxRuntime.jsx(Component, { name: name, payload: payload }, name),
257
+ ]) }) }), document.getElementById(portalName))] }));
257
258
  }
258
259
  function useDPortalContext() {
259
260
  const context = React.useContext(DPortalContext);
@@ -885,9 +886,9 @@ function DBoxFile(_a) {
885
886
  'd-box-file-disabled': props.disabled,
886
887
  'd-box-file-valid': isDragValid,
887
888
  'd-box-file-invalid': isDragInvalid,
888
- }, className), style: style }, dataAttributes, { children: jsxRuntime.jsxs("div", Object.assign({ className: "d-box-file-dropzone", ref: rootRef, onDragEnter: handleDragEnter, onDragOver: (e) => e.preventDefault(), onDragLeave: handleDragLeave, onDrop: handleDrop, onClick: handleClick, onKeyDown: handleKeyDown }, (!props.disabled && !props.noKeyboard ? { tabIndex: 0 } : {}), { role: "presentation", children: [jsxRuntime.jsx("input", { type: "file", multiple: props.multiple, style: { display: 'none' }, ref: inputRef, disabled: props.disabled, onChange: handleFileSelect, onClick: (e) => e.stopPropagation(), tabIndex: -1, accept: acceptAttr }), jsxRuntime.jsx(DIcon, { icon: icon, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: iconMaterialStyle }), jsxRuntime.jsx("div", { className: "d-box-content", children: typeof children === 'function'
889
+ }, className), style: style }, dataAttributes, { children: jsxRuntime.jsxs("div", Object.assign({ className: "d-box-file-dropzone", ref: rootRef, onDragEnter: handleDragEnter, onDragOver: (e) => e.preventDefault(), onDragLeave: handleDragLeave, onDrop: handleDrop, onClick: handleClick, onKeyDown: handleKeyDown }, (!props.disabled && !props.noKeyboard ? { tabIndex: 0 } : {}), { role: "presentation", children: [jsxRuntime.jsx("input", { type: "file", multiple: props.multiple, style: { display: 'none' }, ref: inputRef, disabled: props.disabled, onChange: handleFileSelect, onClick: (e) => e.stopPropagation(), tabIndex: -1, accept: acceptAttr }), icon && iconProp !== false && (jsxRuntime.jsx(DIcon, { icon: icon, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, materialStyle: iconMaterialStyle })), jsxRuntime.jsx("div", { className: "d-box-content", children: typeof children === 'function'
889
890
  ? children(openFileDialog)
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}`))) }))] }));
891
+ : children || (jsxRuntime.jsx("p", { className: "text-center m-0", children: "Drag and drop some files here, or click to select files" })) })] })) })), !!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}`))) }))] }));
891
892
  }
892
893
 
893
894
  const DButton = React.forwardRef((props, ref) => {
@@ -1919,7 +1920,11 @@ function DModalFooter({ className, style, actionPlacement, children, }) {
1919
1920
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "d-modal-separator" }), jsxRuntime.jsx("div", { className: classNames(generateClasses, className), style: style, children: children })] }));
1920
1921
  }
1921
1922
 
1922
- function DModal$1({ name, className, style, staticBackdrop, scrollable, centered, fullScreen, fullScreenFrom, size, children, dataAttributes, }) {
1923
+ const defaultTransition$1 = {
1924
+ ease: 'easeInOut',
1925
+ duration: 0.3,
1926
+ };
1927
+ function DModal$1({ name, className, style, staticBackdrop, scrollable, centered, fullScreen, fullScreenFrom, size, transition, children, dataAttributes, }) {
1923
1928
  const fullScreenClass = React.useMemo(() => {
1924
1929
  if (fullScreen) {
1925
1930
  if (fullScreenFrom) {
@@ -1930,7 +1935,7 @@ function DModal$1({ name, className, style, staticBackdrop, scrollable, centered
1930
1935
  return '';
1931
1936
  }, [fullScreenFrom, fullScreen]);
1932
1937
  const generateModalDialogClasses = React.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]);
1933
- return (jsxRuntime.jsx("div", Object.assign({ className: classNames('modal portal fade show', className), id: name, tabIndex: -1, "aria-labelledby": `${name}Label`, "aria-hidden": "false", style: style }, staticBackdrop && ({
1938
+ return (jsxRuntime.jsx(framerMotion.motion.div, Object.assign({ className: classNames('modal portal show', className), id: name, tabIndex: -1, "aria-labelledby": `${name}Label`, "aria-hidden": "false", style: style, initial: { opacity: 0, scale: 0.95 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.95 }, transition: Object.assign(Object.assign({}, (transition !== null && transition !== void 0 ? transition : defaultTransition$1)), { delay: 0.15 }) }, staticBackdrop && ({
1934
1939
  [`data-${PREFIX_BS}backdrop`]: 'static',
1935
1940
  [`data-${PREFIX_BS}keyboard`]: 'false',
1936
1941
  }), dataAttributes, { children: jsxRuntime.jsx("div", { className: classNames(generateModalDialogClasses), children: jsxRuntime.jsx("div", { className: "modal-content", children: children }) }) })));
@@ -1959,10 +1964,36 @@ function DOffcanvasFooter({ actionPlacement, children, className, style, }) {
1959
1964
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "d-offcanvas-separator" }), jsxRuntime.jsx("div", { className: classNames(generateClasses, className), style: style, children: children })] }));
1960
1965
  }
1961
1966
 
1962
- function DOffcanvas$1({ name, className, style, staticBackdrop, scrollable, openFrom = 'end', children, dataAttributes, }) {
1963
- return (jsxRuntime.jsx("div", Object.assign({ className: classNames('offcanvas portal show', {
1967
+ const variants = {
1968
+ hidden: (openFrom) => {
1969
+ const properties = {};
1970
+ if (openFrom === 'start') {
1971
+ properties.x = '-100%';
1972
+ }
1973
+ if (openFrom === 'end') {
1974
+ properties.x = '100%';
1975
+ }
1976
+ if (openFrom === 'top') {
1977
+ properties.y = '-100%';
1978
+ }
1979
+ if (openFrom === 'bottom') {
1980
+ properties.y = '100%';
1981
+ }
1982
+ return properties;
1983
+ },
1984
+ visible: {
1985
+ x: 0,
1986
+ y: 0,
1987
+ },
1988
+ };
1989
+ const defaultTransition = {
1990
+ ease: 'easeInOut',
1991
+ duration: 0.3,
1992
+ };
1993
+ function DOffcanvas$1({ name, className, style, staticBackdrop, scrollable, openFrom = 'end', transition, children, dataAttributes, }) {
1994
+ return (jsxRuntime.jsx(framerMotion.motion.div, Object.assign({ className: classNames('offcanvas portal show', {
1964
1995
  [`offcanvas-${openFrom}`]: openFrom,
1965
- }, className), style: style, id: name, tabIndex: -1, "aria-labelledby": `${name}Label`, "aria-hidden": "false" }, staticBackdrop && ({
1996
+ }, className), style: Object.assign(Object.assign({}, style), { transition: 'none' }), id: name, tabIndex: -1, "aria-labelledby": `${name}Label`, "aria-hidden": "false", custom: openFrom, variants: variants, initial: "hidden", animate: "visible", exit: "hidden", transition: Object.assign(Object.assign({}, (transition !== null && transition !== void 0 ? transition : defaultTransition)), { delay: 0.15 }) }, staticBackdrop && ({
1966
1997
  [`data-${PREFIX_BS}backdrop`]: 'static',
1967
1998
  [`data-${PREFIX_BS}keyboard`]: 'false',
1968
1999
  }), scrollable && ({
@@ -2216,19 +2247,6 @@ function useDToast() {
2216
2247
  };
2217
2248
  }
2218
2249
 
2219
- function DTableHead({ className, style, field, label, value = '', onChange, }) {
2220
- const handleOnChange = React.useCallback(() => {
2221
- if (value === field) {
2222
- return onChange(`-${field}`);
2223
- }
2224
- if (value === `-${field}`) {
2225
- return onChange('');
2226
- }
2227
- return onChange(field);
2228
- }, [field, value, onChange]);
2229
- return (jsxRuntime.jsx("th", { style: style, className: classNames('d-table-head', className), children: jsxRuntime.jsxs("button", { type: "button", onClick: handleOnChange, children: [label, value && value.includes(field) && (jsxRuntime.jsx(DIcon, { icon: value === field ? 'arrow-up' : 'arrow-down' }))] }) }));
2230
- }
2231
-
2232
2250
  async function configureI8n(resources, _a = {}) {
2233
2251
  var { lng = 'en', fallbackLng = 'en' } = _a, config = tslib.__rest(_a, ["lng", "fallbackLng"]);
2234
2252
  return i18n
@@ -2591,7 +2609,6 @@ exports.DStepper = DStepper;
2591
2609
  exports.DStepperDesktop = DStepper$2;
2592
2610
  exports.DStepperMobile = DStepper$1;
2593
2611
  exports.DTabContent = DTabContent;
2594
- exports.DTableHead = DTableHead;
2595
2612
  exports.DTabs = DTabs;
2596
2613
  exports.DTimeline = DTimeline;
2597
2614
  exports.DToast = DToast;