@tsminh/spreacte 0.1.3

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.
@@ -0,0 +1 @@
1
+ "use strict";var n=require("react/jsx-runtime"),e=require("react"),t=require("@fluejs/noscroll"),r=require("styled-components"),i=function(){return i=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++)for(var i in e=arguments[t])Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n},i.apply(this,arguments)};function o(n,e){return Object.defineProperty?Object.defineProperty(n,"raw",{value:e}):n.raw=e,n}"function"==typeof SuppressedError&&SuppressedError;var a,c,s,l,u=e.createContext({ratio:1}),d=function(){return e.useContext(u)},p=["onClick","children","className","fwidth","safeAreaTop"],f=r.div(c||(c=o(["\n background: rgba(0, 0, 0, 0.7);\n width: var(--vw);\n height: var(--vh);\n position: fixed;\n top: 0;\n left: 0;\n z-index: 99;\n transition: 0.5s ease all;\n ","\n"],["\n background: rgba(0, 0, 0, 0.7);\n width: var(--vw);\n height: var(--vh);\n position: fixed;\n top: 0;\n left: 0;\n z-index: 99;\n transition: 0.5s ease all;\n ","\n"])),function(n){var e=n.$open;return r.css(a||(a=o(["\n opacity: ",";\n pointer-events: ",";\n "],["\n opacity: ",";\n pointer-events: ",";\n "])),e?1:0,e?"all":"none")}),v=r.div(l||(l=o(["\n width: var(--vw);\n height: var(--vh);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n position: fixed;\n top: 0;\n left: 0;\n z-index: 100;\n transition: 0.2s ease all;\n ","\n"],["\n width: var(--vw);\n height: var(--vh);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n position: fixed;\n top: 0;\n left: 0;\n z-index: 100;\n transition: 0.2s ease all;\n ","\n"])),function(n){var e=n.$open;return r.css(s||(s=o(["\n opacity: ",";\n pointer-events: ",";\n transform: translateY(","px) scale(",");\n "],["\n opacity: ",";\n pointer-events: ",";\n transform: translateY(","px) scale(",");\n "])),e?1:0,e?"all":"none",e?0:20,e?1:.9)});var h=Object.freeze({__proto__:null,isDev:function(){return window.location.hostname.includes("localhost")},measureWindowSize:function(){document.documentElement.style.setProperty("--vw","".concat(window.innerWidth,"px")),document.documentElement.style.setProperty("--vh","".concat(window.innerHeight,"px"))},numberWithCommas:function(n){void 0===n&&(n=0);var e=n.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,"."),e.join(".")}});exports.Box=function(t){var r=d().ratio,o=e.useMemo(function(){return i({style:i(i(i(i(i(i({},Object.fromEntries(Object.entries(t).filter(function(n){var e=n[0];return!p.includes(e)&&"style"!==e}).map(function(n){var e,t=n[0],i=n[1];return[(e=t,["p","m"].includes(e[0])&&2===e.length?"".concat({p:"padding",m:"margin"}[e[0]]).concat({l:"Left",r:"Right",b:"Bottom",t:"Top"}[e[1]]):e),i*r]}))),t.img?{backgroundImage:"url(".concat(process.env.PUBLIC_URL,"/img/").concat(t.img,")"),backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundPosition:"center"}:void 0),t.safeAreaTop?{top:"calc(var(--ot) + ".concat((t.top||0)*r,"px)")}:void 0),t.fwidth?{width:"var(--vw)"}:void 0),{aspectRatio:t.aspectRatio,pointerEvents:t.onClick||!t.img?"all":"none"}),t.style)},Object.fromEntries(Object.entries(t).filter(function(n){var e=n[0];return p.includes(e)}).map(function(n){return[n[0],n[1]]})))},[t,r]);return n.jsx("div",i({},o))},exports.GlobalContextProvider=function(t){var r=t.children,o=function(){var n=e.useState({width:window.innerWidth,height:window.innerHeight,ratio:window.innerWidth/393}),t=n[0],r=n[1];return e.useEffect(function(){function n(){r({width:window.screen.availWidth,height:window.screen.availHeight,ratio:window.screen.availWidth/393})}return window.addEventListener("resize",n),n(),function(){return window.removeEventListener("resize",n)}},[]),t}().ratio,a=e.useMemo(function(){return{ratio:o}},[o]);return n.jsx(u.Provider,i({value:a},{children:r}))},exports.Modal=function(r){var o=r.open,a=r.children,c=e.useMemo(function(){return Math.floor(1e3*Math.random())},[]);return e.useEffect(function(){o?t.disablePageScroll():t.enablePageScroll()},[o]),n.jsxs(n.Fragment,{children:[n.jsx(f,{"data-mid":c,$open:o}),n.jsx(v,i({"data-mid":c,$open:o},{children:a}))]})},exports.useGlobalContext=d,exports.utils=h;
@@ -0,0 +1 @@
1
+ import{jsx as n,jsxs as e,Fragment as t}from"react/jsx-runtime";import{useState as r,useEffect as i,createContext as o,useMemo as a,useContext as c}from"react";import{disablePageScroll as s,enablePageScroll as d}from"@fluejs/noscroll";import l,{css as u}from"styled-components";var p=function(){return p=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++)for(var i in e=arguments[t])Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n},p.apply(this,arguments)};function f(n,e){return Object.defineProperty?Object.defineProperty(n,"raw",{value:e}):n.raw=e,n}"function"==typeof SuppressedError&&SuppressedError;var v,h,m,w,g=o({ratio:1}),y=function(e){var t=e.children,o=function(){var n=r({width:window.innerWidth,height:window.innerHeight,ratio:window.innerWidth/393}),e=n[0],t=n[1];return i(function(){function n(){t({width:window.screen.availWidth,height:window.screen.availHeight,ratio:window.screen.availWidth/393})}return window.addEventListener("resize",n),n(),function(){return window.removeEventListener("resize",n)}},[]),e}().ratio,c=a(function(){return{ratio:o}},[o]);return n(g.Provider,p({value:c},{children:t}))},b=function(){return c(g)},x=["onClick","children","className","fwidth","safeAreaTop"],j=function(e){var t=b().ratio,r=a(function(){return p({style:p(p(p(p(p(p({},Object.fromEntries(Object.entries(e).filter(function(n){var e=n[0];return!x.includes(e)&&"style"!==e}).map(function(n){var e,r=n[0],i=n[1];return[(e=r,["p","m"].includes(e[0])&&2===e.length?"".concat({p:"padding",m:"margin"}[e[0]]).concat({l:"Left",r:"Right",b:"Bottom",t:"Top"}[e[1]]):e),i*t]}))),e.img?{backgroundImage:"url(".concat(process.env.PUBLIC_URL,"/img/").concat(e.img,")"),backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundPosition:"center"}:void 0),e.safeAreaTop?{top:"calc(var(--ot) + ".concat((e.top||0)*t,"px)")}:void 0),e.fwidth?{width:"var(--vw)"}:void 0),{aspectRatio:e.aspectRatio,pointerEvents:e.onClick||!e.img?"all":"none"}),e.style)},Object.fromEntries(Object.entries(e).filter(function(n){var e=n[0];return x.includes(e)}).map(function(n){return[n[0],n[1]]})))},[e,t]);return n("div",p({},r))},O=l.div(h||(h=f(["\n background: rgba(0, 0, 0, 0.7);\n width: var(--vw);\n height: var(--vh);\n position: fixed;\n top: 0;\n left: 0;\n z-index: 99;\n transition: 0.5s ease all;\n ","\n"],["\n background: rgba(0, 0, 0, 0.7);\n width: var(--vw);\n height: var(--vh);\n position: fixed;\n top: 0;\n left: 0;\n z-index: 99;\n transition: 0.5s ease all;\n ","\n"])),function(n){var e=n.$open;return u(v||(v=f(["\n opacity: ",";\n pointer-events: ",";\n "],["\n opacity: ",";\n pointer-events: ",";\n "])),e?1:0,e?"all":"none")}),z=l.div(w||(w=f(["\n width: var(--vw);\n height: var(--vh);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n position: fixed;\n top: 0;\n left: 0;\n z-index: 100;\n transition: 0.2s ease all;\n ","\n"],["\n width: var(--vw);\n height: var(--vh);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n position: fixed;\n top: 0;\n left: 0;\n z-index: 100;\n transition: 0.2s ease all;\n ","\n"])),function(n){var e=n.$open;return u(m||(m=f(["\n opacity: ",";\n pointer-events: ",";\n transform: translateY(","px) scale(",");\n "],["\n opacity: ",";\n pointer-events: ",";\n transform: translateY(","px) scale(",");\n "])),e?1:0,e?"all":"none",e?0:20,e?1:.9)}),E=function(r){var o=r.open,c=r.children,l=a(function(){return Math.floor(1e3*Math.random())},[]);return i(function(){o?s():d()},[o]),e(t,{children:[n(O,{"data-mid":l,$open:o}),n(z,p({"data-mid":l,$open:o},{children:c}))]})};var k=Object.freeze({__proto__:null,isDev:function(){return window.location.hostname.includes("localhost")},measureWindowSize:function(){document.documentElement.style.setProperty("--vw","".concat(window.innerWidth,"px")),document.documentElement.style.setProperty("--vh","".concat(window.innerHeight,"px"))},numberWithCommas:function(n){void 0===n&&(n=0);var e=n.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,"."),e.join(".")}});export{j as Box,y as GlobalContextProvider,E as Modal,b as useGlobalContext,k as utils};
@@ -0,0 +1,60 @@
1
+ import { ReactNode, CSSProperties } from 'react';
2
+
3
+ interface BoxProps {
4
+ onClick?: () => void;
5
+ children?: ReactNode;
6
+ style?: CSSProperties;
7
+ width?: number;
8
+ height?: number;
9
+ mt?: number;
10
+ mb?: number;
11
+ ml?: number;
12
+ mr?: number;
13
+ pt?: number;
14
+ pb?: number;
15
+ pl?: number;
16
+ pr?: number;
17
+ top?: number;
18
+ left?: number;
19
+ right?: number;
20
+ bottom?: number;
21
+ fontSize?: number;
22
+ img?: string;
23
+ aspectRatio?: number;
24
+ className?: string;
25
+ fwidth?: boolean;
26
+ safeAreaTop?: boolean;
27
+ }
28
+ declare const Box: React.FC<BoxProps>;
29
+
30
+ interface IModal {
31
+ open?: boolean;
32
+ onClose?: () => void;
33
+ }
34
+ declare const Modal: React.FC<IModal & {
35
+ children?: ReactNode;
36
+ }>;
37
+
38
+ declare function numberWithCommas(x?: number): string;
39
+ declare const isDev: () => boolean;
40
+ declare const measureWindowSize: () => void;
41
+
42
+ declare const utils_isDev: typeof isDev;
43
+ declare const utils_measureWindowSize: typeof measureWindowSize;
44
+ declare const utils_numberWithCommas: typeof numberWithCommas;
45
+ declare namespace utils {
46
+ export {
47
+ utils_isDev as isDev,
48
+ utils_measureWindowSize as measureWindowSize,
49
+ utils_numberWithCommas as numberWithCommas,
50
+ };
51
+ }
52
+
53
+ declare const GlobalContextProvider: React.FC<{
54
+ children: ReactNode;
55
+ }>;
56
+ declare const useGlobalContext: () => {
57
+ ratio: number;
58
+ };
59
+
60
+ export { Box, GlobalContextProvider, Modal, useGlobalContext, utils };
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@tsminh/spreacte",
3
+ "version": "0.1.3",
4
+ "main": "dist/cjs/index.js",
5
+ "module": "dist/esm/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "peerDependencies": {
8
+ "@fluejs/noscroll": "^1.0.0",
9
+ "react": "^19.1.1",
10
+ "react-dom": "^19.1.1",
11
+ "react-hot-toast": "^2.6.0",
12
+ "react-router-dom": "6",
13
+ "styled-components": "^6.1.19"
14
+ },
15
+ "scripts": {
16
+ "start": "react-scripts start",
17
+ "build": "GENERATE_SOURCEMAP=false react-scripts build",
18
+ "test": "react-scripts test",
19
+ "eject": "react-scripts eject",
20
+ "rollup": "rollup -c --bundleConfigAsCjs"
21
+ },
22
+ "eslintConfig": {
23
+ "extends": [
24
+ "react-app",
25
+ "react-app/jest"
26
+ ]
27
+ },
28
+ "browserslist": {
29
+ "production": [
30
+ ">0.2%",
31
+ "not dead",
32
+ "not op_mini all"
33
+ ],
34
+ "development": [
35
+ "last 1 chrome version",
36
+ "last 1 firefox version",
37
+ "last 1 safari version"
38
+ ]
39
+ },
40
+ "devDependencies": {
41
+ "@rollup/plugin-babel": "^6.1.0",
42
+ "@rollup/plugin-commonjs": "^29.0.0",
43
+ "@rollup/plugin-node-resolve": "^16.0.3",
44
+ "@rollup/plugin-terser": "^0.4.4",
45
+ "@rollup/plugin-typescript": "^12.3.0",
46
+ "@types/jest": "^27.5.2",
47
+ "@types/node": "^16.18.126",
48
+ "@types/react": "^19.1.15",
49
+ "@types/react-dom": "^19.1.9",
50
+ "react-scripts": "5.0.1",
51
+ "rollup": "^4.57.1",
52
+ "rollup-plugin-dts": "^6.3.0",
53
+ "rollup-plugin-peer-deps-external": "^2.2.4",
54
+ "tslib": "^2.8.1",
55
+ "typescript": "^4.9.5"
56
+ },
57
+ "files": [
58
+ "dist"
59
+ ],
60
+ "dependencies": {},
61
+ "author": "",
62
+ "license": "ISC",
63
+ "description": "",
64
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
65
+ }