@dr.pogodin/react-utils 1.30.2 → 1.31.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/bin/build.js +5 -0
- package/build/development/client/index.js +1 -1
- package/build/development/client/index.js.map +1 -1
- package/build/development/index.js +8 -1
- package/build/development/index.js.map +1 -1
- package/build/development/server/index.js +1 -1
- package/build/development/server/index.js.map +1 -1
- package/build/development/server/utils/index.js +1 -1
- package/build/development/shared/components/Checkbox/index.js +2 -2
- package/build/development/shared/components/Checkbox/index.js.map +1 -1
- package/build/development/shared/components/Input/index.js +2 -2
- package/build/development/shared/components/Input/index.js.map +1 -1
- package/build/development/shared/components/Modal/index.js +40 -5
- package/build/development/shared/components/Modal/index.js.map +1 -1
- package/build/development/shared/components/TextArea/index.js +5 -0
- package/build/development/shared/components/TextArea/index.js.map +1 -1
- package/build/development/shared/components/WithTooltip/index.js +1 -1
- package/build/development/shared/components/WithTooltip/index.js.map +1 -1
- package/build/development/shared/components/YouTubeVideo/index.js +1 -3
- package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/development/shared/components/index.js +28 -15
- package/build/development/shared/components/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +85 -0
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -0
- package/build/development/shared/components/selectors/CustomDropdown/index.js +105 -0
- package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -0
- package/build/development/shared/components/{Dropdown → selectors/NativeDropdown}/index.js +25 -34
- package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -0
- package/build/development/shared/components/selectors/Switch/index.js +76 -0
- package/build/development/shared/components/selectors/Switch/index.js.map +1 -0
- package/build/development/shared/components/selectors/common.js +24 -0
- package/build/development/shared/components/selectors/common.js.map +1 -0
- package/build/development/shared/components/selectors/index.js +28 -0
- package/build/development/shared/components/selectors/index.js.map +1 -0
- package/build/development/shared/utils/index.js +1 -1
- package/build/development/shared/utils/index.js.map +1 -1
- package/build/development/shared/utils/jest/E2eSsrEnv.js +3 -0
- package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/development/shared/utils/jest/index.js +1 -1
- package/build/development/shared/utils/jest/index.js.map +1 -1
- package/build/development/style.css +387 -225
- package/build/development/web.bundle.js +113 -53
- package/build/production/client/index.js +1 -1
- 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/server/index.js +1 -1
- package/build/production/server/index.js.map +1 -1
- package/build/production/server/utils/index.js +1 -1
- package/build/production/shared/components/Checkbox/index.js +2 -2
- package/build/production/shared/components/Checkbox/index.js.map +1 -1
- package/build/production/shared/components/Input/index.js +1 -1
- package/build/production/shared/components/Input/index.js.map +1 -1
- package/build/production/shared/components/Modal/index.js +4 -2
- package/build/production/shared/components/Modal/index.js.map +1 -1
- package/build/production/shared/components/TextArea/index.js +3 -3
- package/build/production/shared/components/TextArea/index.js.map +1 -1
- package/build/production/shared/components/WithTooltip/index.js +1 -1
- package/build/production/shared/components/WithTooltip/index.js.map +1 -1
- package/build/production/shared/components/YouTubeVideo/index.js +2 -2
- package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/production/shared/components/index.js +1 -1
- package/build/production/shared/components/index.js.map +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +7 -0
- package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -0
- package/build/production/shared/components/selectors/CustomDropdown/index.js +4 -0
- package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -0
- package/build/production/shared/components/selectors/NativeDropdown/index.js +25 -0
- package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -0
- package/build/production/shared/components/selectors/Switch/index.js +2 -0
- package/build/production/shared/components/selectors/Switch/index.js.map +1 -0
- package/build/production/shared/components/selectors/common.js +3 -0
- package/build/production/shared/components/selectors/common.js.map +1 -0
- package/build/production/shared/components/selectors/index.js +2 -0
- package/build/production/shared/components/selectors/index.js.map +1 -0
- 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 +3 -1
- package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/production/shared/utils/jest/index.js +1 -1
- package/build/production/shared/utils/jest/index.js.map +1 -1
- package/build/production/style.css +1 -1
- package/build/production/style.css.map +1 -1
- package/build/production/web.bundle.js +1 -1
- package/build/production/web.bundle.js.map +1 -1
- package/build/types-code/client/index.d.ts +1 -0
- package/build/types-code/index.d.ts +1 -1
- package/build/types-code/shared/components/Checkbox/index.d.ts +1 -1
- package/build/types-code/shared/components/Input/index.d.ts +1 -1
- package/build/types-code/shared/components/Modal/index.d.ts +3 -1
- package/build/types-code/shared/components/TextArea/index.d.ts +1 -0
- package/build/types-code/shared/components/index.d.ts +1 -2
- package/build/types-code/shared/components/selectors/CustomDropdown/Options/index.d.ts +17 -0
- package/build/types-code/shared/components/selectors/CustomDropdown/index.d.ts +4 -0
- package/build/types-code/shared/components/selectors/NativeDropdown/index.d.ts +3 -0
- package/build/types-code/shared/components/selectors/Switch/index.d.ts +13 -0
- package/build/types-code/shared/components/selectors/common.d.ts +27 -0
- package/build/types-code/shared/components/selectors/index.d.ts +3 -0
- package/build/types-scss/src/shared/components/Modal/styles.scss.d.ts +1 -0
- package/build/types-scss/src/shared/components/selectors/CustomDropdown/Options/style.scss.d.ts +1 -0
- package/build/types-scss/src/shared/components/selectors/CustomDropdown/theme.scss.d.ts +10 -0
- package/build/types-scss/src/shared/components/{Dropdown → selectors/NativeDropdown}/theme.scss.d.ts +1 -0
- package/build/types-scss/src/shared/components/selectors/Switch/theme.scss.d.ts +6 -0
- package/package.json +30 -30
- package/src/client/index.tsx +2 -1
- package/src/index.ts +1 -0
- package/src/shared/components/Button/style.scss +1 -0
- package/src/shared/components/Checkbox/index.tsx +3 -3
- package/src/shared/components/Input/index.tsx +3 -3
- package/src/shared/components/Modal/base-theme.scss +1 -1
- package/src/shared/components/Modal/index.tsx +40 -5
- package/src/shared/components/Modal/styles.scss +2 -4
- package/src/shared/components/TextArea/index.tsx +5 -0
- package/src/shared/components/TextArea/style.scss +8 -0
- package/src/shared/components/YouTubeVideo/base.scss +3 -1
- package/src/shared/components/YouTubeVideo/index.tsx +2 -3
- package/src/shared/components/index.ts +2 -2
- package/src/shared/components/selectors/CustomDropdown/Options/index.tsx +107 -0
- package/src/shared/components/selectors/CustomDropdown/Options/style.scss +6 -0
- package/src/shared/components/selectors/CustomDropdown/index.tsx +115 -0
- package/src/shared/components/selectors/CustomDropdown/theme.scss +90 -0
- package/src/shared/components/{Dropdown → selectors/NativeDropdown}/index.tsx +21 -50
- package/src/shared/components/{Dropdown → selectors/NativeDropdown}/theme.scss +5 -0
- package/src/shared/components/selectors/Switch/index.tsx +94 -0
- package/src/shared/components/selectors/Switch/theme.scss +39 -0
- package/src/shared/components/selectors/common.ts +54 -0
- package/src/shared/components/selectors/index.ts +3 -0
- package/src/shared/utils/jest/E2eSsrEnv.ts +5 -1
- package/build/development/shared/components/Dropdown/index.js.map +0 -1
- package/build/development/shared/components/ScalableRect/index.js +0 -80
- package/build/development/shared/components/ScalableRect/index.js.map +0 -1
- package/build/production/shared/components/Dropdown/index.js +0 -24
- package/build/production/shared/components/Dropdown/index.js.map +0 -1
- package/build/production/shared/components/ScalableRect/index.js +0 -21
- package/build/production/shared/components/ScalableRect/index.js.map +0 -1
- package/build/types-code/shared/components/Dropdown/index.d.ts +0 -17
- package/build/types-code/shared/components/ScalableRect/index.d.ts +0 -19
- package/build/types-scss/src/shared/components/ScalableRect/style.scss.d.ts +0 -2
- package/src/shared/components/ScalableRect/index.tsx +0 -84
- package/src/shared/components/ScalableRect/style.scss +0 -10
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_reactThemes","_jsxRuntime","defaultTheme","validThemeKeys","Dropdown","filter","label","onChange","options","theme","value","isValidValue","optionElements","i","length","option","optionValue","optionName","name","push","jsx","className","children","hiddenOption","disabled","jsxs","container","undefined","dropdown","select","arrow","ThemedDropdown","themed","propTypes","PT","func","string","arrayOf","oneOfType","shape","isRequired","themeType","defaultProps","_default","exports","default"],"sources":["../../../../../src/shared/components/Dropdown/index.tsx"],"sourcesContent":["import PT from 'prop-types';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\nconst validThemeKeys = [\n 'arrow',\n 'container',\n 'dropdown',\n 'hiddenOption',\n 'label',\n 'option',\n 'select',\n] as const;\n\ntype DropdownOptionT = {\n name?: string | null;\n value: string;\n};\n\ntype PropsT = {\n filter?: (item: DropdownOptionT | string) => boolean;\n label?: string;\n onChange?: React.ChangeEventHandler<HTMLSelectElement>;\n options?: Array<DropdownOptionT | string>;\n theme: Theme<typeof validThemeKeys>;\n value?: string;\n};\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: React.FunctionComponent<PropsT> = ({\n filter,\n label,\n onChange,\n options = [],\n theme,\n value,\n}) => {\n let isValidValue = false;\n const optionElements = [];\n\n for (let i = 0; i < options.length; ++i) {\n const option = options[i];\n if (!filter || filter(option)) {\n let optionValue: string;\n let optionName: string;\n if (typeof option === 'string') {\n optionName = option;\n optionValue = option;\n } else {\n optionName = option.name || option.value;\n optionValue = option.value;\n }\n isValidValue ||= optionValue === value;\n optionElements.push(\n <option className={theme.option} key={optionValue} value={optionValue}>\n {optionName}\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 disabled\n className={theme.hiddenOption}\n key=\"__reactUtilsHiddenOption\"\n value={value}\n >\n {value}\n </option>\n );\n\n return (\n <div className={theme.container}>\n { label === undefined ? null : <p className={theme.label}>{label}</p> }\n <div className={theme.dropdown}>\n <select\n className={theme.select}\n onChange={onChange}\n value={value}\n >\n {hiddenOption}\n {optionElements}\n </select>\n <div className={theme.arrow}>▼</div>\n </div>\n </div>\n );\n};\n\nconst ThemedDropdown = themed(\n Dropdown,\n 'Dropdown',\n validThemeKeys,\n defaultTheme,\n);\n\nDropdown.propTypes = {\n filter: PT.func,\n label: PT.string,\n onChange: PT.func,\n options: PT.arrayOf(\n PT.oneOfType([\n PT.shape({\n name: PT.string,\n value: PT.string.isRequired,\n }),\n PT.string,\n ]).isRequired,\n ),\n theme: ThemedDropdown.themeType.isRequired,\n value: PT.string,\n};\n\nDropdown.defaultProps = {\n filter: undefined,\n label: undefined,\n onChange: undefined,\n options: [],\n value: '',\n};\n\nexport default ThemedDropdown;\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA8D,IAAAE,WAAA,GAAAF,OAAA;AAAA,MAAAG,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAI9D,MAAMC,cAAc,GAAG,CACrB,OAAO,EACP,WAAW,EACX,UAAU,EACV,cAAc,EACd,OAAO,EACP,QAAQ,EACR,QAAQ,CACA;AAgBV;AACA;AACA;AACA;AACA;AACA;AACA;A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EwB,kBAAE,CAACE;AACZ,CAAC;AAEDhC,QAAQ,CAACsC,YAAY,GAAG;EACtBrC,MAAM,EAAEsB,SAAS;EACjBrB,KAAK,EAAEqB,SAAS;EAChBpB,QAAQ,EAAEoB,SAAS;EACnBnB,OAAO,EAAE,EAAE;EACXE,KAAK,EAAE;AACT,CAAC;AAAC,IAAAiC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEad,cAAc","ignoreList":[]}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
require("react");
|
|
10
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
-
/**
|
|
12
|
-
* The `<ScalableRect>` component implements container keeping given aspect
|
|
13
|
-
* ratio, while its width is altered.
|
|
14
|
-
*
|
|
15
|
-
* **Children:** Component children are rendered as the component's content.
|
|
16
|
-
* @param {object} props
|
|
17
|
-
* @param {string} [props.className] CSS class for component container.
|
|
18
|
-
* @param {string} [props.ratio=1:1] Ratio of the rendered rectangle sides,
|
|
19
|
-
* in `W:H` form.
|
|
20
|
-
*/
|
|
21
|
-
const ScalableRect = ({
|
|
22
|
-
children,
|
|
23
|
-
className,
|
|
24
|
-
ratio
|
|
25
|
-
}) => {
|
|
26
|
-
const aux = ratio.split(':');
|
|
27
|
-
const paddingBottom = `${100 * parseFloat(aux[1]) / parseFloat(aux[0])}%`;
|
|
28
|
-
|
|
29
|
-
/* NOTE: In case the following code looks strange to you, mind that we want to
|
|
30
|
-
* allow the user to set custom styles on this component. If user passes in a
|
|
31
|
-
* "className" prop (possibly "styleName", but that one is converted to
|
|
32
|
-
* "className" by Babel just before being passed into this component), it
|
|
33
|
-
* should not interfere with the sizing behavior, thus we need an extra <div>
|
|
34
|
-
* level in this component; however, if user does not need a custom styling,
|
|
35
|
-
* we can save one level of HTML code, so we do it. */
|
|
36
|
-
const rect = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
37
|
-
style: {
|
|
38
|
-
paddingBottom
|
|
39
|
-
},
|
|
40
|
-
className: "-dr-pogodin-react-utils___src-shared-components-ScalableRect-style___container___EznFz3",
|
|
41
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
42
|
-
className: "-dr-pogodin-react-utils___src-shared-components-ScalableRect-style___wrapper___0vb7tq",
|
|
43
|
-
children: children
|
|
44
|
-
})
|
|
45
|
-
});
|
|
46
|
-
return className ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
47
|
-
className: className,
|
|
48
|
-
children: rect
|
|
49
|
-
}) : rect;
|
|
50
|
-
};
|
|
51
|
-
ScalableRect.defaultProps = {
|
|
52
|
-
children: null,
|
|
53
|
-
className: undefined,
|
|
54
|
-
ratio: '1:1'
|
|
55
|
-
};
|
|
56
|
-
ScalableRect.propTypes = {
|
|
57
|
-
children: _propTypes.default.node,
|
|
58
|
-
className: _propTypes.default.string,
|
|
59
|
-
ratio: (props, name) => {
|
|
60
|
-
const ratio = props[name];
|
|
61
|
-
|
|
62
|
-
// "ratio" prop is not required (defaults "1:1").
|
|
63
|
-
if (ratio === undefined) return null;
|
|
64
|
-
|
|
65
|
-
// If given, "ratio" must be a string.
|
|
66
|
-
if (typeof ratio !== 'string') {
|
|
67
|
-
return Error('"ratio" prop must be a string');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// If given, "ratio" must have "H:W" format.
|
|
71
|
-
if (!ratio.match(/\d+:\d+/)) {
|
|
72
|
-
return Error('"ratio" prop must have "H:W" format');
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Everything looks right.
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
var _default = exports.default = ScalableRect;
|
|
80
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_jsxRuntime","ScalableRect","children","className","ratio","aux","split","paddingBottom","parseFloat","rect","jsx","style","defaultProps","undefined","propTypes","PT","node","string","props","name","Error","match","_default","exports","default"],"sources":["../../../../../src/shared/components/ScalableRect/index.tsx"],"sourcesContent":["import PT from 'prop-types';\nimport { type ReactNode } from 'react';\n\nimport './style.scss';\n\ntype PropsT = {\n children?: ReactNode;\n className?: string;\n ratio?: `${number}:${number}`,\n};\n\n/**\n * The `<ScalableRect>` component implements container keeping given aspect\n * ratio, while its width is altered.\n *\n * **Children:** Component children are rendered as the component's content.\n * @param {object} props\n * @param {string} [props.className] CSS class for component container.\n * @param {string} [props.ratio=1:1] Ratio of the rendered rectangle sides,\n * in `W:H` form.\n */\nconst ScalableRect: React.FunctionComponent<PropsT> = ({\n children,\n className,\n ratio,\n}) => {\n const aux = ratio!.split(':');\n const paddingBottom = `${(100 * parseFloat(aux[1])) / parseFloat(aux[0])}%`;\n\n /* NOTE: In case the following code looks strange to you, mind that we want to\n * allow the user to set custom styles on this component. If user passes in a\n * \"className\" prop (possibly \"styleName\", but that one is converted to\n * \"className\" by Babel just before being passed into this component), it\n * should not interfere with the sizing behavior, thus we need an extra <div>\n * level in this component; however, if user does not need a custom styling,\n * we can save one level of HTML code, so we do it. */\n const rect = (\n <div\n style={{ paddingBottom }}\n styleName=\"container\"\n >\n <div styleName=\"wrapper\">\n {children}\n </div>\n </div>\n );\n return className ? (\n <div className={className}>\n {rect}\n </div>\n ) : rect;\n};\n\nScalableRect.defaultProps = {\n children: null,\n className: undefined,\n ratio: '1:1',\n};\n\nScalableRect.propTypes = {\n children: PT.node,\n className: PT.string,\n ratio: (props, name) => {\n const ratio = props[name];\n\n // \"ratio\" prop is not required (defaults \"1:1\").\n if (ratio === undefined) return null;\n\n // If given, \"ratio\" must be a string.\n if (typeof ratio !== 'string') {\n return Error('\"ratio\" prop must be a string');\n }\n\n // If given, \"ratio\" must have \"H:W\" format.\n if (!ratio.match(/\\d+:\\d+/)) {\n return Error('\"ratio\" prop must have \"H:W\" format');\n }\n\n // Everything looks right.\n return null;\n },\n};\n\nexport default ScalableRect;\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACAA,OAAA;AAAuC,IAAAC,WAAA,GAAAD,OAAA;AAUvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAME,YAA6C,GAAGA,CAAC;EACrDC,QAAQ;EACRC,SAAS;EACTC;AACF,CAAC,KAAK;EACJ,MAAMC,GAAG,GAAGD,KAAK,CAAEE,KAAK,CAAC,GAAG,CAAC;EAC7B,MAAMC,aAAa,GAAI,GAAG,GAAG,GAAGC,UAAU,CAACH,GAAG,CAAC,CAAC,CAAC,CAAC,GAAIG,UAAU,CAACH,GAAG,CAAC,CAAC,CAAC,CAAE,GAAE;;EAE3E;AACF;AACA;AACA;AACA;AACA;AACA;EACE,MAAMI,IAAI,gBACR,IAAAT,WAAA,CAAAU,GAAA;IACEC,KAAK,EAAE;MAAEJ;IAAc,CAAE;IACzBJ,SAAS,EAAC,yFAAW;IAAAD,QAAA,eAErB,IAAAF,WAAA,CAAAU,GAAA;MAAKP,SAAS,EAAC,uFAAS;MAAAD,QAAA,EACrBA;IAAQ,CACN;EAAC,CACH,CACN;EACD,OAAOC,SAAS,gBACd,IAAAH,WAAA,CAAAU,GAAA;IAAKP,SAAS,EAAEA,SAAU;IAAAD,QAAA,EACvBO;EAAI,CACF,CAAC,GACJA,IAAI;AACV,CAAC;AAEDR,YAAY,CAACW,YAAY,GAAG;EAC1BV,QAAQ,EAAE,IAAI;EACdC,SAAS,EAAEU,SAAS;EACpBT,KAAK,EAAE;AACT,CAAC;AAEDH,YAAY,CAACa,SAAS,GAAG;EACvBZ,QAAQ,EAAEa,kBAAE,CAACC,IAAI;EACjBb,SAAS,EAAEY,kBAAE,CAACE,MAAM;EACpBb,KAAK,EAAEA,CAACc,KAAK,EAAEC,IAAI,KAAK;IACtB,MAAMf,KAAK,GAAGc,KAAK,CAACC,IAAI,CAAC;;IAEzB;IACA,IAAIf,KAAK,KAAKS,SAAS,EAAE,OAAO,IAAI;;IAEpC;IACA,IAAI,OAAOT,KAAK,KAAK,QAAQ,EAAE;MAC7B,OAAOgB,KAAK,CAAC,+BAA+B,CAAC;IAC/C;;IAEA;IACA,IAAI,CAAChB,KAAK,CAACiB,KAAK,CAAC,SAAS,CAAC,EAAE;MAC3B,OAAOD,KAAK,CAAC,qCAAqC,CAAC;IACrD;;IAEA;IACA,OAAO,IAAI;EACb;AACF,CAAC;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEavB,YAAY","ignoreList":[]}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _propTypes=_interopRequireDefault(require("prop-types"));var _reactThemes=_interopRequireDefault(require("@dr.pogodin/react-themes"));var _jsxRuntime=require("react/jsx-runtime");const defaultTheme={"context":"haRIry","ad":"D4XHG2","hoc":"N3nd34","dropdown":"-LiQj8","arrow":"-zPK7Y","container":"_9CQpeA","label":"Gv0kyu","option":"xmsujA","hiddenOption":"RdW3yR","select":"JXK1uw"};const validThemeKeys=["arrow","container","dropdown","hiddenOption","label","option","select"];/**
|
|
2
|
-
* Implements a themeable dropdown list. Internally it is rendered with help of
|
|
3
|
-
* the standard HTML `<select>` element, thus the styling support is somewhat
|
|
4
|
-
* limited.
|
|
5
|
-
* @param [props] Component properties.
|
|
6
|
-
* @param [props.filter] Options filter function. If provided, only
|
|
7
|
-
* those elements of `options` list will be used by the dropdown, for which this
|
|
8
|
-
* filter returns `true`.
|
|
9
|
-
* @param [props.label] Dropdown label.
|
|
10
|
-
* @param [props.onChange] Selection event handler.
|
|
11
|
-
* @param [props.options=[]] Array of dropdown
|
|
12
|
-
* options. For string elements the option value and name will be the same.
|
|
13
|
-
* It is allowed to mix DropdownOption and string elements in the same option
|
|
14
|
-
* list.
|
|
15
|
-
* @param [props.theme] _Ad hoc_ theme.
|
|
16
|
-
* @param [props.value] Currently selected value.
|
|
17
|
-
* @param [props....]
|
|
18
|
-
* [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
|
|
19
|
-
*/const Dropdown=({filter,label,onChange,options=[],theme,value})=>{let isValidValue=false;const optionElements=[];for(let i=0;i<options.length;++i){const option=options[i];if(!filter||filter(option)){let optionValue;let optionName;if(typeof option==="string"){optionName=option;optionValue=option}else{optionName=option.name||option.value;optionValue=option.value}isValidValue||=optionValue===value;optionElements.push(/*#__PURE__*/(0,_jsxRuntime.jsx)("option",{className:theme.option,value:optionValue,children:optionName},optionValue))}}// NOTE: This element represents the current `value` when it does not match
|
|
20
|
-
// any valid option. In Chrome, and some other browsers, we are able to hide
|
|
21
|
-
// it from the opened dropdown; in others, e.g. Safari, the best we can do is
|
|
22
|
-
// to show it as disabled.
|
|
23
|
-
const hiddenOption=isValidValue?null:/*#__PURE__*/(0,_jsxRuntime.jsx)("option",{disabled:true,className:theme.hiddenOption,value:value,children:value},"__reactUtilsHiddenOption");return/*#__PURE__*/(0,_jsxRuntime.jsxs)("div",{className:theme.container,children:[label===undefined?null:/*#__PURE__*/(0,_jsxRuntime.jsx)("p",{className:theme.label,children:label}),/*#__PURE__*/(0,_jsxRuntime.jsxs)("div",{className:theme.dropdown,children:[/*#__PURE__*/(0,_jsxRuntime.jsxs)("select",{className:theme.select,onChange:onChange,value:value,children:[hiddenOption,optionElements]}),/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:theme.arrow,children:"\u25BC"})]})]})};const ThemedDropdown=(0,_reactThemes.default)(Dropdown,"Dropdown",validThemeKeys,defaultTheme);Dropdown.propTypes={filter:_propTypes.default.func,label:_propTypes.default.string,onChange:_propTypes.default.func,options:_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.shape({name:_propTypes.default.string,value:_propTypes.default.string.isRequired}),_propTypes.default.string]).isRequired),theme:ThemedDropdown.themeType.isRequired,value:_propTypes.default.string};Dropdown.defaultProps={filter:undefined,label:undefined,onChange:undefined,options:[],value:""};var _default=exports.default=ThemedDropdown;
|
|
24
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_reactThemes","_jsxRuntime","defaultTheme","validThemeKeys","Dropdown","filter","label","onChange","options","theme","value","isValidValue","optionElements","i","length","option","optionValue","optionName","name","push","jsx","className","children","hiddenOption","disabled","jsxs","container","undefined","dropdown","select","arrow","ThemedDropdown","themed","propTypes","PT","func","string","arrayOf","oneOfType","shape","isRequired","themeType","defaultProps","_default","exports","default"],"sources":["../../../../../src/shared/components/Dropdown/index.tsx"],"sourcesContent":["import PT from 'prop-types';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\nconst validThemeKeys = [\n 'arrow',\n 'container',\n 'dropdown',\n 'hiddenOption',\n 'label',\n 'option',\n 'select',\n] as const;\n\ntype DropdownOptionT = {\n name?: string | null;\n value: string;\n};\n\ntype PropsT = {\n filter?: (item: DropdownOptionT | string) => boolean;\n label?: string;\n onChange?: React.ChangeEventHandler<HTMLSelectElement>;\n options?: Array<DropdownOptionT | string>;\n theme: Theme<typeof validThemeKeys>;\n value?: string;\n};\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: React.FunctionComponent<PropsT> = ({\n filter,\n label,\n onChange,\n options = [],\n theme,\n value,\n}) => {\n let isValidValue = false;\n const optionElements = [];\n\n for (let i = 0; i < options.length; ++i) {\n const option = options[i];\n if (!filter || filter(option)) {\n let optionValue: string;\n let optionName: string;\n if (typeof option === 'string') {\n optionName = option;\n optionValue = option;\n } else {\n optionName = option.name || option.value;\n optionValue = option.value;\n }\n isValidValue ||= optionValue === value;\n optionElements.push(\n <option className={theme.option} key={optionValue} value={optionValue}>\n {optionName}\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 disabled\n className={theme.hiddenOption}\n key=\"__reactUtilsHiddenOption\"\n value={value}\n >\n {value}\n </option>\n );\n\n return (\n <div className={theme.container}>\n { label === undefined ? null : <p className={theme.label}>{label}</p> }\n <div className={theme.dropdown}>\n <select\n className={theme.select}\n onChange={onChange}\n value={value}\n >\n {hiddenOption}\n {optionElements}\n </select>\n <div className={theme.arrow}>▼</div>\n </div>\n </div>\n );\n};\n\nconst ThemedDropdown = themed(\n Dropdown,\n 'Dropdown',\n validThemeKeys,\n defaultTheme,\n);\n\nDropdown.propTypes = {\n filter: PT.func,\n label: PT.string,\n onChange: PT.func,\n options: PT.arrayOf(\n PT.oneOfType([\n PT.shape({\n name: PT.string,\n value: PT.string.isRequired,\n }),\n PT.string,\n ]).isRequired,\n ),\n theme: ThemedDropdown.themeType.isRequired,\n value: PT.string,\n};\n\nDropdown.defaultProps = {\n filter: undefined,\n label: undefined,\n onChange: undefined,\n options: [],\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AAE,CAACC,IAAI,CACjB3B,OAAO,CAAE0B,kBAAE,CAACG,OAAO,CACjBH,kBAAE,CAACI,SAAS,CAAC,CACXJ,kBAAE,CAACK,KAAK,CAAC,CACPrB,IAAI,CAAEgB,kBAAE,CAACE,MAAM,CACf1B,KAAK,CAAEwB,kBAAE,CAACE,MAAM,CAACI,UACnB,CAAC,CAAC,CACFN,kBAAE,CAACE,MAAM,CACV,CAAC,CAACI,UACL,CAAC,CACD/B,KAAK,CAAEsB,cAAc,CAACU,SAAS,CAACD,UAAU,CAC1C9B,KAAK,CAAEwB,kBAAE,CAACE,MACZ,CAAC,CAEDhC,QAAQ,CAACsC,YAAY,CAAG,CACtBrC,MAAM,CAAEsB,SAAS,CACjBrB,KAAK,CAAEqB,SAAS,CAChBpB,QAAQ,CAAEoB,SAAS,CACnBnB,OAAO,CAAE,EAAE,CACXE,KAAK,CAAE,EACT,CAAC,CAAC,IAAAiC,QAAA,CAAAC,OAAA,CAAAC,OAAA,CAEad,cAAc","ignoreList":[]}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _propTypes=_interopRequireDefault(require("prop-types"));require("react");var _jsxRuntime=require("react/jsx-runtime");/**
|
|
2
|
-
* The `<ScalableRect>` component implements container keeping given aspect
|
|
3
|
-
* ratio, while its width is altered.
|
|
4
|
-
*
|
|
5
|
-
* **Children:** Component children are rendered as the component's content.
|
|
6
|
-
* @param {object} props
|
|
7
|
-
* @param {string} [props.className] CSS class for component container.
|
|
8
|
-
* @param {string} [props.ratio=1:1] Ratio of the rendered rectangle sides,
|
|
9
|
-
* in `W:H` form.
|
|
10
|
-
*/const ScalableRect=({children,className,ratio})=>{const aux=ratio.split(":");const paddingBottom=`${100*parseFloat(aux[1])/parseFloat(aux[0])}%`;/* NOTE: In case the following code looks strange to you, mind that we want to
|
|
11
|
-
* allow the user to set custom styles on this component. If user passes in a
|
|
12
|
-
* "className" prop (possibly "styleName", but that one is converted to
|
|
13
|
-
* "className" by Babel just before being passed into this component), it
|
|
14
|
-
* should not interfere with the sizing behavior, thus we need an extra <div>
|
|
15
|
-
* level in this component; however, if user does not need a custom styling,
|
|
16
|
-
* we can save one level of HTML code, so we do it. */const rect=/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{style:{paddingBottom},className:"EznFz3",children:/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:"_0vb7tq",children:children})});return className?/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{className:className,children:rect}):rect};ScalableRect.defaultProps={children:null,className:undefined,ratio:"1:1"};ScalableRect.propTypes={children:_propTypes.default.node,className:_propTypes.default.string,ratio:(props,name)=>{const ratio=props[name];// "ratio" prop is not required (defaults "1:1").
|
|
17
|
-
if(ratio===undefined)return null;// If given, "ratio" must be a string.
|
|
18
|
-
if(typeof ratio!=="string"){return Error("\"ratio\" prop must be a string")}// If given, "ratio" must have "H:W" format.
|
|
19
|
-
if(!ratio.match(/\d+:\d+/)){return Error("\"ratio\" prop must have \"H:W\" format")}// Everything looks right.
|
|
20
|
-
return null}};var _default=exports.default=ScalableRect;
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_jsxRuntime","ScalableRect","children","className","ratio","aux","split","paddingBottom","parseFloat","rect","jsx","style","defaultProps","undefined","propTypes","PT","node","string","props","name","Error","match","_default","exports","default"],"sources":["../../../../../src/shared/components/ScalableRect/index.tsx"],"sourcesContent":["import PT from 'prop-types';\nimport { type ReactNode } from 'react';\n\nimport './style.scss';\n\ntype PropsT = {\n children?: ReactNode;\n className?: string;\n ratio?: `${number}:${number}`,\n};\n\n/**\n * The `<ScalableRect>` component implements container keeping given aspect\n * ratio, while its width is altered.\n *\n * **Children:** Component children are rendered as the component's content.\n * @param {object} props\n * @param {string} [props.className] CSS class for component container.\n * @param {string} [props.ratio=1:1] Ratio of the rendered rectangle sides,\n * in `W:H` form.\n */\nconst ScalableRect: React.FunctionComponent<PropsT> = ({\n children,\n className,\n ratio,\n}) => {\n const aux = ratio!.split(':');\n const paddingBottom = `${(100 * parseFloat(aux[1])) / parseFloat(aux[0])}%`;\n\n /* NOTE: In case the following code looks strange to you, mind that we want to\n * allow the user to set custom styles on this component. If user passes in a\n * \"className\" prop (possibly \"styleName\", but that one is converted to\n * \"className\" by Babel just before being passed into this component), it\n * should not interfere with the sizing behavior, thus we need an extra <div>\n * level in this component; however, if user does not need a custom styling,\n * we can save one level of HTML code, so we do it. */\n const rect = (\n <div\n style={{ paddingBottom }}\n styleName=\"container\"\n >\n <div styleName=\"wrapper\">\n {children}\n </div>\n </div>\n );\n return className ? (\n <div className={className}>\n {rect}\n </div>\n ) : rect;\n};\n\nScalableRect.defaultProps = {\n children: null,\n className: undefined,\n ratio: '1:1',\n};\n\nScalableRect.propTypes = {\n children: PT.node,\n className: PT.string,\n ratio: (props, name) => {\n const ratio = props[name];\n\n // \"ratio\" prop is not required (defaults \"1:1\").\n if (ratio === undefined) return null;\n\n // If given, \"ratio\" must be a string.\n if (typeof ratio !== 'string') {\n return Error('\"ratio\" prop must be a string');\n }\n\n // If given, \"ratio\" must have \"H:W\" format.\n if (!ratio.match(/\\d+:\\d+/)) {\n return Error('\"ratio\" prop must have \"H:W\" format');\n }\n\n // Everything looks right.\n return null;\n },\n};\n\nexport default ScalableRect;\n"],"mappings":"gLAAA,IAAAA,UAAA,CAAAC,sBAAA,CAAAC,OAAA,gBACAA,OAAA,UAAuC,IAAAC,WAAA,CAAAD,OAAA,sBAUvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAE,YAA6C,CAAGA,CAAC,CACrDC,QAAQ,CACRC,SAAS,CACTC,KACF,CAAC,GAAK,CACJ,KAAM,CAAAC,GAAG,CAAGD,KAAK,CAAEE,KAAK,CAAC,GA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AA,CAAAC,OAAA,CAAAC,OAAA,CAEavB,YAAY","ignoreList":[]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { type Theme } from '@dr.pogodin/react-themes';
|
|
3
|
-
declare const validThemeKeys: readonly ["arrow", "container", "dropdown", "hiddenOption", "label", "option", "select"];
|
|
4
|
-
type DropdownOptionT = {
|
|
5
|
-
name?: string | null;
|
|
6
|
-
value: string;
|
|
7
|
-
};
|
|
8
|
-
type PropsT = {
|
|
9
|
-
filter?: (item: DropdownOptionT | string) => boolean;
|
|
10
|
-
label?: string;
|
|
11
|
-
onChange?: React.ChangeEventHandler<HTMLSelectElement>;
|
|
12
|
-
options?: Array<DropdownOptionT | string>;
|
|
13
|
-
theme: Theme<typeof validThemeKeys>;
|
|
14
|
-
value?: string;
|
|
15
|
-
};
|
|
16
|
-
declare const ThemedDropdown: import("@dr.pogodin/react-themes").ThemedComponent<PropsT>;
|
|
17
|
-
export default ThemedDropdown;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
|
-
import './style.scss';
|
|
3
|
-
type PropsT = {
|
|
4
|
-
children?: ReactNode;
|
|
5
|
-
className?: string;
|
|
6
|
-
ratio?: `${number}:${number}`;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* The `<ScalableRect>` component implements container keeping given aspect
|
|
10
|
-
* ratio, while its width is altered.
|
|
11
|
-
*
|
|
12
|
-
* **Children:** Component children are rendered as the component's content.
|
|
13
|
-
* @param {object} props
|
|
14
|
-
* @param {string} [props.className] CSS class for component container.
|
|
15
|
-
* @param {string} [props.ratio=1:1] Ratio of the rendered rectangle sides,
|
|
16
|
-
* in `W:H` form.
|
|
17
|
-
*/
|
|
18
|
-
declare const ScalableRect: React.FunctionComponent<PropsT>;
|
|
19
|
-
export default ScalableRect;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import PT from 'prop-types';
|
|
2
|
-
import { type ReactNode } from 'react';
|
|
3
|
-
|
|
4
|
-
import './style.scss';
|
|
5
|
-
|
|
6
|
-
type PropsT = {
|
|
7
|
-
children?: ReactNode;
|
|
8
|
-
className?: string;
|
|
9
|
-
ratio?: `${number}:${number}`,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The `<ScalableRect>` component implements container keeping given aspect
|
|
14
|
-
* ratio, while its width is altered.
|
|
15
|
-
*
|
|
16
|
-
* **Children:** Component children are rendered as the component's content.
|
|
17
|
-
* @param {object} props
|
|
18
|
-
* @param {string} [props.className] CSS class for component container.
|
|
19
|
-
* @param {string} [props.ratio=1:1] Ratio of the rendered rectangle sides,
|
|
20
|
-
* in `W:H` form.
|
|
21
|
-
*/
|
|
22
|
-
const ScalableRect: React.FunctionComponent<PropsT> = ({
|
|
23
|
-
children,
|
|
24
|
-
className,
|
|
25
|
-
ratio,
|
|
26
|
-
}) => {
|
|
27
|
-
const aux = ratio!.split(':');
|
|
28
|
-
const paddingBottom = `${(100 * parseFloat(aux[1])) / parseFloat(aux[0])}%`;
|
|
29
|
-
|
|
30
|
-
/* NOTE: In case the following code looks strange to you, mind that we want to
|
|
31
|
-
* allow the user to set custom styles on this component. If user passes in a
|
|
32
|
-
* "className" prop (possibly "styleName", but that one is converted to
|
|
33
|
-
* "className" by Babel just before being passed into this component), it
|
|
34
|
-
* should not interfere with the sizing behavior, thus we need an extra <div>
|
|
35
|
-
* level in this component; however, if user does not need a custom styling,
|
|
36
|
-
* we can save one level of HTML code, so we do it. */
|
|
37
|
-
const rect = (
|
|
38
|
-
<div
|
|
39
|
-
style={{ paddingBottom }}
|
|
40
|
-
styleName="container"
|
|
41
|
-
>
|
|
42
|
-
<div styleName="wrapper">
|
|
43
|
-
{children}
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
);
|
|
47
|
-
return className ? (
|
|
48
|
-
<div className={className}>
|
|
49
|
-
{rect}
|
|
50
|
-
</div>
|
|
51
|
-
) : rect;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
ScalableRect.defaultProps = {
|
|
55
|
-
children: null,
|
|
56
|
-
className: undefined,
|
|
57
|
-
ratio: '1:1',
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
ScalableRect.propTypes = {
|
|
61
|
-
children: PT.node,
|
|
62
|
-
className: PT.string,
|
|
63
|
-
ratio: (props, name) => {
|
|
64
|
-
const ratio = props[name];
|
|
65
|
-
|
|
66
|
-
// "ratio" prop is not required (defaults "1:1").
|
|
67
|
-
if (ratio === undefined) return null;
|
|
68
|
-
|
|
69
|
-
// If given, "ratio" must be a string.
|
|
70
|
-
if (typeof ratio !== 'string') {
|
|
71
|
-
return Error('"ratio" prop must be a string');
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// If given, "ratio" must have "H:W" format.
|
|
75
|
-
if (!ratio.match(/\d+:\d+/)) {
|
|
76
|
-
return Error('"ratio" prop must have "H:W" format');
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Everything looks right.
|
|
80
|
-
return null;
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export default ScalableRect;
|