@rolster/react-components 19.6.3 → 19.6.7
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 -21
- package/dist/cjs/index.cjs +103 -39
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/es/index.mjs +4576 -0
- package/dist/es/index.mjs.map +1 -0
- package/dist/esm/components/atoms/Breadcrumb/Breadcrumb.d.ts +2 -3
- package/dist/esm/components/atoms/Breadcrumb/Breadcrumb.js.map +1 -1
- package/dist/esm/components/atoms/ProgressCircular/ProgressCircular.d.ts +2 -6
- package/dist/esm/components/atoms/ProgressCircular/ProgressCircular.js.map +1 -1
- package/dist/esm/components/definitions.d.ts +1 -1
- package/dist/esm/components/molecules/ButtonProgress/ButtonProgress.d.ts +2 -3
- package/dist/esm/components/molecules/ButtonProgress/ButtonProgress.js.map +1 -1
- package/dist/esm/components/molecules/FieldFile/FieldFile.d.ts +1 -1
- package/dist/esm/components/molecules/FieldFile/FieldFile.js +3 -3
- package/dist/esm/components/molecules/FieldFile/FieldFile.js.map +1 -1
- package/dist/esm/components/organisms/Confirmation/Confirmation.d.ts +4 -7
- package/dist/esm/components/organisms/Confirmation/Confirmation.js.map +1 -1
- package/dist/esm/components/organisms/ImageEditor/ImageEditor.js +17 -9
- package/dist/esm/components/organisms/ImageEditor/ImageEditor.js.map +1 -1
- package/dist/esm/components/organisms/Notifications/Notifications.d.ts +17 -0
- package/dist/esm/components/organisms/Notifications/Notifications.js +59 -0
- package/dist/esm/components/organisms/Notifications/Notifications.js.map +1 -0
- package/dist/esm/components/organisms/Snackbar/Snackbar.d.ts +2 -3
- package/dist/esm/components/organisms/Snackbar/Snackbar.js.map +1 -1
- package/dist/esm/context.d.ts +4 -1
- package/dist/esm/context.js +14 -12
- package/dist/esm/context.js.map +1 -1
- package/dist/esm/helpers/color.d.ts +1 -1
- package/dist/esm/helpers/color.js +1 -10
- package/dist/esm/helpers/color.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types.d.ts +7 -0
- package/dist/esm/types.js +1 -1
- package/dist/esm/types.js.map +1 -1
- package/package.json +77 -91
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 Rolster Technology
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Rolster Technology
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -414,13 +414,21 @@ function requireReactJsxRuntime_development () {
|
|
|
414
414
|
return reactJsxRuntime_development;
|
|
415
415
|
}
|
|
416
416
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
417
|
+
var hasRequiredJsxRuntime;
|
|
418
|
+
|
|
419
|
+
function requireJsxRuntime () {
|
|
420
|
+
if (hasRequiredJsxRuntime) return jsxRuntime.exports;
|
|
421
|
+
hasRequiredJsxRuntime = 1;
|
|
422
|
+
|
|
423
|
+
if (process.env.NODE_ENV === 'production') {
|
|
424
|
+
jsxRuntime.exports = requireReactJsxRuntime_production();
|
|
425
|
+
} else {
|
|
426
|
+
jsxRuntime.exports = requireReactJsxRuntime_development();
|
|
427
|
+
}
|
|
428
|
+
return jsxRuntime.exports;
|
|
421
429
|
}
|
|
422
430
|
|
|
423
|
-
var jsxRuntimeExports =
|
|
431
|
+
var jsxRuntimeExports = requireJsxRuntime();
|
|
424
432
|
|
|
425
433
|
function renderClassStatus(base, status = {}, additionals) {
|
|
426
434
|
const _classElement = [base];
|
|
@@ -1139,13 +1147,8 @@ function oklabToLinearRgb(l, a, b) {
|
|
|
1139
1147
|
}
|
|
1140
1148
|
const inGamut = ([r, g, b]) => {
|
|
1141
1149
|
const e = 1e-4;
|
|
1142
|
-
return r >= -e && r <= 1 + e && g >= -e && g <= 1 + e && b >= -e && b <= 1 + e;
|
|
1150
|
+
return (r >= -e && r <= 1 + e && g >= -e && g <= 1 + e && b >= -e && b <= 1 + e);
|
|
1143
1151
|
};
|
|
1144
|
-
/**
|
|
1145
|
-
* Converts an OKLCH color to sRGB. If the requested chroma falls outside the
|
|
1146
|
-
* sRGB gamut, chroma is reduced (binary search) while keeping lightness and
|
|
1147
|
-
* hue fixed — this preserves the intended tone instead of clipping channels.
|
|
1148
|
-
*/
|
|
1149
1152
|
function oklchToRgb({ l, c, h }) {
|
|
1150
1153
|
const a = Math.cos(h);
|
|
1151
1154
|
const b = Math.sin(h);
|
|
@@ -1167,10 +1170,6 @@ function oklchToRgb({ l, c, h }) {
|
|
|
1167
1170
|
const [lr, lg, lb] = linearAt(c);
|
|
1168
1171
|
return { r: linearToSrgb(lr), g: linearToSrgb(lg), b: linearToSrgb(lb) };
|
|
1169
1172
|
}
|
|
1170
|
-
/**
|
|
1171
|
-
* Scales chroma down toward the lightness extremes (very light / very dark) so
|
|
1172
|
-
* shades do not look oversaturated at the ends. Peaks at L=0.5 (factor 1).
|
|
1173
|
-
*/
|
|
1174
1173
|
const chromaFactor = (lightness) => 0.4 + 0.6 * (1 - Math.abs(lightness - 0.5) * 2);
|
|
1175
1174
|
function detectShadeLevel(lightness) {
|
|
1176
1175
|
let bestLevel = '500';
|
|
@@ -1574,9 +1573,9 @@ function RlsFieldArea(props) {
|
|
|
1574
1573
|
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsAreaText, { ...props }) }) }), !props.msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
|
|
1575
1574
|
}
|
|
1576
1575
|
|
|
1577
|
-
function RlsFieldFile({ accept, children, disabled:
|
|
1576
|
+
function RlsFieldFile({ accept, children, disabled: _disabled, formControl, identifier, msgErrorDisabled, onValue, placeholder, readOnly, rlsTheme, value }) {
|
|
1578
1577
|
const inputRef = require$$0.useRef(null);
|
|
1579
|
-
const disabled = require$$0.useMemo(() => formControl?.disabled ||
|
|
1578
|
+
const disabled = require$$0.useMemo(() => formControl?.disabled || _disabled, [formControl?.disabled, _disabled]);
|
|
1580
1579
|
const className = require$$0.useMemo(() => renderClassStatus('rls-field-box', {
|
|
1581
1580
|
disabled,
|
|
1582
1581
|
error: formControl?.wrong,
|
|
@@ -1608,7 +1607,7 @@ function RlsFieldFile({ accept, children, disabled: disabledProp, formControl, i
|
|
|
1608
1607
|
const onClickControl = require$$0.useCallback(() => {
|
|
1609
1608
|
!readOnly && !disabled && inputRef.current?.click();
|
|
1610
1609
|
}, [readOnly, disabled]);
|
|
1611
|
-
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", onClick: onClickControl, children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { className: "rls-input__component", readOnly: true, type: "text", value: displayValue, placeholder: placeholder }), jsxRuntimeExports.jsx("input", { ref: inputRef, className: "rls-field-file__input", type: "file", accept: accept, disabled: disabled || readOnly, onChange: onChangeInput }), jsxRuntimeExports.jsx(RlsButtonAction, { icon: currentFile ? 'close' : 'attach
|
|
1610
|
+
return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("span", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", onClick: onClickControl, children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { className: "rls-input__component", readOnly: true, type: "text", value: displayValue, placeholder: placeholder }), jsxRuntimeExports.jsx("input", { ref: inputRef, className: "rls-field-file__input", type: "file", accept: accept, disabled: disabled || readOnly, onChange: onChangeInput }), jsxRuntimeExports.jsx(RlsButtonAction, { icon: currentFile ? 'close' : 'attach', disabled: disabled, onClick: onClickAction })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
|
|
1612
1611
|
}
|
|
1613
1612
|
|
|
1614
1613
|
const reactI18n = i18n.i18n({
|
|
@@ -2596,7 +2595,7 @@ function useListController(props) {
|
|
|
2596
2595
|
};
|
|
2597
2596
|
}
|
|
2598
2597
|
|
|
2599
|
-
const DURATION_ANIMATION$
|
|
2598
|
+
const DURATION_ANIMATION$2 = 240;
|
|
2600
2599
|
const MAX_ELEMENTS = 6;
|
|
2601
2600
|
function useFieldAutocomplete(props) {
|
|
2602
2601
|
const controller = useListController(props);
|
|
@@ -2653,7 +2652,7 @@ function useFieldAutocomplete(props) {
|
|
|
2653
2652
|
clearTimeout(focusTimeoutId.current);
|
|
2654
2653
|
focusTimeoutId.current = setTimeout(() => {
|
|
2655
2654
|
controller.refInput?.current?.focus();
|
|
2656
|
-
}, DURATION_ANIMATION$
|
|
2655
|
+
}, DURATION_ANIMATION$2);
|
|
2657
2656
|
}
|
|
2658
2657
|
}, [controller.setState, props.readOnly]);
|
|
2659
2658
|
require$$0.useEffect(() => {
|
|
@@ -3979,8 +3978,8 @@ function useResize(props) {
|
|
|
3979
3978
|
}, []);
|
|
3980
3979
|
}
|
|
3981
3980
|
|
|
3982
|
-
const
|
|
3983
|
-
const
|
|
3981
|
+
const MIN_SLIDER_VALUE = 50;
|
|
3982
|
+
const MAX_SLIDER_VALUE = 100;
|
|
3984
3983
|
function getRatioFactor(ratio) {
|
|
3985
3984
|
switch (ratio) {
|
|
3986
3985
|
case '16:9':
|
|
@@ -4028,6 +4027,7 @@ function RlsImageEditor(props) {
|
|
|
4028
4027
|
const refPicture = require$$0.useRef(null);
|
|
4029
4028
|
const image = require$$0.useRef(new Image());
|
|
4030
4029
|
const originalImage = require$$0.useRef(undefined);
|
|
4030
|
+
const hasInteracted = require$$0.useRef(false);
|
|
4031
4031
|
const ratio = require$$0.useMemo(() => {
|
|
4032
4032
|
return props.ratio || '1:1';
|
|
4033
4033
|
}, [props.ratio]);
|
|
@@ -4086,18 +4086,22 @@ function RlsImageEditor(props) {
|
|
|
4086
4086
|
image.current.width > 0 &&
|
|
4087
4087
|
image.current.height > 0) {
|
|
4088
4088
|
const { height, width } = image.current.width >= image.current.height
|
|
4089
|
-
?
|
|
4090
|
-
:
|
|
4089
|
+
? refreshSelectionFromWidth(rateSelection)
|
|
4090
|
+
: refreshSelectionFromHeight(rateSelection);
|
|
4091
4091
|
refSelection.current.style.width = `${width}px`;
|
|
4092
4092
|
refSelection.current.style.height = `${height}px`;
|
|
4093
|
+
const left = refImage.current.offsetWidth - width;
|
|
4094
|
+
const top = refImage.current.offsetHeight - height;
|
|
4095
|
+
if (!hasInteracted.current) {
|
|
4096
|
+
refSelection.current.style.left = `${left / 2}px`;
|
|
4097
|
+
refSelection.current.style.top = `${top / 2}px`;
|
|
4098
|
+
}
|
|
4093
4099
|
if (refSelection.current.offsetLeft + width >
|
|
4094
4100
|
refImage.current.offsetWidth) {
|
|
4095
|
-
const left = refImage.current.offsetWidth - width;
|
|
4096
4101
|
refSelection.current.style.left = `${left < 0 ? 0 : left}px`;
|
|
4097
4102
|
}
|
|
4098
4103
|
if (refSelection.current.offsetTop + height >
|
|
4099
4104
|
refImage.current.offsetHeight) {
|
|
4100
|
-
const top = refImage.current.offsetHeight - height;
|
|
4101
4105
|
refSelection.current.style.top = `${top < 0 ? 0 : top}px`;
|
|
4102
4106
|
}
|
|
4103
4107
|
refreshOverlaysStyle();
|
|
@@ -4121,7 +4125,7 @@ function RlsImageEditor(props) {
|
|
|
4121
4125
|
const width = (refBody.current.offsetHeight * image.current.width) /
|
|
4122
4126
|
image.current.height;
|
|
4123
4127
|
return setImageStyle(`${width}px`, '100%');
|
|
4124
|
-
}, [
|
|
4128
|
+
}, []);
|
|
4125
4129
|
require$$0.useEffect(() => {
|
|
4126
4130
|
image.current.onload = () => {
|
|
4127
4131
|
const context = refCanvas.current.getContext('2d', {
|
|
@@ -4160,7 +4164,10 @@ function RlsImageEditor(props) {
|
|
|
4160
4164
|
useRelocationOnComponent({
|
|
4161
4165
|
container: refImage,
|
|
4162
4166
|
element: refSelection,
|
|
4163
|
-
onDrag:
|
|
4167
|
+
onDrag: () => {
|
|
4168
|
+
hasInteracted.current = true;
|
|
4169
|
+
refreshOverlaysStyle();
|
|
4170
|
+
}
|
|
4164
4171
|
});
|
|
4165
4172
|
useResize({ refElement: refImage, onResize: onResizeElement });
|
|
4166
4173
|
const onCropImage = require$$0.useCallback(() => {
|
|
@@ -4199,7 +4206,7 @@ function RlsImageEditor(props) {
|
|
|
4199
4206
|
context?.putImageData(originalImage.current, 0, 0);
|
|
4200
4207
|
}
|
|
4201
4208
|
}, []);
|
|
4202
|
-
return (jsxRuntimeExports.jsxs("div", { className: "rls-image-editor", children: [jsxRuntimeExports.jsx("div", { ref: refBody, className: "rls-image-editor__body", children: jsxRuntimeExports.jsxs("div", { ref: refImage, className: "rls-image-editor__body__image", children: [jsxRuntimeExports.jsx("div", { ref: refSelection, className: "rls-image-editor__body__selection" }), jsxRuntimeExports.jsx("div", { ref: refOverlayTop, className: "rls-image-editor__body__overlay--top" }), jsxRuntimeExports.jsx("div", { ref: refOverlayRight, className: "rls-image-editor__body__overlay--right" }), jsxRuntimeExports.jsx("div", { ref: refOverlayBottom, className: "rls-image-editor__body__overlay--bottom" }), jsxRuntimeExports.jsx("div", { ref: refOverlayLeft, className: "rls-image-editor__body__overlay--left" }), jsxRuntimeExports.jsx("canvas", { ref: refCanvas })] }) }), jsxRuntimeExports.jsxs("div", { className: "rls-image-editor__footer", children: [jsxRuntimeExports.jsx("div", { className: "rls-image-editor__sliders", children: jsxRuntimeExports.jsx(RlsSlider, { prefixIcon: "external-link", value: selection, minValue:
|
|
4209
|
+
return (jsxRuntimeExports.jsxs("div", { className: "rls-image-editor", children: [jsxRuntimeExports.jsx("div", { ref: refBody, className: "rls-image-editor__body", children: jsxRuntimeExports.jsxs("div", { ref: refImage, className: "rls-image-editor__body__image", children: [jsxRuntimeExports.jsx("div", { ref: refSelection, className: "rls-image-editor__body__selection" }), jsxRuntimeExports.jsx("div", { ref: refOverlayTop, className: "rls-image-editor__body__overlay--top" }), jsxRuntimeExports.jsx("div", { ref: refOverlayRight, className: "rls-image-editor__body__overlay--right" }), jsxRuntimeExports.jsx("div", { ref: refOverlayBottom, className: "rls-image-editor__body__overlay--bottom" }), jsxRuntimeExports.jsx("div", { ref: refOverlayLeft, className: "rls-image-editor__body__overlay--left" }), jsxRuntimeExports.jsx("canvas", { ref: refCanvas })] }) }), jsxRuntimeExports.jsxs("div", { className: "rls-image-editor__footer", children: [jsxRuntimeExports.jsx("div", { className: "rls-image-editor__sliders", children: jsxRuntimeExports.jsx(RlsSlider, { prefixIcon: "external-link", value: selection, minValue: MIN_SLIDER_VALUE, maxValue: MAX_SLIDER_VALUE, onValue: setSelection, disabled: props.disabled }) }), jsxRuntimeExports.jsxs("div", { className: "rls-image-editor__actions", children: [props.children, jsxRuntimeExports.jsx(RlsButton, { type: "flat", rlsTheme: "standard", prefixIcon: "refresh", onClick: onRestore, disabled: props.disabled, children: labels.actionRestore }), jsxRuntimeExports.jsx(RlsButton, { type: "raised", rlsTheme: "primary", prefixIcon: "crop", onClick: onCropImage, disabled: props.disabled, children: labels.actionSelect })] })] }), jsxRuntimeExports.jsx("canvas", { ref: refPicture })] }));
|
|
4203
4210
|
}
|
|
4204
4211
|
|
|
4205
4212
|
function RlsImageEditorModal(props) {
|
|
@@ -4295,6 +4302,60 @@ function RlsModalSheet({ autoclose, children, className, controller, onAutoClose
|
|
|
4295
4302
|
return ReactDOM.createPortal(jsxRuntimeExports.jsxs("div", { className: classNameModal, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-modal-sheet__component", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-modal-sheet__backdrop", onClick: onClickBackdrop })] }), document.body);
|
|
4296
4303
|
}
|
|
4297
4304
|
|
|
4305
|
+
const DURATION_ANIMATION$1 = 240;
|
|
4306
|
+
const DURATION_DEFAULT = 4000;
|
|
4307
|
+
let _id = 0;
|
|
4308
|
+
function generateId() {
|
|
4309
|
+
return `rls-notification-${++_id}`;
|
|
4310
|
+
}
|
|
4311
|
+
function RlsNotification({ content, icon, onClose, rlsTheme, title, visible }) {
|
|
4312
|
+
const className = require$$0.useMemo(() => {
|
|
4313
|
+
return renderClassStatus('rls-notification', { visible });
|
|
4314
|
+
}, [visible]);
|
|
4315
|
+
return (jsxRuntimeExports.jsxs("div", { className: className, "rls-theme": rlsTheme, children: [icon && (jsxRuntimeExports.jsx("div", { className: "rls-notification__avatar", children: jsxRuntimeExports.jsx(RlsIcon, { value: icon }) })), jsxRuntimeExports.jsxs("div", { className: "rls-notification__component", children: [jsxRuntimeExports.jsxs("div", { className: "rls-notification__header", children: [jsxRuntimeExports.jsx("div", { className: "rls-notification__title", children: title }), jsxRuntimeExports.jsx("button", { onClick: onClose, children: jsxRuntimeExports.jsx(RlsIcon, { value: "close" }) })] }), jsxRuntimeExports.jsx("div", { className: "rls-notification__content", children: content })] })] }));
|
|
4316
|
+
}
|
|
4317
|
+
function useNotifications() {
|
|
4318
|
+
const [notifications, setNotifications] = require$$0.useState([]);
|
|
4319
|
+
const timersRef = require$$0.useRef(new Map());
|
|
4320
|
+
require$$0.useEffect(() => {
|
|
4321
|
+
const timers = timersRef.current;
|
|
4322
|
+
return () => {
|
|
4323
|
+
timers.forEach((timer) => clearTimeout(timer));
|
|
4324
|
+
timers.clear();
|
|
4325
|
+
};
|
|
4326
|
+
}, []);
|
|
4327
|
+
const remove = require$$0.useCallback((id) => {
|
|
4328
|
+
const timer = timersRef.current.get(id);
|
|
4329
|
+
if (timer) {
|
|
4330
|
+
clearTimeout(timer);
|
|
4331
|
+
timersRef.current.delete(id);
|
|
4332
|
+
}
|
|
4333
|
+
setNotifications((notifications) => notifications.map((notification) => notification.id === id
|
|
4334
|
+
? { ...notification, visible: false }
|
|
4335
|
+
: notification));
|
|
4336
|
+
setTimeout(() => {
|
|
4337
|
+
setNotifications((notifications) => notifications.filter((notification) => notification.id !== id));
|
|
4338
|
+
}, DURATION_ANIMATION$1);
|
|
4339
|
+
}, []);
|
|
4340
|
+
const notify = require$$0.useCallback((config) => {
|
|
4341
|
+
const id = generateId();
|
|
4342
|
+
const duration = config.duration ?? DURATION_DEFAULT;
|
|
4343
|
+
setNotifications((notifications) => [
|
|
4344
|
+
...notifications,
|
|
4345
|
+
{ id, config, visible: true }
|
|
4346
|
+
]);
|
|
4347
|
+
const timer = setTimeout(() => {
|
|
4348
|
+
remove(id);
|
|
4349
|
+
}, duration);
|
|
4350
|
+
timersRef.current.set(id, timer);
|
|
4351
|
+
}, [remove]);
|
|
4352
|
+
const RlsNotifications = ReactDOM.createPortal(jsxRuntimeExports.jsx("div", { className: "rls-notifications", children: notifications.map((notification) => (jsxRuntimeExports.jsx(RlsNotification, { ...notification.config, visible: notification.visible, onClose: () => remove(notification.id) }, notification.id))) }), document.body);
|
|
4353
|
+
return {
|
|
4354
|
+
RlsNotifications,
|
|
4355
|
+
notify
|
|
4356
|
+
};
|
|
4357
|
+
}
|
|
4358
|
+
|
|
4298
4359
|
const DURATION_ANIMATION = 240;
|
|
4299
4360
|
const DURATION_CHAR = 75;
|
|
4300
4361
|
const DURATION_MAX = 9000;
|
|
@@ -4358,17 +4419,17 @@ function useSnackbar() {
|
|
|
4358
4419
|
};
|
|
4359
4420
|
}
|
|
4360
4421
|
|
|
4361
|
-
const RlsContext = require$$0.createContext(
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
});
|
|
4422
|
+
const RlsContext = require$$0.createContext(null);
|
|
4423
|
+
function useRlsContext() {
|
|
4424
|
+
const state = require$$0.useContext(RlsContext);
|
|
4425
|
+
if (!state) {
|
|
4426
|
+
throw new Error('RlsApplication not wrapped in Project');
|
|
4427
|
+
}
|
|
4428
|
+
return state;
|
|
4429
|
+
}
|
|
4370
4430
|
function RlsApplication({ children }) {
|
|
4371
4431
|
const { RlsConfirmation, confirmation } = useConfirmation();
|
|
4432
|
+
const { RlsNotifications, notify } = useNotifications();
|
|
4372
4433
|
const { RlsSnackbar, snackbar } = useSnackbar();
|
|
4373
4434
|
const [navbarInApp, setNavbarInApp] = require$$0.useState(false);
|
|
4374
4435
|
const [navbarIsCondense, setNavbarIsCondense] = require$$0.useState(false);
|
|
@@ -4382,11 +4443,12 @@ function RlsApplication({ children }) {
|
|
|
4382
4443
|
}, [appIsMobile, navbarInApp, navbarIsCondense]);
|
|
4383
4444
|
return (jsxRuntimeExports.jsxs(RlsContext, { value: {
|
|
4384
4445
|
confirmation,
|
|
4446
|
+
notify,
|
|
4385
4447
|
snackbar,
|
|
4386
4448
|
setIsMobile,
|
|
4387
4449
|
setNavbarInApp,
|
|
4388
4450
|
setNavbarIsCondense
|
|
4389
|
-
}, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children, RlsSnackbar] }), RlsConfirmation] }));
|
|
4451
|
+
}, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children, RlsSnackbar] }), RlsNotifications, RlsConfirmation] }));
|
|
4390
4452
|
}
|
|
4391
4453
|
|
|
4392
4454
|
const DEFAULT_DESIGN_SYSTEM = 'bordered';
|
|
@@ -4647,8 +4709,10 @@ exports.useFormSingleSelectionController = useFormSingleSelectionController;
|
|
|
4647
4709
|
exports.useFormToggleController = useFormToggleController;
|
|
4648
4710
|
exports.useImageEditorController = useImageEditorController;
|
|
4649
4711
|
exports.useListController = useListController;
|
|
4712
|
+
exports.useNotifications = useNotifications;
|
|
4650
4713
|
exports.usePortalController = usePortalController;
|
|
4651
4714
|
exports.useRelocationOnComponent = useRelocationOnComponent;
|
|
4652
4715
|
exports.useResize = useResize;
|
|
4716
|
+
exports.useRlsContext = useRlsContext;
|
|
4653
4717
|
exports.useSnackbar = useSnackbar;
|
|
4654
4718
|
//# sourceMappingURL=index.cjs.map
|