@dr.pogodin/react-utils 1.57.0-alpha.1 → 1.57.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/CHANGELOG.md +7 -1
- package/bin/release.sh +1 -1
- package/build/development/shared/components/Button/index.js +6 -6
- package/build/development/shared/components/Checkbox/index.js +10 -10
- package/build/development/shared/components/GenericLink/index.js +1 -1
- package/build/development/shared/components/Input/index.js +9 -9
- package/build/development/shared/components/Modal/index.js +6 -6
- package/build/development/shared/components/PageLayout/index.js +6 -6
- package/build/development/shared/components/TextArea/index.js +9 -9
- package/build/development/shared/components/Throbber/index.js +6 -6
- package/build/development/shared/components/WithTooltip/index.js +7 -7
- package/build/development/shared/components/YouTubeVideo/index.js +9 -9
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/index.js +11 -11
- package/build/development/shared/components/selectors/NativeDropdown/index.js +12 -12
- package/build/development/shared/components/selectors/Switch/index.js +7 -7
- package/build/production/shared/components/Button/index.js +1 -1
- package/build/production/shared/components/Button/index.js.map +1 -1
- package/build/production/shared/components/Checkbox/index.js +1 -1
- package/build/production/shared/components/Checkbox/index.js.map +1 -1
- package/build/production/shared/components/GenericLink/index.js +1 -1
- package/build/production/shared/components/Input/index.js +1 -1
- package/build/production/shared/components/Modal/index.js +1 -1
- package/build/production/shared/components/Modal/index.js.map +1 -1
- package/build/production/shared/components/PageLayout/index.js +1 -1
- package/build/production/shared/components/PageLayout/index.js.map +1 -1
- package/build/production/shared/components/TextArea/index.js +1 -1
- package/build/production/shared/components/Throbber/index.js +1 -1
- package/build/production/shared/components/Throbber/index.js.map +1 -1
- package/build/production/shared/components/WithTooltip/index.js +1 -1
- package/build/production/shared/components/YouTubeVideo/index.js +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/index.js +1 -1
- package/build/production/shared/components/selectors/NativeDropdown/index.js +1 -1
- package/build/production/shared/components/selectors/Switch/index.js +1 -1
- package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/types-code/client/getInj.d.ts +1 -1
- package/build/types-code/client/init.d.ts +1 -1
- package/build/types-code/index.d.ts +3 -3
- package/build/types-code/server/renderer.d.ts +2 -2
- package/build/types-code/shared/components/index.d.ts +11 -11
- package/config/babel/webpack.d.ts +0 -2
- package/config/babel/webpack.js +8 -7
- package/config/webpack/app-base.d.ts +1 -1
- package/config/webpack/app-base.js +45 -57
- package/config/webpack/app-development.js +1 -1
- package/config/webpack/app-production.js +30 -0
- package/package.json +21 -18
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as _c}from"react/compiler-runtime";import{useTheme}from"@dr.pogodin/react-themes";const defaultTheme={"context":"
|
|
1
|
+
import{c as _c}from"react/compiler-runtime";import{useTheme}from"@dr.pogodin/react-themes";const defaultTheme={"context":"eVCJf-","ad":"CU2B6H","hoc":"_1V5iVx","bouncing":"h6ZYmQ","container":"VDVI-X","circle":"Y2rzbL"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
|
|
2
2
|
* Throbber is an "action in progress" indicator, which renders
|
|
3
3
|
* three bouncing circles as a simple pending activity indicator,
|
|
4
4
|
* and can be further themed to a certain degree.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../../src/shared/components/Throbber/index.tsx"],"sourcesContent":["import type { FunctionComponent } from 'react';\n\nimport { type PRIORITY, type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype ThemeKeyT = 'bouncing' | 'circle' | 'container';\n\ntype PropsT = {\n theme?: Theme<ThemeKeyT>;\n themePriority?: PRIORITY;\n};\n\n/**\n * Throbber is an \"action in progress\" indicator, which renders\n * three bouncing circles as a simple pending activity indicator,\n * and can be further themed to a certain degree.\n * @param {object} [props] Component properties.\n * @param {ThrobberTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst Throbber: FunctionComponent<PropsT> = ({ theme, themePriority }) => {\n const custom = useTheme('Throbber', defaultTheme, theme, {\n themePriority,\n });\n\n return (\n <span className={custom.container}>\n <span className={custom.circle} />\n <span className={custom.circle} />\n <span className={custom.circle} />\n </span>\n );\n};\n\nexport default Throbber;\n"],"mappings":"4CAEA,OAAoC,QAAQ,KAAQ,0BAA0B,CAE9E,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../src/shared/components/Throbber/index.tsx"],"sourcesContent":["import type { FunctionComponent } from 'react';\n\nimport { type PRIORITY, type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype ThemeKeyT = 'bouncing' | 'circle' | 'container';\n\ntype PropsT = {\n theme?: Theme<ThemeKeyT>;\n themePriority?: PRIORITY;\n};\n\n/**\n * Throbber is an \"action in progress\" indicator, which renders\n * three bouncing circles as a simple pending activity indicator,\n * and can be further themed to a certain degree.\n * @param {object} [props] Component properties.\n * @param {ThrobberTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst Throbber: FunctionComponent<PropsT> = ({ theme, themePriority }) => {\n const custom = useTheme('Throbber', defaultTheme, theme, {\n themePriority,\n });\n\n return (\n <span className={custom.container}>\n <span className={custom.circle} />\n <span className={custom.circle} />\n <span className={custom.circle} />\n </span>\n );\n};\n\nexport default Throbber;\n"],"mappings":"4CAEA,OAAoC,QAAQ,KAAQ,0BAA0B,CAE9E,iIAAwC,yDASxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,SAAmC,CAAG,oBAAC,6BAAwB,iCACV,iBAEzD,CAAC,2CAFD,aAAe,QAAQ,CAAC,UAAU,CAAE,YAAY,CAAE,KAAK,CAAE,EAExD,CAAC,CAAC,8CAIC,6BAAiB,SAAa,CAAb,MAAM,OAAO,CAAG,CAAC,CAClC,6BAAiB,SAAa,CAAb,MAAM,OAAO,CAAG,CAAC,CAClC,6BAAiB,SAAa,CAAb,MAAM,OAAO,CAAG,CAAC,+IAHpC,8BAAiB,SAAgB,CAAhB,MAAM,UAAU,WAC/B,EAAkC,CAClC,EAAkC,CAClC,EAAkC,EAC9B,CAAC,8EAJP,GAIO,EAEV,CAED,cAAe,SAAQ","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* global window */import{useEffect,useRef,useState}from"react";import{useTheme}from"@dr.pogodin/react-themes";import Tooltip,{PLACEMENTS}from"./Tooltip.js";const defaultTheme={"ad":"
|
|
1
|
+
/* global window */import{useEffect,useRef,useState}from"react";import{useTheme}from"@dr.pogodin/react-themes";import Tooltip,{PLACEMENTS}from"./Tooltip.js";const defaultTheme={"ad":"n6OiU9","hoc":"zwsjGc","context":"JVJPcU","appearance":"_9U4YiR","arrow":"_9n65k-","container":"uA1tHZ","wrapper":"JFVmGf"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
|
|
2
2
|
* Implements a simple to use and themeable tooltip component, _e.g._
|
|
3
3
|
* ```js
|
|
4
4
|
* <WithTooltip tip="This is example tooltip.">
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as _c}from"react/compiler-runtime";import qs from"qs";import{useTheme}from"@dr.pogodin/react-themes";import Throbber from"../Throbber/index.js";const defaultTheme={"context":"
|
|
1
|
+
import{c as _c}from"react/compiler-runtime";import qs from"qs";import{useTheme}from"@dr.pogodin/react-themes";import Throbber from"../Throbber/index.js";const defaultTheme={"context":"Pa7GiX","ad":"NikZ57","hoc":"FydyFQ","container":"pQTzJV","video":"iFTALT"};const throbberTheme={"context":"_0Piy3R","ad":"GD-lgk","hoc":"T5TGzT","container":"IgN6Uf"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
|
|
2
2
|
* A component for embeding a YouTube video.
|
|
3
3
|
* @param [props] Component properties.
|
|
4
4
|
* @param [props.autoplay] If `true` the video will start to play
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _pushInstanceProperty from"core-js-pure/stable/instance/push.js";import{c as _c}from"react/compiler-runtime";import{useImperativeHandle,useRef}from"react";import{BaseModal}from"../../../Modal/index.js";import{optionValueName}from"../../common.js";const S={"overlay":"
|
|
1
|
+
import _pushInstanceProperty from"core-js-pure/stable/instance/push.js";import{c as _c}from"react/compiler-runtime";import{useImperativeHandle,useRef}from"react";import{BaseModal}from"../../../Modal/index.js";import{optionValueName}from"../../common.js";const S={"overlay":"ntZ5My"};import{jsx as _jsx}from"react/jsx-runtime";export function areEqual(a,b){return a?.left===b?.left&&a?.top===b?.top&&a?.width===b?.width;}const Options=t0=>{const $=_c(16);const{containerClass,containerStyle,filter,onCancel,onChange,optionClass,options,ref}=t0;const opsRef=useRef(null);let t1;let t2;if($[0]===Symbol.for("react.memo_cache_sentinel")){t1=()=>({measure:()=>{const e=opsRef.current?.parentElement;if(!e){return;}const rect=opsRef.current.getBoundingClientRect();const style=window.getComputedStyle(e);const mBottom=parseFloat(style.marginBottom);const mTop=parseFloat(style.marginTop);rect.height=rect.height+(mBottom+mTop);return rect;}});t2=[];$[0]=t1;$[1]=t2;}else{t1=$[0];t2=$[1];}useImperativeHandle(ref,t1,t2);let optionNodes;if($[2]!==filter||$[3]!==onChange||$[4]!==optionClass||$[5]!==options){optionNodes=[];for(const option of options){if(!filter||filter(option)){const[iValue,iName]=optionValueName(option);_pushInstanceProperty(optionNodes).call(optionNodes,/*#__PURE__*/_jsx("div",{className:optionClass,onClick:e_0=>{onChange(iValue);e_0.stopPropagation();},onKeyDown:e_1=>{if(e_1.key==="Enter"){onChange(iValue);e_1.stopPropagation();}},role:"button",tabIndex:0,children:iName},iValue));}}$[2]=filter;$[3]=onChange;$[4]=optionClass;$[5]=options;$[6]=optionNodes;}else{optionNodes=$[6];}let t3;if($[7]!==containerClass){t3={ad:"",container:containerClass,context:"",hoc:"",overlay:S.overlay};$[7]=containerClass;$[8]=t3;}else{t3=$[8];}let t4;if($[9]!==optionNodes){t4=/*#__PURE__*/_jsx("div",{ref:opsRef,children:optionNodes});$[9]=optionNodes;$[10]=t4;}else{t4=$[10];}let t5;if($[11]!==containerStyle||$[12]!==onCancel||$[13]!==t3||$[14]!==t4){t5=/*#__PURE__*/_jsx(BaseModal,{cancelOnScrolling:true,dontDisableScrolling:true,onCancel:onCancel,style:containerStyle,theme:t3,children:t4});$[11]=containerStyle;$[12]=onCancel;$[13]=t3;$[14]=t4;$[15]=t5;}else{t5=$[15];}return t5;};export default Options;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as _c}from"react/compiler-runtime";import{useEffect,useRef,useState}from"react";import{useTheme}from"@dr.pogodin/react-themes";import{optionValueName}from"../common.js";import Options,{areEqual}from"./Options/index.js";const defaultTheme={"context":"
|
|
1
|
+
import{c as _c}from"react/compiler-runtime";import{useEffect,useRef,useState}from"react";import{useTheme}from"@dr.pogodin/react-themes";import{optionValueName}from"../common.js";import Options,{areEqual}from"./Options/index.js";const defaultTheme={"context":"SNj3wp","ad":"T6eOJ-","hoc":"KG-OKN","container":"SzHHPE","label":"KTG4ai","dropdown":"xdotm7","option":"y-WCDM","select":"PP5Siy","arrow":"_7-A7Lh","active":"RoOAZK","upward":"_--5Xpy"};import{Fragment as _Fragment,jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const CustomDropdown=t0=>{const $=_c(31);const{filter,label,onChange,options,theme,value}=t0;const custom=useTheme("CustomDropdown",defaultTheme,theme);const[active,setActive]=useState(false);const dropdownRef=useRef(null);const opsRef=useRef(null);const[opsPos,setOpsPos]=useState();const[upward,setUpward]=useState(false);let t1;let t2;if($[0]!==active){t1=()=>{if(!active){return;}let id;const cb=()=>{const anchor=dropdownRef.current?.getBoundingClientRect();const opsRect=opsRef.current?.measure();if(anchor&&opsRect){const fitsDown=anchor.bottom+opsRect.height<(window.visualViewport?.height??0);const fitsUp=anchor.top-opsRect.height>0;const up=!fitsDown&&fitsUp;setUpward(up);const pos=up?{left:anchor.left,top:anchor.top-opsRect.height-1,width:anchor.width}:{left:anchor.left,top:anchor.bottom,width:anchor.width};setOpsPos(now=>areEqual(now,pos)?now:pos);}id=requestAnimationFrame(cb);};requestAnimationFrame(cb);return()=>{cancelAnimationFrame(id);};};t2=[active];$[0]=active;$[1]=t1;$[2]=t2;}else{t1=$[1];t2=$[2];}useEffect(t1,t2);let t3;if($[3]===Symbol.for("react.memo_cache_sentinel")){t3=e=>{const view=window.visualViewport;const rect=dropdownRef.current.getBoundingClientRect();setActive(true);setOpsPos({left:view?.width??0,top:view?.height??0,width:rect.width});e.stopPropagation();};$[3]=t3;}else{t3=$[3];}const openList=t3;let t4;if($[4]===Symbol.for("react.memo_cache_sentinel")){t4=/*#__PURE__*/_jsx(_Fragment,{children:""});$[4]=t4;}else{t4=$[4];}let selected=t4;if($[5]!==filter||$[6]!==options||$[7]!==value){for(const option of options){if(!filter||filter(option)){const[iValue,iName]=optionValueName(option);if(iValue===value){selected=iName;break;}}}$[5]=filter;$[6]=options;$[7]=value;$[8]=selected;}else{selected=$[8];}let containerClassName=custom.container;if(active){containerClassName=containerClassName+` ${custom.active}`;}let opsContainerClass=custom.select??"";if(upward){containerClassName=containerClassName+` ${custom.upward}`;opsContainerClass=opsContainerClass+` ${custom.upward}`;}let t5;if($[9]!==custom.label||$[10]!==label){t5=label===undefined?null:/*#__PURE__*/_jsx("div",{className:custom.label,children:label});$[9]=custom.label;$[10]=label;$[11]=t5;}else{t5=$[11];}let t6;if($[12]===Symbol.for("react.memo_cache_sentinel")){t6=e_0=>{if(e_0.key==="Enter"){openList(e_0);}};$[12]=t6;}else{t6=$[12];}let t7;if($[13]!==custom.arrow){t7=/*#__PURE__*/_jsx("div",{className:custom.arrow});$[13]=custom.arrow;$[14]=t7;}else{t7=$[14];}let t8;if($[15]!==custom.dropdown||$[16]!==selected||$[17]!==t7){t8=/*#__PURE__*/_jsxs("div",{className:custom.dropdown,onClick:openList,onKeyDown:t6,ref:dropdownRef,role:"listbox",tabIndex:0,children:[selected,t7]});$[15]=custom.dropdown;$[16]=selected;$[17]=t7;$[18]=t8;}else{t8=$[18];}let t9;if($[19]!==active||$[20]!==custom.option||$[21]!==onChange||$[22]!==opsContainerClass||$[23]!==opsPos||$[24]!==options){t9=active?/*#__PURE__*/_jsx(Options,{containerClass:opsContainerClass,containerStyle:opsPos,onCancel:()=>{setActive(false);},onChange:newValue=>{setActive(false);if(onChange){onChange(newValue);}},optionClass:custom.option??"",options:options,ref:opsRef}):null;$[19]=active;$[20]=custom.option;$[21]=onChange;$[22]=opsContainerClass;$[23]=opsPos;$[24]=options;$[25]=t9;}else{t9=$[25];}let t10;if($[26]!==containerClassName||$[27]!==t5||$[28]!==t8||$[29]!==t9){t10=/*#__PURE__*/_jsxs("div",{className:containerClassName,children:[t5,t8,t9]});$[26]=containerClassName;$[27]=t5;$[28]=t8;$[29]=t9;$[30]=t10;}else{t10=$[30];}return t10;};export default CustomDropdown;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _pushInstanceProperty from"core-js-pure/stable/instance/push.js";// Implements dropdown based on the native HTML <select> element.
|
|
2
|
-
import{useTheme}from"@dr.pogodin/react-themes";import{optionValueName}from"../common.js";const defaultTheme={"context":"
|
|
2
|
+
import{useTheme}from"@dr.pogodin/react-themes";import{optionValueName}from"../common.js";const defaultTheme={"context":"WbwY1Y","ad":"AP5hsY","hoc":"ODAJeW","dropdown":"wabw76","arrow":"WFSB9z","container":"vE9M8Z","active":"sfLSJA","label":"bQLBhS","option":"wgCtdC","hiddenOption":"ty19C2","select":"ntbzPR","invalid":"_3CzMM4"};/**
|
|
3
3
|
* Implements a themeable dropdown list. Internally it is rendered with help of
|
|
4
4
|
* the standard HTML `<select>` element, thus the styling support is somewhat
|
|
5
5
|
* limited.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _pushInstanceProperty from"core-js-pure/stable/instance/push.js";import{c as _c}from"react/compiler-runtime";import{useTheme}from"@dr.pogodin/react-themes";import{optionValueName}from"../common.js";const defaultTheme={"context":"
|
|
1
|
+
import _pushInstanceProperty from"core-js-pure/stable/instance/push.js";import{c as _c}from"react/compiler-runtime";import{useTheme}from"@dr.pogodin/react-themes";import{optionValueName}from"../common.js";const defaultTheme={"context":"akD3dQ","ad":"xcXtdE","hoc":"N3iziJ","container":"BYeWyJ","option":"_7MFXEN","selected":"CDbWAd","options":"_9-eOZo"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const Switch=t0=>{const $=_c(16);const{label,onChange,options,theme,value}=t0;const composed=useTheme("Switch",defaultTheme,theme);if(!options||!composed.option){throw Error("Internal error");}let optionNodes;if($[0]!==composed.option||$[1]!==composed.selected||$[2]!==onChange||$[3]!==options||$[4]!==value){optionNodes=[];for(const option of options){const[iValue,iName]=optionValueName(option);let className=composed.option;let onPress;if(iValue===value){className=className+` ${composed.selected}`;}else{if(onChange){onPress=()=>{onChange(iValue);};}}_pushInstanceProperty(optionNodes).call(optionNodes,onPress?/*#__PURE__*/_jsx("div",{className:className,onClick:onPress,onKeyDown:e=>{if(e.key==="Enter"){onPress();}},role:"button",tabIndex:0,children:iName},iValue):/*#__PURE__*/_jsx("div",{className:className,children:iName},iValue));}$[0]=composed.option;$[1]=composed.selected;$[2]=onChange;$[3]=options;$[4]=value;$[5]=optionNodes;}else{optionNodes=$[5];}let t1;if($[6]!==composed.label||$[7]!==label){t1=label?/*#__PURE__*/_jsx("div",{className:composed.label,children:label}):null;$[6]=composed.label;$[7]=label;$[8]=t1;}else{t1=$[8];}let t2;if($[9]!==composed.options||$[10]!==optionNodes){t2=/*#__PURE__*/_jsx("div",{className:composed.options,children:optionNodes});$[9]=composed.options;$[10]=optionNodes;$[11]=t2;}else{t2=$[11];}let t3;if($[12]!==composed.container||$[13]!==t1||$[14]!==t2){t3=/*#__PURE__*/_jsxs("div",{className:composed.container,children:[t1,t2]});$[12]=composed.container;$[13]=t1;$[14]=t2;$[15]=t3;}else{t3=$[15];}return t3;};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../src/shared/components/selectors/Switch/index.tsx"],"sourcesContent":["import type { FunctionComponent, ReactNode } from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport {\n type OptionsT,\n type ValueT,\n optionValueName,\n} from '../common';\n\nimport defaultTheme from './theme.scss';\n\ntype ThemeT = Theme<'container' | 'label' | 'option' | 'options' | 'selected'>;\n\ntype PropsT = {\n label?: ReactNode;\n onChange?: (value: ValueT) => void;\n options?: Readonly<OptionsT<ReactNode>>;\n theme?: ThemeT;\n value?: ValueT;\n};\n\nexport const Switch: FunctionComponent<PropsT> = ({\n label,\n onChange,\n options,\n theme,\n value,\n}) => {\n const composed = useTheme('Switch', defaultTheme, theme);\n\n if (!options || !composed.option) throw Error('Internal error');\n\n const optionNodes: React.ReactNode[] = [];\n for (const option of options) {\n const [iValue, iName] = optionValueName(option);\n\n let className: string = composed.option;\n let onPress: (() => void) | undefined;\n if (iValue === value) className += ` ${composed.selected}`;\n else if (onChange) {\n onPress = () => {\n onChange(iValue);\n };\n }\n\n optionNodes.push(\n onPress\n ? (\n <div\n className={className}\n key={iValue}\n onClick={onPress}\n onKeyDown={(e) => {\n if (e.key === 'Enter') onPress();\n }}\n role=\"button\"\n tabIndex={0}\n >\n {iName}\n </div>\n )\n : <div className={className} key={iValue}>{iName}</div>,\n );\n }\n\n return (\n <div className={composed.container}>\n {label ? <div className={composed.label}>{label}</div> : null}\n\n <div className={composed.options}>\n {optionNodes}\n </div>\n </div>\n );\n};\n"],"mappings":"oHAEA,OAAqB,QAAQ,KAAQ,0BAA0B,CAAC,OAK9D,eAAe,oBAGjB,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../src/shared/components/selectors/Switch/index.tsx"],"sourcesContent":["import type { FunctionComponent, ReactNode } from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport {\n type OptionsT,\n type ValueT,\n optionValueName,\n} from '../common';\n\nimport defaultTheme from './theme.scss';\n\ntype ThemeT = Theme<'container' | 'label' | 'option' | 'options' | 'selected'>;\n\ntype PropsT = {\n label?: ReactNode;\n onChange?: (value: ValueT) => void;\n options?: Readonly<OptionsT<ReactNode>>;\n theme?: ThemeT;\n value?: ValueT;\n};\n\nexport const Switch: FunctionComponent<PropsT> = ({\n label,\n onChange,\n options,\n theme,\n value,\n}) => {\n const composed = useTheme('Switch', defaultTheme, theme);\n\n if (!options || !composed.option) throw Error('Internal error');\n\n const optionNodes: React.ReactNode[] = [];\n for (const option of options) {\n const [iValue, iName] = optionValueName(option);\n\n let className: string = composed.option;\n let onPress: (() => void) | undefined;\n if (iValue === value) className += ` ${composed.selected}`;\n else if (onChange) {\n onPress = () => {\n onChange(iValue);\n };\n }\n\n optionNodes.push(\n onPress\n ? (\n <div\n className={className}\n key={iValue}\n onClick={onPress}\n onKeyDown={(e) => {\n if (e.key === 'Enter') onPress();\n }}\n role=\"button\"\n tabIndex={0}\n >\n {iName}\n </div>\n )\n : <div className={className} key={iValue}>{iName}</div>,\n );\n }\n\n return (\n <div className={composed.container}>\n {label ? <div className={composed.label}>{label}</div> : null}\n\n <div className={composed.options}>\n {optionNodes}\n </div>\n </div>\n );\n};\n"],"mappings":"oHAEA,OAAqB,QAAQ,KAAQ,0BAA0B,CAAC,OAK9D,eAAe,oBAGjB,qJAAwC,yDAYxC,MAAO,MAAM,OAAiC,CAAG,oBAAC,4CAMjD,CACC,eAAiB,QAAQ,CAAC,QAAQ,CAAE,YAAY,CAAE,KAAK,CAAC,CAExD,GAAI,CAAC,OAA2B,EAA5B,CAAa,QAAQ,OAAO,EAAE,KAAM,MAAK,CAAC,gBAAgB,CAAC,CAAC,qHAEhE,YAAuC,EAAE,CACzC,IAAK,YAAY,GAAI,QAAO,EAC1B,oBAAwB,eAAe,CAAC,MAAM,CAAC,CAE/C,cAAwB,QAAQ,OAAO,CACnC,YACJ,GAAI,MAAM,GAAK,KAAK,EAAE,mBAAS,CAAI,IAAI,QAAQ,SAAS,EAAE,OACrD,GAAI,QAAQ,EACf,QAAU,KACR,QAAQ,CAAC,MAAM,CAAC,EACjB,CAFM,CAGR,CAED,iCAAW,OAAX,WAAW,CACT,OAAO,cAAP,YAGiB,SAAS,CAAT,SAAS,CAEX,OAAO,CAAP,OAAO,CACL,SAEV,CAFU,IACT,GAAI,CAAC,IAAI,GAAK,OAAO,EAAE,OAAO,CAAC,CAAC,EAAC,CAClC,CACI,IAAQ,CAAR,QAAQ,CACH,QAAC,CAAD,CAAC,UAEV,KAAK,EARD,MAW6C,CAAC,cAfzD,YAeoB,SAAS,CAAT,SAAS,UAAgB,KAAK,EAAd,MAAoB,CAC1D,CAAC,EACF,0KAII,QAAK,cAAL,YAAwB,SAAc,CAAd,QAAQ,MAAM,UAAG,KAAK,CAAa,CAAC,CAA5D,IAA4D,+GAE7D,4BAAgB,SAAgB,CAAhB,QAAQ,QAAQ,UAC7B,WAAW,CACT,CAAC,gIALR,6BAAgB,SAAkB,CAAlB,QAAQ,UAAU,WAC/B,EAA4D,CAE7D,EAEM,EACH,CAAC,2EANN,GAMM,EAET","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { InjT } from '../shared/utils/globalState';
|
|
1
|
+
import type { InjT } from '../shared/utils/globalState.js';
|
|
2
2
|
export default function getInj(): InjT | Promise<InjT>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Initialization of client-side environment.
|
|
3
3
|
*/
|
|
4
|
-
import { type BuildInfoT } from '../shared/utils/isomorphy/buildInfo';
|
|
4
|
+
import { type BuildInfoT } from '../shared/utils/isomorphy/buildInfo.js';
|
|
5
5
|
declare global {
|
|
6
6
|
interface Window {
|
|
7
7
|
__DEV_BUILD_INFO__: BuildInfoT | undefined;
|
|
@@ -6,7 +6,7 @@ declare global {
|
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
export { type AsyncCollectionLoaderT, type AsyncCollectionT, type AsyncDataEnvelopeT, type AsyncDataLoaderT, type ForceT, GlobalStateProvider, type UseAsyncDataOptionsT, type UseAsyncDataResT, type UseGlobalStateResT, type ValueOrInitializerT, newAsyncDataEnvelope, useAsyncCollection, useAsyncData, useGlobalState, useGlobalStateObject, withGlobalStateType, } from '@dr.pogodin/react-global-state';
|
|
9
|
-
export * from './shared/components';
|
|
9
|
+
export * from './shared/components/index.js';
|
|
10
10
|
export { type BeforeRenderResT, type BeforeRenderT, type ConfigT, type ServerSsrContext, type ServerT, } from './server';
|
|
11
|
-
export { Barrier, Cached, Emitter, type Listener, type ObjectKey, Semaphore, THEME_COMPOSE, THEME_PRIORITY, type Theme, ThemeProvider, assertEmptyObject, getConfig, setClientChunkGroups, splitComponent, time, useSsrContext, useTheme, webpack, withRetries, } from './shared/utils';
|
|
12
|
-
export * from './shared/utils/isomorphy';
|
|
11
|
+
export { Barrier, Cached, Emitter, type Listener, type ObjectKey, Semaphore, THEME_COMPOSE, THEME_PRIORITY, type Theme, ThemeProvider, assertEmptyObject, getConfig, setClientChunkGroups, splitComponent, time, useSsrContext, useTheme, webpack, withRetries, } from './shared/utils/index.js';
|
|
12
|
+
export * from './shared/utils/isomorphy/index.js';
|
|
@@ -6,8 +6,8 @@ import type { ComponentType } from 'react';
|
|
|
6
6
|
import type { Configuration, Stats } from 'webpack';
|
|
7
7
|
import winston from 'winston';
|
|
8
8
|
import { SsrContext } from '@dr.pogodin/react-global-state';
|
|
9
|
-
import type { ChunkGroupsT, SsrContextT } from '../shared/utils/globalState';
|
|
10
|
-
import { type BuildInfoT } from '../shared/utils/isomorphy/buildInfo';
|
|
9
|
+
import type { ChunkGroupsT, SsrContextT } from '../shared/utils/globalState.js';
|
|
10
|
+
import { type BuildInfoT } from '../shared/utils/isomorphy/buildInfo.js';
|
|
11
11
|
interface LogMethodI {
|
|
12
12
|
(level: string, message: string, ...meta: unknown[]): void;
|
|
13
13
|
}
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
* Just an aggregation of all exported components into a single module.
|
|
3
3
|
*/
|
|
4
4
|
export { MetaTags } from '@dr.pogodin/react-helmet';
|
|
5
|
-
export * from './selectors';
|
|
6
|
-
export { BaseButton, default as Button } from './Button';
|
|
7
|
-
export { default as Checkbox } from './Checkbox';
|
|
8
|
-
export { default as Input } from './Input';
|
|
9
|
-
export { default as Link } from './Link';
|
|
10
|
-
export { BaseModal, default as Modal } from './Modal';
|
|
11
|
-
export { default as NavLink } from './NavLink';
|
|
12
|
-
export { default as PageLayout } from './PageLayout';
|
|
13
|
-
export { default as Throbber } from './Throbber';
|
|
14
|
-
export { default as WithTooltip } from './WithTooltip';
|
|
15
|
-
export { default as YouTubeVideo } from './YouTubeVideo';
|
|
5
|
+
export * from './selectors/index.js';
|
|
6
|
+
export { BaseButton, default as Button } from './Button/index.js';
|
|
7
|
+
export { default as Checkbox } from './Checkbox/index.js';
|
|
8
|
+
export { default as Input } from './Input/index.js';
|
|
9
|
+
export { default as Link } from './Link.js';
|
|
10
|
+
export { BaseModal, default as Modal } from './Modal/index.js';
|
|
11
|
+
export { default as NavLink } from './NavLink.js';
|
|
12
|
+
export { default as PageLayout } from './PageLayout/index.js';
|
|
13
|
+
export { default as Throbber } from './Throbber/index.js';
|
|
14
|
+
export { default as WithTooltip } from './WithTooltip/index.js';
|
|
15
|
+
export { default as YouTubeVideo } from './YouTubeVideo/index.js';
|
|
16
16
|
export { default as TextArea } from './TextArea';
|
|
@@ -18,8 +18,6 @@ export declare enum ENVIRONMENTS {
|
|
|
18
18
|
type ModuleT = 'amd' | 'auto' | 'cjs' | 'commonjs' | 'systemjs' | 'umd' | false;
|
|
19
19
|
export type OptionsT = {
|
|
20
20
|
addImportExtensions?: AddImportExtensionOptions | boolean;
|
|
21
|
-
/** Must match Webpack config context for */
|
|
22
|
-
context?: string;
|
|
23
21
|
modules?: ModuleT;
|
|
24
22
|
noRR?: boolean;
|
|
25
23
|
noReactCompiler?: boolean;
|
package/config/babel/webpack.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { localIdentNameFactory, } from '@dr.pogodin/babel-plugin-react-css-modules/utils';
|
|
2
|
+
const localIdentNameDev = localIdentNameFactory('[package]___[path][name]___[local]___[hash:base64:6]');
|
|
3
|
+
const localIdentNameProd = localIdentNameFactory('[hash:base64:6]');
|
|
1
4
|
/**
|
|
2
5
|
* Supported Babel environments.
|
|
3
6
|
*/
|
|
@@ -58,10 +61,9 @@ function newBaseConfig(options) {
|
|
|
58
61
|
* @return {object} Returns mutated config for chaining.
|
|
59
62
|
* @ignore
|
|
60
63
|
*/
|
|
61
|
-
function addStyling(config, env
|
|
64
|
+
function addStyling(config, env) {
|
|
62
65
|
const cssModulesOps = {
|
|
63
66
|
autoResolveMultipleImports: true,
|
|
64
|
-
context,
|
|
65
67
|
filetypes: {
|
|
66
68
|
'.scss': { syntax: 'postcss-scss' },
|
|
67
69
|
},
|
|
@@ -70,10 +72,10 @@ function addStyling(config, env, context) {
|
|
|
70
72
|
switch (env) {
|
|
71
73
|
case ENVIRONMENTS.DEV:
|
|
72
74
|
case ENVIRONMENTS.TEST:
|
|
73
|
-
cssModulesOps.
|
|
75
|
+
cssModulesOps.localIdentName = localIdentNameDev;
|
|
74
76
|
break;
|
|
75
77
|
case ENVIRONMENTS.PROD:
|
|
76
|
-
cssModulesOps.
|
|
78
|
+
cssModulesOps.localIdentName = localIdentNameProd;
|
|
77
79
|
break;
|
|
78
80
|
default:
|
|
79
81
|
}
|
|
@@ -92,9 +94,8 @@ function addStyling(config, env, context) {
|
|
|
92
94
|
export default function getPreset(babel, ops = {}) {
|
|
93
95
|
const env = babel.env();
|
|
94
96
|
const res = newBaseConfig(ops);
|
|
95
|
-
if (!ops.noStyling)
|
|
96
|
-
addStyling(res, env
|
|
97
|
-
}
|
|
97
|
+
if (!ops.noStyling)
|
|
98
|
+
addStyling(res, env);
|
|
98
99
|
if (env === ENVIRONMENTS.DEV && !ops.noRR) {
|
|
99
100
|
res.plugins.push('react-refresh/babel');
|
|
100
101
|
}
|
|
@@ -133,4 +133,4 @@ export type OptionsT = {
|
|
|
133
133
|
* - **`rndkey`** — The value set for `BUILD_RNDKEY`;
|
|
134
134
|
* - **`timestamp`** — The value set for `BUILD_TIMESTAMP`.
|
|
135
135
|
*/
|
|
136
|
-
export default function configFactory(
|
|
136
|
+
export default function configFactory({ babelEnv, babelLoaderExclude, babelLoaderOptions, context, cssLocalIdent, dontEmitBuildInfo, dontUseProgressPlugin, entry, fs, keepBuildInfo, mode, outputPath, publicPath, sitemap, typescript, workbox, }: OptionsT): Configuration;
|
|
@@ -3,13 +3,14 @@ import { randomBytes } from 'node:crypto';
|
|
|
3
3
|
import nodeFs from 'node:fs';
|
|
4
4
|
import { createRequire } from 'node:module';
|
|
5
5
|
import { resolve } from 'node:path';
|
|
6
|
-
import {
|
|
6
|
+
import { isFunction } from 'lodash-es';
|
|
7
7
|
import { SitemapStream, streamToPromise } from 'sitemap';
|
|
8
8
|
// NOTE: As "webpack" is still distributed as CJS module, now that we have
|
|
9
9
|
// switched to MJS, importing plugins from it in MJS import style does not work,
|
|
10
10
|
// thus we need to import the default export, and use its fields.
|
|
11
11
|
import webpack from 'webpack';
|
|
12
12
|
import WorkboxPlugin from 'workbox-webpack-plugin';
|
|
13
|
+
import { localIdentNameFactory, } from '@dr.pogodin/babel-plugin-react-css-modules/utils';
|
|
13
14
|
const COREJS_REGEX = /\/core-js/;
|
|
14
15
|
const require = createRequire(import.meta.url);
|
|
15
16
|
/**
|
|
@@ -121,21 +122,13 @@ const require = createRequire(import.meta.url);
|
|
|
121
122
|
* - **`rndkey`** — The value set for `BUILD_RNDKEY`;
|
|
122
123
|
* - **`timestamp`** — The value set for `BUILD_TIMESTAMP`.
|
|
123
124
|
*/
|
|
124
|
-
export default function configFactory(
|
|
125
|
-
var _a;
|
|
126
|
-
const o = defaults(clone(ops), {
|
|
127
|
-
babelLoaderOptions: {},
|
|
128
|
-
cssLocalIdent: '[hash:base64:6]',
|
|
129
|
-
outputPath: 'build/web-public',
|
|
130
|
-
publicPath: '',
|
|
131
|
-
});
|
|
132
|
-
const fs = (_a = ops.fs) !== null && _a !== void 0 ? _a : nodeFs;
|
|
125
|
+
export default function configFactory({ babelEnv, babelLoaderExclude, babelLoaderOptions = {}, context, cssLocalIdent = '[hash:base64:6]', dontEmitBuildInfo, dontUseProgressPlugin, entry, fs = nodeFs, keepBuildInfo, mode, outputPath = 'build/web-public', publicPath = '', sitemap, typescript, workbox, }) {
|
|
133
126
|
// TODO: Should it be improved and re-validated? Are we using it in any project
|
|
134
127
|
// as is?
|
|
135
128
|
/* TODO: This works in practice, but being async and not awaited it is a bad
|
|
136
129
|
* pattern. */
|
|
137
|
-
if (
|
|
138
|
-
const sitemapUrl = resolve(
|
|
130
|
+
if (sitemap) {
|
|
131
|
+
const sitemapUrl = resolve(context, sitemap);
|
|
139
132
|
// eslint-disable-next-line import/no-dynamic-require
|
|
140
133
|
let source = require(sitemapUrl);
|
|
141
134
|
if (isFunction(source))
|
|
@@ -145,11 +138,11 @@ export default function configFactory(ops) {
|
|
|
145
138
|
sm.write(item);
|
|
146
139
|
});
|
|
147
140
|
sm.end();
|
|
148
|
-
void streamToPromise(sm).then((
|
|
149
|
-
const outUrl = resolve(
|
|
141
|
+
void streamToPromise(sm).then((sitemapRes) => {
|
|
142
|
+
const outUrl = resolve(context, outputPath);
|
|
150
143
|
if (!fs.existsSync(outUrl))
|
|
151
144
|
fs.mkdirSync(outUrl);
|
|
152
|
-
fs.writeFileSync(resolve(
|
|
145
|
+
fs.writeFileSync(resolve(context, outputPath, 'sitemap.xml'), new DataView(sitemapRes.buffer));
|
|
153
146
|
});
|
|
154
147
|
}
|
|
155
148
|
// TODO: Once all assets are named by hashes, we probably don't need build
|
|
@@ -158,10 +151,10 @@ export default function configFactory(ops) {
|
|
|
158
151
|
// timestamp, and any other similar information to the actual app, so it
|
|
159
152
|
// can be used in some scenarious.
|
|
160
153
|
let buildInfo;
|
|
161
|
-
const buildInfoUrl = resolve(
|
|
162
|
-
if (
|
|
154
|
+
const buildInfoUrl = resolve(context, '.build-info');
|
|
155
|
+
if (keepBuildInfo) {
|
|
163
156
|
// If "true" - attempt to load from the filesystem.
|
|
164
|
-
if (
|
|
157
|
+
if (keepBuildInfo === true) {
|
|
165
158
|
if (fs.existsSync(buildInfoUrl)) {
|
|
166
159
|
buildInfo = JSON.parse(fs.readFileSync(buildInfoUrl, 'utf8'));
|
|
167
160
|
}
|
|
@@ -169,7 +162,7 @@ export default function configFactory(ops) {
|
|
|
169
162
|
// to use in the build.
|
|
170
163
|
}
|
|
171
164
|
else
|
|
172
|
-
buildInfo =
|
|
165
|
+
buildInfo = keepBuildInfo;
|
|
173
166
|
}
|
|
174
167
|
// Even if "keepBuildInfo" option was provided, we still generate a new
|
|
175
168
|
// build info object in case nothing could be loaded.
|
|
@@ -177,57 +170,55 @@ export default function configFactory(ops) {
|
|
|
177
170
|
/* A random 32-bit key, that can be used for encryption. */
|
|
178
171
|
key: randomBytes(32).toString('base64'),
|
|
179
172
|
/* Public path used during build. */
|
|
180
|
-
publicPath
|
|
173
|
+
publicPath,
|
|
181
174
|
/* `true` if client-side code should setup a service worker. */
|
|
182
|
-
useServiceWorker: Boolean(
|
|
175
|
+
useServiceWorker: Boolean(workbox),
|
|
183
176
|
// Build timestamp.
|
|
184
177
|
timestamp: new Date().toISOString(),
|
|
185
178
|
}));
|
|
186
179
|
// If not opted-out, we write the build info to the filesystem. We also attach
|
|
187
180
|
// it to the factory function itself, so it can be easily accessed right after
|
|
188
181
|
// the factory call in testing scenarios.
|
|
189
|
-
if (!
|
|
182
|
+
if (!dontEmitBuildInfo) {
|
|
190
183
|
// Note: this is needed if "fs" option is provided, to ensure the factory
|
|
191
184
|
// does not crash if the folder is not created in that filesystem.
|
|
192
|
-
fs.mkdirSync(
|
|
185
|
+
fs.mkdirSync(context, { recursive: true });
|
|
193
186
|
fs.writeFileSync(buildInfoUrl, JSON.stringify(buildInfo));
|
|
194
187
|
}
|
|
195
188
|
/* Entry points normalization. */
|
|
196
|
-
const
|
|
189
|
+
const normalizedEntry = [
|
|
197
190
|
'nodelist-foreach-polyfill',
|
|
198
|
-
...Array.isArray(
|
|
191
|
+
...Array.isArray(entry) ? entry : [entry],
|
|
199
192
|
];
|
|
200
193
|
const plugins = [
|
|
201
194
|
new webpack.DefinePlugin({ BUILD_INFO: JSON.stringify(buildInfo) }),
|
|
202
195
|
];
|
|
203
|
-
if (!
|
|
196
|
+
if (!dontUseProgressPlugin)
|
|
204
197
|
plugins.push(new webpack.ProgressPlugin());
|
|
205
198
|
/* Adds InjectManifest plugin from WorkBox, if opted to. */
|
|
206
|
-
if (
|
|
207
|
-
|
|
208
|
-
o.workbox = {};
|
|
209
|
-
plugins.push(new WorkboxPlugin.InjectManifest(Object.assign(Object.assign({ swSrc: resolve(import.meta.dirname, '../workbox/default.js') }, o.workbox), { swDest: '__service-worker.js' })));
|
|
199
|
+
if (workbox) {
|
|
200
|
+
plugins.push(new WorkboxPlugin.InjectManifest(Object.assign(Object.assign({ swSrc: resolve(import.meta.dirname, '../workbox/default.js') }, workbox === true ? {} : workbox), { swDest: '__service-worker.js' })));
|
|
210
201
|
}
|
|
211
|
-
let
|
|
212
|
-
if (
|
|
213
|
-
if (!Array.isArray(
|
|
202
|
+
let babelLoaderExclude2 = babelLoaderExclude;
|
|
203
|
+
if (babelLoaderExclude2) {
|
|
204
|
+
if (!Array.isArray(babelLoaderExclude2))
|
|
214
205
|
throw Error('Not supported');
|
|
215
206
|
// BEWARE: This ensures Babel loader does not process CoreJS library,
|
|
216
207
|
// which would break it creating circular references in its code.
|
|
217
|
-
|
|
208
|
+
babelLoaderExclude2 = [...babelLoaderExclude2, COREJS_REGEX];
|
|
218
209
|
}
|
|
219
210
|
else {
|
|
220
|
-
|
|
211
|
+
babelLoaderExclude2 = [COREJS_REGEX];
|
|
221
212
|
}
|
|
222
213
|
const res = {
|
|
223
|
-
context
|
|
224
|
-
entry,
|
|
214
|
+
context,
|
|
215
|
+
entry: normalizedEntry,
|
|
225
216
|
experiments: { css: true },
|
|
226
|
-
mode
|
|
217
|
+
mode,
|
|
227
218
|
module: {
|
|
228
219
|
generator: {
|
|
229
220
|
'css/module': {
|
|
230
|
-
localIdentName:
|
|
221
|
+
localIdentName: localIdentNameFactory(cssLocalIdent),
|
|
231
222
|
},
|
|
232
223
|
},
|
|
233
224
|
parser: {
|
|
@@ -253,12 +244,11 @@ export default function configFactory(ops) {
|
|
|
253
244
|
// Loads JS modules (.cjs, .js, .jsx, .mjs); TS modules (.ts, .tsx);
|
|
254
245
|
// and SVG assets (.svg).
|
|
255
246
|
test: /\.(cjs|js|jsx|mjs|svg|ts|tsx)$/,
|
|
256
|
-
exclude:
|
|
247
|
+
exclude: babelLoaderExclude2,
|
|
257
248
|
loader: 'babel-loader',
|
|
258
|
-
options: Object.assign({ babelrc: false, configFile: false, envName:
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}]], sourceType: 'unambiguous' }, o.babelLoaderOptions),
|
|
249
|
+
options: Object.assign({ babelrc: false, configFile: false, envName: babelEnv, presets: [['@dr.pogodin/react-utils/config/babel/webpack', {
|
|
250
|
+
typescript,
|
|
251
|
+
}]], sourceType: 'unambiguous' }, babelLoaderOptions),
|
|
262
252
|
}, {
|
|
263
253
|
/* Loads image assets. */
|
|
264
254
|
test: /\.(gif|jpe?g|png)$/,
|
|
@@ -270,14 +260,12 @@ export default function configFactory(ops) {
|
|
|
270
260
|
/* Loads SCSS stylesheets. */
|
|
271
261
|
test: /\.scss$/,
|
|
272
262
|
type: 'css/module',
|
|
273
|
-
use:
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
sourceMap: true,
|
|
278
|
-
},
|
|
263
|
+
use: {
|
|
264
|
+
loader: 'sass-loader',
|
|
265
|
+
options: {
|
|
266
|
+
sourceMap: true,
|
|
279
267
|
},
|
|
280
|
-
|
|
268
|
+
},
|
|
281
269
|
}],
|
|
282
270
|
},
|
|
283
271
|
node: {
|
|
@@ -286,17 +274,17 @@ export default function configFactory(ops) {
|
|
|
286
274
|
output: {
|
|
287
275
|
chunkFilename: '[contenthash].js',
|
|
288
276
|
filename: '[contenthash].js',
|
|
289
|
-
path: resolve(import.meta.dirname,
|
|
290
|
-
publicPath: `${
|
|
277
|
+
path: resolve(import.meta.dirname, context, outputPath),
|
|
278
|
+
publicPath: `${publicPath}/`,
|
|
291
279
|
},
|
|
292
280
|
plugins,
|
|
293
281
|
resolve: {
|
|
294
282
|
alias: {
|
|
295
283
|
// Aliases to JS an JSX files are handled by Babel.
|
|
296
|
-
assets: resolve(
|
|
297
|
-
components: resolve(
|
|
298
|
-
fonts: resolve(
|
|
299
|
-
styles: resolve(
|
|
284
|
+
assets: resolve(context, 'src/assets'),
|
|
285
|
+
components: resolve(context, 'src/shared/components'),
|
|
286
|
+
fonts: resolve(context, 'src/assets/fonts'),
|
|
287
|
+
styles: resolve(context, 'src/styles'),
|
|
300
288
|
},
|
|
301
289
|
extensions: [
|
|
302
290
|
'.ts',
|
|
@@ -11,7 +11,7 @@ import baseFactory from './app-base.js';
|
|
|
11
11
|
*/
|
|
12
12
|
export default function configFactory(ops) {
|
|
13
13
|
const o = defaults(clone(ops), {
|
|
14
|
-
cssLocalIdent: '[
|
|
14
|
+
cssLocalIdent: '[package]___[path][name]___[local]___[hash:base64:6]',
|
|
15
15
|
});
|
|
16
16
|
const entry = ['@dr.pogodin/react-utils/build/development/client/init'];
|
|
17
17
|
if (!o.dontUseHmr)
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* @desc Production Webpack configuration for applications.
|
|
5
5
|
*/
|
|
6
6
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
7
|
+
import MinimizerPlugin from 'minimizer-webpack-plugin';
|
|
7
8
|
import webpack from 'webpack';
|
|
8
9
|
import { merge } from 'webpack-merge';
|
|
9
10
|
import baseFactory from './app-base.js';
|
|
@@ -19,6 +20,35 @@ export default function configFactory(ops) {
|
|
|
19
20
|
...Array.isArray(ops.entry) ? ops.entry : [ops.entry],
|
|
20
21
|
];
|
|
21
22
|
const res = merge(baseFactory(Object.assign(Object.assign({ babelLoaderExclude: [] }, ops), { babelEnv: 'production', babelLoaderOptions: Object.assign({ compact: true }, ops.babelLoaderOptions), entry, mode: 'production' })), {
|
|
23
|
+
optimization: {
|
|
24
|
+
minimizer: [
|
|
25
|
+
'...',
|
|
26
|
+
// TODO: This sets up (S)CSS minimization with CSS Nano minimizer
|
|
27
|
+
// (the same we relied upon in previous versions of Webpack setup);
|
|
28
|
+
// however, Webpack now includes its own, build-in CSS minimizer,
|
|
29
|
+
// and encourages to drop CSS Nano / PostCSS dependency for minimization.
|
|
30
|
+
// At the first glance, out of the box the built-in minimizer does not
|
|
31
|
+
// produce identical results (perhaps, because it does not handle .scss
|
|
32
|
+
// modules by default); because of this, and to be on the safer side,
|
|
33
|
+
// we'll keep CSS Nano in the pipeline for now, and look to get rid of
|
|
34
|
+
// it later.
|
|
35
|
+
new MinimizerPlugin({
|
|
36
|
+
minify: {
|
|
37
|
+
implementation: MinimizerPlugin.cssnanoMinify,
|
|
38
|
+
options: {
|
|
39
|
+
preset: ['default', {
|
|
40
|
+
// Due to the way our styles are organized, these dangerous
|
|
41
|
+
// optimizations can break our styles, thus they are disabled.
|
|
42
|
+
discardUnused: false,
|
|
43
|
+
reduceIdents: false,
|
|
44
|
+
zindex: false,
|
|
45
|
+
}],
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
test: /\.s?css$/,
|
|
49
|
+
}),
|
|
50
|
+
],
|
|
51
|
+
},
|
|
22
52
|
plugins: [
|
|
23
53
|
new webpack.DefinePlugin({
|
|
24
54
|
'process.env.BABEL_ENV': JSON.stringify('production'),
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.57.0
|
|
2
|
+
"version": "1.57.0",
|
|
3
3
|
"bin": {
|
|
4
4
|
"react-utils-build": "bin/build.js",
|
|
5
5
|
"react-utils-run-with-babel": "bin/run-with-babel.js",
|
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@babel/runtime-corejs3": "^8.0.6",
|
|
13
13
|
"@commander-js/extra-typings": "^15.0.0",
|
|
14
|
-
"@dr.pogodin/babel-plugin-react-css-modules": "^8.0.0
|
|
15
|
-
"@dr.pogodin/csurf": "^1.
|
|
14
|
+
"@dr.pogodin/babel-plugin-react-css-modules": "^8.0.0",
|
|
15
|
+
"@dr.pogodin/csurf": "^1.18.1",
|
|
16
16
|
"@dr.pogodin/js-utils": "^0.2.0",
|
|
17
17
|
"@dr.pogodin/react-global-state": "^0.25.0",
|
|
18
|
-
"@dr.pogodin/react-helmet": "^3.2
|
|
18
|
+
"@dr.pogodin/react-helmet": "^3.3.2",
|
|
19
19
|
"@dr.pogodin/react-themes": "^1.11.0",
|
|
20
20
|
"@jest/environment": "^30.5.2",
|
|
21
21
|
"axios": "^1.20.0",
|
|
22
22
|
"commander": "^15.0.0",
|
|
23
|
-
"compression": "^1.8.
|
|
23
|
+
"compression": "^1.8.2",
|
|
24
24
|
"config": "^5.0.1",
|
|
25
25
|
"cookie": "^2.0.1",
|
|
26
26
|
"cookie-parser": "^1.4.7",
|
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
"helmet": "^8.3.0",
|
|
32
32
|
"http-status-codes": "^2.3.0",
|
|
33
33
|
"lodash-es": "^4.18.1",
|
|
34
|
-
"morgan": "^1.12.
|
|
34
|
+
"morgan": "^1.12.1",
|
|
35
35
|
"qs": "^6.16.0",
|
|
36
36
|
"raf": "^3.4.1",
|
|
37
|
-
"react": "^19.
|
|
38
|
-
"react-dom": "^19.
|
|
39
|
-
"react-router": "^8.
|
|
37
|
+
"react": "^19.3.0",
|
|
38
|
+
"react-dom": "^19.3.0",
|
|
39
|
+
"react-router": "^8.4.0",
|
|
40
40
|
"request-ip": "^3.3.0",
|
|
41
41
|
"rimraf": "^6.1.3",
|
|
42
|
-
"serialize-javascript": "^7.1.
|
|
42
|
+
"serialize-javascript": "^7.1.2",
|
|
43
43
|
"serve-favicon": "^2.5.1",
|
|
44
44
|
"source-map-support": "^0.5.21",
|
|
45
45
|
"winston": "^3.19.0"
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@babel/cli": "^8.0.6",
|
|
50
50
|
"@babel/core": "^8.0.6",
|
|
51
51
|
"@babel/plugin-transform-runtime": "^8.0.6",
|
|
52
|
-
"@babel/preset-env": "^8.0.
|
|
52
|
+
"@babel/preset-env": "^8.0.6",
|
|
53
53
|
"@babel/preset-react": "^8.0.1",
|
|
54
54
|
"@babel/preset-typescript": "^8.0.1",
|
|
55
55
|
"@babel/register": "^8.0.6",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"@types/lodash-es": "^4.17.12",
|
|
75
75
|
"@types/morgan": "^1.9.10",
|
|
76
76
|
"@types/pretty": "^2.0.3",
|
|
77
|
-
"@types/react": "^19.
|
|
78
|
-
"@types/react-dom": "^19.
|
|
77
|
+
"@types/react": "^19.3.0",
|
|
78
|
+
"@types/react-dom": "^19.3.0",
|
|
79
79
|
"@types/request-ip": "^0.0.41",
|
|
80
80
|
"@types/serialize-javascript": "^5.0.4",
|
|
81
81
|
"@types/serve-favicon": "^2.5.7",
|
|
@@ -86,24 +86,27 @@
|
|
|
86
86
|
"babel-plugin-module-resolver": "^5.0.3",
|
|
87
87
|
"babel-plugin-polyfill-corejs3": "^1.0.0",
|
|
88
88
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
89
|
+
"cssnano": "^9.2.2",
|
|
89
90
|
"identity-obj-proxy": "^3.0.0",
|
|
90
91
|
"jest": "^30.5.2",
|
|
91
92
|
"jest-environment-jsdom": "^30.5.2",
|
|
92
93
|
"memfs": "^4.71.0",
|
|
94
|
+
"minimizer-webpack-plugin": "^5.13.0",
|
|
93
95
|
"mockdate": "^3.0.5",
|
|
94
96
|
"nodelist-foreach-polyfill": "^1.2.0",
|
|
97
|
+
"postcss": "^8.5.28",
|
|
95
98
|
"postcss-scss": "^4.0.9",
|
|
96
99
|
"pretty": "^2.0.0",
|
|
97
|
-
"react-refresh": "^0.
|
|
100
|
+
"react-refresh": "^0.19.0",
|
|
98
101
|
"sass": "^1.104.1",
|
|
99
102
|
"sass-loader": "^17.0.1",
|
|
100
103
|
"sitemap": "^9.0.1",
|
|
101
104
|
"source-map-loader": "^5.0.0",
|
|
102
|
-
"stylelint": "^17.
|
|
105
|
+
"stylelint": "^17.16.0",
|
|
103
106
|
"stylelint-config-standard-scss": "^17.0.0",
|
|
104
|
-
"supertest": "^7.
|
|
105
|
-
"tsc-alias": "^1.9.
|
|
106
|
-
"tstyche": "^7.2.
|
|
107
|
+
"supertest": "^7.3.1",
|
|
108
|
+
"tsc-alias": "^1.9.7",
|
|
109
|
+
"tstyche": "^7.2.5",
|
|
107
110
|
"typed-scss-modules": "^8.1.1",
|
|
108
111
|
"typescript": "^6.0.3",
|
|
109
112
|
"webpack": "^5.111.1",
|