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