@dynamic-framework/ui-react 1.1.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.
- package/LICENSE +21 -0
- package/README.md +16 -0
- package/dist/css/dynamic-ui-react.css +3 -0
- package/dist/css/dynamic-ui-react.css.map +1 -0
- package/dist/index.esm.js +857 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +924 -0
- package/dist/index.js.map +1 -0
- package/dist/types/components/MBoxFile.d.ts +10 -0
- package/dist/types/components/MCalendar.d.ts +25 -0
- package/dist/types/components/MCollapse.d.ts +11 -0
- package/dist/types/components/MCurrencyText.d.ts +7 -0
- package/dist/types/components/MFormikInput.d.ts +7 -0
- package/dist/types/components/MFormikInputSelect.d.ts +9 -0
- package/dist/types/components/MInputCurrency.d.ts +7 -0
- package/dist/types/components/MPopover.d.ts +8 -0
- package/dist/types/components/MSkeleton.d.ts +8 -0
- package/dist/types/components/MTabContent.d.ts +6 -0
- package/dist/types/components/MTabs.d.ts +19 -0
- package/dist/types/components/MToastContainer.d.ts +12 -0
- package/dist/types/components/MTooltip.d.ts +17 -0
- package/dist/types/components/banking/MCollapseIconText.d.ts +23 -0
- package/dist/types/components/banking/MPermissionGroup.d.ts +12 -0
- package/dist/types/components/banking/MPermissionItem.d.ts +10 -0
- package/dist/types/components/banking/MSummaryCard.d.ts +12 -0
- package/dist/types/components/banking/index.d.ts +4 -0
- package/dist/types/components/banking/interface.d.ts +7 -0
- package/dist/types/components/index.d.ts +16 -0
- package/dist/types/components/proxies.d.ts +23 -0
- package/dist/types/components/react-component-lib/createComponent.d.ts +10 -0
- package/dist/types/components/react-component-lib/createOverlayComponent.d.ts +21 -0
- package/dist/types/components/react-component-lib/index.d.ts +2 -0
- package/dist/types/components/react-component-lib/interfaces.d.ts +29 -0
- package/dist/types/components/react-component-lib/utils/attachProps.d.ts +16 -0
- package/dist/types/components/react-component-lib/utils/case.d.ts +2 -0
- package/dist/types/components/react-component-lib/utils/dev.d.ts +2 -0
- package/dist/types/components/react-component-lib/utils/index.d.ts +10 -0
- package/dist/types/contexts/LiquidContext.d.ts +14 -0
- package/dist/types/contexts/ModalContext.d.ts +44 -0
- package/dist/types/contexts/OffcanvasContext.d.ts +44 -0
- package/dist/types/contexts/index.d.ts +3 -0
- package/dist/types/hooks/index.d.ts +5 -0
- package/dist/types/hooks/useFormatCurrency.d.ts +4 -0
- package/dist/types/hooks/useScreenshot.d.ts +5 -0
- package/dist/types/hooks/useScreenshotDownload.d.ts +5 -0
- package/dist/types/hooks/useScreenshotWebShare.d.ts +5 -0
- package/dist/types/hooks/useStackState.d.ts +19 -0
- package/dist/types/hooks/useToast.d.ts +11 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/stories/components/MBoxFile.stories.d.ts +6 -0
- package/dist/types/stories/components/MButton.stories.d.ts +35 -0
- package/dist/types/stories/components/MCalendar.stories.d.ts +6 -0
- package/dist/types/stories/components/MFormikInput.stories.d.ts +7 -0
- package/dist/types/stories/components/MFormikInputSelect.stories.d.ts +7 -0
- package/dist/types/stories/components/MIcon.stories.d.ts +7 -0
- package/dist/types/stories/components/MInput.stories.d.ts +11 -0
- package/dist/types/stories/components/MInputCheck.stories.d.ts +13 -0
- package/dist/types/stories/components/MInputCounter.stories.d.ts +9 -0
- package/dist/types/stories/components/MInputCurrency.stories.d.ts +11 -0
- package/dist/types/stories/components/MInputCurrencyBase.stories.d.ts +11 -0
- package/dist/types/stories/components/MInputPassword.stories.d.ts +10 -0
- package/dist/types/stories/components/MInputPin.stories.d.ts +10 -0
- package/dist/types/stories/components/MInputSearch.stories.d.ts +10 -0
- package/dist/types/stories/components/MInputSelect.stories.d.ts +9 -0
- package/dist/types/stories/components/MInputSwitch.stories.d.ts +11 -0
- package/dist/types/stories/components/MProgressBar.stories.d.ts +12 -0
- package/dist/types/stories/components/MQuickActionButton.stories.d.ts +10 -0
- package/dist/types/stories/components/MQuickActionCheck.stories.d.ts +8 -0
- package/dist/types/stories/components/MQuickActionSelect.stories.d.ts +8 -0
- package/dist/types/stories/components/MQuickActionSwitch.stories.d.ts +9 -0
- package/dist/types/stories/components/MSkeleton.stories.d.ts +6 -0
- package/dist/types/stories/components/MTooltip.stories.d.ts +18 -0
- package/dist/types/stories/config/liquidConfig.d.ts +1 -0
- package/dist/types/stories/constants.d.ts +8 -0
- package/dist/types/stories/hooks/useFormatCurrency.stories.d.ts +7 -0
- package/dist/types/stories/hooks/useModalContext.stories.d.ts +7 -0
- package/dist/types/stories/hooks/useOffcanvasContext.stories.d.ts +8 -0
- package/dist/types/stories/hooks/useToast.stories.d.ts +18 -0
- package/dist/types/stories/patterns/MAlert.stories.d.ts +24 -0
- package/dist/types/stories/patterns/MBadge.stories.d.ts +8 -0
- package/dist/types/stories/patterns/MChip.stories.d.ts +9 -0
- package/dist/types/stories/patterns/MCollapse.stories.d.ts +8 -0
- package/dist/types/stories/patterns/MCollapseIconText.stories.d.ts +6 -0
- package/dist/types/stories/patterns/MModal.stories.d.ts +12 -0
- package/dist/types/stories/patterns/MOffcanvas.stories.d.ts +12 -0
- package/dist/types/stories/patterns/MPopover.stories.d.ts +8 -0
- package/dist/types/stories/patterns/MTabs.stories.d.ts +7 -0
- package/dist/types/utils/configureI18n.d.ts +2 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/package.json +134 -0
- package/src/style/_shame.scss +1 -0
- package/src/style/abstracts/_+import.scss +3 -0
- package/src/style/abstracts/variables/_+import.scss +2 -0
- package/src/style/abstracts/variables/_box-file.scss +15 -0
- package/src/style/abstracts/variables/_calendar.scss +19 -0
- package/src/style/abstracts/variables/_collapse-icon-text.scss +3 -0
- package/src/style/components/_+import.scss +6 -0
- package/src/style/components/_m-box-file.scss +66 -0
- package/src/style/components/_m-calendar.scss +205 -0
- package/src/style/components/_m-collapse-icon-text.scss +16 -0
- package/src/style/components/_m-collapse.scss +56 -0
- package/src/style/components/_m-popover.scss +12 -0
- package/src/style/components/_m-tabs.scss +56 -0
- package/src/style/main.scss +7 -0
|
@@ -0,0 +1,857 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import DatePicker, { registerLocale } from 'react-datepicker';
|
|
3
|
+
import { DateTime } from 'luxon';
|
|
4
|
+
import es from 'date-fns/locale/es';
|
|
5
|
+
import React, { createElement, useState, useEffect, createContext, useMemo, useContext, useCallback, useRef } from 'react';
|
|
6
|
+
import { PREFIX_BS, liquidParser, formatCurrency } from '@dynamic-framework/ui';
|
|
7
|
+
import ContentLoader from 'react-content-loader';
|
|
8
|
+
import classnames from 'classnames';
|
|
9
|
+
import { ToastContainer, Slide, toast } from 'react-toastify';
|
|
10
|
+
import 'react-toastify/dist/ReactToastify.css';
|
|
11
|
+
import { useFloating, offset, flip, shift, autoUpdate, useClick, useDismiss, useRole, useInteractions, useId, FloatingFocusManager, arrow, useHover, useFocus, FloatingPortal, FloatingArrow } from '@floating-ui/react';
|
|
12
|
+
import { __rest } from 'tslib';
|
|
13
|
+
import { useField } from 'formik';
|
|
14
|
+
import { defineCustomElement } from '@dynamic-framework/ui/components/m-alert.js';
|
|
15
|
+
import { defineCustomElement as defineCustomElement$1 } from '@dynamic-framework/ui/components/m-badge.js';
|
|
16
|
+
import { defineCustomElement as defineCustomElement$2 } from '@dynamic-framework/ui/components/m-button.js';
|
|
17
|
+
import { defineCustomElement as defineCustomElement$3 } from '@dynamic-framework/ui/components/m-chip.js';
|
|
18
|
+
import { defineCustomElement as defineCustomElement$4 } from '@dynamic-framework/ui/components/m-icon.js';
|
|
19
|
+
import { defineCustomElement as defineCustomElement$5 } from '@dynamic-framework/ui/components/m-input.js';
|
|
20
|
+
import { defineCustomElement as defineCustomElement$6 } from '@dynamic-framework/ui/components/m-input-check.js';
|
|
21
|
+
import { defineCustomElement as defineCustomElement$7 } from '@dynamic-framework/ui/components/m-input-counter.js';
|
|
22
|
+
import { defineCustomElement as defineCustomElement$8 } from '@dynamic-framework/ui/components/m-input-currency-base.js';
|
|
23
|
+
import { defineCustomElement as defineCustomElement$9 } from '@dynamic-framework/ui/components/m-input-password.js';
|
|
24
|
+
import { defineCustomElement as defineCustomElement$a } from '@dynamic-framework/ui/components/m-input-pin.js';
|
|
25
|
+
import { defineCustomElement as defineCustomElement$b } from '@dynamic-framework/ui/components/m-input-search.js';
|
|
26
|
+
import { defineCustomElement as defineCustomElement$c } from '@dynamic-framework/ui/components/m-input-select.js';
|
|
27
|
+
import { defineCustomElement as defineCustomElement$d } from '@dynamic-framework/ui/components/m-input-switch.js';
|
|
28
|
+
import { defineCustomElement as defineCustomElement$e } from '@dynamic-framework/ui/components/m-modal.js';
|
|
29
|
+
import { defineCustomElement as defineCustomElement$f } from '@dynamic-framework/ui/components/m-offcanvas.js';
|
|
30
|
+
import { defineCustomElement as defineCustomElement$g } from '@dynamic-framework/ui/components/m-progress-bar.js';
|
|
31
|
+
import { defineCustomElement as defineCustomElement$h } from '@dynamic-framework/ui/components/m-quick-action-button.js';
|
|
32
|
+
import { defineCustomElement as defineCustomElement$i } from '@dynamic-framework/ui/components/m-quick-action-check.js';
|
|
33
|
+
import { defineCustomElement as defineCustomElement$j } from '@dynamic-framework/ui/components/m-quick-action-select.js';
|
|
34
|
+
import { defineCustomElement as defineCustomElement$k } from '@dynamic-framework/ui/components/m-quick-action-switch.js';
|
|
35
|
+
import { useDropzone } from 'react-dropzone';
|
|
36
|
+
import i18n from 'i18next';
|
|
37
|
+
import { initReactI18next } from 'react-i18next';
|
|
38
|
+
import html2canvas from 'html2canvas';
|
|
39
|
+
import { createPortal } from 'react-dom';
|
|
40
|
+
|
|
41
|
+
const dashToPascalCase = (str) => str
|
|
42
|
+
.toLowerCase()
|
|
43
|
+
.split('-')
|
|
44
|
+
.map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))
|
|
45
|
+
.join('');
|
|
46
|
+
const camelToDashCase = (str) => str.replace(/([A-Z])/g, (m) => `-${m[0].toLowerCase()}`);
|
|
47
|
+
|
|
48
|
+
const attachProps = (node, newProps, oldProps = {}) => {
|
|
49
|
+
// some test frameworks don't render DOM elements, so we test here to make sure we are dealing with DOM first
|
|
50
|
+
if (node instanceof Element) {
|
|
51
|
+
// add any classes in className to the class list
|
|
52
|
+
const className = getClassName(node.classList, newProps, oldProps);
|
|
53
|
+
if (className !== '') {
|
|
54
|
+
node.className = className;
|
|
55
|
+
}
|
|
56
|
+
Object.keys(newProps).forEach((name) => {
|
|
57
|
+
if (name === 'children' ||
|
|
58
|
+
name === 'style' ||
|
|
59
|
+
name === 'ref' ||
|
|
60
|
+
name === 'class' ||
|
|
61
|
+
name === 'className' ||
|
|
62
|
+
name === 'forwardedRef') {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
|
|
66
|
+
const eventName = name.substring(2);
|
|
67
|
+
const eventNameLc = eventName[0].toLowerCase() + eventName.substring(1);
|
|
68
|
+
if (!isCoveredByReact(eventNameLc)) {
|
|
69
|
+
syncEvent(node, eventNameLc, newProps[name]);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
node[name] = newProps[name];
|
|
74
|
+
const propType = typeof newProps[name];
|
|
75
|
+
if (propType === 'string') {
|
|
76
|
+
node.setAttribute(camelToDashCase(name), newProps[name]);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const getClassName = (classList, newProps, oldProps) => {
|
|
83
|
+
const newClassProp = newProps.className || newProps.class;
|
|
84
|
+
const oldClassProp = oldProps.className || oldProps.class;
|
|
85
|
+
// map the classes to Maps for performance
|
|
86
|
+
const currentClasses = arrayToMap(classList);
|
|
87
|
+
const incomingPropClasses = arrayToMap(newClassProp ? newClassProp.split(' ') : []);
|
|
88
|
+
const oldPropClasses = arrayToMap(oldClassProp ? oldClassProp.split(' ') : []);
|
|
89
|
+
const finalClassNames = [];
|
|
90
|
+
// loop through each of the current classes on the component
|
|
91
|
+
// to see if it should be a part of the classNames added
|
|
92
|
+
currentClasses.forEach((currentClass) => {
|
|
93
|
+
if (incomingPropClasses.has(currentClass)) {
|
|
94
|
+
// add it as its already included in classnames coming in from newProps
|
|
95
|
+
finalClassNames.push(currentClass);
|
|
96
|
+
incomingPropClasses.delete(currentClass);
|
|
97
|
+
}
|
|
98
|
+
else if (!oldPropClasses.has(currentClass)) {
|
|
99
|
+
// add it as it has NOT been removed by user
|
|
100
|
+
finalClassNames.push(currentClass);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
incomingPropClasses.forEach((s) => finalClassNames.push(s));
|
|
104
|
+
return finalClassNames.join(' ');
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Transforms a React event name to a browser event name.
|
|
108
|
+
*/
|
|
109
|
+
const transformReactEventName = (eventNameSuffix) => {
|
|
110
|
+
switch (eventNameSuffix) {
|
|
111
|
+
case 'doubleclick':
|
|
112
|
+
return 'dblclick';
|
|
113
|
+
}
|
|
114
|
+
return eventNameSuffix;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Checks if an event is supported in the current execution environment.
|
|
118
|
+
* @license Modernizr 3.0.0pre (Custom Build) | MIT
|
|
119
|
+
*/
|
|
120
|
+
const isCoveredByReact = (eventNameSuffix) => {
|
|
121
|
+
if (typeof document === 'undefined') {
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
const eventName = 'on' + transformReactEventName(eventNameSuffix);
|
|
126
|
+
let isSupported = eventName in document;
|
|
127
|
+
if (!isSupported) {
|
|
128
|
+
const element = document.createElement('div');
|
|
129
|
+
element.setAttribute(eventName, 'return;');
|
|
130
|
+
isSupported = typeof element[eventName] === 'function';
|
|
131
|
+
}
|
|
132
|
+
return isSupported;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const syncEvent = (node, eventName, newEventHandler) => {
|
|
136
|
+
const eventStore = node.__events || (node.__events = {});
|
|
137
|
+
const oldEventHandler = eventStore[eventName];
|
|
138
|
+
// Remove old listener so they don't double up.
|
|
139
|
+
if (oldEventHandler) {
|
|
140
|
+
node.removeEventListener(eventName, oldEventHandler);
|
|
141
|
+
}
|
|
142
|
+
// Bind new listener.
|
|
143
|
+
node.addEventListener(eventName, (eventStore[eventName] = function handler(e) {
|
|
144
|
+
if (newEventHandler) {
|
|
145
|
+
newEventHandler.call(this, e);
|
|
146
|
+
}
|
|
147
|
+
}));
|
|
148
|
+
};
|
|
149
|
+
const arrayToMap = (arr) => {
|
|
150
|
+
const map = new Map();
|
|
151
|
+
arr.forEach((s) => map.set(s, s));
|
|
152
|
+
return map;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const setRef = (ref, value) => {
|
|
156
|
+
if (typeof ref === 'function') {
|
|
157
|
+
ref(value);
|
|
158
|
+
}
|
|
159
|
+
else if (ref != null) {
|
|
160
|
+
// Cast as a MutableRef so we can assign current
|
|
161
|
+
ref.current = value;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
const mergeRefs = (...refs) => {
|
|
165
|
+
return (value) => {
|
|
166
|
+
refs.forEach((ref) => {
|
|
167
|
+
setRef(ref, value);
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
const createForwardRef = (ReactComponent, displayName) => {
|
|
172
|
+
const forwardRef = (props, ref) => {
|
|
173
|
+
return jsx(ReactComponent, Object.assign({}, props, { forwardedRef: ref }));
|
|
174
|
+
};
|
|
175
|
+
forwardRef.displayName = displayName;
|
|
176
|
+
const forwardedRef = React.forwardRef(forwardRef);
|
|
177
|
+
forwardedRef.displayName = displayName;
|
|
178
|
+
return forwardedRef;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction, defineCustomElement) => {
|
|
182
|
+
if (defineCustomElement !== undefined) {
|
|
183
|
+
defineCustomElement();
|
|
184
|
+
}
|
|
185
|
+
const displayName = dashToPascalCase(tagName);
|
|
186
|
+
const ReactComponent = class extends React.Component {
|
|
187
|
+
constructor(props) {
|
|
188
|
+
super(props);
|
|
189
|
+
this.setComponentElRef = (element) => {
|
|
190
|
+
this.componentEl = element;
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
componentDidMount() {
|
|
194
|
+
this.componentDidUpdate(this.props);
|
|
195
|
+
}
|
|
196
|
+
componentDidUpdate(prevProps) {
|
|
197
|
+
attachProps(this.componentEl, this.props, prevProps);
|
|
198
|
+
}
|
|
199
|
+
render() {
|
|
200
|
+
const _a = this.props, { children, forwardedRef, style, className, ref } = _a, cProps = __rest(_a, ["children", "forwardedRef", "style", "className", "ref"]);
|
|
201
|
+
let propsToPass = Object.keys(cProps).reduce((acc, name) => {
|
|
202
|
+
const value = cProps[name];
|
|
203
|
+
if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
|
|
204
|
+
const eventName = name.substring(2).toLowerCase();
|
|
205
|
+
if (typeof document !== 'undefined' && isCoveredByReact(eventName)) {
|
|
206
|
+
acc[name] = value;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
// we should only render strings, booleans, and numbers as attrs in html.
|
|
211
|
+
// objects, functions, arrays etc get synced via properties on mount.
|
|
212
|
+
const type = typeof value;
|
|
213
|
+
if (type === 'string' || type === 'boolean' || type === 'number') {
|
|
214
|
+
acc[camelToDashCase(name)] = value;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return acc;
|
|
218
|
+
}, {});
|
|
219
|
+
if (manipulatePropsFunction) {
|
|
220
|
+
propsToPass = manipulatePropsFunction(this.props, propsToPass);
|
|
221
|
+
}
|
|
222
|
+
const newProps = Object.assign(Object.assign({}, propsToPass), { ref: mergeRefs(forwardedRef, this.setComponentElRef), style });
|
|
223
|
+
/**
|
|
224
|
+
* We use createElement here instead of
|
|
225
|
+
* React.createElement to work around a
|
|
226
|
+
* bug in Vite (https://github.com/vitejs/vite/issues/6104).
|
|
227
|
+
* React.createElement causes all elements to be rendered
|
|
228
|
+
* as <tagname> instead of the actual Web Component.
|
|
229
|
+
*/
|
|
230
|
+
return createElement(tagName, newProps, children);
|
|
231
|
+
}
|
|
232
|
+
static get displayName() {
|
|
233
|
+
return displayName;
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
// If context was passed to createReactComponent then conditionally add it to the Component Class
|
|
237
|
+
if (ReactComponentContext) {
|
|
238
|
+
ReactComponent.contextType = ReactComponentContext;
|
|
239
|
+
}
|
|
240
|
+
return createForwardRef(ReactComponent, displayName);
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
/* eslint-disable */
|
|
244
|
+
const MAlert = /*@__PURE__*/ createReactComponent('m-alert', undefined, undefined, defineCustomElement);
|
|
245
|
+
const MBadge = /*@__PURE__*/ createReactComponent('m-badge', undefined, undefined, defineCustomElement$1);
|
|
246
|
+
const MButton = /*@__PURE__*/ createReactComponent('m-button', undefined, undefined, defineCustomElement$2);
|
|
247
|
+
const MChip = /*@__PURE__*/ createReactComponent('m-chip', undefined, undefined, defineCustomElement$3);
|
|
248
|
+
const MIcon = /*@__PURE__*/ createReactComponent('m-icon', undefined, undefined, defineCustomElement$4);
|
|
249
|
+
const MInput = /*@__PURE__*/ createReactComponent('m-input', undefined, undefined, defineCustomElement$5);
|
|
250
|
+
const MInputCheck = /*@__PURE__*/ createReactComponent('m-input-check', undefined, undefined, defineCustomElement$6);
|
|
251
|
+
const MInputCounter = /*@__PURE__*/ createReactComponent('m-input-counter', undefined, undefined, defineCustomElement$7);
|
|
252
|
+
const MInputCurrencyBase = /*@__PURE__*/ createReactComponent('m-input-currency-base', undefined, undefined, defineCustomElement$8);
|
|
253
|
+
const MInputPassword = /*@__PURE__*/ createReactComponent('m-input-password', undefined, undefined, defineCustomElement$9);
|
|
254
|
+
const MInputPin = /*@__PURE__*/ createReactComponent('m-input-pin', undefined, undefined, defineCustomElement$a);
|
|
255
|
+
const MInputSearch = /*@__PURE__*/ createReactComponent('m-input-search', undefined, undefined, defineCustomElement$b);
|
|
256
|
+
const MInputSelect = /*@__PURE__*/ createReactComponent('m-input-select', undefined, undefined, defineCustomElement$c);
|
|
257
|
+
const MInputSwitch = /*@__PURE__*/ createReactComponent('m-input-switch', undefined, undefined, defineCustomElement$d);
|
|
258
|
+
const MModal = /*@__PURE__*/ createReactComponent('m-modal', undefined, undefined, defineCustomElement$e);
|
|
259
|
+
const MOffcanvas = /*@__PURE__*/ createReactComponent('m-offcanvas', undefined, undefined, defineCustomElement$f);
|
|
260
|
+
const MProgressBar = /*@__PURE__*/ createReactComponent('m-progress-bar', undefined, undefined, defineCustomElement$g);
|
|
261
|
+
const MQuickActionButton = /*@__PURE__*/ createReactComponent('m-quick-action-button', undefined, undefined, defineCustomElement$h);
|
|
262
|
+
const MQuickActionCheck = /*@__PURE__*/ createReactComponent('m-quick-action-check', undefined, undefined, defineCustomElement$i);
|
|
263
|
+
const MQuickActionSelect = /*@__PURE__*/ createReactComponent('m-quick-action-select', undefined, undefined, defineCustomElement$j);
|
|
264
|
+
const MQuickActionSwitch = /*@__PURE__*/ createReactComponent('m-quick-action-switch', undefined, undefined, defineCustomElement$k);
|
|
265
|
+
|
|
266
|
+
function MCollapse({ id, className, Component, hasSeparator = false, defaultCollapsed = false, onChange, children, }) {
|
|
267
|
+
const [toggle, setToggle] = useState(defaultCollapsed);
|
|
268
|
+
const onChangeCollapse = () => setToggle((prev) => !prev);
|
|
269
|
+
useEffect(() => {
|
|
270
|
+
if (onChange) {
|
|
271
|
+
onChange(toggle);
|
|
272
|
+
}
|
|
273
|
+
}, [toggle, onChange]);
|
|
274
|
+
useEffect(() => {
|
|
275
|
+
setToggle(defaultCollapsed);
|
|
276
|
+
}, [defaultCollapsed]);
|
|
277
|
+
return (jsxs("div", Object.assign({ id: id, className: classnames('m-collapse collapse-container', className) }, { children: [jsxs("button", Object.assign({ className: "collapse-button", type: "button", onClick: onChangeCollapse }, { children: [jsx("div", Object.assign({ className: "flex-grow-1" }, { children: Component })), jsx(MIcon, { color: `var(--${PREFIX_BS}gray)`, size: `var(--${PREFIX_BS}ref-fs-small)`, icon: toggle ? 'chevron-up' : 'chevron-down' })] })), toggle && (jsx("div", Object.assign({ className: classnames({
|
|
278
|
+
'collapse-body': true,
|
|
279
|
+
}), style: {
|
|
280
|
+
[`--${PREFIX_BS}m-collapse-separator-display`]: hasSeparator ? 'block' : 'none',
|
|
281
|
+
} }, { children: children })))] })));
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function MCollapseIconText({ children, icon, iconSize = '1.5rem', iconTheme = 'primary', title, iconFamilyClass, iconFamilyPrefix, }) {
|
|
285
|
+
return (jsx(MCollapse, Object.assign({ defaultCollapsed: true, className: "m-collapse-icon-text", Component: (jsxs("div", Object.assign({ className: "m-collapse-icon-text-header" }, { children: [jsx(MIcon, { icon: icon, size: iconSize, theme: iconTheme, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix, hasCircle: true }), jsx("span", Object.assign({ className: "m-collapse-icon-text-title" }, { children: title }))] }))) }, { children: children })));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function MPermissionItem({ permission, permissionState, onChange, onAction = () => { }, }) {
|
|
289
|
+
return (jsxs("div", Object.assign({ role: "button", tabIndex: 0, onKeyDown: () => { }, className: "d-flex permission-item align-items-center", onClick: onAction }, { children: [jsx("span", Object.assign({ className: "flex-grow-1 label" }, { children: permission.label })), permission.type === 'custom' && (jsx(MBadge, { theme: "tertiary", text: permissionState })), jsx(MInputSwitch, { mId: permission.id, isChecked: !!permission.value, isDisabled: !permission.enabled, onMChange: ({ detail: checked }) => onChange(checked) })] })));
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function MPermissionGroup({ title, description, permissionState, permissionList, onChangePermission, onCustomAction = () => { }, }) {
|
|
293
|
+
return (jsxs("div", Object.assign({ className: "row operation-group g-0 mb-3 mb-lg-0" }, { children: [jsxs("div", Object.assign({ className: "col-12 col-lg-4 d-flex flex-column justify-content-center" }, { children: [jsx("h6", Object.assign({ className: "fw-bold mb-3 mb-lg-2" }, { children: title })), jsx("p", Object.assign({ className: "fs-8 d-none d-lg-block m-0" }, { children: description }))] })), jsx("div", Object.assign({ className: "col-12 offset-lg-1 col-lg-7" }, { children: permissionList.map((permission) => (jsx(MPermissionItem, { permission: permission, permissionState: permissionState, onChange: (isChecked) => onChangePermission(permission, isChecked), onAction: () => onCustomAction(permission) }, permission.id))) }))] })));
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function MSummaryCard({ title, description, icon, iconSize, iconTheme, Summary, }) {
|
|
297
|
+
return (jsxs("div", { children: [jsx("h6", Object.assign({ className: "fw-bold fs-6" }, { children: title })), jsx("p", Object.assign({ className: "fs-8" }, { children: description })), jsxs("div", Object.assign({ className: "bg-white rounded p-4 d-flex gap-3 shadow-sm text-gray-700 fs-8" }, { children: [jsx(MIcon, { icon: icon, theme: iconTheme, size: iconSize }), Summary] }))] }));
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const LiquidContext = createContext({
|
|
301
|
+
language: 'en-US',
|
|
302
|
+
currency: {
|
|
303
|
+
symbol: '$',
|
|
304
|
+
precision: 2,
|
|
305
|
+
separator: ',',
|
|
306
|
+
decimal: '.',
|
|
307
|
+
},
|
|
308
|
+
});
|
|
309
|
+
function LiquidContextProvider({ children, }) {
|
|
310
|
+
const value = useMemo(() => ({
|
|
311
|
+
language: liquidParser.parse('{{site.language}}'),
|
|
312
|
+
currency: {
|
|
313
|
+
symbol: liquidParser.parse('{{vars.currency-symbol}}'),
|
|
314
|
+
precision: parseInt(liquidParser.parse('{{vars.currency-precision}}'), 10),
|
|
315
|
+
separator: liquidParser.parse('{{vars.currency-separator}}'),
|
|
316
|
+
decimal: liquidParser.parse('{{vars.currency-decimal}}'),
|
|
317
|
+
},
|
|
318
|
+
}), []);
|
|
319
|
+
return (jsx(LiquidContext.Provider, Object.assign({ value: value }, { children: children })));
|
|
320
|
+
}
|
|
321
|
+
function useLiquidContext() {
|
|
322
|
+
const context = useContext(LiquidContext);
|
|
323
|
+
if (context === undefined) {
|
|
324
|
+
throw new Error('useLiquidContext was used outside of LiquidContextProvider');
|
|
325
|
+
}
|
|
326
|
+
return context;
|
|
327
|
+
}
|
|
328
|
+
var LiquidContext$1 = LiquidContext;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* useStackState inspired from rooks
|
|
332
|
+
* @see https://github.com/imbhargav5/rooks/blob/main/packages/rooks/src/hooks/useStackState.ts
|
|
333
|
+
* @description Manages a stack with react hooks.
|
|
334
|
+
* @param initialList Initial value of the list
|
|
335
|
+
* @returns The list and controls to modify the stack
|
|
336
|
+
* @see https://react-hooks.org/docs/useStackState
|
|
337
|
+
*/
|
|
338
|
+
function useStackState(initialList) {
|
|
339
|
+
const [list, setList] = useState(initialList);
|
|
340
|
+
const { length } = list;
|
|
341
|
+
const push = useCallback((item) => {
|
|
342
|
+
setList((prevList) => [
|
|
343
|
+
...prevList,
|
|
344
|
+
item,
|
|
345
|
+
]);
|
|
346
|
+
}, []);
|
|
347
|
+
const pop = useCallback(() => {
|
|
348
|
+
setList((prevList) => {
|
|
349
|
+
if (prevList.length === 0) {
|
|
350
|
+
return prevList;
|
|
351
|
+
}
|
|
352
|
+
const [, ...newList] = prevList;
|
|
353
|
+
return newList;
|
|
354
|
+
});
|
|
355
|
+
}, []);
|
|
356
|
+
const peek = useCallback(() => {
|
|
357
|
+
if (list.length > 0) {
|
|
358
|
+
return list[list.length - 1];
|
|
359
|
+
}
|
|
360
|
+
return undefined;
|
|
361
|
+
}, [list]);
|
|
362
|
+
const clear = () => setList([]);
|
|
363
|
+
const isEmpty = useCallback(() => list.length === 0, [list]);
|
|
364
|
+
const controls = {
|
|
365
|
+
clear,
|
|
366
|
+
isEmpty,
|
|
367
|
+
length,
|
|
368
|
+
peek,
|
|
369
|
+
pop,
|
|
370
|
+
push,
|
|
371
|
+
};
|
|
372
|
+
return [list, controls];
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
const ModalContext = createContext(undefined);
|
|
376
|
+
function enhanceModal(Modal, callbacks) {
|
|
377
|
+
return function EnhancedModal(_a) {
|
|
378
|
+
var { name, payload } = _a, otherProps = __rest(_a, ["name", "payload"]);
|
|
379
|
+
useEffect(() => {
|
|
380
|
+
if (callbacks === null || callbacks === void 0 ? void 0 : callbacks.onAfterOpen) {
|
|
381
|
+
callbacks.onAfterOpen(payload);
|
|
382
|
+
}
|
|
383
|
+
return () => {
|
|
384
|
+
if (callbacks === null || callbacks === void 0 ? void 0 : callbacks.onAfterClose) {
|
|
385
|
+
callbacks.onAfterClose({ fromModal: false }, payload);
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
}, [payload]);
|
|
389
|
+
return (
|
|
390
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
391
|
+
jsx(Modal, Object.assign({ name: name, payload: payload }, otherProps)));
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
function ModalContextProvider({ portalName, children, availableModals, }) {
|
|
395
|
+
const [hasPortal, setHasPortal] = useState(false);
|
|
396
|
+
useEffect(() => {
|
|
397
|
+
const previousPortal = document.querySelector(`#${portalName}`);
|
|
398
|
+
if (previousPortal) {
|
|
399
|
+
previousPortal.remove();
|
|
400
|
+
}
|
|
401
|
+
const portal = document.createElement('div');
|
|
402
|
+
portal.id = portalName;
|
|
403
|
+
document.body.appendChild(portal);
|
|
404
|
+
setHasPortal(true);
|
|
405
|
+
}, [portalName]);
|
|
406
|
+
const [stack, { push, pop, peek }] = useStackState([]);
|
|
407
|
+
useEffect(() => {
|
|
408
|
+
if (stack.length) {
|
|
409
|
+
document.body.style.overflow = 'hidden';
|
|
410
|
+
document.body.style.paddingRight = '0';
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
document.body.style.overflow = 'unset';
|
|
414
|
+
document.body.style.paddingRight = 'unset';
|
|
415
|
+
}
|
|
416
|
+
}, [stack.length]);
|
|
417
|
+
const openModal = useCallback((modalName, { payload, callbacks } = { payload: {} }) => {
|
|
418
|
+
const Component = availableModals[modalName];
|
|
419
|
+
if (!Component) {
|
|
420
|
+
throw new Error(`there is no component for modal ${modalName}`);
|
|
421
|
+
}
|
|
422
|
+
const stackItem = {
|
|
423
|
+
modalName,
|
|
424
|
+
Component,
|
|
425
|
+
payload,
|
|
426
|
+
callbacks,
|
|
427
|
+
};
|
|
428
|
+
if (callbacks === null || callbacks === void 0 ? void 0 : callbacks.onBeforeOpen) {
|
|
429
|
+
callbacks.onBeforeOpen(payload);
|
|
430
|
+
}
|
|
431
|
+
push(stackItem);
|
|
432
|
+
}, [availableModals, push]);
|
|
433
|
+
const closeModal = useCallback((context = { fromModal: false }) => {
|
|
434
|
+
var _a;
|
|
435
|
+
const stackItem = peek();
|
|
436
|
+
if (!stackItem) {
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
if ((_a = stackItem.callbacks) === null || _a === void 0 ? void 0 : _a.onBeforeClose) {
|
|
440
|
+
stackItem.callbacks.onBeforeClose(context, stackItem.payload);
|
|
441
|
+
}
|
|
442
|
+
pop();
|
|
443
|
+
}, [peek, pop]);
|
|
444
|
+
const value = useMemo(() => ({
|
|
445
|
+
stack,
|
|
446
|
+
openModal,
|
|
447
|
+
closeModal,
|
|
448
|
+
}), [stack, openModal, closeModal]);
|
|
449
|
+
return (jsxs(ModalContext.Provider, Object.assign({ value: value }, { children: [children, hasPortal && createPortal(jsxs(Fragment, { children: [stack.map(({ Component, modalName, callbacks, payload, }) => {
|
|
450
|
+
const EnhancedComponent = enhanceModal(Component, callbacks);
|
|
451
|
+
return (jsx(EnhancedComponent, { name: modalName, payload: payload, openModal: openModal, closeModal: closeModal }, modalName));
|
|
452
|
+
}), !!stack.length && jsx("div", { className: "modal-backdrop fade show" })] }), document.getElementById(portalName))] })));
|
|
453
|
+
}
|
|
454
|
+
function useModalContext() {
|
|
455
|
+
const context = useContext(ModalContext);
|
|
456
|
+
if (context === undefined) {
|
|
457
|
+
throw new Error('useModalContext was used outside of ModalContextProvider');
|
|
458
|
+
}
|
|
459
|
+
return context;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
const OffcanvasContext = createContext(undefined);
|
|
463
|
+
function enhanceOffcanvas(Offcanvas, callbacks) {
|
|
464
|
+
return function EnhancedOffcanvas(_a) {
|
|
465
|
+
var { name, payload } = _a, otherProps = __rest(_a, ["name", "payload"]);
|
|
466
|
+
useEffect(() => {
|
|
467
|
+
if (callbacks === null || callbacks === void 0 ? void 0 : callbacks.onAfterOpen) {
|
|
468
|
+
callbacks.onAfterOpen(payload);
|
|
469
|
+
}
|
|
470
|
+
return () => {
|
|
471
|
+
if (callbacks === null || callbacks === void 0 ? void 0 : callbacks.onAfterClose) {
|
|
472
|
+
callbacks.onAfterClose({ fromOffcanvas: false }, payload);
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
}, [payload]);
|
|
476
|
+
return (
|
|
477
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
478
|
+
jsx(Offcanvas, Object.assign({ name: name, payload: payload }, otherProps)));
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
function OffcanvasContextProvider({ portalName, children, availableOffcanvas, }) {
|
|
482
|
+
const [hasPortal, setHasPortal] = useState(false);
|
|
483
|
+
useEffect(() => {
|
|
484
|
+
const previousPortal = document.querySelector(`#${portalName}`);
|
|
485
|
+
if (previousPortal) {
|
|
486
|
+
previousPortal.remove();
|
|
487
|
+
}
|
|
488
|
+
const portal = document.createElement('div');
|
|
489
|
+
portal.id = portalName;
|
|
490
|
+
document.body.appendChild(portal);
|
|
491
|
+
setHasPortal(true);
|
|
492
|
+
}, [portalName]);
|
|
493
|
+
const [stack, { push, pop, peek }] = useStackState([]);
|
|
494
|
+
useEffect(() => {
|
|
495
|
+
if (stack.length) {
|
|
496
|
+
document.body.style.overflow = 'hidden';
|
|
497
|
+
document.body.style.paddingRight = '0';
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
document.body.style.overflow = 'unset';
|
|
501
|
+
document.body.style.paddingRight = 'unset';
|
|
502
|
+
}
|
|
503
|
+
}, [stack.length]);
|
|
504
|
+
const openOffcanvas = useCallback((offcanvasName, { payload, callbacks } = { payload: {} }) => {
|
|
505
|
+
const Component = availableOffcanvas[offcanvasName];
|
|
506
|
+
if (!Component) {
|
|
507
|
+
throw new Error(`there is no component for offcanvas ${offcanvasName}`);
|
|
508
|
+
}
|
|
509
|
+
const stackItem = {
|
|
510
|
+
offcanvasName,
|
|
511
|
+
Component,
|
|
512
|
+
payload,
|
|
513
|
+
callbacks,
|
|
514
|
+
};
|
|
515
|
+
if (callbacks === null || callbacks === void 0 ? void 0 : callbacks.onBeforeOpen) {
|
|
516
|
+
callbacks.onBeforeOpen(payload);
|
|
517
|
+
}
|
|
518
|
+
push(stackItem);
|
|
519
|
+
}, [availableOffcanvas, push]);
|
|
520
|
+
const closeOffcanvas = useCallback((context = { fromOffcanvas: false }) => {
|
|
521
|
+
var _a;
|
|
522
|
+
const stackItem = peek();
|
|
523
|
+
if (!stackItem) {
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
if ((_a = stackItem.callbacks) === null || _a === void 0 ? void 0 : _a.onBeforeClose) {
|
|
527
|
+
stackItem.callbacks.onBeforeClose(context, stackItem.payload);
|
|
528
|
+
}
|
|
529
|
+
pop();
|
|
530
|
+
}, [peek, pop]);
|
|
531
|
+
const value = useMemo(() => ({
|
|
532
|
+
stack,
|
|
533
|
+
openOffcanvas,
|
|
534
|
+
closeOffcanvas,
|
|
535
|
+
}), [stack, openOffcanvas, closeOffcanvas]);
|
|
536
|
+
return (jsxs(OffcanvasContext.Provider, Object.assign({ value: value }, { children: [children, hasPortal && createPortal(jsxs(Fragment, { children: [stack.map(({ Component, offcanvasName, callbacks, payload, }) => {
|
|
537
|
+
const EnhancedComponent = enhanceOffcanvas(Component, callbacks);
|
|
538
|
+
return (jsx(EnhancedComponent, { name: offcanvasName, payload: payload, openOffcanvas: openOffcanvas, closeOffcanvas: closeOffcanvas }, offcanvasName));
|
|
539
|
+
}), !!stack.length && jsx("div", { className: "offcanvas-backdrop fade show" })] }), document.getElementById(portalName))] })));
|
|
540
|
+
}
|
|
541
|
+
function useOffcanvasContext() {
|
|
542
|
+
const context = useContext(OffcanvasContext);
|
|
543
|
+
if (context === undefined) {
|
|
544
|
+
throw new Error('useOffcanvasContext was used outside of OffcanvasContextProvider');
|
|
545
|
+
}
|
|
546
|
+
return context;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
registerLocale('es', es);
|
|
550
|
+
function MCalendar({ setDate, date, calendarContainer, inline = true, withPortal, minDate, showTimeInput, calendarStartDay, timeInputLabel, dateFormat, className, calendarClassName, selectsRange, selectsStart, selectsEnd, startDate, endDate, autoFocus, monthsShown, fixedHeight, }) {
|
|
551
|
+
const dateJS = (value) => DateTime.fromISO(value).toJSDate();
|
|
552
|
+
const { language } = useLiquidContext();
|
|
553
|
+
const lang = language === 'en' ? undefined : 'es';
|
|
554
|
+
return (jsx(DatePicker, Object.assign({ selected: dateJS(date), onChange: (value) => {
|
|
555
|
+
if (Array.isArray(value)) {
|
|
556
|
+
const [start, end] = value;
|
|
557
|
+
setDate([
|
|
558
|
+
start ? DateTime.fromJSDate(start).toISO() : null,
|
|
559
|
+
end ? DateTime.fromJSDate(end).toISO() : null,
|
|
560
|
+
]);
|
|
561
|
+
}
|
|
562
|
+
else {
|
|
563
|
+
setDate(value ? DateTime.fromJSDate(value).toISO() : null);
|
|
564
|
+
}
|
|
565
|
+
},
|
|
566
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
567
|
+
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 })));
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
function MSkeleton({ speed = 2, viewBox, backgroundColor, foregroundColor, children, }) {
|
|
571
|
+
const innerBackgroundColor = useMemo(() => {
|
|
572
|
+
if (backgroundColor) {
|
|
573
|
+
return backgroundColor;
|
|
574
|
+
}
|
|
575
|
+
const computedStyle = getComputedStyle(document.documentElement);
|
|
576
|
+
return computedStyle.getPropertyValue(`--${PREFIX_BS}secondary-100`);
|
|
577
|
+
}, [backgroundColor]);
|
|
578
|
+
const innerForegroundColor = useMemo(() => {
|
|
579
|
+
if (foregroundColor) {
|
|
580
|
+
return foregroundColor;
|
|
581
|
+
}
|
|
582
|
+
const computedStyle = getComputedStyle(document.documentElement);
|
|
583
|
+
return computedStyle.getPropertyValue(`--${PREFIX_BS}gray-100`);
|
|
584
|
+
}, [foregroundColor]);
|
|
585
|
+
return (jsx(ContentLoader, Object.assign({ speed: speed, viewBox: viewBox, backgroundColor: innerBackgroundColor, foregroundColor: innerForegroundColor }, { children: children })));
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
const TabContext = createContext(undefined);
|
|
589
|
+
function MTabs({ children, defaultSelected, onChange, options, className, isVertical, }) {
|
|
590
|
+
const [selected, setSelected] = useState(defaultSelected);
|
|
591
|
+
const onSelect = useCallback((option) => {
|
|
592
|
+
if (option.tab) {
|
|
593
|
+
setSelected(option.tab);
|
|
594
|
+
}
|
|
595
|
+
onChange(option);
|
|
596
|
+
}, [onChange]);
|
|
597
|
+
useEffect(() => {
|
|
598
|
+
setSelected(defaultSelected);
|
|
599
|
+
}, [defaultSelected]);
|
|
600
|
+
const isSelected = useCallback((tab) => (selected === tab), [selected]);
|
|
601
|
+
const value = useMemo(() => ({
|
|
602
|
+
isSelected,
|
|
603
|
+
}), [isSelected]);
|
|
604
|
+
return (jsx(TabContext.Provider, Object.assign({ value: value }, { children: jsxs("div", Object.assign({ className: classnames({
|
|
605
|
+
'm-tabs': true,
|
|
606
|
+
'm-tabs-vertical': isVertical,
|
|
607
|
+
}) }, { children: [jsx("nav", Object.assign({ className: "nav" }, { children: options.map((option) => (jsx("button", Object.assign({ id: `${option.tab}Tab`, className: classnames('nav-link', {
|
|
608
|
+
active: option.tab === selected,
|
|
609
|
+
}, className), type: "button", role: "tab", "aria-controls": `${option.tab}Pane`, "aria-selected": option.tab === selected, disabled: option.isDisabled, onClick: () => onSelect(option) }, { children: option.label }), option.label))) })), jsx("div", Object.assign({ className: "tab-content" }, { children: children }))] })) })));
|
|
610
|
+
}
|
|
611
|
+
function useTabContext() {
|
|
612
|
+
const context = useContext(TabContext);
|
|
613
|
+
if (context === undefined) {
|
|
614
|
+
throw new Error('useTabContext was used outside of MTab');
|
|
615
|
+
}
|
|
616
|
+
return context;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
function MTabContent({ tab, children }) {
|
|
620
|
+
const { isSelected } = useTabContext();
|
|
621
|
+
if (!isSelected(tab)) {
|
|
622
|
+
return null;
|
|
623
|
+
}
|
|
624
|
+
return (jsx("div", Object.assign({ className: "tab-pane fade show active", id: `${tab}Pane`, role: "tabpanel", tabIndex: 0, "aria-labelledby": `${tab}Tab` }, { children: children })));
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
function MToastContainer({ style, position = 'bottom-center', }) {
|
|
628
|
+
return (jsx(ToastContainer, { toastClassName: () => 'shadow-none p-0 cursor-default', position: position, autoClose: false, hideProgressBar: true, closeOnClick: false, closeButton: false, transition: Slide, style: style }));
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
function MPopover({ children, renderComponent, isOpen, setIsOpen = () => { }, }) {
|
|
632
|
+
const [innerIsOpen, setInnerIsOpen] = useState(false);
|
|
633
|
+
useEffect(() => {
|
|
634
|
+
setInnerIsOpen(isOpen);
|
|
635
|
+
}, [isOpen]);
|
|
636
|
+
const onOpenChange = useCallback((value) => {
|
|
637
|
+
setInnerIsOpen(value);
|
|
638
|
+
setIsOpen(value);
|
|
639
|
+
}, [setIsOpen]);
|
|
640
|
+
const { refs, floatingStyles, context } = useFloating({
|
|
641
|
+
open: innerIsOpen,
|
|
642
|
+
onOpenChange,
|
|
643
|
+
middleware: [
|
|
644
|
+
offset(0),
|
|
645
|
+
flip({ fallbackAxisSideDirection: 'none' }),
|
|
646
|
+
shift(),
|
|
647
|
+
],
|
|
648
|
+
whileElementsMounted: autoUpdate,
|
|
649
|
+
});
|
|
650
|
+
const click = useClick(context);
|
|
651
|
+
const dismiss = useDismiss(context);
|
|
652
|
+
const role = useRole(context);
|
|
653
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
654
|
+
click,
|
|
655
|
+
dismiss,
|
|
656
|
+
role,
|
|
657
|
+
]);
|
|
658
|
+
const headingId = useId();
|
|
659
|
+
return (jsxs("div", Object.assign({ className: "m-popover" }, { children: [jsx("div", Object.assign({ ref: refs.setReference }, getReferenceProps(), { children: renderComponent(innerIsOpen) })), innerIsOpen && (jsx(FloatingFocusManager, Object.assign({ context: context, modal: false }, { children: jsx("div", Object.assign({ className: "m-popover-content", ref: refs.setFloating, style: floatingStyles, "aria-labelledby": headingId }, getFloatingProps(), { children: children })) })))] })));
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
function useFormatCurrency(...args) {
|
|
663
|
+
const { currency } = useLiquidContext();
|
|
664
|
+
const format = useCallback((value) => formatCurrency(value, currency), [currency]);
|
|
665
|
+
const values = (args || []).map((value) => (formatCurrency(value !== null && value !== void 0 ? value : 0, currency)));
|
|
666
|
+
return {
|
|
667
|
+
format,
|
|
668
|
+
values,
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
function MCurrencyText({ value, className, }) {
|
|
673
|
+
const { values: [valueFormatted] } = useFormatCurrency(value);
|
|
674
|
+
return (jsx("span", Object.assign({ className: className }, { children: valueFormatted })));
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
function MFormikInput(_a) {
|
|
678
|
+
var { name } = _a, props = __rest(_a, ["name"]);
|
|
679
|
+
const [field, meta, helpers] = useField(name);
|
|
680
|
+
return (jsx(MInput, Object.assign({}, props, { name: field.name, value: field.value, onMChange: ({ detail }) => helpers.setValue(detail), onMBlur: ({ detail }) => field.onBlur(detail), isInvalid: !!meta.error })));
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
function MFormikInputSelect(_a) {
|
|
684
|
+
var { name, labelExtractor = (item) => item === null || item === void 0 ? void 0 : item.label, valueExtractor = (item) => item === null || item === void 0 ? void 0 : item.value } = _a, props = __rest(_a, ["name", "labelExtractor", "valueExtractor"]);
|
|
685
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
686
|
+
const [field, , helpers] = useField(name);
|
|
687
|
+
return (jsx(MInputSelect, Object.assign({}, props, { name: field.name, selectedOption: field.value, labelExtractor: labelExtractor, valueExtractor: valueExtractor, onMChange: ({ detail }) => helpers.setValue(detail), onMBlur: ({ detail }) => field.onBlur(detail) })));
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
const TOOLTIP_FONT_SIZE_BY_SIZE = {
|
|
691
|
+
sm: `var(--${PREFIX_BS}ref-fs-subparagraph)`,
|
|
692
|
+
default: `var(--${PREFIX_BS}body-font-size)`,
|
|
693
|
+
lg: `var(--${PREFIX_BS}ref-fs-6)`,
|
|
694
|
+
};
|
|
695
|
+
const ARROW_WIDTH = 8;
|
|
696
|
+
const ARROW_HEIGHT = 4;
|
|
697
|
+
const GAP = 2;
|
|
698
|
+
function MTooltip({ classNameContainer, className, offSet = ARROW_HEIGHT + GAP, padding, withFocus = false, withClick = false, withHover = true, isOpen = false, placement = 'top', size, Component, children, }) {
|
|
699
|
+
const [open, setOpen] = useState(isOpen);
|
|
700
|
+
const styleVariables = useMemo(() => {
|
|
701
|
+
const defaultFontSize = size
|
|
702
|
+
? TOOLTIP_FONT_SIZE_BY_SIZE[size]
|
|
703
|
+
: TOOLTIP_FONT_SIZE_BY_SIZE.default;
|
|
704
|
+
return {
|
|
705
|
+
background: `var(--${PREFIX_BS}m-tooltip-bg, var(--${PREFIX_BS}m-tooltip-component-bg, var(--${PREFIX_BS}secondary)))`,
|
|
706
|
+
borderRadius: `var(--${PREFIX_BS}m-tooltip-border-radius, var(--${PREFIX_BS}m-tooltip-component-border-radius, var(--${PREFIX_BS}border-radius)))`,
|
|
707
|
+
color: `var(--${PREFIX_BS}m-tooltip-color, var(--${PREFIX_BS}m-tooltip-component-color, var(--${PREFIX_BS}white)))`,
|
|
708
|
+
fontSize: `var(--${PREFIX_BS}m-tooltip-font-size, var(--${PREFIX_BS}m-tooltip-component-font-size, ${defaultFontSize}))`,
|
|
709
|
+
padding: `var(--${PREFIX_BS}m-tooltip-padding, var(--${PREFIX_BS}m-tooltip-component-padding, var(--${PREFIX_BS}ref-spacer-2)))`,
|
|
710
|
+
maxWidth: `var(--${PREFIX_BS}m-tooltip-max-width, var(--${PREFIX_BS}m-tooltip-component-max-width, 300px))`,
|
|
711
|
+
};
|
|
712
|
+
}, [size]);
|
|
713
|
+
const arrowRef = useRef(null);
|
|
714
|
+
const { refs, context, floatingStyles, } = useFloating({
|
|
715
|
+
open,
|
|
716
|
+
onOpenChange: setOpen,
|
|
717
|
+
placement,
|
|
718
|
+
whileElementsMounted: autoUpdate,
|
|
719
|
+
middleware: [
|
|
720
|
+
offset(offSet),
|
|
721
|
+
flip(),
|
|
722
|
+
shift({
|
|
723
|
+
padding,
|
|
724
|
+
}),
|
|
725
|
+
arrow({
|
|
726
|
+
element: arrowRef,
|
|
727
|
+
}),
|
|
728
|
+
],
|
|
729
|
+
});
|
|
730
|
+
const hover = useHover(context, { move: false });
|
|
731
|
+
const focus = useFocus(context);
|
|
732
|
+
const dismiss = useDismiss(context);
|
|
733
|
+
const click = useClick(context);
|
|
734
|
+
const role = useRole(context, { role: 'tooltip' });
|
|
735
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
736
|
+
withHover ? hover : undefined,
|
|
737
|
+
withClick ? click : undefined,
|
|
738
|
+
withFocus ? focus : undefined,
|
|
739
|
+
dismiss,
|
|
740
|
+
role,
|
|
741
|
+
]);
|
|
742
|
+
return (jsxs(Fragment, { children: [jsx("div", Object.assign({ className: className, ref: refs.setReference }, getReferenceProps(), { children: Component })), jsx(FloatingPortal, { children: open && (jsxs("div", Object.assign({ className: classNameContainer, ref: refs.setFloating, style: Object.assign(Object.assign({}, floatingStyles), styleVariables) }, getFloatingProps(), { children: [jsx(FloatingArrow, { ref: arrowRef, context: context, style: {
|
|
743
|
+
fill: styleVariables.background,
|
|
744
|
+
}, width: ARROW_WIDTH, height: ARROW_HEIGHT }), children] }))) })] }));
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
function MInputCurrency(_a) {
|
|
748
|
+
var { onChange } = _a, otherProps = __rest(_a, ["onChange"]);
|
|
749
|
+
const { currency } = useLiquidContext();
|
|
750
|
+
return (jsx(MInputCurrencyBase, Object.assign({ currencyOptions: currency, onMChange: ({ detail }) => onChange(detail) }, otherProps)));
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
function MBoxFile(_a) {
|
|
754
|
+
var { icon = 'cloud-upload', iconFamilyClass, iconFamilyPrefix, isDisabled = false, children } = _a, dropzoneOptions = __rest(_a, ["icon", "iconFamilyClass", "iconFamilyPrefix", "isDisabled", "children"]);
|
|
755
|
+
const { acceptedFiles, getRootProps, getInputProps, } = useDropzone(Object.assign({ disabled: isDisabled }, dropzoneOptions));
|
|
756
|
+
return (jsxs("section", Object.assign({ className: classnames('m-box-file', {
|
|
757
|
+
'm-box-file-selected': !!acceptedFiles.length,
|
|
758
|
+
}) }, { children: [jsxs("div", Object.assign({}, getRootProps({
|
|
759
|
+
className: classnames('m-box-file-dropzone', {
|
|
760
|
+
disabled: isDisabled,
|
|
761
|
+
}),
|
|
762
|
+
}), { children: [jsx("input", Object.assign({}, getInputProps())), jsx(MIcon, { icon: icon, familyClass: iconFamilyClass, familyPrefix: iconFamilyPrefix }), jsx("div", Object.assign({ className: "m-box-content" }, { children: children }))] })), !!acceptedFiles.length && (jsx("aside", Object.assign({ className: "m-box-files" }, { children: acceptedFiles.map((file) => (jsx("div", Object.assign({ className: "m-box-files-text" }, { children: `${file.name} - ${file.size} bytes` }), file.name))) })))] })));
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
const LANG = liquidParser.parse('{{site.language}}');
|
|
766
|
+
async function configureI8n(resources, _a = {}) {
|
|
767
|
+
var { lng = LANG, fallbackLng = 'es' } = _a, config = __rest(_a, ["lng", "fallbackLng"]);
|
|
768
|
+
return i18n
|
|
769
|
+
.use(initReactI18next)
|
|
770
|
+
.init(Object.assign({ resources,
|
|
771
|
+
lng, initImmediate: true, fallbackLng, interpolation: {
|
|
772
|
+
escapeValue: false,
|
|
773
|
+
prefix: '{',
|
|
774
|
+
suffix: '}',
|
|
775
|
+
// skipOnVariables: false,
|
|
776
|
+
} }, config))
|
|
777
|
+
.then((t) => t);
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
function useToast() {
|
|
781
|
+
const toast$1 = useCallback((message, { position = 'bottom-center', type = 'info', showClose = true, autoClose = false, } = {}) => {
|
|
782
|
+
toast(({ closeToast }) => (jsx(MAlert, Object.assign({ type: type, showClose: showClose, onMClose: closeToast }, { children: message }))), {
|
|
783
|
+
transition: Slide,
|
|
784
|
+
position,
|
|
785
|
+
autoClose,
|
|
786
|
+
});
|
|
787
|
+
}, []);
|
|
788
|
+
return {
|
|
789
|
+
toast: toast$1,
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
function useScreenshot() {
|
|
794
|
+
const clipRef = useRef(null);
|
|
795
|
+
const takeBlob = useCallback(async (type) => {
|
|
796
|
+
if (!clipRef.current) {
|
|
797
|
+
throw new Error('set the clipRef');
|
|
798
|
+
}
|
|
799
|
+
const canvas = await html2canvas(clipRef === null || clipRef === void 0 ? void 0 : clipRef.current, {
|
|
800
|
+
allowTaint: true,
|
|
801
|
+
useCORS: true,
|
|
802
|
+
});
|
|
803
|
+
return (new Promise((resolve, reject) => {
|
|
804
|
+
canvas.toBlob((innerBlob) => {
|
|
805
|
+
if (!innerBlob) {
|
|
806
|
+
return reject();
|
|
807
|
+
}
|
|
808
|
+
return resolve(innerBlob);
|
|
809
|
+
}, type);
|
|
810
|
+
}));
|
|
811
|
+
}, []);
|
|
812
|
+
return {
|
|
813
|
+
clipRef,
|
|
814
|
+
takeBlob,
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
function useScreenshotDownload() {
|
|
819
|
+
const { clipRef, takeBlob } = useScreenshot();
|
|
820
|
+
const download = useCallback(async () => {
|
|
821
|
+
const blob = await takeBlob();
|
|
822
|
+
const url = window.URL.createObjectURL(blob);
|
|
823
|
+
const link = window.document.createElement('a');
|
|
824
|
+
link.style.display = 'none';
|
|
825
|
+
link.href = url;
|
|
826
|
+
link.download = 'voucher.jpg';
|
|
827
|
+
document.body.appendChild(link);
|
|
828
|
+
link.click();
|
|
829
|
+
document.body.removeChild(link);
|
|
830
|
+
window.URL.revokeObjectURL(url);
|
|
831
|
+
}, [takeBlob]);
|
|
832
|
+
return {
|
|
833
|
+
download,
|
|
834
|
+
downloadRef: clipRef,
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
function useScreenshotWebShare() {
|
|
839
|
+
const { takeBlob, clipRef } = useScreenshot();
|
|
840
|
+
const share = useCallback(async () => {
|
|
841
|
+
const blob = await takeBlob();
|
|
842
|
+
const image = new File([blob], 'voucher.jpeg', { type: 'image/jpeg' });
|
|
843
|
+
if (!navigator.canShare
|
|
844
|
+
&& (navigator.canShare && !navigator.canShare({ files: [image] }))) {
|
|
845
|
+
window.print();
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
await navigator.share({ files: [image] });
|
|
849
|
+
}, [takeBlob]);
|
|
850
|
+
return {
|
|
851
|
+
share,
|
|
852
|
+
shareRef: clipRef,
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
export { LiquidContext$1 as LiquidContext, LiquidContextProvider, MAlert, MBadge, MBoxFile, MButton, MCalendar, MChip, MCollapse, MCollapseIconText, MCurrencyText, MFormikInput, MFormikInputSelect, MIcon, MInput, MInputCheck, MInputCounter, MInputCurrency, MInputCurrencyBase, MInputPassword, MInputPin, MInputSearch, MInputSelect, MInputSwitch, MModal, MOffcanvas, MPermissionGroup, MPermissionItem, MPopover, MProgressBar, MQuickActionButton, MQuickActionCheck, MQuickActionSelect, MQuickActionSwitch, MSkeleton, MSummaryCard, MTabContent, MTabs, MToastContainer, MTooltip, ModalContext, ModalContextProvider, OffcanvasContext, OffcanvasContextProvider, configureI8n as configureI18n, useFormatCurrency, useLiquidContext, useModalContext, useOffcanvasContext, useScreenshot, useScreenshotDownload, useScreenshotWebShare, useTabContext, useToast };
|
|
857
|
+
//# sourceMappingURL=index.esm.js.map
|