@dr.pogodin/react-utils 1.53.1 → 1.54.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/build/development/client/index.js +2 -0
- package/build/development/client/index.js.map +1 -1
- package/build/development/index.js +2 -2
- package/build/development/index.js.map +1 -1
- package/build/development/shared/components/Button/index.js +149 -71
- package/build/development/shared/components/Button/index.js.map +1 -1
- package/build/development/shared/components/Checkbox/index.js +77 -24
- package/build/development/shared/components/Checkbox/index.js.map +1 -1
- package/build/development/shared/components/GenericLink/index.js +133 -54
- package/build/development/shared/components/GenericLink/index.js.map +1 -1
- package/build/development/shared/components/Input/index.js +168 -45
- package/build/development/shared/components/Input/index.js.map +1 -1
- package/build/development/shared/components/Link.js +23 -13
- package/build/development/shared/components/Link.js.map +1 -1
- package/build/development/shared/components/Modal/index.js +203 -87
- package/build/development/shared/components/Modal/index.js.map +1 -1
- package/build/development/shared/components/NavLink.js +16 -7
- package/build/development/shared/components/NavLink.js.map +1 -1
- package/build/development/shared/components/PageLayout/index.js +77 -15
- package/build/development/shared/components/PageLayout/index.js.map +1 -1
- package/build/development/shared/components/TextArea/index.js +169 -68
- package/build/development/shared/components/TextArea/index.js.map +1 -1
- package/build/development/shared/components/Throbber/index.js +51 -13
- package/build/development/shared/components/Throbber/index.js.map +1 -1
- package/build/development/shared/components/WithTooltip/Tooltip.js +73 -34
- package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/development/shared/components/WithTooltip/index.js +19 -19
- package/build/development/shared/components/WithTooltip/index.js.map +1 -1
- package/build/development/shared/components/YouTubeVideo/index.js +66 -23
- package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +104 -56
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/index.js +173 -75
- package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/Switch/index.js +86 -36
- package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/development/shared/utils/globalState.js +2 -2
- package/build/development/shared/utils/globalState.js.map +1 -1
- package/build/development/shared/utils/index.js +1 -1
- package/build/development/shared/utils/index.js.map +1 -1
- package/build/development/shared/utils/splitComponent.js +125 -55
- package/build/development/shared/utils/splitComponent.js.map +1 -1
- package/build/development/shared/utils/time.js +55 -20
- package/build/development/shared/utils/time.js.map +1 -1
- package/build/production/client/index.js +2 -2
- package/build/production/client/index.js.map +1 -1
- package/build/production/index.js +1 -1
- package/build/production/index.js.map +1 -1
- package/build/production/shared/components/Button/index.js +2 -13
- 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 +2 -15
- package/build/production/shared/components/GenericLink/index.js.map +1 -1
- package/build/production/shared/components/Input/index.js +2 -11
- package/build/production/shared/components/Input/index.js.map +1 -1
- package/build/production/shared/components/Link.js +2 -4
- package/build/production/shared/components/Link.js.map +1 -1
- package/build/production/shared/components/Modal/index.js +2 -10
- package/build/production/shared/components/Modal/index.js.map +1 -1
- package/build/production/shared/components/NavLink.js +1 -4
- package/build/production/shared/components/NavLink.js.map +1 -1
- package/build/production/shared/components/PageLayout/index.js +2 -2
- package/build/production/shared/components/PageLayout/index.js.map +1 -1
- package/build/production/shared/components/TextArea/index.js +1 -21
- package/build/production/shared/components/TextArea/index.js.map +1 -1
- package/build/production/shared/components/Throbber/index.js +2 -2
- package/build/production/shared/components/Throbber/index.js.map +1 -1
- package/build/production/shared/components/WithTooltip/Tooltip.js +2 -7
- package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/production/shared/components/WithTooltip/index.js +3 -3
- package/build/production/shared/components/WithTooltip/index.js.map +1 -1
- package/build/production/shared/components/YouTubeVideo/index.js +2 -5
- package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +1 -6
- package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/index.js +1 -7
- package/build/production/shared/components/selectors/CustomDropdown/index.js.map +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/production/shared/utils/globalState.js +1 -1
- package/build/production/shared/utils/globalState.js.map +1 -1
- package/build/production/shared/utils/index.js +1 -1
- package/build/production/shared/utils/index.js.map +1 -1
- package/build/production/shared/utils/splitComponent.js +3 -10
- package/build/production/shared/utils/splitComponent.js.map +1 -1
- package/build/production/shared/utils/time.js +2 -2
- package/build/production/shared/utils/time.js.map +1 -1
- package/build/types-code/index.d.ts +2 -2
- package/build/types-code/shared/utils/globalState.d.ts +2 -2
- package/build/types-code/shared/utils/index.d.ts +1 -1
- package/build/types-code/shared/utils/splitComponent.d.ts +1 -0
- package/build/web/client/index.js +2 -2
- package/build/web/client/index.js.map +1 -1
- package/build/web/index.js +1 -1
- package/build/web/index.js.map +1 -1
- package/build/web/shared/components/Button/index.js +2 -13
- package/build/web/shared/components/Button/index.js.map +1 -1
- package/build/web/shared/components/Checkbox/index.js +1 -1
- package/build/web/shared/components/Checkbox/index.js.map +1 -1
- package/build/web/shared/components/GenericLink/index.js +2 -15
- package/build/web/shared/components/GenericLink/index.js.map +1 -1
- package/build/web/shared/components/Input/index.js +2 -11
- package/build/web/shared/components/Input/index.js.map +1 -1
- package/build/web/shared/components/Link.js +2 -4
- package/build/web/shared/components/Link.js.map +1 -1
- package/build/web/shared/components/Modal/index.js +2 -10
- package/build/web/shared/components/Modal/index.js.map +1 -1
- package/build/web/shared/components/NavLink.js +1 -4
- package/build/web/shared/components/NavLink.js.map +1 -1
- package/build/web/shared/components/PageLayout/index.js +2 -2
- package/build/web/shared/components/PageLayout/index.js.map +1 -1
- package/build/web/shared/components/TextArea/index.js +1 -21
- package/build/web/shared/components/TextArea/index.js.map +1 -1
- package/build/web/shared/components/Throbber/index.js +2 -2
- package/build/web/shared/components/Throbber/index.js.map +1 -1
- package/build/web/shared/components/WithTooltip/Tooltip.js +2 -7
- package/build/web/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/web/shared/components/WithTooltip/index.js +3 -3
- package/build/web/shared/components/WithTooltip/index.js.map +1 -1
- package/build/web/shared/components/YouTubeVideo/index.js +2 -5
- package/build/web/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/web/shared/components/selectors/CustomDropdown/Options/index.js +1 -6
- package/build/web/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/web/shared/components/selectors/CustomDropdown/index.js +1 -7
- package/build/web/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/web/shared/components/selectors/Switch/index.js +1 -1
- package/build/web/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/web/shared/utils/globalState.js +1 -1
- package/build/web/shared/utils/globalState.js.map +1 -1
- package/build/web/shared/utils/index.js +1 -1
- package/build/web/shared/utils/index.js.map +1 -1
- package/build/web/shared/utils/splitComponent.js +3 -10
- package/build/web/shared/utils/splitComponent.js.map +1 -1
- package/build/web/shared/utils/time.js +2 -2
- package/build/web/shared/utils/time.js.map +1 -1
- package/config/babel/webpack.d.ts +1 -0
- package/config/babel/webpack.js +10 -12
- package/package.json +6 -4
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { BrowserRouter } from "react-router";
|
|
4
4
|
import { GlobalStateProvider } from "@dr.pogodin/react-global-state";
|
|
5
5
|
import { HelmetProvider } from "@dr.pogodin/react-helmet";
|
|
6
|
+
import { setClientChunkGroups } from "../shared/utils/splitComponent.js";
|
|
6
7
|
import getInj from "./getInj.js";
|
|
7
8
|
import { jsx as _jsx } from "react/jsx-runtime"; /**
|
|
8
9
|
* Prepares and launches the app at client side.
|
|
@@ -11,6 +12,7 @@ import { jsx as _jsx } from "react/jsx-runtime"; /**
|
|
|
11
12
|
*/
|
|
12
13
|
export async function launchClient(Application, options = {}) {
|
|
13
14
|
const inj = await getInj();
|
|
15
|
+
setClientChunkGroups(inj.CHUNK_GROUPS ?? {});
|
|
14
16
|
const container = document.getElementById("react-view");
|
|
15
17
|
if (!container) throw Error("Failed to find container for React app");
|
|
16
18
|
const scene = /*#__PURE__*/_jsx(GlobalStateProvider, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["createRoot","hydrateRoot","BrowserRouter","GlobalStateProvider","HelmetProvider","getInj","jsx","_jsx","launchClient","Application","options","inj","container","document","getElementById","Error","scene","initialState","ISTATE","children","dontHydrate","root","render"],"sources":["../../../src/client/index.tsx"],"sourcesContent":["// Initialization of client-side code.\n/* global document */\n\nimport type { ComponentType } from 'react';\nimport { createRoot, hydrateRoot } from 'react-dom/client';\nimport { BrowserRouter } from 'react-router';\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\nimport { HelmetProvider } from '@dr.pogodin/react-helmet';\n\nimport getInj from './getInj';\n\ntype OptionsT = {\n dontHydrate?: boolean;\n initialState?: unknown;\n};\n\n/**\n * Prepares and launches the app at client side.\n * @param Application Root application component\n * @param [options={}] Optional. Additional settings.\n */\nexport async function launchClient(\n Application: ComponentType,\n options: OptionsT = {},\n): Promise<void> {\n const inj = await getInj();\n\n const container = document.getElementById('react-view');\n if (!container) throw Error('Failed to find container for React app');\n const scene = (\n <GlobalStateProvider initialState={inj.ISTATE ?? options.initialState}>\n <BrowserRouter>\n <HelmetProvider>\n <Application />\n </HelmetProvider>\n </BrowserRouter>\n </GlobalStateProvider>\n );\n\n if (options.dontHydrate) {\n const root = createRoot(container);\n root.render(scene);\n } else hydrateRoot(container, scene);\n}\n"],"mappings":"AAAA;AACA,qBAGA,SAASA,UAAU,EAAEC,WAAW,QAAQ,kBAAkB;AAC1D,SAASC,aAAa,QAAQ,cAAc;AAE5C,SAASC,mBAAmB,QAAQ,gCAAgC;AACpE,SAASC,cAAc,QAAQ,0BAA0B;AAEzD,
|
|
1
|
+
{"version":3,"file":"index.js","names":["createRoot","hydrateRoot","BrowserRouter","GlobalStateProvider","HelmetProvider","setClientChunkGroups","getInj","jsx","_jsx","launchClient","Application","options","inj","CHUNK_GROUPS","container","document","getElementById","Error","scene","initialState","ISTATE","children","dontHydrate","root","render"],"sources":["../../../src/client/index.tsx"],"sourcesContent":["// Initialization of client-side code.\n/* global document */\n\nimport type { ComponentType } from 'react';\nimport { createRoot, hydrateRoot } from 'react-dom/client';\nimport { BrowserRouter } from 'react-router';\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\nimport { HelmetProvider } from '@dr.pogodin/react-helmet';\n\nimport { setClientChunkGroups } from 'utils/splitComponent';\n\nimport getInj from './getInj';\n\ntype OptionsT = {\n dontHydrate?: boolean;\n initialState?: unknown;\n};\n\n/**\n * Prepares and launches the app at client side.\n * @param Application Root application component\n * @param [options={}] Optional. Additional settings.\n */\nexport async function launchClient(\n Application: ComponentType,\n options: OptionsT = {},\n): Promise<void> {\n const inj = await getInj();\n\n setClientChunkGroups(inj.CHUNK_GROUPS ?? {});\n\n const container = document.getElementById('react-view');\n if (!container) throw Error('Failed to find container for React app');\n const scene = (\n <GlobalStateProvider initialState={inj.ISTATE ?? options.initialState}>\n <BrowserRouter>\n <HelmetProvider>\n <Application />\n </HelmetProvider>\n </BrowserRouter>\n </GlobalStateProvider>\n );\n\n if (options.dontHydrate) {\n const root = createRoot(container);\n root.render(scene);\n } else hydrateRoot(container, scene);\n}\n"],"mappings":"AAAA;AACA,qBAGA,SAASA,UAAU,EAAEC,WAAW,QAAQ,kBAAkB;AAC1D,SAASC,aAAa,QAAQ,cAAc;AAE5C,SAASC,mBAAmB,QAAQ,gCAAgC;AACpE,SAASC,cAAc,QAAQ,0BAA0B;AAEzD,SAASC,oBAAoB;AAAA,OAEtBC,MAAM;AAAiB,SAAAC,GAAA,IAAAC,IAAA,4BAO9B;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,YAAYA,CAChCC,WAA0B,EAC1BC,OAAiB,GAAG,CAAC,CAAC,EACP;EACf,MAAMC,GAAG,GAAG,MAAMN,MAAM,CAAC,CAAC;EAE1BD,oBAAoB,CAACO,GAAG,CAACC,YAAY,IAAI,CAAC,CAAC,CAAC;EAE5C,MAAMC,SAAS,GAAGC,QAAQ,CAACC,cAAc,CAAC,YAAY,CAAC;EACvD,IAAI,CAACF,SAAS,EAAE,MAAMG,KAAK,CAAC,wCAAwC,CAAC;EACrE,MAAMC,KAAK,gBACTV,IAAA,CAACL,mBAAmB;IAACgB,YAAY,EAAEP,GAAG,CAACQ,MAAM,IAAIT,OAAO,CAACQ,YAAa;IAAAE,QAAA,eACpEb,IAAA,CAACN,aAAa;MAAAmB,QAAA,eACZb,IAAA,CAACJ,cAAc;QAAAiB,QAAA,eACbb,IAAA,CAACE,WAAW,IAAE;MAAC,CACD;IAAC,CACJ;EAAC,CACG,CACtB;EAED,IAAIC,OAAO,CAACW,WAAW,EAAE;IACvB,MAAMC,IAAI,GAAGvB,UAAU,CAACc,SAAS,CAAC;IAClCS,IAAI,CAACC,MAAM,CAACN,KAAK,CAAC;EACpB,CAAC,MAAMjB,WAAW,CAACa,SAAS,EAAEI,KAAK,CAAC;AACtC","ignoreList":[]}
|
|
@@ -27,8 +27,8 @@ if (import.meta.webpackHot) {
|
|
|
27
27
|
delete global.REACT_UTILS_LIBRARY_LOADED;
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
*/export { GlobalStateProvider,
|
|
30
|
+
*/export { GlobalStateProvider, newAsyncDataEnvelope, useAsyncCollection, useAsyncData, useGlobalState, useGlobalStateObject, withGlobalStateType } from "@dr.pogodin/react-global-state";
|
|
31
31
|
export * from "./shared/components/index.js";
|
|
32
|
-
export { Barrier, Cached, Emitter, Semaphore, THEME_COMPOSE, THEME_PRIORITY, ThemeProvider, assertEmptyObject, getConfig,
|
|
32
|
+
export { Barrier, Cached, Emitter, Semaphore, THEME_COMPOSE, THEME_PRIORITY, ThemeProvider, assertEmptyObject, getConfig, splitComponent, time, useSsrContext, useTheme, webpack, withRetries } from "./shared/utils/index.js";
|
|
33
33
|
export * from "./shared/utils/isomorphy/index.js";
|
|
34
34
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["GlobalStateProvider","
|
|
1
|
+
{"version":3,"file":"index.js","names":["GlobalStateProvider","newAsyncDataEnvelope","useAsyncCollection","useAsyncData","useGlobalState","useGlobalStateObject","withGlobalStateType","Barrier","Cached","Emitter","Semaphore","THEME_COMPOSE","THEME_PRIORITY","ThemeProvider","assertEmptyObject","getConfig","splitComponent","time","useSsrContext","useTheme","webpack","withRetries"],"sources":["../../src/index.ts"],"sourcesContent":["// TODO: For now I commented out this safeguard check, as I am not sure how\n// to easily make it work: it should not be triggered in HMR mode, but if I\n// add the code relying on import.meta, it fails in Jest environment, because\n// Jest does not support ES modules yet, and import.meta is not support in\n// CommonJS modules, and the \"babel-plugin-transform-import-meta\" plugin\n// we use to workaround this issue for import.meta.dirname, etc. does not\n// transform import.meta.webpackHot\n\n// It is a safeguard against multiple instances / versions of the library\n// being loaded into environment by mistake (e.g. because of different\n// packages pinning down different exact versions of the lib, thus preventing\n// a proper dedupe and using a single common library version).\n// if (global.REACT_UTILS_LIBRARY_LOADED) {\n// throw Error('React utils library is already loaded');\n// } else global.REACT_UTILS_LIBRARY_LOADED = true;\n\n/*\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface ImportMeta {\n webpackHot?: {\n dispose(cb: () => void): void;\n };\n }\n}\n\nif (import.meta.webpackHot) {\n import.meta.webpackHot.dispose(() => {\n delete global.REACT_UTILS_LIBRARY_LOADED;\n });\n}\n*/\n\nexport {\n type AsyncCollectionLoaderT,\n type AsyncCollectionT,\n type AsyncDataEnvelopeT,\n type AsyncDataLoaderT,\n type ForceT,\n GlobalStateProvider,\n type UseAsyncDataOptionsT,\n type UseAsyncDataResT,\n type UseGlobalStateResT,\n type ValueOrInitializerT,\n newAsyncDataEnvelope,\n useAsyncCollection,\n useAsyncData,\n useGlobalState,\n useGlobalStateObject,\n withGlobalStateType,\n} from '@dr.pogodin/react-global-state';\n\nexport * from 'components';\n\nexport {\n type BeforeRenderResT,\n type BeforeRenderT,\n type ConfigT,\n type ServerSsrContext,\n type ServerT,\n} from './server';\n\nexport {\n Barrier,\n Cached,\n Emitter,\n type Listener,\n type ObjectKey,\n Semaphore,\n THEME_COMPOSE,\n THEME_PRIORITY,\n type Theme,\n ThemeProvider,\n assertEmptyObject,\n getConfig,\n splitComponent,\n time,\n useSsrContext,\n useTheme,\n webpack,\n withRetries,\n} from 'utils';\n\nexport * from 'utils/isomorphy';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAEA,SAMEA,mBAAmB,EAKnBC,oBAAoB,EACpBC,kBAAkB,EAClBC,YAAY,EACZC,cAAc,EACdC,oBAAoB,EACpBC,mBAAmB,QACd,gCAAgC;AAEvC;AAAA,SAWEC,OAAO,EACPC,MAAM,EACNC,OAAO,EAGPC,SAAS,EACTC,aAAa,EACbC,cAAc,EAEdC,aAAa,EACbC,iBAAiB,EACjBC,SAAS,EACTC,cAAc,EACdC,IAAI,EACJC,aAAa,EACbC,QAAQ,EACRC,OAAO,EACPC,WAAW;AAAA","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// The <Button> component implements a standard button / button-like link.
|
|
1
|
+
import { c as _c } from "react/compiler-runtime"; // The <Button> component implements a standard button / button-like link.
|
|
2
2
|
import { useTheme } from "@dr.pogodin/react-themes";
|
|
3
3
|
import Link from "../Link.js";
|
|
4
4
|
const defaultTheme = {
|
|
@@ -10,93 +10,171 @@ const defaultTheme = {
|
|
|
10
10
|
"disabled": "-dr-pogodin-react-utils___build-web-shared-components-Button-style___disabled___-6CH9q"
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
export const BaseButton =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
export const BaseButton = t0 => {
|
|
14
|
+
const $ = _c(32);
|
|
15
|
+
const {
|
|
16
|
+
active,
|
|
17
|
+
children,
|
|
18
|
+
disabled,
|
|
19
|
+
enforceA,
|
|
20
|
+
keepScrollPosition,
|
|
21
|
+
onClick,
|
|
22
|
+
onKeyDown: onKeyDownProp,
|
|
23
|
+
onKeyUp,
|
|
24
|
+
onMouseDown,
|
|
25
|
+
onMouseUp,
|
|
26
|
+
onPointerDown,
|
|
27
|
+
onPointerUp,
|
|
28
|
+
openNewTab,
|
|
29
|
+
replace,
|
|
30
|
+
testId,
|
|
31
|
+
theme,
|
|
32
|
+
to
|
|
33
|
+
} = t0;
|
|
32
34
|
let className = theme.button;
|
|
33
|
-
if (active && theme.active)
|
|
35
|
+
if (active && theme.active) {
|
|
36
|
+
className = className + ` ${theme.active}`;
|
|
37
|
+
}
|
|
34
38
|
if (disabled) {
|
|
35
|
-
if (theme.disabled)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
if (theme.disabled) {
|
|
40
|
+
className = className + ` ${theme.disabled}`;
|
|
41
|
+
}
|
|
42
|
+
const t1 = process.env.NODE_ENV === "production" ? undefined : testId;
|
|
43
|
+
let t2;
|
|
44
|
+
if ($[0] !== children || $[1] !== className || $[2] !== t1) {
|
|
45
|
+
t2 = /*#__PURE__*/_jsx("div", {
|
|
46
|
+
className: className,
|
|
47
|
+
"data-testid": t1,
|
|
48
|
+
children: children
|
|
49
|
+
});
|
|
50
|
+
$[0] = children;
|
|
51
|
+
$[1] = className;
|
|
52
|
+
$[2] = t1;
|
|
53
|
+
$[3] = t2;
|
|
54
|
+
} else {
|
|
55
|
+
t2 = $[3];
|
|
56
|
+
}
|
|
57
|
+
return t2;
|
|
41
58
|
}
|
|
42
59
|
let onKeyDown = onKeyDownProp;
|
|
43
60
|
if (!onKeyDown && onClick) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
61
|
+
let t1;
|
|
62
|
+
if ($[4] !== onClick) {
|
|
63
|
+
t1 = e => {
|
|
64
|
+
if (e.key === "Enter") {
|
|
65
|
+
onClick(e);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
$[4] = onClick;
|
|
69
|
+
$[5] = t1;
|
|
70
|
+
} else {
|
|
71
|
+
t1 = $[5];
|
|
72
|
+
}
|
|
73
|
+
onKeyDown = t1;
|
|
47
74
|
}
|
|
48
75
|
if (to) {
|
|
49
|
-
|
|
76
|
+
const t1 = process.env.NODE_ENV === "production" ? undefined : testId;
|
|
77
|
+
let t2;
|
|
78
|
+
if ($[6] !== children || $[7] !== className || $[8] !== enforceA || $[9] !== keepScrollPosition || $[10] !== onClick || $[11] !== onKeyUp || $[12] !== onMouseDown || $[13] !== onMouseUp || $[14] !== onPointerDown || $[15] !== onPointerUp || $[16] !== openNewTab || $[17] !== replace || $[18] !== t1 || $[19] !== to) {
|
|
79
|
+
t2 = /*#__PURE__*/_jsx(Link, {
|
|
80
|
+
className: className,
|
|
81
|
+
"data-testid": t1,
|
|
82
|
+
enforceA: enforceA,
|
|
83
|
+
keepScrollPosition: keepScrollPosition,
|
|
84
|
+
onClick: onClick,
|
|
85
|
+
onKeyUp: onKeyUp,
|
|
86
|
+
onMouseDown: onMouseDown,
|
|
87
|
+
onMouseUp: onMouseUp,
|
|
88
|
+
onPointerDown: onPointerDown,
|
|
89
|
+
onPointerUp: onPointerUp,
|
|
90
|
+
openNewTab: openNewTab,
|
|
91
|
+
replace: replace,
|
|
92
|
+
to: to,
|
|
93
|
+
children: children
|
|
94
|
+
});
|
|
95
|
+
$[6] = children;
|
|
96
|
+
$[7] = className;
|
|
97
|
+
$[8] = enforceA;
|
|
98
|
+
$[9] = keepScrollPosition;
|
|
99
|
+
$[10] = onClick;
|
|
100
|
+
$[11] = onKeyUp;
|
|
101
|
+
$[12] = onMouseDown;
|
|
102
|
+
$[13] = onMouseUp;
|
|
103
|
+
$[14] = onPointerDown;
|
|
104
|
+
$[15] = onPointerUp;
|
|
105
|
+
$[16] = openNewTab;
|
|
106
|
+
$[17] = replace;
|
|
107
|
+
$[18] = t1;
|
|
108
|
+
$[19] = to;
|
|
109
|
+
$[20] = t2;
|
|
110
|
+
} else {
|
|
111
|
+
t2 = $[20];
|
|
112
|
+
}
|
|
113
|
+
return t2;
|
|
114
|
+
}
|
|
115
|
+
const t1 = process.env.NODE_ENV === "production" ? undefined : testId;
|
|
116
|
+
let t2;
|
|
117
|
+
if ($[21] !== children || $[22] !== className || $[23] !== onClick || $[24] !== onKeyDown || $[25] !== onKeyUp || $[26] !== onMouseDown || $[27] !== onMouseUp || $[28] !== onPointerDown || $[29] !== onPointerUp || $[30] !== t1) {
|
|
118
|
+
t2 = /*#__PURE__*/_jsx("div", {
|
|
50
119
|
className: className,
|
|
51
|
-
"data-testid":
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
// automatically opt to keep the position here; and enforce <a> (as
|
|
55
|
-
// react-router link does not seem to respect the hash tag either,
|
|
56
|
-
// at least not without some additional settings).
|
|
57
|
-
,
|
|
58
|
-
keepScrollPosition: keepScrollPosition,
|
|
59
|
-
onClick: onClick // TODO: For now, the `onKeyDown` handler is not passed to the <Link>,
|
|
60
|
-
// as <Link> component does not call it anyway, presumably due to
|
|
61
|
-
// the inner implementation details. We should look into supporting it:
|
|
62
|
-
// https://github.com/birdofpreyru/react-utils/issues/444
|
|
63
|
-
// onKeyDown={onKeyDown}
|
|
64
|
-
,
|
|
120
|
+
"data-testid": t1,
|
|
121
|
+
onClick: onClick,
|
|
122
|
+
onKeyDown: onKeyDown,
|
|
65
123
|
onKeyUp: onKeyUp,
|
|
66
124
|
onMouseDown: onMouseDown,
|
|
67
125
|
onMouseUp: onMouseUp,
|
|
68
126
|
onPointerDown: onPointerDown,
|
|
69
127
|
onPointerUp: onPointerUp,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
to: to,
|
|
128
|
+
role: "button",
|
|
129
|
+
tabIndex: 0,
|
|
73
130
|
children: children
|
|
74
131
|
});
|
|
132
|
+
$[21] = children;
|
|
133
|
+
$[22] = className;
|
|
134
|
+
$[23] = onClick;
|
|
135
|
+
$[24] = onKeyDown;
|
|
136
|
+
$[25] = onKeyUp;
|
|
137
|
+
$[26] = onMouseDown;
|
|
138
|
+
$[27] = onMouseUp;
|
|
139
|
+
$[28] = onPointerDown;
|
|
140
|
+
$[29] = onPointerUp;
|
|
141
|
+
$[30] = t1;
|
|
142
|
+
$[31] = t2;
|
|
143
|
+
} else {
|
|
144
|
+
t2 = $[31];
|
|
75
145
|
}
|
|
76
|
-
return
|
|
77
|
-
className: className,
|
|
78
|
-
"data-testid": process.env.NODE_ENV === "production" ? undefined : testId,
|
|
79
|
-
onClick: onClick,
|
|
80
|
-
onKeyDown: onKeyDown,
|
|
81
|
-
onKeyUp: onKeyUp,
|
|
82
|
-
onMouseDown: onMouseDown,
|
|
83
|
-
onMouseUp: onMouseUp,
|
|
84
|
-
onPointerDown: onPointerDown,
|
|
85
|
-
onPointerUp: onPointerUp,
|
|
86
|
-
role: "button",
|
|
87
|
-
tabIndex: 0,
|
|
88
|
-
children: children
|
|
89
|
-
});
|
|
146
|
+
return t2;
|
|
90
147
|
};
|
|
91
|
-
const Button =
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
148
|
+
const Button = t0 => {
|
|
149
|
+
const $ = _c(6);
|
|
150
|
+
let rest;
|
|
151
|
+
let theme;
|
|
152
|
+
if ($[0] !== t0) {
|
|
153
|
+
({
|
|
154
|
+
theme,
|
|
155
|
+
...rest
|
|
156
|
+
} = t0);
|
|
157
|
+
$[0] = t0;
|
|
158
|
+
$[1] = rest;
|
|
159
|
+
$[2] = theme;
|
|
160
|
+
} else {
|
|
161
|
+
rest = $[1];
|
|
162
|
+
theme = $[2];
|
|
163
|
+
}
|
|
164
|
+
const composed = useTheme("Button", defaultTheme, theme);
|
|
165
|
+
let t1;
|
|
166
|
+
if ($[3] !== composed || $[4] !== rest) {
|
|
167
|
+
t1 = /*#__PURE__*/_jsx(BaseButton, {
|
|
168
|
+
...rest,
|
|
169
|
+
theme: composed
|
|
170
|
+
});
|
|
171
|
+
$[3] = composed;
|
|
172
|
+
$[4] = rest;
|
|
173
|
+
$[5] = t1;
|
|
174
|
+
} else {
|
|
175
|
+
t1 = $[5];
|
|
176
|
+
}
|
|
177
|
+
return t1;
|
|
100
178
|
};
|
|
101
179
|
export default Button;
|
|
102
180
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useTheme","Link","defaultTheme","jsx","_jsx","BaseButton","active","children","disabled","enforceA","keepScrollPosition","onClick","onKeyDown","onKeyDownProp","onKeyUp","onMouseDown","onMouseUp","onPointerDown","onPointerUp","openNewTab","replace","testId","theme","to","className","button","process","env","NODE_ENV","undefined","e","key","role","tabIndex","Button","rest","composed"],"sources":["../../../../../src/shared/components/Button/index.tsx"],"sourcesContent":["// The <Button> component implements a standard button / button-like link.\n\nimport type {\n FunctionComponent,\n KeyboardEventHandler,\n MouseEventHandler,\n PointerEventHandler,\n ReactNode,\n} from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport Link from 'components/Link';\n\nimport defaultTheme from './style.scss';\n\ntype ThemeT = Theme<'active' | 'button' | 'disabled'>;\n\ntype PropsT = {\n active?: boolean;\n children?: ReactNode;\n disabled?: boolean;\n enforceA?: boolean;\n keepScrollPosition?: boolean;\n onClick?: KeyboardEventHandler & MouseEventHandler;\n onKeyDown?: KeyboardEventHandler;\n onKeyUp?: KeyboardEventHandler;\n onMouseDown?: MouseEventHandler;\n onMouseUp?: MouseEventHandler;\n onPointerDown?: PointerEventHandler;\n onPointerUp?: PointerEventHandler;\n openNewTab?: boolean;\n replace?: boolean;\n testId?: string;\n theme: ThemeT;\n\n // TODO: It needs a more precise typing of the object option.\n to?: object | string;\n};\n\nexport const BaseButton: FunctionComponent<PropsT> = ({\n active,\n children,\n disabled,\n enforceA,\n keepScrollPosition,\n onClick,\n onKeyDown: onKeyDownProp,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onPointerDown,\n onPointerUp,\n openNewTab,\n replace,\n testId,\n theme,\n to,\n}) => {\n let className = theme.button;\n if (active && theme.active) className += ` ${theme.active}`;\n if (disabled) {\n if (theme.disabled) className += ` ${theme.disabled}`;\n return (\n <div\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n >\n {children}\n </div>\n );\n }\n\n let onKeyDown = onKeyDownProp;\n if (!onKeyDown && onClick) {\n onKeyDown = (e) => {\n if (e.key === 'Enter') onClick(e);\n };\n }\n\n if (to) {\n return (\n <Link\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n enforceA={enforceA}\n\n // TODO: This was exposed as a hotifx... however, I guess we better want\n // to check if the `to` URL contains an anchor (#), and if it does we should\n // automatically opt to keep the position here; and enforce <a> (as\n // react-router link does not seem to respect the hash tag either,\n // at least not without some additional settings).\n keepScrollPosition={keepScrollPosition}\n\n onClick={onClick}\n\n // TODO: For now, the `onKeyDown` handler is not passed to the <Link>,\n // as <Link> component does not call it anyway, presumably due to\n // the inner implementation details. We should look into supporting it:\n // https://github.com/birdofpreyru/react-utils/issues/444\n // onKeyDown={onKeyDown}\n\n onKeyUp={onKeyUp}\n onMouseDown={onMouseDown}\n onMouseUp={onMouseUp}\n onPointerDown={onPointerDown}\n onPointerUp={onPointerUp}\n openNewTab={openNewTab}\n replace={replace}\n to={to}\n >\n {children}\n </Link>\n );\n }\n\n return (\n <div\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onClick={onClick}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n onMouseDown={onMouseDown}\n onMouseUp={onMouseUp}\n onPointerDown={onPointerDown}\n onPointerUp={onPointerUp}\n role=\"button\"\n tabIndex={0}\n >\n {children}\n </div>\n );\n};\n\nconst Button: FunctionComponent<\n Omit<PropsT, 'theme'> & { theme?: ThemeT }\n> = ({ theme, ...rest }) => {\n const composed = useTheme('Button', defaultTheme, theme);\n\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <BaseButton {...rest} theme={composed} />;\n};\n\nexport default Button;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["useTheme","Link","defaultTheme","jsx","_jsx","BaseButton","t0","$","_c","active","children","disabled","enforceA","keepScrollPosition","onClick","onKeyDown","onKeyDownProp","onKeyUp","onMouseDown","onMouseUp","onPointerDown","onPointerUp","openNewTab","replace","testId","theme","to","className","button","t1","process","env","NODE_ENV","undefined","t2","e","key","role","tabIndex","Button","rest","composed"],"sources":["../../../../../src/shared/components/Button/index.tsx"],"sourcesContent":["// The <Button> component implements a standard button / button-like link.\n\nimport type {\n FunctionComponent,\n KeyboardEventHandler,\n MouseEventHandler,\n PointerEventHandler,\n ReactNode,\n} from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport Link from 'components/Link';\n\nimport defaultTheme from './style.scss';\n\ntype ThemeT = Theme<'active' | 'button' | 'disabled'>;\n\ntype PropsT = {\n active?: boolean;\n children?: ReactNode;\n disabled?: boolean;\n enforceA?: boolean;\n keepScrollPosition?: boolean;\n onClick?: KeyboardEventHandler & MouseEventHandler;\n onKeyDown?: KeyboardEventHandler;\n onKeyUp?: KeyboardEventHandler;\n onMouseDown?: MouseEventHandler;\n onMouseUp?: MouseEventHandler;\n onPointerDown?: PointerEventHandler;\n onPointerUp?: PointerEventHandler;\n openNewTab?: boolean;\n replace?: boolean;\n testId?: string;\n theme: ThemeT;\n\n // TODO: It needs a more precise typing of the object option.\n to?: object | string;\n};\n\nexport const BaseButton: FunctionComponent<PropsT> = ({\n active,\n children,\n disabled,\n enforceA,\n keepScrollPosition,\n onClick,\n onKeyDown: onKeyDownProp,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onPointerDown,\n onPointerUp,\n openNewTab,\n replace,\n testId,\n theme,\n to,\n}) => {\n let className = theme.button;\n if (active && theme.active) className += ` ${theme.active}`;\n if (disabled) {\n if (theme.disabled) className += ` ${theme.disabled}`;\n return (\n <div\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n >\n {children}\n </div>\n );\n }\n\n let onKeyDown = onKeyDownProp;\n if (!onKeyDown && onClick) {\n onKeyDown = (e) => {\n if (e.key === 'Enter') onClick(e);\n };\n }\n\n if (to) {\n return (\n <Link\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n enforceA={enforceA}\n\n // TODO: This was exposed as a hotifx... however, I guess we better want\n // to check if the `to` URL contains an anchor (#), and if it does we should\n // automatically opt to keep the position here; and enforce <a> (as\n // react-router link does not seem to respect the hash tag either,\n // at least not without some additional settings).\n keepScrollPosition={keepScrollPosition}\n\n onClick={onClick}\n\n // TODO: For now, the `onKeyDown` handler is not passed to the <Link>,\n // as <Link> component does not call it anyway, presumably due to\n // the inner implementation details. We should look into supporting it:\n // https://github.com/birdofpreyru/react-utils/issues/444\n // onKeyDown={onKeyDown}\n\n onKeyUp={onKeyUp}\n onMouseDown={onMouseDown}\n onMouseUp={onMouseUp}\n onPointerDown={onPointerDown}\n onPointerUp={onPointerUp}\n openNewTab={openNewTab}\n replace={replace}\n to={to}\n >\n {children}\n </Link>\n );\n }\n\n return (\n <div\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onClick={onClick}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n onMouseDown={onMouseDown}\n onMouseUp={onMouseUp}\n onPointerDown={onPointerDown}\n onPointerUp={onPointerUp}\n role=\"button\"\n tabIndex={0}\n >\n {children}\n </div>\n );\n};\n\nconst Button: FunctionComponent<\n Omit<PropsT, 'theme'> & { theme?: ThemeT }\n> = ({ theme, ...rest }) => {\n const composed = useTheme('Button', defaultTheme, theme);\n\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <BaseButton {...rest} theme={composed} />;\n};\n\nexport default Button;\n"],"mappings":"iDAAA;AAUA,SAAqBA,QAAQ,QAAQ,0BAA0B;AAE/D,OAAOC,IAAI;AAAA,MAAAC,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAE6B,SAAAC,GAAA,IAAAC,IAAA;AA0BxC,OAAO,MAAMC,UAAqC,GAAGC,EAAA;EAAA,MAAAC,CAAA,GAAAC,EAAA;EAAC;IAAAC,MAAA;IAAAC,QAAA;IAAAC,QAAA;IAAAC,QAAA;IAAAC,kBAAA;IAAAC,OAAA;IAAAC,SAAA,EAAAC,aAAA;IAAAC,OAAA;IAAAC,WAAA;IAAAC,SAAA;IAAAC,aAAA;IAAAC,WAAA;IAAAC,UAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,KAAA;IAAAC;EAAA,IAAApB,EAkBrD;EACC,IAAAqB,SAAA,GAAgBF,KAAK,CAAAG,MAAO;EAC5B,IAAInB,MAAsB,IAAZgB,KAAK,CAAAhB,MAAO;IAAEkB,SAAA,GAAAA,SAAS,GAAI,IAAIF,KAAK,CAAAhB,MAAO,EAAE;EAAA;EAC3D,IAAIE,QAAQ;IACV,IAAIc,KAAK,CAAAd,QAAS;MAAEgB,SAAA,GAAAA,SAAS,GAAI,IAAIF,KAAK,CAAAd,QAAS,EAAE;IAAA;IAIpC,MAAAkB,EAAA,GAAAC,OAAO,CAAAC,G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,KAAA,GAAAlB,CAAA;EAAA;EACrB,MAAAkC,QAAA,GAAiBzC,QAAQ,CAAC,QAAQ,EAAEE,YAAY,EAAEuB,KAAK,CAAC;EAAC,IAAAI,EAAA;EAAA,IAAAtB,CAAA,QAAAkC,QAAA,IAAAlC,CAAA,QAAAiC,IAAA;IAGlDX,EAAA,gBAAAzB,IAAA,CAACC,UAAU;MAAA,GAAKmC,IAAI;MAASf,KAAQ,EAARgB;IAAQ,CAAG,CAAC;IAAAlC,CAAA,MAAAkC,QAAA;IAAAlC,CAAA,MAAAiC,IAAA;IAAAjC,CAAA,MAAAsB,EAAA;EAAA;IAAAA,EAAA,GAAAtB,CAAA;EAAA;EAAA,OAAzCsB,EAAyC;AAAA,CACjD;AAED,eAAeU,MAAM","ignoreList":[]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
1
2
|
import { useTheme } from "@dr.pogodin/react-themes";
|
|
2
3
|
const defaultTheme = {
|
|
3
4
|
"context": "-dr-pogodin-react-utils___build-web-shared-components-Checkbox-theme___context___08mmmo",
|
|
@@ -12,41 +13,93 @@ const defaultTheme = {
|
|
|
12
13
|
"disabled": "-dr-pogodin-react-utils___build-web-shared-components-Checkbox-theme___disabled___baVvQA"
|
|
13
14
|
};
|
|
14
15
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
-
const Checkbox =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
const Checkbox = t0 => {
|
|
17
|
+
const $ = _c(17);
|
|
18
|
+
const {
|
|
19
|
+
checked,
|
|
20
|
+
disabled,
|
|
21
|
+
error,
|
|
22
|
+
label,
|
|
23
|
+
onChange,
|
|
24
|
+
testId,
|
|
25
|
+
theme
|
|
26
|
+
} = t0;
|
|
24
27
|
const composed = useTheme("Checkbox", defaultTheme, theme);
|
|
25
28
|
let containerClassName = composed.container;
|
|
26
|
-
if (disabled)
|
|
29
|
+
if (disabled) {
|
|
30
|
+
containerClassName = containerClassName + ` ${composed.disabled}`;
|
|
31
|
+
}
|
|
27
32
|
let checkboxClassName = composed.checkbox;
|
|
28
|
-
if (checked === "indeterminate")
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
if (checked === "indeterminate") {
|
|
34
|
+
checkboxClassName = checkboxClassName + ` ${composed.indeterminate}`;
|
|
35
|
+
}
|
|
36
|
+
if (error) {
|
|
37
|
+
containerClassName = containerClassName + ` ${composed.error}`;
|
|
38
|
+
}
|
|
39
|
+
let t1;
|
|
40
|
+
if ($[0] !== composed.label || $[1] !== label) {
|
|
41
|
+
t1 = label === undefined ? null : /*#__PURE__*/_jsx("div", {
|
|
33
42
|
className: composed.label,
|
|
34
43
|
children: label
|
|
35
|
-
})
|
|
36
|
-
|
|
44
|
+
});
|
|
45
|
+
$[0] = composed.label;
|
|
46
|
+
$[1] = label;
|
|
47
|
+
$[2] = t1;
|
|
48
|
+
} else {
|
|
49
|
+
t1 = $[2];
|
|
50
|
+
}
|
|
51
|
+
const t2 = checked === undefined ? undefined : checked === true;
|
|
52
|
+
const t3 = process.env.NODE_ENV === "production" ? undefined : testId;
|
|
53
|
+
let t4;
|
|
54
|
+
if ($[3] !== checkboxClassName || $[4] !== disabled || $[5] !== onChange || $[6] !== t2 || $[7] !== t3) {
|
|
55
|
+
t4 = /*#__PURE__*/_jsx("input", {
|
|
56
|
+
checked: t2,
|
|
37
57
|
className: checkboxClassName,
|
|
38
|
-
"data-testid":
|
|
58
|
+
"data-testid": t3,
|
|
39
59
|
disabled: disabled,
|
|
40
60
|
onChange: onChange,
|
|
41
|
-
onClick:
|
|
42
|
-
e.stopPropagation();
|
|
43
|
-
},
|
|
61
|
+
onClick: _temp,
|
|
44
62
|
type: "checkbox"
|
|
45
|
-
})
|
|
63
|
+
});
|
|
64
|
+
$[3] = checkboxClassName;
|
|
65
|
+
$[4] = disabled;
|
|
66
|
+
$[5] = onChange;
|
|
67
|
+
$[6] = t2;
|
|
68
|
+
$[7] = t3;
|
|
69
|
+
$[8] = t4;
|
|
70
|
+
} else {
|
|
71
|
+
t4 = $[8];
|
|
72
|
+
}
|
|
73
|
+
let t5;
|
|
74
|
+
if ($[9] !== composed.errorMessage || $[10] !== error) {
|
|
75
|
+
t5 = error && error !== true ? /*#__PURE__*/_jsx("div", {
|
|
46
76
|
className: composed.errorMessage,
|
|
47
77
|
children: error
|
|
48
|
-
}) : null
|
|
49
|
-
|
|
78
|
+
}) : null;
|
|
79
|
+
$[9] = composed.errorMessage;
|
|
80
|
+
$[10] = error;
|
|
81
|
+
$[11] = t5;
|
|
82
|
+
} else {
|
|
83
|
+
t5 = $[11];
|
|
84
|
+
}
|
|
85
|
+
let t6;
|
|
86
|
+
if ($[12] !== containerClassName || $[13] !== t1 || $[14] !== t4 || $[15] !== t5) {
|
|
87
|
+
t6 = /*#__PURE__*/_jsxs("div", {
|
|
88
|
+
className: containerClassName,
|
|
89
|
+
children: [t1, t4, t5]
|
|
90
|
+
});
|
|
91
|
+
$[12] = containerClassName;
|
|
92
|
+
$[13] = t1;
|
|
93
|
+
$[14] = t4;
|
|
94
|
+
$[15] = t5;
|
|
95
|
+
$[16] = t6;
|
|
96
|
+
} else {
|
|
97
|
+
t6 = $[16];
|
|
98
|
+
}
|
|
99
|
+
return t6;
|
|
50
100
|
};
|
|
51
101
|
export default Checkbox;
|
|
102
|
+
function _temp(e) {
|
|
103
|
+
e.stopPropagation();
|
|
104
|
+
}
|
|
52
105
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useTheme","defaultTheme","jsx","_jsx","jsxs","_jsxs","Checkbox","checked","disabled","error","label","onChange","testId","theme","composed","containerClassName","container","checkboxClassName","checkbox","indeterminate","className","children","
|
|
1
|
+
{"version":3,"file":"index.js","names":["useTheme","defaultTheme","jsx","_jsx","jsxs","_jsxs","Checkbox","t0","$","_c","checked","disabled","error","label","onChange","testId","theme","composed","containerClassName","container","checkboxClassName","checkbox","indeterminate","t1","undefined","className","children","t2","t3","process","env","NODE_ENV","t4","onClick","_temp","type","t5","errorMessage","t6","e","stopPropagation"],"sources":["../../../../../src/shared/components/Checkbox/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype PropT<ValueT> = {\n checked?: ValueT;\n disabled?: boolean;\n error?: ReactNode;\n label?: React.ReactNode;\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\n testId?: string;\n theme?: Theme<\n | 'checkbox'\n | 'container'\n | 'disabled'\n | 'error'\n | 'errorMessage'\n | 'indeterminate'\n | 'label'\n >;\n};\n\nconst Checkbox = <ValueT extends 'indeterminate' | boolean = boolean>({\n checked,\n disabled,\n error,\n label,\n onChange,\n testId,\n theme,\n}: PropT<ValueT>): ReactNode => {\n const composed = useTheme('Checkbox', defaultTheme, theme);\n\n let containerClassName = composed.container;\n if (disabled) containerClassName += ` ${composed.disabled}`;\n\n let checkboxClassName = composed.checkbox;\n if (checked === 'indeterminate') checkboxClassName += ` ${composed.indeterminate}`;\n\n if (error) containerClassName += ` ${composed.error}`;\n\n return (\n <div className={containerClassName}>\n { label === undefined\n ? null : <div className={composed.label}>{label}</div> }\n <input\n checked={checked === undefined ? undefined : checked === true}\n className={checkboxClassName}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n disabled={disabled}\n onChange={onChange}\n onClick={(e) => {\n e.stopPropagation();\n }}\n type=\"checkbox\"\n />\n {error && error !== true\n ? <div className={composed.errorMessage}>{error}</div>\n : null}\n </div>\n );\n};\n\nexport default Checkbox;\n"],"mappings":";AAEA,SAAqBA,QAAQ,QAAQ,0BAA0B;AAE/D,MAAAC,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA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