@dynamic-framework/ui-react 1.2.0 → 1.2.1

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.
Files changed (32) hide show
  1. package/dist/css/dynamic-ui-all.css +1 -1
  2. package/dist/css/dynamic-ui-react.css +1 -1
  3. package/dist/css/dynamic-ui.css +1 -1
  4. package/dist/index.esm.js +89 -32
  5. package/dist/index.esm.js.map +1 -1
  6. package/dist/index.js +91 -30
  7. package/dist/index.js.map +1 -1
  8. package/dist/types/components/MCard.d.ts +7 -0
  9. package/dist/types/components/MCardAccount.d.ts +13 -0
  10. package/dist/types/components/MCardBody.d.ts +6 -0
  11. package/dist/types/components/MCardFooter.d.ts +6 -0
  12. package/dist/types/components/MCardHeader.d.ts +6 -0
  13. package/dist/types/components/MDatePicker.d.ts +20 -0
  14. package/dist/types/components/MDatePickerHeader.d.ts +19 -0
  15. package/dist/types/components/MDatePickerInput.d.ts +9 -0
  16. package/dist/types/components/MDatePickerTime.d.ts +9 -0
  17. package/dist/types/components/MInputCurrency.d.ts +2 -2
  18. package/dist/types/components/MMonthPicker.d.ts +7 -0
  19. package/dist/types/components/index.d.ts +6 -1
  20. package/dist/types/stories/components/MCard.stories.d.ts +10 -0
  21. package/dist/types/stories/components/MCardAccount.stories.d.ts +6 -0
  22. package/dist/types/stories/components/MDatePicker.stories.d.ts +14 -0
  23. package/package.json +3 -3
  24. package/src/style/components/_+import.scss +4 -1
  25. package/src/style/components/_m-card-account.scss +15 -0
  26. package/src/style/components/_m-datepicker.scss +224 -0
  27. package/src/style/components/_m-monthpicker.scss +90 -0
  28. package/src/style/components/_m-timepicker.scss +37 -0
  29. package/dist/types/components/MCalendar.d.ts +0 -25
  30. package/dist/types/stories/components/MCalendar.stories.d.ts +0 -6
  31. package/src/style/abstracts/variables/_calendar.scss +0 -19
  32. package/src/style/components/_m-calendar.scss +0 -205
package/dist/index.js CHANGED
@@ -2,19 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ const tslib = require('tslib');
5
6
  const jsxRuntime = require('react/jsx-runtime');
6
7
  const DatePicker = require('react-datepicker');
7
8
  const luxon = require('luxon');
8
- const es = require('date-fns/locale/es');
9
9
  const React = require('react');
10
- const ui = require('@dynamic-framework/ui');
11
- const ContentLoader = require('react-content-loader');
12
- const classNames = require('classnames');
13
- const reactToastify = require('react-toastify');
14
- require('react-toastify/dist/ReactToastify.css');
15
- const react = require('@floating-ui/react');
16
- const tslib = require('tslib');
17
- const formik = require('formik');
18
10
  const mAlert_js = require('@dynamic-framework/ui/components/m-alert.js');
19
11
  const mBadge_js = require('@dynamic-framework/ui/components/m-badge.js');
20
12
  const mButton_js = require('@dynamic-framework/ui/components/m-button.js');
@@ -36,6 +28,13 @@ const mQuickActionButton_js = require('@dynamic-framework/ui/components/m-quick-
36
28
  const mQuickActionCheck_js = require('@dynamic-framework/ui/components/m-quick-action-check.js');
37
29
  const mQuickActionSelect_js = require('@dynamic-framework/ui/components/m-quick-action-select.js');
38
30
  const mQuickActionSwitch_js = require('@dynamic-framework/ui/components/m-quick-action-switch.js');
31
+ const ui = require('@dynamic-framework/ui');
32
+ const ContentLoader = require('react-content-loader');
33
+ const classNames = require('classnames');
34
+ const reactToastify = require('react-toastify');
35
+ require('react-toastify/dist/ReactToastify.css');
36
+ const react = require('@floating-ui/react');
37
+ const formik = require('formik');
39
38
  const reactDropzone = require('react-dropzone');
40
39
  const reactSplide = require('@splidejs/react-splide');
41
40
  const i18n = require('i18next');
@@ -46,7 +45,6 @@ const ReactDOM = require('react-dom');
46
45
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
47
46
 
48
47
  const DatePicker__default = /*#__PURE__*/_interopDefaultLegacy(DatePicker);
49
- const es__default = /*#__PURE__*/_interopDefaultLegacy(es);
50
48
  const React__default = /*#__PURE__*/_interopDefaultLegacy(React);
51
49
  const ContentLoader__default = /*#__PURE__*/_interopDefaultLegacy(ContentLoader);
52
50
  const classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
@@ -313,7 +311,7 @@ function MSummaryCard({ title, description, icon, iconSize, iconTheme, Summary,
313
311
  }
314
312
 
315
313
  const LiquidContext = React.createContext({
316
- language: 'en-US',
314
+ language: 'en',
317
315
  currency: {
318
316
  symbol: '$',
319
317
  precision: 2,
@@ -561,25 +559,59 @@ function useOffcanvasContext() {
561
559
  return context;
562
560
  }
563
561
 
564
- DatePicker.registerLocale('es', es__default["default"]);
565
- function MCalendar({ setDate, date, calendarContainer, inline = true, withPortal, minDate, showTimeInput, calendarStartDay, timeInputLabel, dateFormat, className, calendarClassName, selectsRange, selectsStart, selectsEnd, startDate, endDate, autoFocus, monthsShown, fixedHeight, }) {
562
+ function MDatePickerTime(_a) {
563
+ var { value, onChange, mId, label } = _a, props = tslib.__rest(_a, ["value", "onChange", "mId", "label"]);
564
+ return (jsxRuntime.jsxs("div", Object.assign({ className: "d-flex align-items-center gap-2 flex-column m-datepicker-time" }, { children: [label && (jsxRuntime.jsx("p", Object.assign({ className: "m-datepicker-time-label" }, { children: label }))), jsxRuntime.jsx(MInput, Object.assign({}, onChange && {
565
+ onMChange: (time) => onChange(time),
566
+ }, { type: "time", mId: mId, value: value }, props))] })));
567
+ }
568
+
569
+ function MDatePickerInput(_a, ref) {
570
+ var { value, onClick, mId, iconEnd } = _a, props = tslib.__rest(_a, ["value", "onClick", "mId", "iconEnd"]);
571
+ React.useImperativeHandle(ref, () => ({}), []);
572
+ return (jsxRuntime.jsx("div", Object.assign({ role: "button", onClick: onClick, onKeyDown: () => { }, tabIndex: -1 }, { children: jsxRuntime.jsx(MInput, Object.assign({ isReadOnly: true, type: "text", mId: mId, value: value, onMIconEndClick: onClick, iconEnd: iconEnd }, props)) })));
573
+ }
574
+ const MDatePickerInput$1 = React.forwardRef(MDatePickerInput);
575
+
576
+ function MMonthPicker(_a) {
577
+ var { setDate, date } = _a, props = tslib.__rest(_a, ["setDate", "date"]);
566
578
  const dateJS = (value) => luxon.DateTime.fromISO(value).toJSDate();
567
579
  const { language } = useLiquidContext();
568
- const lang = language === 'en' ? undefined : 'es';
569
- return (jsxRuntime.jsx(DatePicker__default["default"], Object.assign({ selected: dateJS(date), onChange: (value) => {
570
- if (Array.isArray(value)) {
571
- const [start, end] = value;
572
- setDate([
573
- start ? luxon.DateTime.fromJSDate(start).toISO() : null,
574
- end ? luxon.DateTime.fromJSDate(end).toISO() : null,
575
- ]);
576
- }
577
- else {
578
- setDate(value ? luxon.DateTime.fromJSDate(value).toISO() : null);
579
- }
580
- },
581
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
582
- calendarContainer: calendarContainer, inline: inline, withPortal: withPortal, minDate: minDate ? dateJS(minDate) : undefined, showTimeInput: showTimeInput, calendarStartDay: calendarStartDay, timeInputLabel: timeInputLabel, dateFormat: dateFormat, className: className, calendarClassName: calendarClassName, selectsRange: selectsRange, selectsEnd: selectsEnd, selectsStart: selectsStart, startDate: startDate, endDate: endDate, autoFocus: autoFocus, monthsShown: monthsShown, fixedHeight: fixedHeight }, lang && { locale: lang })));
580
+ const lang = language || 'en';
581
+ return (jsxRuntime.jsx(DatePicker__default["default"], Object.assign({ showMonthYearPicker: true, selected: dateJS(date), calendarClassName: "m-month-picker", onChange: (value) => {
582
+ setDate(value);
583
+ }, customInput: (jsxRuntime.jsx("p", Object.assign({ className: "fw-bold text-capitalize" }, { children: luxon.DateTime.fromISO(date).setLocale(lang).toFormat('MMMM yyyy') }))), renderCustomHeader: ({ monthDate, decreaseYear, increaseYear, prevYearButtonDisabled, nextYearButtonDisabled, }) => (jsxRuntime.jsxs("div", Object.assign({ className: "d-flex align-items-center justify-content-between gap-4 fs-6 bg-dark" }, { children: [jsxRuntime.jsx(MButton, { iconStart: "chevron-left", size: "sm", variant: "link", theme: "light", onMClick: decreaseYear, isDisabled: prevYearButtonDisabled }), jsxRuntime.jsx("p", Object.assign({ className: "fs-6 fw-bold" }, { children: monthDate.getFullYear() })), jsxRuntime.jsx(MButton, { iconStart: "chevron-right", size: "sm", variant: "link", theme: "light", onMClick: increaseYear, isDisabled: nextYearButtonDisabled })] }))) }, props)));
584
+ }
585
+
586
+ function MDatePickerHeader({ monthDate, changeMonth, changeYear, decreaseMonth, increaseMonth, prevMonthButtonDisabled, nextMonthButtonDisabled, withMonthSelector, decreaseMonthIcon, increaseMonthIcon, iconSize, buttonVariant, buttonTheme, }) {
587
+ const { language } = useLiquidContext();
588
+ const lang = language || 'en';
589
+ return (jsxRuntime.jsxs("div", Object.assign({ className: "d-flex align-items-center justify-content-between m-datepicker-header" }, { children: [jsxRuntime.jsx(MButton, { iconStart: decreaseMonthIcon, size: iconSize, variant: buttonVariant, theme: buttonTheme, onMClick: decreaseMonth, isDisabled: prevMonthButtonDisabled }), jsxRuntime.jsx(MMonthPicker, Object.assign({}, !withMonthSelector && { readOnly: true }, { date: monthDate.toISOString(), setDate: (value) => {
590
+ if (value) {
591
+ changeMonth(luxon.DateTime.fromJSDate(value).month - 1);
592
+ changeYear(luxon.DateTime.fromJSDate(value).year);
593
+ }
594
+ } }, lang && { locale: lang })), jsxRuntime.jsx(MButton, { iconStart: increaseMonthIcon, size: iconSize, variant: buttonVariant, theme: buttonTheme, onMClick: increaseMonth, isDisabled: nextMonthButtonDisabled })] })));
595
+ }
596
+
597
+ function MDatePicker(_a) {
598
+ var { setDate, date, selectsRange, withMonthSelector, inputLabel, inputIcon = 'calendar', inputId = 'input-calendar', timeId = 'input-time', timeLabel, headerDecreaseMonthIcon = 'chevron-left', headerIncreaseMonthIcon = 'chevron-right', headerIconSize = 'sm', headerButtonVariant = 'link', headerButtonTheme = 'dark' } = _a, props = tslib.__rest(_a, ["setDate", "date", "selectsRange", "withMonthSelector", "inputLabel", "inputIcon", "inputId", "timeId", "timeLabel", "headerDecreaseMonthIcon", "headerIncreaseMonthIcon", "headerIconSize", "headerButtonVariant", "headerButtonTheme"]);
599
+ const dateJS = (value) => luxon.DateTime.fromISO(value).toJSDate();
600
+ const { language } = useLiquidContext();
601
+ const lang = language || 'en';
602
+ // eslint-disable-next-line react/no-unstable-nested-components
603
+ const InputPicker = React.forwardRef(({ value, onClick }, ref) => (jsxRuntime.jsx(MDatePickerInput$1, { label: inputLabel, mId: inputId, iconEnd: inputIcon, value: value, onClick: onClick, ref: ref })));
604
+ const TimeInputPicker = React.useCallback(({ value, onChange }) => (jsxRuntime.jsx(MDatePickerTime, { onChange: onChange, value: value, label: timeLabel, mId: timeId })), [timeLabel, timeId]);
605
+ const DatePickerHeader = React.useCallback((headerProps) => (jsxRuntime.jsx(MDatePickerHeader, Object.assign({}, headerProps, { decreaseMonthIcon: headerDecreaseMonthIcon, increaseMonthIcon: headerIncreaseMonthIcon, iconSize: headerIconSize, buttonVariant: headerButtonVariant, buttonTheme: headerButtonTheme, withMonthSelector: !!withMonthSelector }))), [headerButtonTheme,
606
+ headerButtonVariant,
607
+ headerDecreaseMonthIcon,
608
+ headerIconSize,
609
+ headerIncreaseMonthIcon,
610
+ withMonthSelector,
611
+ ]);
612
+ return (jsxRuntime.jsx(DatePicker__default["default"], Object.assign({ selected: dateJS(date), calendarClassName: "m-date-picker", onChange: (value) => {
613
+ setDate(value);
614
+ }, renderCustomHeader: (headerProps) => jsxRuntime.jsx(DatePickerHeader, Object.assign({}, headerProps)), customInput: jsxRuntime.jsx(InputPicker, {}), customTimeInput: jsxRuntime.jsx(TimeInputPicker, {}), selectsRange: selectsRange }, lang && { locale: lang }, props)));
583
615
  }
584
616
 
585
617
  function MSkeleton({ speed = 2, viewBox, backgroundColor, foregroundColor, children, }) {
@@ -762,7 +794,11 @@ function MTooltip({ classNameContainer, className, offSet = ARROW_HEIGHT + GAP,
762
794
  function MInputCurrency(_a) {
763
795
  var { onChange, onBlur, onFocus } = _a, otherProps = tslib.__rest(_a, ["onChange", "onBlur", "onFocus"]);
764
796
  const { currency } = useLiquidContext();
765
- return (jsxRuntime.jsx(MInputCurrencyBase, Object.assign({ currencyOptions: currency, onMChange: ({ detail }) => onChange(detail), onMBlur: ({ detail }) => onBlur(detail), onMFocus: ({ detail }) => onFocus(detail) }, otherProps)));
797
+ return (jsxRuntime.jsx(MInputCurrencyBase, Object.assign({ currencyOptions: currency, onMChange: ({ detail }) => onChange(detail) }, onBlur && {
798
+ onMBlur: ({ detail }) => onBlur(detail),
799
+ }, onFocus && {
800
+ onMFocus: ({ detail }) => onFocus(detail),
801
+ }, otherProps)));
766
802
  }
767
803
 
768
804
  function MBoxFile(_a) {
@@ -932,6 +968,26 @@ function MFormikInputCurrency(_a) {
932
968
  return (jsxRuntime.jsx(MInputCurrency, Object.assign({}, props, { name: field.name, value: field.value, onChange: (value) => helpers.setValue(value), onMBlur: ({ detail }) => field.onBlur(detail), isInvalid: !!meta.error, hint: meta.error || hint })));
933
969
  }
934
970
 
971
+ function MCard({ className, style, children, }) {
972
+ return (jsxRuntime.jsx("div", Object.assign({ style: style, className: classNames__default["default"]('card', className) }, { children: children })));
973
+ }
974
+
975
+ function MCardBody({ className, children, }) {
976
+ return (jsxRuntime.jsx("div", Object.assign({ className: classNames__default["default"]('card-body', className) }, { children: children })));
977
+ }
978
+
979
+ function MCardAccount({ className, icon, theme, name, number, balance, balanceText, onClick, onClickText, }) {
980
+ return (jsxRuntime.jsx(MCard, Object.assign({ className: classNames__default["default"]('m-card-account', className) }, { children: jsxRuntime.jsxs(MCardBody, { children: [jsxRuntime.jsxs("div", Object.assign({ className: "d-flex gap-3 align-items-center" }, { children: [jsxRuntime.jsx(MIcon, { icon: icon, hasCircle: true, theme: theme, size: "1.5rem" }), jsxRuntime.jsxs("div", Object.assign({ className: "d-block flex-grow-1" }, { children: [jsxRuntime.jsx("p", Object.assign({ className: "text-gray-700" }, { children: name })), jsxRuntime.jsx("small", Object.assign({ className: "text-gray" }, { children: number }))] }))] })), jsxRuntime.jsxs("div", Object.assign({ className: "d-block" }, { children: [jsxRuntime.jsx("p", Object.assign({ className: "fw-bold fs-6 text-body" }, { children: balance })), jsxRuntime.jsx("small", Object.assign({ className: "text-gray-700" }, { children: balanceText }))] })), jsxRuntime.jsx("div", Object.assign({ className: "d-flex justify-content-end" }, { children: jsxRuntime.jsx(MButton, { text: onClickText, variant: "link", size: "sm", theme: "secondary", iconEnd: "chevron-right", onMClick: onClick }) }))] }) })));
981
+ }
982
+
983
+ function MCardHeader({ className, children, }) {
984
+ return (jsxRuntime.jsx("div", Object.assign({ className: classNames__default["default"]('card-header', className) }, { children: children })));
985
+ }
986
+
987
+ function MCardFooter({ className, children, }) {
988
+ return (jsxRuntime.jsx("div", Object.assign({ className: classNames__default["default"]('card-footer', className) }, { children: children })));
989
+ }
990
+
935
991
  const LANG = ui.liquidParser.parse('{{site.language}}');
936
992
  async function configureI8n(resources, _a = {}) {
937
993
  var { lng = LANG, fallbackLng = 'es' } = _a, config = tslib.__rest(_a, ["lng", "fallbackLng"]);
@@ -957,13 +1013,18 @@ exports.MAlert = MAlert;
957
1013
  exports.MBadge = MBadge;
958
1014
  exports.MBoxFile = MBoxFile;
959
1015
  exports.MButton = MButton;
960
- exports.MCalendar = MCalendar;
1016
+ exports.MCard = MCard;
1017
+ exports.MCardAccount = MCardAccount;
1018
+ exports.MCardBody = MCardBody;
1019
+ exports.MCardFooter = MCardFooter;
1020
+ exports.MCardHeader = MCardHeader;
961
1021
  exports.MCarousel = MCarousel;
962
1022
  exports.MCarouselSlide = MCarouselSlide;
963
1023
  exports.MChip = MChip;
964
1024
  exports.MCollapse = MCollapse;
965
1025
  exports.MCollapseIconText = MCollapseIconText;
966
1026
  exports.MCurrencyText = MCurrencyText;
1027
+ exports.MDatePicker = MDatePicker;
967
1028
  exports.MFormikInput = MFormikInput;
968
1029
  exports.MFormikInputCurrency = MFormikInputCurrency;
969
1030
  exports.MFormikInputSelect = MFormikInputSelect;