@onepercentio/one-ui 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/EmailInput/EmailInput.d.ts +1 -1
- package/dist/context/OneUIProvider.d.ts +5 -0
- package/dist/context/OneUIProvider.js +14 -3
- package/dist/context/OneUIProvider.js.map +1 -1
- package/dist/hooks/ui/useAdaptiveImage.d.ts +6 -0
- package/dist/hooks/ui/useAdaptiveImage.js +39 -0
- package/dist/hooks/ui/useAdaptiveImage.js.map +1 -0
- package/package.json +2 -2
|
@@ -19,7 +19,7 @@ declare const _default: React.ForwardRefExoticComponent<Pick<Omit<{
|
|
|
19
19
|
messages: {
|
|
20
20
|
invalidEmail: string;
|
|
21
21
|
};
|
|
22
|
-
}, "className" | "accept" | "acceptCharset" | "action" | "allowFullScreen" | "allowTransparency" | "alt" | "as" | "async" | "autoComplete" | "autoFocus" | "autoPlay" | "capture" | "cellPadding" | "cellSpacing" | "charSet" | "challenge" | "checked" | "cite" | "classID" | "cols" | "colSpan" | "content" | "controls" | "coords" | "crossOrigin" | "data" | "dateTime" | "default" | "defer" | "disabled" | "download" | "encType" | "form" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "frameBorder" | "headers" | "height" | "high" | "href" | "hrefLang" | "htmlFor" | "httpEquiv" | "integrity" | "keyParams" | "keyType" | "kind" | "label" | "list" | "loop" | "low" | "manifest" | "marginHeight" | "marginWidth" | "max" | "maxLength" | "media" | "mediaGroup" | "method" | "min" | "minLength" | "multiple" | "muted" | "name" | "nonce" | "noValidate" | "open" | "optimum" | "pattern" | "placeholder" | "playsInline" | "poster" | "preload" | "readOnly" | "rel" | "required" | "reversed" | "rows" | "rowSpan" | "sandbox" | "scope" | "scoped" | "scrolling" | "seamless" | "selected" | "shape" | "size" | "sizes" | "span" | "src" | "srcDoc" | "srcLang" | "srcSet" | "start" | "step" | "summary" | "target" | "type" | "useMap" | "value" | "width" | "wmode" | "wrap" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "
|
|
22
|
+
}, "className" | "accept" | "acceptCharset" | "action" | "allowFullScreen" | "allowTransparency" | "alt" | "as" | "async" | "autoComplete" | "autoFocus" | "autoPlay" | "capture" | "cellPadding" | "cellSpacing" | "charSet" | "challenge" | "checked" | "cite" | "classID" | "cols" | "colSpan" | "content" | "controls" | "coords" | "crossOrigin" | "data" | "dateTime" | "default" | "defer" | "disabled" | "download" | "encType" | "form" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "frameBorder" | "headers" | "height" | "high" | "href" | "hrefLang" | "htmlFor" | "httpEquiv" | "integrity" | "keyParams" | "keyType" | "kind" | "label" | "list" | "loop" | "low" | "manifest" | "marginHeight" | "marginWidth" | "max" | "maxLength" | "media" | "mediaGroup" | "method" | "min" | "minLength" | "multiple" | "muted" | "name" | "nonce" | "noValidate" | "open" | "optimum" | "pattern" | "placeholder" | "playsInline" | "poster" | "preload" | "readOnly" | "rel" | "required" | "reversed" | "rows" | "rowSpan" | "sandbox" | "scope" | "scoped" | "scrolling" | "seamless" | "selected" | "shape" | "size" | "sizes" | "span" | "src" | "srcDoc" | "srcLang" | "srcSet" | "start" | "step" | "summary" | "target" | "type" | "useMap" | "value" | "width" | "wmode" | "wrap" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "error" | "border" | "Icon" | "messages" | "icon" | "hideError" | "disclaimer" | "multiline" | "decoration"> & React.RefAttributes<{
|
|
23
23
|
validateEmail: (email: string) => boolean;
|
|
24
24
|
}>>;
|
|
25
25
|
export default _default;
|
|
@@ -2,6 +2,7 @@ import { Get } from "type-fest";
|
|
|
2
2
|
import React, { ReactElement } from "react";
|
|
3
3
|
import { PropsWithChildren } from "react";
|
|
4
4
|
import { FieldPath } from "../type-utils";
|
|
5
|
+
import { ImageScales } from "@muritavo/webpack-microfrontend-scripts/bin/types/ImageScales";
|
|
5
6
|
declare type DeepPartial<T> = {
|
|
6
7
|
[P in keyof T]?: T[P] extends Function ? T[P] : DeepPartial<T[P]>;
|
|
7
8
|
};
|
|
@@ -78,6 +79,9 @@ export declare type OneUIContextSpecs = {
|
|
|
78
79
|
};
|
|
79
80
|
};
|
|
80
81
|
};
|
|
82
|
+
state: {
|
|
83
|
+
imageScale: ImageScales;
|
|
84
|
+
};
|
|
81
85
|
};
|
|
82
86
|
declare type ContextConfigSpecs = DeepPartial<OneUIContextSpecs>;
|
|
83
87
|
export default function OneUIProvider({ children, config, }: PropsWithChildren<{
|
|
@@ -85,4 +89,5 @@ export default function OneUIProvider({ children, config, }: PropsWithChildren<{
|
|
|
85
89
|
}>): JSX.Element;
|
|
86
90
|
export declare function useOneUIContext(): OneUIContextSpecs;
|
|
87
91
|
export declare function useOneUIConfig<P extends FieldPath<OneUIContextSpecs>, T extends Get<OneUIContextSpecs, P>>(prop: P, defaultValue?: T): NonNullable<Get<OneUIContextSpecs, P>>;
|
|
92
|
+
export declare function useCurrentImageScale(): DeepPartial<ImageScales>;
|
|
88
93
|
export {};
|
|
@@ -26,18 +26,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.useOneUIConfig = exports.useOneUIContext = void 0;
|
|
29
|
+
exports.useCurrentImageScale = exports.useOneUIConfig = exports.useOneUIContext = void 0;
|
|
30
30
|
const get_1 = __importDefault(require("lodash/get"));
|
|
31
31
|
const merge_1 = __importDefault(require("lodash/merge"));
|
|
32
32
|
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
33
33
|
const react_1 = __importStar(require("react"));
|
|
34
34
|
const react_2 = require("react");
|
|
35
|
+
const useAdaptiveImage_1 = __importDefault(require("../hooks/ui/useAdaptiveImage"));
|
|
35
36
|
const Context = (0, react_2.createContext)(null);
|
|
36
37
|
function OneUIProvider({ children, config, }) {
|
|
37
38
|
const prevCtx = (0, react_2.useContext)(Context);
|
|
39
|
+
const scale = (0, useAdaptiveImage_1.default)();
|
|
38
40
|
const mergedConfig = (0, react_1.useMemo)(() => {
|
|
39
|
-
return (0, merge_1.default)((0, cloneDeep_1.default)(prevCtx), config
|
|
40
|
-
|
|
41
|
+
return (0, merge_1.default)((0, cloneDeep_1.default)(prevCtx), config, {
|
|
42
|
+
state: {
|
|
43
|
+
imageScale: scale,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}, [prevCtx, config, scale]);
|
|
41
47
|
return react_1.default.createElement(Context.Provider, { value: mergedConfig }, children);
|
|
42
48
|
}
|
|
43
49
|
exports.default = OneUIProvider;
|
|
@@ -99,4 +105,9 @@ function useOneUIConfig(prop, defaultValue) {
|
|
|
99
105
|
return value || defaultValue;
|
|
100
106
|
}
|
|
101
107
|
exports.useOneUIConfig = useOneUIConfig;
|
|
108
|
+
function useCurrentImageScale() {
|
|
109
|
+
const context = (0, react_2.useContext)(Context);
|
|
110
|
+
return context.state.imageScale;
|
|
111
|
+
}
|
|
112
|
+
exports.useCurrentImageScale = useCurrentImageScale;
|
|
102
113
|
//# sourceMappingURL=OneUIProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OneUIProvider.js","sourceRoot":"","sources":["../../src/context/OneUIProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA6B;AAC7B,yDAAiC;AACjC,iEAAqC;AAErC,+CAAqD;AACrD,iCAAqE;
|
|
1
|
+
{"version":3,"file":"OneUIProvider.js","sourceRoot":"","sources":["../../src/context/OneUIProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA6B;AAC7B,yDAAiC;AACjC,iEAAqC;AAErC,+CAAqD;AACrD,iCAAqE;AAErE,oFAA4D;AAqF5D,MAAM,OAAO,GAAG,IAAA,qBAAa,EAAqB,IAAW,CAAC,CAAC;AAE/D,SAAwB,aAAa,CAAC,EACpC,QAAQ,EACR,MAAM,GAC4C;IAClD,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,OAAO,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG,IAAA,0BAAgB,GAAE,CAAC;IACjC,MAAM,YAAY,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAChC,OAAO,IAAA,eAAK,EAAC,IAAA,mBAAK,EAAC,OAAO,CAAC,EAAE,MAAM,EAAE;YACnC,KAAK,EAAE;gBACL,UAAU,EAAE,KAAK;aAClB;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAE7B,OAAO,8BAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,IAAG,QAAQ,CAAoB,CAAC;AAC9E,CAAC;AAf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BD,wCAgBC;AAED,SAAgB,oBAAoB;IAClC,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,OAAO,CAAC,CAAC;IAEpC,OAAO,OAAO,CAAC,KAAM,CAAC,UAAW,CAAC;AACpC,CAAC;AAJD,oDAIC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ImageScales } from "@muritavo/webpack-microfrontend-scripts/bin/types/ImageScales";
|
|
2
|
+
/**
|
|
3
|
+
* This hooks is built over the implementation of this loader https://github.com/Muritavo/webpack-microfrontend-scripts#imageresolutionoptimizer
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export default function useAdaptiveImage(): ImageScales;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ImageScales_1 = require("@muritavo/webpack-microfrontend-scripts/bin/types/ImageScales");
|
|
7
|
+
const throttle_1 = __importDefault(require("lodash/throttle"));
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
/**
|
|
10
|
+
* This hooks is built over the implementation of this loader https://github.com/Muritavo/webpack-microfrontend-scripts#imageresolutionoptimizer
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
function useAdaptiveImage() {
|
|
14
|
+
function ScaleFromCurrentWidth() {
|
|
15
|
+
const width = window.visualViewport.width;
|
|
16
|
+
if (width < 480)
|
|
17
|
+
return ImageScales_1.ImageScales.SMALL;
|
|
18
|
+
if (width < 800)
|
|
19
|
+
return ImageScales_1.ImageScales.NORMAL;
|
|
20
|
+
if (width < 1280)
|
|
21
|
+
return ImageScales_1.ImageScales.BIG;
|
|
22
|
+
if (width < 1920)
|
|
23
|
+
return ImageScales_1.ImageScales.LARGE;
|
|
24
|
+
else
|
|
25
|
+
return ImageScales_1.ImageScales.EXTRA_LARGE;
|
|
26
|
+
}
|
|
27
|
+
const [currentScale, setCurrentScale] = (0, react_1.useState)(() => ScaleFromCurrentWidth());
|
|
28
|
+
(0, react_1.useEffect)(() => {
|
|
29
|
+
const onResizeThrottle = (0, throttle_1.default)(() => {
|
|
30
|
+
setCurrentScale(ScaleFromCurrentWidth());
|
|
31
|
+
}, 1000 / 4);
|
|
32
|
+
const onResize = () => onResizeThrottle();
|
|
33
|
+
window.addEventListener("resize", onResize);
|
|
34
|
+
return () => window.removeEventListener("resize", onResize);
|
|
35
|
+
}, []);
|
|
36
|
+
return currentScale;
|
|
37
|
+
}
|
|
38
|
+
exports.default = useAdaptiveImage;
|
|
39
|
+
//# sourceMappingURL=useAdaptiveImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAdaptiveImage.js","sourceRoot":"","sources":["../../../src/hooks/ui/useAdaptiveImage.tsx"],"names":[],"mappings":";;;;;AAAA,+FAA4F;AAC5F,+DAAuC;AACvC,iCAA4C;AAE5C;;;GAGG;AACH,SAAwB,gBAAgB;IACtC,SAAS,qBAAqB;QAC5B,MAAM,KAAK,GAAG,MAAM,CAAC,cAAe,CAAC,KAAK,CAAC;QAC3C,IAAI,KAAK,GAAG,GAAG;YAAE,OAAO,yBAAW,CAAC,KAAK,CAAC;QAC1C,IAAI,KAAK,GAAG,GAAG;YAAE,OAAO,yBAAW,CAAC,MAAM,CAAC;QAC3C,IAAI,KAAK,GAAG,IAAI;YAAE,OAAO,yBAAW,CAAC,GAAG,CAAC;QACzC,IAAI,KAAK,GAAG,IAAI;YAAE,OAAO,yBAAW,CAAC,KAAK,CAAC;;YACtC,OAAO,yBAAW,CAAC,WAAW,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAAc,GAAG,EAAE,CACjE,qBAAqB,EAAE,CACxB,CAAC;IAEF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,gBAAgB,GAAG,IAAA,kBAAQ,EAAC,GAAG,EAAE;YACrC,eAAe,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAC3C,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC;QACb,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,gBAAgB,EAAE,CAAC;QAC1C,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC5C,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,YAAY,CAAC;AACtB,CAAC;AAxBD,mCAwBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onepercentio/one-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "A set of reusable components created through the development of Onepercent projects",
|
|
5
5
|
"repository": "git@github.com:onepercentio/one-ui.git",
|
|
6
6
|
"author": "Murilo Oliveira de Araujo <muritavo@outlook.com>",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"@firebase/rules-unit-testing": "^2.0.2",
|
|
13
13
|
"@metamask/providers": "^9.1.0",
|
|
14
14
|
"@muritavo/cypress-toolkit": "^0.8.0",
|
|
15
|
-
"@muritavo/webpack-microfrontend-scripts": "^0.0
|
|
15
|
+
"@muritavo/webpack-microfrontend-scripts": "^0.1.0",
|
|
16
16
|
"@storybook/addon-actions": "^6.4.18",
|
|
17
17
|
"@storybook/addon-essentials": "^6.4.18",
|
|
18
18
|
"@storybook/addon-links": "^6.4.18",
|