@dr.pogodin/react-utils 1.47.5 → 1.48.1
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/index.js +1 -1
- package/build/development/index.js.map +1 -1
- package/build/development/server/server.js +0 -1
- package/build/development/server/server.js.map +1 -1
- package/build/development/shared/components/Button/index.js +13 -9
- package/build/development/shared/components/Button/index.js.map +1 -1
- package/build/development/shared/components/Checkbox/index.js +8 -7
- package/build/development/shared/components/Checkbox/index.js.map +1 -1
- package/build/development/shared/components/Input/index.js +14 -12
- package/build/development/shared/components/Input/index.js.map +1 -1
- package/build/development/shared/components/Modal/index.js +15 -3
- package/build/development/shared/components/Modal/index.js.map +1 -1
- package/build/development/shared/components/PageLayout/index.js +18 -15
- package/build/development/shared/components/PageLayout/index.js.map +1 -1
- package/build/development/shared/components/TextArea/index.js +9 -8
- package/build/development/shared/components/TextArea/index.js.map +1 -1
- package/build/development/shared/components/Throbber/index.js +15 -12
- package/build/development/shared/components/Throbber/index.js.map +1 -1
- package/build/development/shared/components/WithTooltip/index.js +6 -6
- package/build/development/shared/components/WithTooltip/index.js.map +1 -1
- package/build/development/shared/components/YouTubeVideo/index.js +6 -5
- package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/index.js +13 -12
- package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/NativeDropdown/index.js +11 -10
- package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/Switch/index.js +9 -9
- package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/development/shared/components/selectors/common.js.map +1 -1
- package/build/development/shared/components/selectors/index.js +1 -1
- package/build/development/shared/components/selectors/index.js.map +1 -1
- package/build/development/shared/utils/index.js +2 -5
- package/build/development/shared/utils/index.js.map +1 -1
- package/build/development/shared/utils/jest/E2eSsrEnv.js +0 -1
- package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/production/index.js +1 -1
- package/build/production/index.js.map +1 -1
- package/build/production/server/server.js +1 -1
- package/build/production/server/server.js.map +1 -1
- package/build/production/shared/components/Button/index.js +3 -8
- 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/Input/index.js +6 -6
- package/build/production/shared/components/Input/index.js.map +1 -1
- package/build/production/shared/components/Modal/index.js +3 -2
- package/build/production/shared/components/Modal/index.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 +4 -4
- 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/index.js +3 -3
- package/build/production/shared/components/WithTooltip/index.js.map +1 -1
- package/build/production/shared/components/YouTubeVideo/index.js +4 -4
- package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/index.js +2 -2
- package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/production/shared/components/selectors/NativeDropdown/index.js +3 -3
- package/build/production/shared/components/selectors/NativeDropdown/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/components/selectors/common.js.map +1 -1
- package/build/production/shared/components/selectors/index.js +1 -1
- package/build/production/shared/components/selectors/index.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/jest/E2eSsrEnv.js +1 -1
- package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/types-code/index.d.ts +1 -1
- package/build/types-code/shared/components/Button/index.d.ts +6 -10
- package/build/types-code/shared/components/Checkbox/index.d.ts +4 -3
- package/build/types-code/shared/components/Input/index.d.ts +12 -4
- package/build/types-code/shared/components/Modal/index.d.ts +6 -3
- package/build/types-code/shared/components/PageLayout/index.d.ts +19 -4
- package/build/types-code/shared/components/TextArea/index.d.ts +4 -4
- package/build/types-code/shared/components/Throbber/index.d.ts +13 -3
- package/build/types-code/shared/components/WithTooltip/index.d.ts +18 -4
- package/build/types-code/shared/components/YouTubeVideo/index.d.ts +20 -4
- package/build/types-code/shared/components/selectors/CustomDropdown/index.d.ts +3 -2
- package/build/types-code/shared/components/selectors/NativeDropdown/index.d.ts +22 -2
- package/build/types-code/shared/components/selectors/Switch/index.d.ts +7 -6
- package/build/types-code/shared/components/selectors/common.d.ts +2 -3
- package/build/types-code/shared/components/selectors/index.d.ts +2 -2
- package/build/types-code/shared/utils/index.d.ts +2 -7
- package/build/web/index.js +1 -1
- package/build/web/index.js.map +1 -1
- package/build/web/server/server.js +0 -1
- package/build/web/server/server.js.map +1 -1
- package/build/web/shared/components/Button/index.js +13 -9
- package/build/web/shared/components/Button/index.js.map +1 -1
- package/build/web/shared/components/Checkbox/index.js +8 -7
- package/build/web/shared/components/Checkbox/index.js.map +1 -1
- package/build/web/shared/components/Input/index.js +14 -12
- package/build/web/shared/components/Input/index.js.map +1 -1
- package/build/web/shared/components/Modal/index.js +15 -3
- package/build/web/shared/components/Modal/index.js.map +1 -1
- package/build/web/shared/components/PageLayout/index.js +18 -15
- package/build/web/shared/components/PageLayout/index.js.map +1 -1
- package/build/web/shared/components/TextArea/index.js +9 -8
- package/build/web/shared/components/TextArea/index.js.map +1 -1
- package/build/web/shared/components/Throbber/index.js +15 -12
- package/build/web/shared/components/Throbber/index.js.map +1 -1
- package/build/web/shared/components/WithTooltip/index.js +6 -6
- package/build/web/shared/components/WithTooltip/index.js.map +1 -1
- package/build/web/shared/components/YouTubeVideo/index.js +6 -5
- package/build/web/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/web/shared/components/selectors/CustomDropdown/index.js +13 -12
- package/build/web/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/web/shared/components/selectors/NativeDropdown/index.js +11 -10
- package/build/web/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/web/shared/components/selectors/Switch/index.js +9 -9
- package/build/web/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/web/shared/components/selectors/common.js.map +1 -1
- package/build/web/shared/components/selectors/index.js +1 -1
- package/build/web/shared/components/selectors/index.js.map +1 -1
- package/build/web/shared/utils/index.js +2 -5
- package/build/web/shared/utils/index.js.map +1 -1
- package/build/web/shared/utils/jest/E2eSsrEnv.js +0 -1
- package/build/web/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/config/babel/webpack.js +1 -1
- package/package.json +15 -15
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{useEffect,useLayoutEffect,useRef,useState}from"react";import
|
|
1
|
+
import{useEffect,useLayoutEffect,useRef,useState}from"react";import{useTheme}from"@dr.pogodin/react-themes";const defaultTheme={"context":"tECG8C","ad":"epeH4O","hoc":"_2kFnSt","container":"lV5ZyX","label":"_7qDPW1","textarea":"gkaNJJ","error":"ObwtG4","errorMessage":"ikIw0x","hidden":"-UyujK"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const TextArea=({disabled,error,label,onBlur,onChange,onKeyDown,placeholder,testId,theme,value})=>{const custom=useTheme("TextArea",defaultTheme,theme);const hiddenAreaRef=useRef(null);const[height,setHeight]=useState();const textAreaRef=useRef(null);const[localValue,setLocalValue]=useState(value??"");if(value!==undefined&&localValue!==value)setLocalValue(value);// This resizes text area's height when its width is changed for any reason.
|
|
2
2
|
useEffect(()=>{const el=hiddenAreaRef.current;if(!el)return undefined;const cb=()=>{setHeight(el.scrollHeight)};const observer=new ResizeObserver(cb);observer.observe(el);return()=>{observer.disconnect()}},[]);// Resizes the text area when its content is modified.
|
|
3
3
|
//
|
|
4
4
|
// NOTE: useLayoutEffect() instead of useEffect() makes difference here,
|
|
@@ -6,7 +6,7 @@ useEffect(()=>{const el=hiddenAreaRef.current;if(!el)return undefined;const cb=(
|
|
|
6
6
|
// useEffect() it becomes visible how the content is modified first,
|
|
7
7
|
// and then input height is incremented, if necessary).
|
|
8
8
|
// See: https://github.com/birdofpreyru/react-utils/issues/313
|
|
9
|
-
useLayoutEffect(()=>{const el=hiddenAreaRef.current;if(el)setHeight(el.scrollHeight)},[localValue]);let containerClassName=
|
|
9
|
+
useLayoutEffect(()=>{const el=hiddenAreaRef.current;if(el)setHeight(el.scrollHeight)},[localValue]);let containerClassName=custom.container;if(error)containerClassName+=` ${custom.error}`;return/*#__PURE__*/_jsxs("div",{className:containerClassName,onFocus:()=>{textAreaRef.current?.focus()},children:[label===undefined?null:/*#__PURE__*/_jsx("div",{className:custom.label,children:label}),/*#__PURE__*/_jsx("textarea",{className:`${custom.textarea} ${custom.hidden}`// This text area is hidden underneath the primary one below,
|
|
10
10
|
// and it is used for text measurements, to implement auto-scaling
|
|
11
11
|
// of the primary textarea's height.
|
|
12
12
|
,readOnly:true,ref:hiddenAreaRef// The "-1" value of "tabIndex" removes this hidden text area from
|
|
@@ -15,8 +15,8 @@ useLayoutEffect(()=>{const el=hiddenAreaRef.current;if(el)setHeight(el.scrollHei
|
|
|
15
15
|
// area is zero, thus collapsing <TextArea> height below the single line
|
|
16
16
|
// input height. To avoid it we fallback to whitespace (" ") character
|
|
17
17
|
// here.
|
|
18
|
-
,value:localValue||" "}),/*#__PURE__*/_jsx("textarea",{className:
|
|
18
|
+
,value:localValue||" "}),/*#__PURE__*/_jsx("textarea",{className:custom.textarea,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,disabled:disabled,onBlur:onBlur// When value is "undefined" the text area is not-managed, and we should
|
|
19
19
|
// manage it internally for the measurement / resizing functionality
|
|
20
20
|
// to work.
|
|
21
|
-
,onChange:value===undefined?e=>{setLocalValue(e.target.value)}:onChange,onKeyDown:onKeyDown,placeholder:placeholder,ref:textAreaRef,style:{height},value:localValue}),error&&error!==true?/*#__PURE__*/_jsx("div",{className:
|
|
21
|
+
,onChange:value===undefined?e=>{setLocalValue(e.target.value)}:onChange,onKeyDown:onKeyDown,placeholder:placeholder,ref:textAreaRef,style:{height},value:localValue}),error&&error!==true?/*#__PURE__*/_jsx("div",{className:custom.errorMessage,children:error}):null]})};export default TextArea;
|
|
22
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useEffect","useLayoutEffect","useRef","useState","
|
|
1
|
+
{"version":3,"file":"index.js","names":["useEffect","useLayoutEffect","useRef","useState","useTheme","defaultTheme","jsx","_jsx","jsxs","_jsxs","TextArea","disabled","error","label","onBlur","onChange","onKeyDown","placeholder","testId","theme","value","custom","hiddenAreaRef","height","setHeight","textAreaRef","localValue","setLocalValue","undefined","el","current","cb","scrollHeight","observer","ResizeObserver","observe","disconnect","containerClassName","container","className","onFocus","focus","children","textarea","hidden","readOnly","ref","tabIndex","process","env","NODE_ENV","e","target","style","errorMessage"],"sources":["../../../../../src/shared/components/TextArea/index.tsx"],"sourcesContent":["import {\n type ChangeEventHandler,\n type FocusEventHandler,\n type FunctionComponent,\n type KeyboardEventHandler,\n type ReactNode,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './style.scss';\n\ntype ThemeKeyT = 'container' | 'error' | 'errorMessage' | 'hidden' | 'label'\n | 'textarea';\n\ntype Props = {\n disabled?: boolean;\n error?: ReactNode;\n label?: string;\n onBlur?: FocusEventHandler<HTMLTextAreaElement>;\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;\n placeholder?: string;\n testId?: string;\n theme?: Theme<ThemeKeyT>;\n value?: string;\n};\n\nconst TextArea: FunctionComponent<Props> = ({\n disabled,\n error,\n label,\n onBlur,\n onChange,\n onKeyDown,\n placeholder,\n testId,\n theme,\n value,\n}) => {\n const custom = useTheme('TextArea', defaultTheme, theme);\n\n const hiddenAreaRef = useRef<HTMLTextAreaElement>(null);\n const [height, setHeight] = useState<number | undefined>();\n\n const textAreaRef = useRef<HTMLTextAreaElement>(null);\n\n const [localValue, setLocalValue] = useState(value ?? '');\n if (value !== undefined && localValue !== value) setLocalValue(value);\n\n // This resizes text area's height when its width is changed for any reason.\n useEffect(() => {\n const el = hiddenAreaRef.current;\n if (!el) return undefined;\n\n const cb = () => {\n setHeight(el.scrollHeight);\n };\n const observer = new ResizeObserver(cb);\n observer.observe(el);\n\n return () => {\n observer.disconnect();\n };\n }, []);\n\n // Resizes the text area when its content is modified.\n //\n // NOTE: useLayoutEffect() instead of useEffect() makes difference here,\n // as it helps to avoid visible \"content/height\" jumps (i.e. with just\n // useEffect() it becomes visible how the content is modified first,\n // and then input height is incremented, if necessary).\n // See: https://github.com/birdofpreyru/react-utils/issues/313\n useLayoutEffect(() => {\n const el = hiddenAreaRef.current;\n if (el) setHeight(el.scrollHeight);\n }, [localValue]);\n\n let containerClassName = custom.container;\n if (error) containerClassName += ` ${custom.error}`;\n\n return (\n <div\n className={containerClassName}\n onFocus={() => {\n textAreaRef.current?.focus();\n }}\n >\n {label === undefined ? null : <div className={custom.label}>{label}</div>}\n <textarea\n className={`${custom.textarea} ${custom.hidden}`}\n\n // This text area is hidden underneath the primary one below,\n // and it is used for text measurements, to implement auto-scaling\n // of the primary textarea's height.\n readOnly\n ref={hiddenAreaRef}\n\n // The \"-1\" value of \"tabIndex\" removes this hidden text area from\n // the tab-focus-chain.\n tabIndex={-1}\n\n // NOTE: With empty string value (\"\") the scrolling height of this text\n // area is zero, thus collapsing <TextArea> height below the single line\n // input height. To avoid it we fallback to whitespace (\" \") character\n // here.\n value={localValue || ' '}\n />\n <textarea\n className={custom.textarea}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n disabled={disabled}\n onBlur={onBlur}\n\n // When value is \"undefined\" the text area is not-managed, and we should\n // manage it internally for the measurement / resizing functionality\n // to work.\n onChange={\n value === undefined\n ? (e) => {\n setLocalValue(e.target.value);\n } : onChange\n }\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n ref={textAreaRef}\n style={{ height }}\n value={localValue}\n />\n {error && error !== true\n ? <div className={custom.errorMessage}>{error}</div>\n : null}\n </div>\n );\n};\n\nexport default TextArea;\n"],"mappings":"AAAA,OAMEA,SAAS,CACTC,eAAe,CACfC,MAAM,CACNC,QAAQ,KACH,OAAO,CAEd,OAAqBC,QAAQ,KAAQ,0BAA0B,OAAAC,YAAA,0KAEvB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAkBxC,KAAM,CAAAC,QAAkC,CAAGA,CAAC,CAC1CC,QAAQ,CACRC,KAAK,CACLC,KAAK,CACLC,MAAM,CACNC,QAAQ,CACRC,SAAS,CACTC,WAAW,CACXC,MAAM,CACNC,KAAK,CACLC,KACF,CAAC,GAAK,CACJ,KAAM,CAAAC,MAAM,CAAGjB,QAAQ,CAAC,UAAU,CAAEC,YAAY,CAAEc,KAAK,CAAC,CAExD,KAAM,CAAAG,aAAa,CAAGpB,MAAM,CAAsB,IAAI,CAAC,CACvD,KAAM,CAACqB,MAAM,CAAEC,SAAS,CAAC,CAAGrB,QAAQ,CAAqB,CAAC,CAE1D,KAAM,CAAAsB,WAAW,CAAGvB,MAAM,CAAsB,IAAI,CAAC,CAErD,KAAM,CAACwB,UAAU,CAAEC,aAAa,CAAC,CAAGxB,QAAQ,CAACiB,KAAK,EAAI,EAAE,CAAC,CACzD,GAAIA,KAAK,GAAKQ,SAAS,EAAIF,UAAU,GAAKN,KAAK,CAAEO,aAAa,CAACP,KAAK,CAAC,CAErE;AACApB,SAAS,CAAC,IAAM,CACd,KAAM,CAAA6B,EAAE,CAAGP,aAAa,CAACQ,OAAO,CAChC,GAAI,CAACD,EAAE,CAAE,MAAO,CAAAD,SAAS,CAEzB,KAA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C3B,cAAaK,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGtB,SAAS,CAAGV,MAAO,CACxEP,QAAQ,CAAEA,QAAS,CACnBG,MAAM,CAAEA,MAER;AACA;AACA;AAAA,CACAC,QAAQ,CACNK,KAAK,GAAKQ,SAAS,CACduB,CAAC,EAAK,CACPxB,aAAa,CAACwB,CAAC,CAACC,MAAM,CAAChC,KAAK,CAC9B,CAAC,CAAGL,QACP,CACDC,SAAS,CAAEA,SAAU,CACrBC,WAAW,CAAEA,WAAY,CACzB6B,GAAG,CAAErB,WAAY,CACjB4B,KAAK,CAAE,CAAE9B,MAAO,CAAE,CAClBH,KAAK,CAAEM,UAAW,CACnB,CAAC,CACDd,KAAK,EAAIA,KAAK,GAAK,IAAI,cACpBL,IAAA,QAAKgC,SAAS,CAAElB,MAAM,CAACiC,YAAa,CAAAZ,QAAA,CAAE9B,KAAK,CAAM,CAAC,CAClD,IAAI,EACL,CAET,CAAC,CAED,cAAe,CAAAF,QAAQ","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
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.
|
|
@@ -6,5 +6,5 @@ import themed from"@dr.pogodin/react-themes";const defaultTheme={"context":"eVCJ
|
|
|
6
6
|
* @param {ThrobberTheme} [props.theme] _Ad hoc_ theme.
|
|
7
7
|
* @param {...any} [props....]
|
|
8
8
|
* [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
|
|
9
|
-
*/const Throbber=({theme})
|
|
9
|
+
*/const Throbber=({theme})=>{const custom=useTheme("Throbber",defaultTheme,theme);return/*#__PURE__*/_jsxs("span",{className:custom.container,children:[/*#__PURE__*/_jsx("span",{className:custom.circle}),/*#__PURE__*/_jsx("span",{className:custom.circle}),/*#__PURE__*/_jsx("span",{className:custom.circle})]})};export default Throbber;
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["useTheme","defaultTheme","jsx","_jsx","jsxs","_jsxs","Throbber","theme","custom","className","container","children","circle"],"sources":["../../../../../src/shared/components/Throbber/index.tsx"],"sourcesContent":["import type { FunctionComponent } from 'react';\n\nimport { 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};\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 }) => {\n const custom = useTheme('Throbber', defaultTheme, theme);\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":"AAEA,OAAqBA,QAAQ,KAAQ,0BAA0B,OAAAC,YAAA,+GAEvB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAQxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,QAAmC,CAAGA,CAAC,CAAEC,KAAM,CAAC,GAAK,CACzD,KAAM,CAAAC,MAAM,CAAGR,QAAQ,CAAC,UAAU,CAAEC,YAAY,CAAEM,KAAK,CAAC,CAExD,mBACEF,KAAA,SAAMI,SAAS,CAAED,MAAM,CAACE,SAAU,CAAAC,QAAA,eAChCR,IAAA,SAAMM,SAAS,CAAED,MAAM,CAACI,MAAO,CAAE,CAAC,cAClCT,IAAA,SAAMM,SAAS,CAAED,MAAM,CAACI,MAAO,CAAE,CAAC,cAClCT,IAAA,SAAMM,SAAS,CAAED,MAAM,CAACI,MAAO,CAAE,CAAC,EAC9B,CAEV,CAAC,CAED,cAAe,CAAAN,QAAQ","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* global window */import{useEffect,useRef,useState}from"react";import
|
|
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.">
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* @param tip – Anything React is able to render,
|
|
12
12
|
* _e.g._ a tooltip text. This will be the tooltip content.
|
|
13
13
|
* @param {WithTooltipTheme} props.theme _Ad hoc_ theme.
|
|
14
|
-
*/const
|
|
14
|
+
*/const WithTooltip=({children,placement=PLACEMENTS.ABOVE_CURSOR,tip,theme})=>{const custom=useTheme("WithTooltip",defaultTheme,theme);const{current:heap}=useRef({lastCursorX:0,lastCursorY:0,timerId:undefined,triggeredByTouch:false});const tooltipRef=useRef(null);const wrapperRef=useRef(null);const[showTooltip,setShowTooltip]=useState(false);const updatePortalPosition=(cursorX,cursorY)=>{if(showTooltip){const wrapperRect=wrapperRef.current.getBoundingClientRect();if(cursorX<wrapperRect.left||cursorX>wrapperRect.right||cursorY<wrapperRect.top||cursorY>wrapperRect.bottom){setShowTooltip(false)}else if(tooltipRef.current){tooltipRef.current.pointTo(cursorX+window.scrollX,cursorY+window.scrollY,placement,wrapperRef.current)}}else{heap.lastCursorX=cursorX;heap.lastCursorY=cursorY;// If tooltip was triggered by a touch, we delay its opening by a bit,
|
|
15
15
|
// to ensure it was not a touch-click - in the case of touch click we
|
|
16
16
|
// want to do the click, rather than show the tooltip, and the delay
|
|
17
17
|
// gives click handler a chance to abort the tooltip openning.
|
|
@@ -21,5 +21,5 @@ if(heap.triggeredByTouch){heap.timerId??=setTimeout(()=>{heap.triggeredByTouch=f
|
|
|
21
21
|
// once opened (because similar call above does not have effect until
|
|
22
22
|
// the tooltip is fully mounted, and that is delayed to future rendering
|
|
23
23
|
// cycle due to the implementation).
|
|
24
|
-
if(tooltipRef.current){tooltipRef.current.pointTo(heap.lastCursorX+window.scrollX,heap.lastCursorY+window.scrollY,placement,wrapperRef.current)}const listener=()=>{setShowTooltip(false)};window.addEventListener("scroll",listener);return()=>{window.removeEventListener("scroll",listener)}}return undefined},[heap.lastCursorX,heap.lastCursorY,placement,showTooltip,tip]);return/*#__PURE__*/_jsxs("div",{className:
|
|
24
|
+
if(tooltipRef.current){tooltipRef.current.pointTo(heap.lastCursorX+window.scrollX,heap.lastCursorY+window.scrollY,placement,wrapperRef.current)}const listener=()=>{setShowTooltip(false)};window.addEventListener("scroll",listener);return()=>{window.removeEventListener("scroll",listener)}}return undefined},[heap.lastCursorX,heap.lastCursorY,placement,showTooltip,tip]);return/*#__PURE__*/_jsxs("div",{className:custom.wrapper,onClick:()=>{if(heap.timerId){clearTimeout(heap.timerId);heap.timerId=undefined;heap.triggeredByTouch=false}},onMouseLeave:()=>{setShowTooltip(false)},onMouseMove:e=>{updatePortalPosition(e.clientX,e.clientY)},onTouchStart:()=>{heap.triggeredByTouch=true},ref:wrapperRef,role:"presentation",children:[showTooltip&&tip!==null?/*#__PURE__*/_jsx(Tooltip,{ref:tooltipRef,theme:custom,children:tip}):null,children]})};const e=WithTooltip;e.PLACEMENTS=PLACEMENTS;export default e;
|
|
25
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useEffect","useRef","useState","
|
|
1
|
+
{"version":3,"file":"index.js","names":["useEffect","useRef","useState","useTheme","Tooltip","PLACEMENTS","defaultTheme","jsx","_jsx","jsxs","_jsxs","WithTooltip","children","placement","ABOVE_CURSOR","tip","theme","custom","current","heap","lastCursorX","lastCursorY","timerId","undefined","triggeredByTouch","tooltipRef","wrapperRef","showTooltip","setShowTooltip","updatePortalPosition","cursorX","cursorY","wrapperRect","getBoundingClientRect","left","right","top","bottom","pointTo","window","scrollX","scrollY","setTimeout","listener","addEventListener","removeEventListener","className","wrapper","onClick","clearTimeout","onMouseLeave","onMouseMove","e","clientX","clientY","onTouchStart","ref","role"],"sources":["../../../../../src/shared/components/WithTooltip/index.tsx"],"sourcesContent":["/* global window */\n\nimport {\n type FunctionComponent,\n type ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport Tooltip, {\n type ThemeKeysT as TooltipThemeKeysT,\n PLACEMENTS,\n} from './Tooltip';\n\nimport defaultTheme from './default-theme.scss';\n\ntype PropsT = {\n children?: ReactNode;\n placement?: PLACEMENTS;\n tip?: ReactNode;\n theme?: Theme<'wrapper' | TooltipThemeKeysT>;\n};\n\ntype TooltipRefT = {\n pointTo: (\n x: number,\n y: number,\n placement: PLACEMENTS,\n wrapperRef: HTMLDivElement,\n ) => void;\n};\n\ntype HeapT = {\n lastCursorX: number;\n lastCursorY: number;\n triggeredByTouch: boolean;\n timerId?: NodeJS.Timeout;\n};\n\n/**\n * Implements a simple to use and themeable tooltip component, _e.g._\n * ```js\n * <WithTooltip tip=\"This is example tooltip.\">\n * <p>Hover to see the tooltip.</p>\n * </WithTooltip>\n * ```\n * **Children:** Children are rendered in the place of `<WithTooltip>`,\n * and when hovered the tooltip is shown. By default the wrapper itself is\n * `<div>` block with `display: inline-block`.\n * @param tip – Anything React is able to render,\n * _e.g._ a tooltip text. This will be the tooltip content.\n * @param {WithTooltipTheme} props.theme _Ad hoc_ theme.\n */\nconst WithTooltip: FunctionComponent<PropsT> = ({\n children,\n placement = PLACEMENTS.ABOVE_CURSOR,\n tip,\n theme,\n}) => {\n const custom = useTheme('WithTooltip', defaultTheme, theme);\n\n const { current: heap } = useRef<HeapT>({\n lastCursorX: 0,\n lastCursorY: 0,\n timerId: undefined,\n triggeredByTouch: false,\n });\n const tooltipRef = useRef<TooltipRefT>(null);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const [showTooltip, setShowTooltip] = useState(false);\n\n const updatePortalPosition = (cursorX: number, cursorY: number) => {\n if (showTooltip) {\n const wrapperRect = wrapperRef.current!.getBoundingClientRect();\n if (\n cursorX < wrapperRect.left\n || cursorX > wrapperRect.right\n || cursorY < wrapperRect.top\n || cursorY > wrapperRect.bottom\n ) {\n setShowTooltip(false);\n } else if (tooltipRef.current) {\n tooltipRef.current.pointTo(\n cursorX + window.scrollX,\n cursorY + window.scrollY,\n placement,\n wrapperRef.current!,\n );\n }\n } else {\n heap.lastCursorX = cursorX;\n heap.lastCursorY = cursorY;\n\n // If tooltip was triggered by a touch, we delay its opening by a bit,\n // to ensure it was not a touch-click - in the case of touch click we\n // want to do the click, rather than show the tooltip, and the delay\n // gives click handler a chance to abort the tooltip openning.\n if (heap.triggeredByTouch) {\n heap.timerId ??= setTimeout(() => {\n heap.triggeredByTouch = false;\n heap.timerId = undefined;\n setShowTooltip(true);\n }, 300);\n\n // Otherwise we can just open the tooltip right away.\n } else setShowTooltip(true);\n }\n };\n\n useEffect(() => {\n if (showTooltip && tip !== null) {\n // This is necessary to ensure that even when a single mouse event\n // arrives to a tool-tipped component, the tooltip is correctly positioned\n // once opened (because similar call above does not have effect until\n // the tooltip is fully mounted, and that is delayed to future rendering\n // cycle due to the implementation).\n if (tooltipRef.current) {\n tooltipRef.current.pointTo(\n heap.lastCursorX + window.scrollX,\n heap.lastCursorY + window.scrollY,\n placement,\n wrapperRef.current!,\n );\n }\n\n const listener = () => {\n setShowTooltip(false);\n };\n window.addEventListener('scroll', listener);\n return () => {\n window.removeEventListener('scroll', listener);\n };\n }\n return undefined;\n }, [\n heap.lastCursorX,\n heap.lastCursorY,\n placement,\n showTooltip,\n tip,\n ]);\n\n return (\n <div\n className={custom.wrapper}\n onClick={() => {\n if (heap.timerId) {\n clearTimeout(heap.timerId);\n heap.timerId = undefined;\n heap.triggeredByTouch = false;\n }\n }}\n onMouseLeave={() => {\n setShowTooltip(false);\n }}\n onMouseMove={(e) => {\n updatePortalPosition(e.clientX, e.clientY);\n }}\n onTouchStart={() => {\n heap.triggeredByTouch = true;\n }}\n ref={wrapperRef}\n role=\"presentation\"\n >\n {\n showTooltip && tip !== null\n ? <Tooltip ref={tooltipRef} theme={custom}>{tip}</Tooltip>\n : null\n }\n {children}\n </div>\n );\n};\n\ntype ExportT = typeof WithTooltip & {\n PLACEMENTS: typeof PLACEMENTS;\n};\n\nconst e: ExportT = WithTooltip as ExportT;\n\ne.PLACEMENTS = PLACEMENTS;\n\nexport default e;\n"],"mappings":"AAAA,mBAEA,OAGEA,SAAS,CACTC,MAAM,CACNC,QAAQ,KACH,OAAO,CAEd,OAAqBC,QAAQ,KAAQ,0BAA0B,OAExD,CAAAC,OAAO,EAEZC,UAAU,0BAAAC,YAAA,oIAGoC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAyBhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,WAAsC,CAAGA,CAAC,CAC9CC,QAAQ,CACRC,SAAS,CAAGR,UAAU,CAACS,YAAY,CACnCC,GAAG,CACHC,KACF,CAAC,GAAK,CACJ,KAAM,CAAA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AE,CACFuB,WAAW,CAAGC,CAAC,EAAK,CAClBvB,oBAAoB,CAACuB,CAAC,CAACC,OAAO,CAAED,CAAC,CAACE,OAAO,CAC3C,CAAE,CACFC,YAAY,CAAEA,CAAA,GAAM,CAClBpC,IAAI,CAACK,gBAAgB,CAAG,IAC1B,CAAE,CACFgC,GAAG,CAAE9B,UAAW,CAChB+B,IAAI,CAAC,cAAc,CAAA7C,QAAA,EAGjBe,WAAW,EAAIZ,GAAG,GAAK,IAAI,cACvBP,IAAA,CAACJ,OAAO,EAACoD,GAAG,CAAE/B,UAAW,CAACT,KAAK,CAAEC,MAAO,CAAAL,QAAA,CAAEG,GAAG,CAAU,CAAC,CACxD,IAAI,CAETH,QAAQ,EACN,CAET,CAAC,CAMD,KAAM,CAAAwC,CAAU,CAAGzC,WAAsB,CAEzCyC,CAAC,CAAC/C,UAAU,CAAGA,UAAU,CAEzB,cAAe,CAAA+C,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import qs from"qs";import
|
|
1
|
+
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
|
|
@@ -12,8 +12,8 @@ import qs from"qs";import themed from"@dr.pogodin/react-themes";import Throbber
|
|
|
12
12
|
* @param [props.theme] _Ad hoc_ theme.
|
|
13
13
|
* @param [props.title] The `title` attribute to add to the player
|
|
14
14
|
* IFrame.
|
|
15
|
-
*/const YouTubeVideo=({autoplay,src,theme,title})=>{const srcParts=src.split("?");let[url]=srcParts;const[,queryString]=srcParts;const query=queryString?qs.parse(queryString):{};const videoId=query.v??url?.match(/\/([a-zA-Z0-9-_]*)$/)?.[1];url=`https://www.youtube.com/embed/${videoId}`;delete query.v;query.autoplay=autoplay?"1":"0";url+=`?${qs.stringify(query)}`;// TODO: https://developers.google.com/youtube/player_parameters
|
|
15
|
+
*/const YouTubeVideo=({autoplay,src,theme,title})=>{const custom=useTheme("YouTubeVideo",defaultTheme,theme);const srcParts=src.split("?");let[url]=srcParts;const[,queryString]=srcParts;const query=queryString?qs.parse(queryString):{};const videoId=query.v??url?.match(/\/([a-zA-Z0-9-_]*)$/)?.[1];url=`https://www.youtube.com/embed/${videoId}`;delete query.v;query.autoplay=autoplay?"1":"0";url+=`?${qs.stringify(query)}`;// TODO: https://developers.google.com/youtube/player_parameters
|
|
16
16
|
// More query parameters can be exposed via the component props.
|
|
17
|
-
return/*#__PURE__*/_jsxs("div",{className:
|
|
18
|
-
allow:"autoplay",allowFullScreen:true,className:
|
|
17
|
+
return/*#__PURE__*/_jsxs("div",{className:custom.container,children:[/*#__PURE__*/_jsx(Throbber,{theme:throbberTheme}),/*#__PURE__*/_jsx("iframe",{// eslint-disable-line react/iframe-missing-sandbox
|
|
18
|
+
allow:"autoplay",allowFullScreen:true,className:custom.video,src:url,title:title})]})};export default YouTubeVideo;
|
|
19
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["qs","
|
|
1
|
+
{"version":3,"file":"index.js","names":["qs","useTheme","Throbber","defaultTheme","throbberTheme","jsx","_jsx","jsxs","_jsxs","YouTubeVideo","autoplay","src","theme","title","custom","srcParts","split","url","queryString","query","parse","videoId","v","match","stringify","className","container","children","allow","allowFullScreen","video"],"sources":["../../../../../src/shared/components/YouTubeVideo/index.tsx"],"sourcesContent":["import qs from 'qs';\nimport type { FunctionComponent } from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport Throbber from 'components/Throbber';\n\nimport defaultTheme from './base.scss';\nimport throbberTheme from './throbber.scss';\n\ntype ThemeT = Theme<'container' | 'video'>;\n\ntype PropsT = {\n autoplay?: boolean;\n src: string;\n theme?: ThemeT;\n title?: string;\n};\n\n/**\n * A component for embeding a YouTube video.\n * @param [props] Component properties.\n * @param [props.autoplay] If `true` the video will start to play\n * automatically once loaded.\n * @param [props.src] URL of the video to play. Can be in any of\n * the following formats, and keeps any additional query parameters understood\n * by the YouTube IFrame player:\n * - `https://www.youtube.com/watch?v=NdF6Rmt6Ado`\n * - `https://youtu.be/NdF6Rmt6Ado`\n * - `https://www.youtube.com/embed/NdF6Rmt6Ado`\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props.title] The `title` attribute to add to the player\n * IFrame.\n */\nconst YouTubeVideo: FunctionComponent<PropsT> = ({\n autoplay,\n src,\n theme,\n title,\n}) => {\n const custom = useTheme('YouTubeVideo', defaultTheme, theme);\n\n const srcParts = src.split('?');\n let [url] = srcParts;\n const [, queryString] = srcParts;\n const query = queryString ? qs.parse(queryString) : {};\n\n const videoId = query.v ?? url?.match(/\\/([a-zA-Z0-9-_]*)$/)?.[1];\n url = `https://www.youtube.com/embed/${videoId as string}`;\n\n delete query.v;\n query.autoplay = autoplay ? '1' : '0';\n url += `?${qs.stringify(query)}`;\n\n // TODO: https://developers.google.com/youtube/player_parameters\n // More query parameters can be exposed via the component props.\n\n return (\n <div className={custom.container}>\n <Throbber theme={throbberTheme} />\n {/* TODO: I guess, we better add the sanbox, but right now I don't have\n time to carefully explore which restrictions should be lifted to allow\n embed YouTube player to work... sometime later we'll take care of it */\n }\n <iframe // eslint-disable-line react/iframe-missing-sandbox\n allow=\"autoplay\"\n allowFullScreen\n className={custom.video}\n src={url}\n title={title}\n />\n </div>\n );\n};\n\nexport default YouTubeVideo;\n"],"mappings":"AAAA,MAAO,CAAAA,EAAE,KAAM,IAAI,CAGnB,OAAqBC,QAAQ,KAAQ,0BAA0B,OAExD,CAAAC,QAAQ,kCAAAC,YAAA,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AAM,CACd,CAAC,EACC,CAET,CAAC,CAED,cAAe,CAAAJ,YAAY","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import"core-js/modules/es.iterator.filter.js";import"core-js/modules/es.iterator.constructor.js";import"core-js/modules/es.iterator.filter.js";import{useEffect,useRef,useState}from"react";import
|
|
1
|
+
import"core-js/modules/es.iterator.filter.js";import"core-js/modules/es.iterator.constructor.js";import"core-js/modules/es.iterator.filter.js";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=({filter,label,onChange,options,theme,value})=>{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);useEffect(()=>{if(!active)return undefined;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)}},[active]);const openList=e=>{const view=window.visualViewport;const rect=dropdownRef.current.getBoundingClientRect();setActive(true);// NOTE: This first opens the dropdown off-screen, where it is measured
|
|
2
2
|
// by an effect declared above, and then positioned below, or above
|
|
3
3
|
// the original dropdown element, depending where it fits best
|
|
4
4
|
// (if we first open it downward, it would flick if we immediately
|
|
5
5
|
// move it above, at least with the current position update via local
|
|
6
6
|
// react state, and not imperatively).
|
|
7
|
-
setOpsPos({left:view?.width??0,top:view?.height??0,width:rect.width});e.stopPropagation()};let selected=/*#__PURE__*/_jsx(_Fragment,{children:"\u200C"});for(const option of options){if(!filter||filter(option)){const[iValue,iName]=optionValueName(option);if(iValue===value){selected=iName;break}}}let containerClassName=
|
|
7
|
+
setOpsPos({left:view?.width??0,top:view?.height??0,width:rect.width});e.stopPropagation()};let selected=/*#__PURE__*/_jsx(_Fragment,{children:"\u200C"});for(const option of options){if(!filter||filter(option)){const[iValue,iName]=optionValueName(option);if(iValue===value){selected=iName;break}}}let containerClassName=custom.container;if(active)containerClassName+=` ${custom.active}`;let opsContainerClass=custom.select??"";if(upward){containerClassName+=` ${custom.upward}`;opsContainerClass+=` ${custom.upward}`}return/*#__PURE__*/_jsxs("div",{className:containerClassName,children:[label===undefined?null:/*#__PURE__*/_jsx("div",{className:custom.label,children:label}),/*#__PURE__*/_jsxs("div",{className:custom.dropdown,onClick:openList,onKeyDown:e=>{if(e.key==="Enter")openList(e)},ref:dropdownRef,role:"listbox",tabIndex:0,children:[selected,/*#__PURE__*/_jsx("div",{className:custom.arrow})]}),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]})};export default CustomDropdown;
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useEffect","useRef","useState","
|
|
1
|
+
{"version":3,"file":"index.js","names":["useEffect","useRef","useState","useTheme","optionValueName","Options","areEqual","defaultTheme","Fragment","_Fragment","jsx","_jsx","jsxs","_jsxs","CustomDropdown","filter","label","onChange","options","theme","value","custom","active","setActive","dropdownRef","opsRef","opsPos","setOpsPos","upward","setUpward","undefined","id","cb","anchor","current","getBoundingClientRect","opsRect","measure","fitsDown","bottom","height","window","visualViewport","fitsUp","top","up","pos","left","width","now","requestAnimationFrame","cancelAnimationFrame","openList","e","view","rect","stopPropagation","selected","children","option","iValue","iName","containerClassName","container","opsContainerClass","select","className","dropdown","onClick","onKeyDown","key","ref","role","tabIndex","arrow","containerClass","containerStyle","onCancel","newValue","optionClass"],"sources":["../../../../../../src/shared/components/selectors/CustomDropdown/index.tsx"],"sourcesContent":["import {\n type FunctionComponent,\n type ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { useTheme } from '@dr.pogodin/react-themes';\n\nimport { type PropsT, type ValueT, optionValueName } from '../common';\n\nimport Options, { type ContainerPosT, type RefT, areEqual } from './Options';\n\nimport defaultTheme from './theme.scss';\n\nconst CustomDropdown: FunctionComponent<\n PropsT<ReactNode, (value: ValueT) => void>\n> = ({\n filter,\n label,\n onChange,\n options,\n theme,\n value,\n}) => {\n const custom = useTheme('CustomDropdown', defaultTheme, theme);\n\n const [active, setActive] = useState(false);\n\n const dropdownRef = useRef<HTMLDivElement>(null);\n const opsRef = useRef<RefT>(null);\n\n const [opsPos, setOpsPos] = useState<ContainerPosT>();\n const [upward, setUpward] = useState(false);\n\n useEffect(() => {\n if (!active) return undefined;\n\n let id: number;\n const cb = () => {\n const anchor = dropdownRef.current?.getBoundingClientRect();\n const opsRect = opsRef.current?.measure();\n if (anchor && opsRect) {\n const fitsDown = anchor.bottom + opsRect.height\n < (window.visualViewport?.height ?? 0);\n const fitsUp = anchor.top - opsRect.height > 0;\n\n const up = !fitsDown && fitsUp;\n setUpward(up);\n\n const pos = up ? {\n left: anchor.left,\n top: anchor.top - opsRect.height - 1,\n width: anchor.width,\n } : {\n left: anchor.left,\n top: anchor.bottom,\n width: anchor.width,\n };\n\n setOpsPos((now) => (areEqual(now, pos) ? now : pos));\n }\n id = requestAnimationFrame(cb);\n };\n requestAnimationFrame(cb);\n\n return () => {\n cancelAnimationFrame(id);\n };\n }, [active]);\n\n const openList = (\n e: React.KeyboardEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement>,\n ) => {\n const view = window.visualViewport;\n const rect = dropdownRef.current!.getBoundingClientRect();\n setActive(true);\n\n // NOTE: This first opens the dropdown off-screen, where it is measured\n // by an effect declared above, and then positioned below, or above\n // the original dropdown element, depending where it fits best\n // (if we first open it downward, it would flick if we immediately\n // move it above, at least with the current position update via local\n // react state, and not imperatively).\n setOpsPos({\n left: view?.width ?? 0,\n top: view?.height ?? 0,\n width: rect.width,\n });\n\n e.stopPropagation();\n };\n\n let selected: React.ReactNode = <>‌</>;\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n if (iValue === value) {\n selected = iName;\n break;\n }\n }\n }\n\n let containerClassName = custom.container;\n if (active) containerClassName += ` ${custom.active}`;\n\n let opsContainerClass = custom.select ?? '';\n if (upward) {\n containerClassName += ` ${custom.upward}`;\n opsContainerClass += ` ${custom.upward}`;\n }\n\n return (\n <div className={containerClassName}>\n {label === undefined ? null\n : <div className={custom.label}>{label}</div>}\n <div\n className={custom.dropdown}\n onClick={openList}\n onKeyDown={(e) => {\n if (e.key === 'Enter') openList(e);\n }}\n ref={dropdownRef}\n role=\"listbox\"\n tabIndex={0}\n >\n {selected}\n <div className={custom.arrow} />\n </div>\n {\n active ? (\n <Options\n containerClass={opsContainerClass}\n containerStyle={opsPos}\n onCancel={() => {\n setActive(false);\n }}\n onChange={(newValue) => {\n setActive(false);\n if (onChange) onChange(newValue);\n }}\n optionClass={custom.option ?? ''}\n options={options}\n ref={opsRef}\n />\n ) : null\n }\n </div>\n );\n};\n\nexport default CustomDropdown;\n"],"mappings":"+IAAA,OAGEA,SAAS,CACTC,MAAM,CACNC,QAAQ,KACH,OAAO,CAEd,OAASC,QAAQ,KAAQ,0BAA0B,QAEhBC,eAAe,0BAE3C,CAAAC,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,MAAM,CAACqD,KAAM,CAAE,CAAC,EAC7B,CAAC,CAEJpD,MAAM,cACJX,IAAA,CAACN,OAAO,EACNsE,cAAc,CAAEX,iBAAkB,CAClCY,cAAc,CAAElD,MAAO,CACvBmD,QAAQ,CAAEA,CAAA,GAAM,CACdtD,SAAS,CAAC,KAAK,CACjB,CAAE,CACFN,QAAQ,CAAG6D,QAAQ,EAAK,CACtBvD,SAAS,CAAC,KAAK,CAAC,CAChB,GAAIN,QAAQ,CAAEA,QAAQ,CAAC6D,QAAQ,CACjC,CAAE,CACFC,WAAW,CAAE1D,MAAM,CAACsC,MAAM,EAAI,EAAG,CACjCzC,OAAO,CAAEA,OAAQ,CACjBqD,GAAG,CAAE9C,MAAO,CACb,CAAC,CACA,IAAI,EAEP,CAET,CAAC,CAED,cAAe,CAAAX,cAAc","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import"core-js/modules/es.iterator.filter.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.iterator.constructor.js";import"core-js/modules/es.iterator.filter.js";// Implements dropdown based on the native HTML <select> element.
|
|
2
|
-
import
|
|
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.
|
|
@@ -17,9 +17,9 @@ import themed from"@dr.pogodin/react-themes";import{optionValueName}from"../comm
|
|
|
17
17
|
* @param [props.value] Currently selected value.
|
|
18
18
|
* @param [props....]
|
|
19
19
|
* [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
|
|
20
|
-
*/import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const Dropdown=({filter,label,onChange,options,testId,theme,value})=>{let isValidValue=false;const optionElements=[];for(const option of options){if(!filter||filter(option)){const[iValue,iName]=optionValueName(option);isValidValue||=iValue===value;optionElements.push(/*#__PURE__*/_jsx("option",{className:
|
|
20
|
+
*/import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const Dropdown=({filter,label,onChange,options,testId,theme,value})=>{let isValidValue=false;const optionElements=[];const composed=useTheme("Dropdown",defaultTheme,theme);for(const option of options){if(!filter||filter(option)){const[iValue,iName]=optionValueName(option);isValidValue||=iValue===value;optionElements.push(/*#__PURE__*/_jsx("option",{className:composed.option,value:iValue,children:iName},iValue))}}// NOTE: This element represents the current `value` when it does not match
|
|
21
21
|
// any valid option. In Chrome, and some other browsers, we are able to hide
|
|
22
22
|
// it from the opened dropdown; in others, e.g. Safari, the best we can do is
|
|
23
23
|
// to show it as disabled.
|
|
24
|
-
const hiddenOption=isValidValue?null:/*#__PURE__*/_jsx("option",{className:
|
|
24
|
+
const hiddenOption=isValidValue?null:/*#__PURE__*/_jsx("option",{className:composed.hiddenOption,disabled:true,value:value,children:value},"__reactUtilsHiddenOption");let selectClassName=composed.select;if(!isValidValue)selectClassName+=` ${composed.invalid}`;return/*#__PURE__*/_jsxs("div",{className:composed.container,children:[label===undefined?null:/*#__PURE__*/_jsx("div",{className:composed.label,children:label}),/*#__PURE__*/_jsxs("div",{className:composed.dropdown,children:[/*#__PURE__*/_jsxs("select",{className:selectClassName,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,onChange:onChange,value:value,children:[hiddenOption,optionElements]}),/*#__PURE__*/_jsx("div",{className:composed.arrow})]})]})};export default Dropdown;
|
|
25
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["useTheme","optionValueName","defaultTheme","jsx","_jsx","jsxs","_jsxs","Dropdown","filter","label","onChange","options","testId","theme","value","isValidValue","optionElements","composed","option","iValue","iName","push","className","children","hiddenOption","disabled","selectClassName","select","invalid","container","undefined","dropdown","process","env","NODE_ENV","arrow"],"sources":["../../../../../../src/shared/components/selectors/NativeDropdown/index.tsx"],"sourcesContent":["// Implements dropdown based on the native HTML <select> element.\n\nimport type { FunctionComponent } from 'react';\n\nimport { useTheme } from '@dr.pogodin/react-themes';\n\nimport { optionValueName, type PropsT } from '../common';\n\nimport defaultTheme from './theme.scss';\n\n/**\n * Implements a themeable dropdown list. Internally it is rendered with help of\n * the standard HTML `<select>` element, thus the styling support is somewhat\n * limited.\n * @param [props] Component properties.\n * @param [props.filter] Options filter function. If provided, only\n * those elements of `options` list will be used by the dropdown, for which this\n * filter returns `true`.\n * @param [props.label] Dropdown label.\n * @param [props.onChange] Selection event handler.\n * @param [props.options=[]] Array of dropdown\n * options. For string elements the option value and name will be the same.\n * It is allowed to mix DropdownOption and string elements in the same option\n * list.\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props.value] Currently selected value.\n * @param [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst Dropdown: FunctionComponent<PropsT<string>> = ({\n filter,\n label,\n onChange,\n options,\n testId,\n theme,\n value,\n}) => {\n let isValidValue = false;\n const optionElements = [];\n\n const composed = useTheme('Dropdown', defaultTheme, theme);\n\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n isValidValue ||= iValue === value;\n optionElements.push(\n <option className={composed.option} key={iValue} value={iValue}>\n {iName}\n </option>,\n );\n }\n }\n\n // NOTE: This element represents the current `value` when it does not match\n // any valid option. In Chrome, and some other browsers, we are able to hide\n // it from the opened dropdown; in others, e.g. Safari, the best we can do is\n // to show it as disabled.\n const hiddenOption = isValidValue ? null : (\n <option\n className={composed.hiddenOption}\n disabled\n key=\"__reactUtilsHiddenOption\"\n value={value}\n >\n {value}\n </option>\n );\n\n let selectClassName = composed.select;\n if (!isValidValue) selectClassName += ` ${composed.invalid}`;\n\n return (\n <div className={composed.container}>\n { label === undefined\n ? null : <div className={composed.label}>{label}</div> }\n <div className={composed.dropdown}>\n <select\n className={selectClassName}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onChange={onChange}\n value={value}\n >\n {hiddenOption}\n {optionElements}\n </select>\n <div className={composed.arrow} />\n </div>\n </div>\n );\n};\n\nexport default Dropdown;\n"],"mappings":"wLAAA;AAIA,OAASA,QAAQ,KAAQ,0BAA0B,QAE1CC,eAAe,0BAAAC,YAAA,gOAIxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAlBA,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAmBA,KAAM,CAAAC,QAA2C,CAAGA,CAAC,CACnDC,MAAM,CACNC,KAAK,CACLC,QAAQ,CACRC,OAAO,CACPC,MAAM,CACNC,KAAK,CACLC,KACF,CAAC,GAAK,CACJ,GAAI,CAAAC,YAAY,CAAG,KAAK,CACxB,KAAM,CAAAC,cAAc,CAAG,EAAE,CAEzB,KAAM,CAAAC,QAAQ,CAAGjB,QAAQ,CAAC,UAAU,CAAEE,YAAY,CAAEW,KAAK,CAAC,CAE1D,IAAK,KAAM,CAAAK,MAAM,GAAI,CAAAP,OAAO,CAAE,CAC5B,GAAI,CAACH,MAAM,EAAIA,MAAM,CAACU,MAAM,CAAC,CAAE,CAC7B,KAAM,CAACC,MAAM,CAAEC,KAAK,CAAC,CAAGnB,eAAe,CAACiB,MAAM,CAAC,CAC/CH,YAAY,GAAKI,MAAM,GAAKL,KAAK,CACjCE,cAAc,CAACK,IAAI,cACjBjB,IAAA,WAAQkB,SAAS,CAAEL,QAAQ,CAACC,MAAO,CAAcJ,KAAK,CAAEK,MAAO,CAAAI,QAAA,CAC5DH,KAAK,EADiCD,MAEjC,CACV,CACF,CACF,CAEA;AACA;AACA;AACA;AACA,KAAM,CAAAK,YAAY,CAAGT,YAAY,CAAG,IAAI,cACtCX,IAAA,WACEkB,SAAS,CAAEL,QAAQ,CAACO,YAAa,CACjCC,QAAQ,MAERX,KAAK,CAAEA,KAAM,CAAAS,QAAA,CAEZT,KAAK,EAHF,0BAIE,CACT,CAED,GAAI,CAAAY,eAAe,CAAGT,QAAQ,CAACU,MAAM,CACrC,GAAI,CAACZ,YAAY,CAAEW,eAAe,EAAI,IAAIT,QAAQ,CAACW,OAAO,EAAE,CAE5D,mBACEtB,KAAA,QAAKgB,SAAS,CAAEL,QAAQ,CAACY,SAAU,CAAAN,QAAA,EAC/Bd,KAAK,GAAKqB,SAAS,CACjB,IAAI,cAAG1B,IAAA,QAAKkB,SAAS,CAAEL,QAAQ,CAACR,KAAM,CAAAc,QAAA,CAAEd,KAAK,CAAM,CAAC,cACxDH,KAAA,QAAKgB,SAAS,CAAEL,QAAQ,CAACc,QAAS,CAAAR,QAAA,eAChCjB,KAAA,WACEgB,SAAS,CAAEI,eAAgB,CAC3B,cAAaM,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGJ,SAAS,CAAGlB,MAAO,CACxEF,QAAQ,CAAEA,QAAS,CACnBI,KAAK,CAAEA,KAAM,CAAAS,QAAA,EAEZC,YAAY,CACZR,cAAc,EACT,CAAC,cACTZ,IAAA,QAAKkB,SAAS,CAAEL,QAAQ,CAACkB,KAAM,CAAE,CAAC,EAC/B,CAAC,EACH,CAET,CAAC,CAED,cAAe,CAAA5B,QAAQ","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"core-js/modules/es.array.push.js";import
|
|
1
|
+
import"core-js/modules/es.array.push.js";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=({label,onChange,options,theme,value})=>{const composed=useTheme("Switch",defaultTheme,theme);if(!options||!composed.option)throw Error("Internal error");const optionNodes=[];for(const option of options){const[iValue,iName]=optionValueName(option);let className=composed.option;let onPress;if(iValue===value)className+=` ${composed.selected}`;else if(onChange){onPress=()=>{onChange(iValue)}}optionNodes.push(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))}return/*#__PURE__*/_jsxs("div",{className:composed.container,children:[label?/*#__PURE__*/_jsx("div",{className:composed.label,children:label}):null,/*#__PURE__*/_jsx("div",{className:composed.options,children:optionNodes})]})};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["useTheme","optionValueName","defaultTheme","jsx","_jsx","jsxs","_jsxs","Switch","label","onChange","options","theme","value","composed","option","Error","optionNodes","iValue","iName","className","onPress","selected","push","onClick","onKeyDown","e","key","role","tabIndex","children","container"],"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":"yCAEA,OAAqBA,QAAQ,KAAQ,0BAA0B,QAK7DC,eAAe,0BAAAC,YAAA,mIAGuB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAYxC,MAAO,MAAM,CAAAC,MAAiC,CAAGA,CAAC,CAChDC,KAAK,CACLC,QAAQ,CACRC,OAAO,CACPC,KAAK,CACLC,KACF,CAAC,GAAK,CACJ,KAAM,CAAAC,QAAQ,CAAGb,QAAQ,CAAC,QAAQ,CAAEE,YAAY,CAAES,KAAK,CAAC,CAExD,GAAI,CAACD,OAAO,EAAI,CAACG,QAAQ,CAACC,MAAM,CAAE,KAAM,CAAAC,KAAK,CAAC,gBAAgB,CAAC,CAE/D,KAAM,CAAAC,WAA8B,CAAG,EAAE,CACzC,IAAK,KAAM,CAAAF,MAAM,GAAI,CAAAJ,OAAO,CAAE,CAC5B,KAAM,CAACO,MAAM,CAAEC,KAAK,CAAC,CAAGjB,eAAe,CAACa,MAAM,CAAC,CAE/C,GAAI,CAAAK,SAAiB,CAAGN,QAAQ,CAACC,MAAM,CACvC,GAAI,CAAAM,OAAiC,CACrC,GAAIH,MAAM,GAAKL,KAAK,CAAEO,SAAS,EAAI,IAAIN,QAAQ,CAACQ,QAAQ,EAAE,CAAC,IACtD,IAAIZ,QAAQ,CAAE,CACjBW,OAAO,CAAGA,CAAA,GAAM,CACdX,QAAQ,CAACQ,MAAM,CACjB,CACF,CAEAD,WAAW,CAACM,IAAI,CACdF,OAAO,cAEHhB,IAAA,QACEe,SAAS,CAAEA,SAAU,CAErBI,OAAO,CAAEH,OAAQ,CACjBI,SAAS,CAAGC,CAAC,EAAK,CAChB,GAAIA,CAAC,CAACC,GAAG,GAAK,OAAO,CAAEN,OAAO,CAAC,CACjC,CAAE,CACFO,IAAI,CAAC,QAAQ,CACbC,QAAQ,CAAE,CAAE,CAAAC,QAAA,CAEXX,KAAK,EARDD,MASF,CAAC,cAENb,IAAA,QAAKe,SAAS,CAAEA,SAAU,CAAAU,QAAA,CAAeX,KAAK,EAAdD,MAAoB,CAC1D,CACF,CAEA,mBACEX,KAAA,QAAKa,SAAS,CAAEN,QAAQ,CAACiB,SAAU,CAAAD,QAAA,EAChCrB,KAAK,cAAGJ,IAAA,QAAKe,SAAS,CAAEN,QAAQ,CAACL,KAAM,CAAAqB,QAAA,CAAErB,KAAK,CAAM,CAAC,CAAG,IAAI,cAE7DJ,IAAA,QAAKe,SAAS,CAAEN,QAAQ,CAACH,OAAQ,CAAAmB,QAAA,CAC9Bb,WAAW,CACT,CAAC,EACH,CAET,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","names":["isValue","x","type","optionValueName","option","value","name"],"sources":["../../../../../src/shared/components/selectors/common.ts"],"sourcesContent":["// The stuff common between different dropdown implementations.\n\nimport type { Theme } from '@dr.pogodin/react-themes';\n\
|
|
1
|
+
{"version":3,"file":"common.js","names":["isValue","x","type","optionValueName","option","value","name"],"sources":["../../../../../src/shared/components/selectors/common.ts"],"sourcesContent":["// The stuff common between different dropdown implementations.\n\nimport type { Theme } from '@dr.pogodin/react-themes';\n\nexport type ThemeT = Theme<\n | 'active'\n | 'arrow'\n | 'container'\n | 'dropdown'\n | 'hiddenOption'\n | 'label'\n | 'option'\n | 'select'\n\n // TODO: This is currently only valid for (native) <Dropdown>,\n // other kinds of selectors should be evaluated, and aligned with this\n // feature, if appropriate.\n | 'invalid'\n\n // TODO: This is only valid for <CustomDropdown>, thus we need to re-factor it\n // into a separate theme spec for that component.\n | 'upward'\n>;\n\nexport type ValueT = number | string;\n\nexport type OptionT<NameT> = {\n name?: NameT | null;\n value: ValueT;\n};\n\nexport type OptionsT<NameT> = Readonly<Array<OptionT<NameT> | ValueT>>;\n\nexport type PropsT<\n NameT,\n OnChangeT = React.ChangeEventHandler<HTMLSelectElement>,\n> = {\n filter?: (item: OptionT<NameT> | ValueT) => boolean;\n label?: React.ReactNode;\n onChange?: OnChangeT;\n options: Readonly<OptionsT<NameT>>;\n testId?: string;\n theme?: ThemeT;\n value?: ValueT;\n};\n\nfunction isValue<T>(x: OptionT<T> | ValueT): x is ValueT {\n const type = typeof x;\n return type === 'number' || type === 'string';\n}\n\n/** Returns option value and name as a tuple. */\nexport function optionValueName<NameT>(\n option: OptionT<NameT> | ValueT,\n): [ValueT, NameT | ValueT] {\n return isValue(option)\n ? [option, option]\n : [option.value, option.name ?? option.value];\n}\n"],"mappings":"AAAA;AA8CA,QAAS,CAAAA,OAAOA,CAAIC,CAAsB,CAAe,CACvD,KAAM,CAAAC,IAAI,CAAG,MAAO,CAAAD,CAAC,CACrB,MAAO,CAAAC,IAAI,GAAK,QAAQ,EAAIA,IAAI,GAAK,QACvC,CAEA,gDACA,MAAO,SAAS,CAAAC,eAAeA,CAC7BC,MAA+B,CACL,CAC1B,MAAO,CAAAJ,OAAO,CAACI,MAAM,CAAC,CAClB,CAACA,MAAM,CAAEA,MAAM,CAAC,CAChB,CAACA,MAAM,CAACC,KAAK,CAAED,MAAM,CAACE,IAAI,EAAIF,MAAM,CAACC,KAAK,CAChD","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{default as CustomDropdown}from"./CustomDropdown/index.js";export{default as Dropdown}from"./NativeDropdown/index.js";export{
|
|
1
|
+
export{default as CustomDropdown}from"./CustomDropdown/index.js";export{default as Dropdown}from"./NativeDropdown/index.js";export{Switch}from"./Switch/index.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default","CustomDropdown","Dropdown","Switch"],"sources":["../../../../../src/shared/components/selectors/index.ts"],"sourcesContent":["export { default as CustomDropdown } from './CustomDropdown';\nexport { default as Dropdown } from './NativeDropdown';\nexport {
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","CustomDropdown","Dropdown","Switch"],"sources":["../../../../../src/shared/components/selectors/index.ts"],"sourcesContent":["export { default as CustomDropdown } from './CustomDropdown';\nexport { default as Dropdown } from './NativeDropdown';\nexport { Switch } from './Switch';\n\nexport type { OptionT, OptionsT } from './common';\n"],"mappings":"OAASA,OAAO,GAAI,CAAAC,cAAc,wCACzBD,OAAO,GAAI,CAAAE,QAAQ,wCACnBC,MAAM","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{getConfig}from"./config.js";import*as isomorphy from"./isomorphy/index.js";import time from"./time.js";import*as webpack from"./webpack.js";export{assertEmptyObject,Barrier,Cached,Emitter,Semaphore,withRetries}from"@dr.pogodin/js-utils";export{COMPOSE as THEME_COMPOSE,PRIORITY as THEME_PRIORITY,ThemeProvider,useTheme}from"@dr.pogodin/react-themes";export{getSsrContext}from"./globalState.js";export{default as splitComponent}from"./splitComponent.js";export{getConfig,isomorphy,time,webpack};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["getConfig","isomorphy","time","webpack","assertEmptyObject","Barrier","Cached","Emitter","Semaphore","withRetries","COMPOSE","THEME_COMPOSE","PRIORITY","THEME_PRIORITY","ThemeProvider","useTheme","getSsrContext","default","splitComponent"],"sources":["../../../../src/shared/utils/index.ts"],"sourcesContent":["import { getConfig } from './config';\nimport * as isomorphy from './isomorphy';\nimport time from './time';\nimport * as webpack from './webpack';\n\nexport {\n assertEmptyObject,\n type Listener,\n type ObjectKey,\n Barrier,\n Cached,\n Emitter,\n Semaphore,\n withRetries,\n} from '@dr.pogodin/js-utils';\n\nexport {\n COMPOSE as THEME_COMPOSE,\n PRIORITY as THEME_PRIORITY,\n type Theme,\n ThemeProvider,\n useTheme,\n} from '@dr.pogodin/react-themes';\n\nexport { getSsrContext } from './globalState';\nexport { default as splitComponent } from './splitComponent';\n\nexport {\n getConfig,\n isomorphy,\n time,\n webpack,\n};\n"],"mappings":"OAASA,SAAS,yBACX,GAAK,CAAAC,SAAS,kCACd,CAAAC,IAAI,uBACJ,GAAK,CAAAC,OAAO,oBAEnB,OACEC,iBAAiB,CAGjBC,OAAO,CACPC,MAAM,CACNC,OAAO,CACPC,SAAS,CACTC,WAAW,KACN,sBAAsB,CAE7B,OACEC,OAAO,GAAI,CAAAC,aAAa,CACxBC,QAAQ,GAAI,CAAAC,cAAc,CAE1BC,aAAa,CACbC,QAAQ,KACH,0BAA0B,QAExBC,aAAa,+BACbC,OAAO,GAAI,CAAAC,cAAc,2BAElC,OACElB,SAAS,CACTC,SAAS,CACTC,IAAI,CACJC,OAAO","ignoreList":[]}
|
|
@@ -21,7 +21,7 @@ import path from"node:path";import{defaults,set}from"lodash-es";// As this envir
|
|
|
21
21
|
*/async loadWebpackConfig(){const optionsString=this.pragmas["webpack-config-options"];const options=optionsString?JSON.parse(optionsString):{};defaults(options,{context:this.testFolder,fs:this.global.webpackOutputFs});const factoryPath=this.pragmas["webpack-config-factory"];let factory=await import(/* webpackChunkName: "not-a-valid-chunk" */path.resolve(this.rootDir,factoryPath));factory="default"in factory?factory.default:factory;this.global.webpackConfig=factory(options);const fs=this.global.webpackOutputFs;let buildInfo=`${options.context}/.build-info`;if(fs.existsSync(buildInfo)){buildInfo=fs.readFileSync(buildInfo,"utf8");this.global.buildInfo=JSON.parse(buildInfo)}}/**
|
|
22
22
|
* Executes Webpack build.
|
|
23
23
|
* @return {Promise}
|
|
24
|
-
*/async runWebpack(){await this.loadWebpackConfig();if(!this.global.webpackConfig)throw Error("Failed to load Webpack config");const compiler=webpack(this.global.webpackConfig)
|
|
24
|
+
*/async runWebpack(){await this.loadWebpackConfig();if(!this.global.webpackConfig)throw Error("Failed to load Webpack config");const compiler=webpack(this.global.webpackConfig);// TODO: The "as typeof compiler.outputFileSystem" piece below is
|
|
25
25
|
// a workaround for the Webpack regression:
|
|
26
26
|
// https://github.com/webpack/webpack/issues/18242
|
|
27
27
|
compiler.outputFileSystem=this.global.webpackOutputFs;return new Promise((done,fail)=>{compiler.run((err,stats)=>{if(err)fail(err);if(stats?.hasErrors()){// eslint-disable-next-line no-console
|