@skbkontur/react-ui 3.12.1 → 3.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/cjs/components/DatePicker/DatePicker.d.ts +0 -3
- package/cjs/components/DatePicker/DatePicker.js +14 -9
- package/cjs/components/DatePicker/DatePicker.js.map +1 -1
- package/cjs/internal/DropdownContainer/DropdownContainer.d.ts +1 -1
- package/cjs/internal/DropdownContainer/DropdownContainer.js +15 -13
- package/cjs/internal/DropdownContainer/DropdownContainer.js.map +1 -1
- package/components/DatePicker/DatePicker/DatePicker.js +19 -15
- package/components/DatePicker/DatePicker/DatePicker.js.map +1 -1
- package/components/DatePicker/DatePicker.d.ts +0 -3
- package/internal/DropdownContainer/DropdownContainer/DropdownContainer.js +18 -21
- package/internal/DropdownContainer/DropdownContainer/DropdownContainer.js.map +1 -1
- package/internal/DropdownContainer/DropdownContainer.d.ts +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.12.2](https://github.com/skbkontur/retail-ui/compare/@skbkontur/react-ui@3.12.1...@skbkontur/react-ui@3.12.2) (2022-03-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **DatePicker:** scroll to date ([#2830](https://github.com/skbkontur/retail-ui/issues/2830)) ([9fbd169](https://github.com/skbkontur/retail-ui/commit/9fbd1694199f71ad9337f2e89626320b78bd4e47))
|
|
12
|
+
* **DropdownContainer:** position with relative body (lts) ([#2828](https://github.com/skbkontur/retail-ui/issues/2828)) ([8db4e1c](https://github.com/skbkontur/retail-ui/commit/8db4e1cc6214f2a1bc9d8f02a071881a29f711d0))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
## [3.12.1](https://github.com/skbkontur/retail-ui/compare/@skbkontur/react-ui@3.12.0...@skbkontur/react-ui@3.12.1) (2022-03-01)
|
|
7
19
|
|
|
8
20
|
|
|
@@ -100,9 +100,6 @@ export declare class DatePicker extends React.PureComponent<DatePickerProps<Date
|
|
|
100
100
|
state: DatePickerState;
|
|
101
101
|
private input;
|
|
102
102
|
private focused;
|
|
103
|
-
private internalDate?;
|
|
104
|
-
private minDate?;
|
|
105
|
-
private maxDate?;
|
|
106
103
|
private setRootNode;
|
|
107
104
|
componentDidMount(): void;
|
|
108
105
|
componentDidUpdate(): void;
|
|
@@ -174,9 +174,6 @@ DatePicker = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/fu
|
|
|
174
174
|
|
|
175
175
|
input = null;_this.
|
|
176
176
|
focused = false;_this.
|
|
177
|
-
internalDate = _this.parseValueToDate(_this.props.value);_this.
|
|
178
|
-
minDate = _this.parseValueToDate(_this.props.minDate);_this.
|
|
179
|
-
maxDate = _this.parseValueToDate(_this.props.maxDate);_this.
|
|
180
177
|
setRootNode = void 0;_this.
|
|
181
178
|
|
|
182
179
|
|
|
@@ -237,19 +234,27 @@ DatePicker = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/fu
|
|
|
237
234
|
|
|
238
235
|
|
|
239
236
|
|
|
237
|
+
renderMain = function (props) {
|
|
238
|
+
var picker = null;var _this$props =
|
|
240
239
|
|
|
240
|
+
_this.props,value = _this$props.value,minDate = _this$props.minDate,maxDate = _this$props.maxDate;
|
|
241
241
|
|
|
242
|
+
var internalDate = _this.parseValueToDate(value);
|
|
243
|
+
var date = internalDate ? internalDate.toNativeFormat() : null;
|
|
244
|
+
|
|
245
|
+
var parsedMinDate = _this.parseValueToDate(minDate);
|
|
246
|
+
var formattedMinDate = parsedMinDate && parsedMinDate.toNativeFormat() || undefined;
|
|
247
|
+
|
|
248
|
+
var parsedMaxDate = _this.parseValueToDate(maxDate);
|
|
249
|
+
var formattedMaxDate = parsedMaxDate && parsedMaxDate.toNativeFormat() || undefined;
|
|
242
250
|
|
|
243
|
-
renderMain = function (props) {
|
|
244
|
-
var picker = null;
|
|
245
|
-
var date = _this.internalDate ? _this.internalDate.toNativeFormat() : null;
|
|
246
251
|
if (_this.state.opened) {
|
|
247
252
|
picker = /*#__PURE__*/
|
|
248
253
|
_react.default.createElement(_DropdownContainer.DropdownContainer, { getParent: _this.getParent, offsetY: 2, align: _this.props.menuAlign }, /*#__PURE__*/
|
|
249
254
|
_react.default.createElement(_Picker.Picker, {
|
|
250
255
|
value: date,
|
|
251
|
-
minDate:
|
|
252
|
-
maxDate:
|
|
256
|
+
minDate: formattedMinDate,
|
|
257
|
+
maxDate: formattedMaxDate,
|
|
253
258
|
onPick: _this.handlePick,
|
|
254
259
|
onSelect: _this.handleSelect,
|
|
255
260
|
enableTodayLink: _this.props.enableTodayLink,
|
|
@@ -359,7 +364,7 @@ DatePicker = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/fu
|
|
|
359
364
|
isHoliday = function (_ref2) {var date = _ref2.date,month = _ref2.month,year = _ref2.year,isWeekend = _ref2.isWeekend;
|
|
360
365
|
var dateString = _InternalDateTransformer.InternalDateTransformer.dateToInternalString({ date: date, month: month + 1, year: year });
|
|
361
366
|
return _this.props.isHoliday(dateString, isWeekend);
|
|
362
|
-
};return _this;}var _proto = DatePicker.prototype;_proto.componentDidMount = function componentDidMount() {if (this.props.useMobileNativeDatePicker && _client.isMobile) {this.setState({ canUseMobileNativeDatePicker: true });}if (this.props.autoFocus) {this.focus();}};_proto.componentDidUpdate = function componentDidUpdate() {var
|
|
367
|
+
};return _this;}var _proto = DatePicker.prototype;_proto.componentDidMount = function componentDidMount() {if (this.props.useMobileNativeDatePicker && _client.isMobile) {this.setState({ canUseMobileNativeDatePicker: true });}if (this.props.autoFocus) {this.focus();}};_proto.componentDidUpdate = function componentDidUpdate() {var disabled = this.props.disabled;var opened = this.state.opened;if (disabled && opened) {this.close();}} /**
|
|
363
368
|
* @public
|
|
364
369
|
*/;_proto.blur = function blur() {if (this.input) {this.input.blur();}this.handleBlur();} /**
|
|
365
370
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DatePicker.tsx"],"names":["INPUT_PASS_PROPS","autoFocus","disabled","warning","error","size","onKeyDown","MIN_WIDTH","DatePicker","rootNode","state","opened","canUseMobileNativeDatePicker","input","focused","internalDate","parseValueToDate","props","value","minDate","maxDate","setRootNode","renderMain","picker","date","toNativeFormat","getParent","menuAlign","undefined","handlePick","handleSelect","enableTodayLink","isHoliday","styles","root","getRootStyle","onMouseEnter","onMouseLeave","onMouseOver","getInputRef","handleBlur","handleFocus","onValueChange","width","minWidth","ref","setState","onFocus","close","onBlur","dateShape","blur","month","year","InternalDateTransformer","dateToInternalString","isWeekend","dateString","componentDidMount","useMobileNativeDatePicker","isMobile","focus","componentDidUpdate","render","InternalDate","validate","checks","InternalDateValidateCheck","NotNull","Native","React","PureComponent","__KONTUR_REACT_UI__","propTypes","PropTypes","bool","string","isRequired","oneOf","oneOfType","number","func","defaultProps","MIN_FULLDATE","MAX_FULLDATE","_day","range","order","InternalDateOrder","DMY","separator","InternalDateSeparator","Dot","setRangeStart","setRangeEnd","parseValue","Number","Limits","Range"],"mappings":"0cAAA;AACA;;AAEA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,iD;;AAEA,IAAMA,gBAAgB,GAAG;AACvBC,EAAAA,SAAS,EAAE,IADY;AAEvBC,EAAAA,QAAQ,EAAE,IAFa;AAGvBC,EAAAA,OAAO,EAAE,IAHc;AAIvBC,EAAAA,KAAK,EAAE,IAJgB;AAKvBC,EAAAA,IAAI,EAAE,IALiB;AAMvBC,EAAAA,SAAS,EAAE,IANY,EAAzB;;;AASO,IAAMC,SAAS,GAAG,GAAlB,C;;;;;;;;;;;;;;;;;;;;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E,CAKxEA,OALwE,+BAK9DgE,uBAL8D,kBAMxG,IAAMrE,YAAY,GAAG,IAAIiD,0BAAJ,CAAiB,EACpCuB,KAAK,EAAEC,yBAAkBC,GADW,EAEpCC,SAAS,EAAEC,6BAAsBC,GAFG,EAAjB,EAIlBC,aAJkB,CAIJ,IAAI7B,0BAAJ,CAAiB,EAAE9C,KAAK,EAAEC,OAAT,EAAjB,CAJI,EAKlB2E,WALkB,CAKN,IAAI9B,0BAAJ,CAAiB,EAAE9C,KAAK,EAAEE,OAAT,EAAjB,CALM,EAMlB2E,UANkB,CAMP7E,KANO,CAArB,CAQA,OAAOH,YAAY,CAACkD,QAAb,CAAsB,EAC3BC,MAAM,EAAE,CACNC,iCAA0BC,OADpB,EAEND,iCAA0B6B,MAFpB,EAGN7B,iCAA0BE,MAHpB,EAINF,iCAA0B8B,MAJpB,EAKN9B,iCAA0B+B,KALpB,CADmB,EAAtB,CAAP,CASD,C","sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nimport { InternalDate } from '../../lib/date/InternalDate';\nimport { InternalDateTransformer } from '../../lib/date/InternalDateTransformer';\nimport { MAX_FULLDATE, MIN_FULLDATE } from '../../lib/date/constants';\nimport { InternalDateOrder, InternalDateSeparator, InternalDateValidateCheck } from '../../lib/date/types';\nimport { Nullable } from '../../typings/utility-types';\nimport { CalendarDateShape } from '../../internal/Calendar';\nimport { DateInput } from '../DateInput';\nimport { DropdownContainer } from '../../internal/DropdownContainer';\nimport { filterProps } from '../../lib/filterProps';\nimport { CommonWrapper, CommonProps, CommonWrapperRestProps } from '../../internal/CommonWrapper';\nimport { isMobile } from '../../lib/client';\nimport { NativeDateInput } from '../../internal/NativeDateInput';\nimport { getRootNode, rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { isNonNullable } from '../../lib/utils';\n\nimport { Picker } from './Picker';\nimport { styles } from './DatePicker.styles';\n\nconst INPUT_PASS_PROPS = {\n autoFocus: true,\n disabled: true,\n warning: true,\n error: true,\n size: true,\n onKeyDown: true,\n};\n\nexport const MIN_WIDTH = 120;\n\nexport interface DatePickerProps<T> extends CommonProps {\n autoFocus?: boolean;\n disabled?: boolean;\n enableTodayLink?: boolean;\n /**\n * Cостояние валидации при ошибке.\n */\n error?: boolean;\n minDate: T;\n maxDate: T;\n menuAlign?: 'left' | 'right';\n size?: 'small' | 'medium' | 'large';\n value?: T | null;\n /**\n * Cостояние валидации при предупреждении.\n */\n warning?: boolean;\n width?: number | string;\n onBlur?: () => void;\n /**\n * Вызывается при изменении `value`\n *\n * @param value - строка в формате `dd.mm.yyyy`.\n */\n onValueChange: (value: T) => void;\n onFocus?: () => void;\n onKeyDown?: (e: React.KeyboardEvent<any>) => void;\n onMouseEnter?: (e: React.MouseEvent<any>) => void;\n onMouseLeave?: (e: React.MouseEvent<any>) => void;\n onMouseOver?: (e: React.MouseEvent<any>) => void;\n /**\n * Использовать на мобильных устройствах нативный календарь для выбора дат.\n *\n * - На iOS нативный календарь не умеет работать с minDate и maxDate\n */\n useMobileNativeDatePicker?: boolean;\n\n /**\n * Функция для определения праздничных дней\n * @default (_day, isWeekend) => isWeekend\n * @param {T} day - строка в формате `dd.mm.yyyy`\n * @param {boolean} isWeekend - флаг выходного (суббота или воскресенье)\n *\n * @returns {boolean} `true` для выходного или `false` для рабочего дня\n */\n isHoliday: (day: T, isWeekend: boolean) => boolean;\n}\n\nexport interface DatePickerState {\n opened: boolean;\n canUseMobileNativeDatePicker: boolean;\n}\n\ntype DatePickerValue = string;\n\n@rootNode\nexport class DatePicker extends React.PureComponent<DatePickerProps<DatePickerValue>, DatePickerState> {\n public static __KONTUR_REACT_UI__ = 'DatePicker';\n\n public static propTypes = {\n autoFocus: PropTypes.bool,\n\n disabled: PropTypes.bool,\n\n /**\n * Включает кнопку сегодня в календаре\n */\n enableTodayLink: PropTypes.bool,\n\n error: PropTypes.bool,\n\n /**\n * Максимальная дата в календаре.\n */\n maxDate: PropTypes.string.isRequired,\n\n menuAlign: PropTypes.oneOf(['left', 'right'] as Array<'left' | 'right'>),\n\n /**\n * Минимальная дата в календаре.\n */\n minDate: PropTypes.string.isRequired,\n\n /**\n * Строка формата `dd.mm.yyyy`\n */\n value: PropTypes.string,\n\n warning: PropTypes.bool,\n\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,\n\n onBlur: PropTypes.func,\n\n onValueChange: PropTypes.func.isRequired,\n\n onFocus: PropTypes.func,\n\n onKeyDown: PropTypes.func,\n\n onMouseEnter: PropTypes.func,\n\n onMouseLeave: PropTypes.func,\n\n onMouseOver: PropTypes.func,\n\n isHoliday: PropTypes.func.isRequired,\n };\n\n public static defaultProps = {\n minDate: MIN_FULLDATE,\n maxDate: MAX_FULLDATE,\n isHoliday: (_day: DatePickerValue, isWeekend: boolean) => isWeekend,\n };\n\n public static validate = (value: Nullable<string>, range: { minDate?: string; maxDate?: string } = {}) => {\n if (!value) {\n return false;\n }\n\n const { minDate = MIN_FULLDATE, maxDate = MAX_FULLDATE } = range;\n const internalDate = new InternalDate({\n order: InternalDateOrder.DMY,\n separator: InternalDateSeparator.Dot,\n })\n .setRangeStart(new InternalDate({ value: minDate }))\n .setRangeEnd(new InternalDate({ value: maxDate }))\n .parseValue(value);\n\n return internalDate.validate({\n checks: [\n InternalDateValidateCheck.NotNull,\n InternalDateValidateCheck.Number,\n InternalDateValidateCheck.Native,\n InternalDateValidateCheck.Limits,\n InternalDateValidateCheck.Range,\n ],\n });\n };\n\n public state: DatePickerState = { opened: false, canUseMobileNativeDatePicker: false };\n\n private input: DateInput | null = null;\n private focused = false;\n private internalDate?: InternalDate = this.parseValueToDate(this.props.value);\n private minDate?: InternalDate = this.parseValueToDate(this.props.minDate);\n private maxDate?: InternalDate = this.parseValueToDate(this.props.maxDate);\n private setRootNode!: TSetRootNode;\n\n public componentDidMount() {\n if (this.props.useMobileNativeDatePicker && isMobile) {\n this.setState({\n canUseMobileNativeDatePicker: true,\n });\n }\n if (this.props.autoFocus) {\n this.focus();\n }\n }\n\n public componentDidUpdate() {\n const { disabled, value, minDate, maxDate } = this.props;\n const { opened } = this.state;\n if (disabled && opened) {\n this.close();\n }\n this.internalDate = this.parseValueToDate(value);\n this.minDate = this.parseValueToDate(minDate);\n this.maxDate = this.parseValueToDate(maxDate);\n }\n\n /**\n * @public\n */\n public blur() {\n if (this.input) {\n this.input.blur();\n }\n this.handleBlur();\n }\n\n /**\n * @public\n */\n public focus() {\n if (this.props.disabled) {\n return;\n }\n if (this.input) {\n this.input.focus();\n }\n this.handleFocus();\n }\n\n /**\n * Закрывает выпадашку выбора дня\n * @public\n */\n public close() {\n this.setState({ opened: false });\n }\n\n public render() {\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n {this.renderMain}\n </CommonWrapper>\n );\n }\n\n public renderMain = (props: CommonWrapperRestProps<DatePickerProps<DatePickerValue>>) => {\n let picker = null;\n const date = this.internalDate ? this.internalDate.toNativeFormat() : null;\n if (this.state.opened) {\n picker = (\n <DropdownContainer getParent={this.getParent} offsetY={2} align={this.props.menuAlign}>\n <Picker\n value={date}\n minDate={(this.minDate && this.minDate.toNativeFormat()) || undefined}\n maxDate={(this.maxDate && this.maxDate.toNativeFormat()) || undefined}\n onPick={this.handlePick}\n onSelect={this.handleSelect}\n enableTodayLink={this.props.enableTodayLink}\n isHoliday={this.isHoliday}\n />\n </DropdownContainer>\n );\n }\n\n return (\n <label\n className={styles.root()}\n style={this.getRootStyle()}\n onMouseEnter={this.props.onMouseEnter}\n onMouseLeave={this.props.onMouseLeave}\n onMouseOver={this.props.onMouseOver}\n >\n <DateInput\n {...filterProps(props, INPUT_PASS_PROPS)}\n ref={this.getInputRef}\n value={this.props.value || ''}\n width=\"100%\"\n withIcon\n minDate={this.props.minDate}\n maxDate={this.props.maxDate}\n onBlur={this.handleBlur}\n onFocus={this.handleFocus}\n onValueChange={this.props.onValueChange}\n />\n {this.state.canUseMobileNativeDatePicker && (\n <NativeDateInput\n onValueChange={this.props.onValueChange}\n value={this.props.value || ''}\n minDate={this.props.minDate}\n maxDate={this.props.maxDate}\n disabled={this.props.disabled}\n />\n )}\n {!this.state.canUseMobileNativeDatePicker && picker}\n </label>\n );\n };\n\n public getParent = () => {\n return getRootNode(this);\n };\n\n private getRootStyle = () => {\n const { width } = this.props;\n return isNonNullable(width) ? { width } : { minWidth: MIN_WIDTH };\n };\n\n private getInputRef = (ref: DateInput | null) => {\n this.input = ref;\n };\n\n private parseValueToDate(value?: Nullable<string>): InternalDate | undefined {\n if (value === undefined || value === null) {\n return undefined;\n }\n const date = new InternalDate({ value });\n if (date.validate({ checks: [InternalDateValidateCheck.NotNull, InternalDateValidateCheck.Native] })) {\n return date;\n }\n return undefined;\n }\n\n private handleFocus = () => {\n if (this.focused) {\n return;\n }\n\n this.focused = true;\n\n this.setState({ opened: true });\n\n if (this.props.onFocus) {\n this.props.onFocus();\n }\n };\n\n private handleBlur = () => {\n if (!this.focused) {\n return;\n }\n\n this.focused = false;\n this.close();\n\n if (this.props.onBlur) {\n this.props.onBlur();\n }\n };\n\n private handlePick = (dateShape: CalendarDateShape) => {\n this.handleSelect(dateShape);\n this.blur();\n };\n\n private handleSelect = ({ date, month, year }: CalendarDateShape) => {\n const value = InternalDateTransformer.dateToInternalString({ date, month: month + 1, year });\n if (this.props.onValueChange) {\n this.props.onValueChange(value);\n }\n };\n\n private isHoliday = ({ date, month, year, isWeekend }: CalendarDateShape & { isWeekend: boolean }) => {\n const dateString = InternalDateTransformer.dateToInternalString({ date, month: month + 1, year });\n return this.props.isHoliday(dateString, isWeekend);\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["DatePicker.tsx"],"names":["INPUT_PASS_PROPS","autoFocus","disabled","warning","error","size","onKeyDown","MIN_WIDTH","DatePicker","rootNode","state","opened","canUseMobileNativeDatePicker","input","focused","setRootNode","renderMain","props","picker","value","minDate","maxDate","internalDate","parseValueToDate","date","toNativeFormat","parsedMinDate","formattedMinDate","undefined","parsedMaxDate","formattedMaxDate","getParent","menuAlign","handlePick","handleSelect","enableTodayLink","isHoliday","styles","root","getRootStyle","onMouseEnter","onMouseLeave","onMouseOver","getInputRef","handleBlur","handleFocus","onValueChange","width","minWidth","ref","setState","onFocus","close","onBlur","dateShape","blur","month","year","InternalDateTransformer","dateToInternalString","isWeekend","dateString","componentDidMount","useMobileNativeDatePicker","isMobile","focus","componentDidUpdate","render","InternalDate","validate","checks","InternalDateValidateCheck","NotNull","Native","React","PureComponent","__KONTUR_REACT_UI__","propTypes","PropTypes","bool","string","isRequired","oneOf","oneOfType","number","func","defaultProps","MIN_FULLDATE","MAX_FULLDATE","_day","range","order","InternalDateOrder","DMY","separator","InternalDateSeparator","Dot","setRangeStart","setRangeEnd","parseValue","Number","Limits","Range"],"mappings":"0cAAA;AACA;;AAEA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,iD;;AAEA,IAAMA,gBAAgB,GAAG;AACvBC,EAAAA,SAAS,EAAE,IADY;AAEvBC,EAAAA,QAAQ,EAAE,IAFa;AAGvBC,EAAAA,OAAO,EAAE,IAHc;AAIvBC,EAAAA,KAAK,EAAE,IAJgB;AAKvBC,EAAAA,IAAI,EAAE,IALiB;AAMvBC,EAAAA,SAAS,EAAE,IANY,EAAzB;;;AASO,IAAMC,SAAS,GAAG,GAAlB,C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DMC,U,OADZC,kB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFQC,IAAAA,K,GAAyB,EAAEC,MAAM,EAAE,KAAV,EAAiBC,4BAA4B,EAAE,KAA/C,E;;AAExBC,IAAAA,K,GAA0B,I;AAC1BC,IAAAA,O,GAAU,K;AACVC,IAAAA,W;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA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,EAKN9B,iCAA0B+B,KALpB,CADmB,EAAtB,CAAP,CASD,C","sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nimport { InternalDate } from '../../lib/date/InternalDate';\nimport { InternalDateTransformer } from '../../lib/date/InternalDateTransformer';\nimport { MAX_FULLDATE, MIN_FULLDATE } from '../../lib/date/constants';\nimport { InternalDateOrder, InternalDateSeparator, InternalDateValidateCheck } from '../../lib/date/types';\nimport { Nullable } from '../../typings/utility-types';\nimport { CalendarDateShape } from '../../internal/Calendar';\nimport { DateInput } from '../DateInput';\nimport { DropdownContainer } from '../../internal/DropdownContainer';\nimport { filterProps } from '../../lib/filterProps';\nimport { CommonWrapper, CommonProps, CommonWrapperRestProps } from '../../internal/CommonWrapper';\nimport { isMobile } from '../../lib/client';\nimport { NativeDateInput } from '../../internal/NativeDateInput';\nimport { getRootNode, rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { isNonNullable } from '../../lib/utils';\n\nimport { Picker } from './Picker';\nimport { styles } from './DatePicker.styles';\n\nconst INPUT_PASS_PROPS = {\n autoFocus: true,\n disabled: true,\n warning: true,\n error: true,\n size: true,\n onKeyDown: true,\n};\n\nexport const MIN_WIDTH = 120;\n\nexport interface DatePickerProps<T> extends CommonProps {\n autoFocus?: boolean;\n disabled?: boolean;\n enableTodayLink?: boolean;\n /**\n * Cостояние валидации при ошибке.\n */\n error?: boolean;\n minDate: T;\n maxDate: T;\n menuAlign?: 'left' | 'right';\n size?: 'small' | 'medium' | 'large';\n value?: T | null;\n /**\n * Cостояние валидации при предупреждении.\n */\n warning?: boolean;\n width?: number | string;\n onBlur?: () => void;\n /**\n * Вызывается при изменении `value`\n *\n * @param value - строка в формате `dd.mm.yyyy`.\n */\n onValueChange: (value: T) => void;\n onFocus?: () => void;\n onKeyDown?: (e: React.KeyboardEvent<any>) => void;\n onMouseEnter?: (e: React.MouseEvent<any>) => void;\n onMouseLeave?: (e: React.MouseEvent<any>) => void;\n onMouseOver?: (e: React.MouseEvent<any>) => void;\n /**\n * Использовать на мобильных устройствах нативный календарь для выбора дат.\n *\n * - На iOS нативный календарь не умеет работать с minDate и maxDate\n */\n useMobileNativeDatePicker?: boolean;\n\n /**\n * Функция для определения праздничных дней\n * @default (_day, isWeekend) => isWeekend\n * @param {T} day - строка в формате `dd.mm.yyyy`\n * @param {boolean} isWeekend - флаг выходного (суббота или воскресенье)\n *\n * @returns {boolean} `true` для выходного или `false` для рабочего дня\n */\n isHoliday: (day: T, isWeekend: boolean) => boolean;\n}\n\nexport interface DatePickerState {\n opened: boolean;\n canUseMobileNativeDatePicker: boolean;\n}\n\ntype DatePickerValue = string;\n\n@rootNode\nexport class DatePicker extends React.PureComponent<DatePickerProps<DatePickerValue>, DatePickerState> {\n public static __KONTUR_REACT_UI__ = 'DatePicker';\n\n public static propTypes = {\n autoFocus: PropTypes.bool,\n\n disabled: PropTypes.bool,\n\n /**\n * Включает кнопку сегодня в календаре\n */\n enableTodayLink: PropTypes.bool,\n\n error: PropTypes.bool,\n\n /**\n * Максимальная дата в календаре.\n */\n maxDate: PropTypes.string.isRequired,\n\n menuAlign: PropTypes.oneOf(['left', 'right'] as Array<'left' | 'right'>),\n\n /**\n * Минимальная дата в календаре.\n */\n minDate: PropTypes.string.isRequired,\n\n /**\n * Строка формата `dd.mm.yyyy`\n */\n value: PropTypes.string,\n\n warning: PropTypes.bool,\n\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,\n\n onBlur: PropTypes.func,\n\n onValueChange: PropTypes.func.isRequired,\n\n onFocus: PropTypes.func,\n\n onKeyDown: PropTypes.func,\n\n onMouseEnter: PropTypes.func,\n\n onMouseLeave: PropTypes.func,\n\n onMouseOver: PropTypes.func,\n\n isHoliday: PropTypes.func.isRequired,\n };\n\n public static defaultProps = {\n minDate: MIN_FULLDATE,\n maxDate: MAX_FULLDATE,\n isHoliday: (_day: DatePickerValue, isWeekend: boolean) => isWeekend,\n };\n\n public static validate = (value: Nullable<string>, range: { minDate?: string; maxDate?: string } = {}) => {\n if (!value) {\n return false;\n }\n\n const { minDate = MIN_FULLDATE, maxDate = MAX_FULLDATE } = range;\n const internalDate = new InternalDate({\n order: InternalDateOrder.DMY,\n separator: InternalDateSeparator.Dot,\n })\n .setRangeStart(new InternalDate({ value: minDate }))\n .setRangeEnd(new InternalDate({ value: maxDate }))\n .parseValue(value);\n\n return internalDate.validate({\n checks: [\n InternalDateValidateCheck.NotNull,\n InternalDateValidateCheck.Number,\n InternalDateValidateCheck.Native,\n InternalDateValidateCheck.Limits,\n InternalDateValidateCheck.Range,\n ],\n });\n };\n\n public state: DatePickerState = { opened: false, canUseMobileNativeDatePicker: false };\n\n private input: DateInput | null = null;\n private focused = false;\n private setRootNode!: TSetRootNode;\n\n public componentDidMount() {\n if (this.props.useMobileNativeDatePicker && isMobile) {\n this.setState({\n canUseMobileNativeDatePicker: true,\n });\n }\n if (this.props.autoFocus) {\n this.focus();\n }\n }\n\n public componentDidUpdate() {\n const { disabled } = this.props;\n const { opened } = this.state;\n if (disabled && opened) {\n this.close();\n }\n }\n\n /**\n * @public\n */\n public blur() {\n if (this.input) {\n this.input.blur();\n }\n this.handleBlur();\n }\n\n /**\n * @public\n */\n public focus() {\n if (this.props.disabled) {\n return;\n }\n if (this.input) {\n this.input.focus();\n }\n this.handleFocus();\n }\n\n /**\n * Закрывает выпадашку выбора дня\n * @public\n */\n public close() {\n this.setState({ opened: false });\n }\n\n public render() {\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n {this.renderMain}\n </CommonWrapper>\n );\n }\n\n public renderMain = (props: CommonWrapperRestProps<DatePickerProps<DatePickerValue>>) => {\n let picker = null;\n\n const { value, minDate, maxDate } = this.props;\n\n const internalDate = this.parseValueToDate(value);\n const date = internalDate ? internalDate.toNativeFormat() : null;\n\n const parsedMinDate = this.parseValueToDate(minDate);\n const formattedMinDate = (parsedMinDate && parsedMinDate.toNativeFormat()) || undefined;\n\n const parsedMaxDate = this.parseValueToDate(maxDate);\n const formattedMaxDate = (parsedMaxDate && parsedMaxDate.toNativeFormat()) || undefined;\n\n if (this.state.opened) {\n picker = (\n <DropdownContainer getParent={this.getParent} offsetY={2} align={this.props.menuAlign}>\n <Picker\n value={date}\n minDate={formattedMinDate}\n maxDate={formattedMaxDate}\n onPick={this.handlePick}\n onSelect={this.handleSelect}\n enableTodayLink={this.props.enableTodayLink}\n isHoliday={this.isHoliday}\n />\n </DropdownContainer>\n );\n }\n\n return (\n <label\n className={styles.root()}\n style={this.getRootStyle()}\n onMouseEnter={this.props.onMouseEnter}\n onMouseLeave={this.props.onMouseLeave}\n onMouseOver={this.props.onMouseOver}\n >\n <DateInput\n {...filterProps(props, INPUT_PASS_PROPS)}\n ref={this.getInputRef}\n value={this.props.value || ''}\n width=\"100%\"\n withIcon\n minDate={this.props.minDate}\n maxDate={this.props.maxDate}\n onBlur={this.handleBlur}\n onFocus={this.handleFocus}\n onValueChange={this.props.onValueChange}\n />\n {this.state.canUseMobileNativeDatePicker && (\n <NativeDateInput\n onValueChange={this.props.onValueChange}\n value={this.props.value || ''}\n minDate={this.props.minDate}\n maxDate={this.props.maxDate}\n disabled={this.props.disabled}\n />\n )}\n {!this.state.canUseMobileNativeDatePicker && picker}\n </label>\n );\n };\n\n public getParent = () => {\n return getRootNode(this);\n };\n\n private getRootStyle = () => {\n const { width } = this.props;\n return isNonNullable(width) ? { width } : { minWidth: MIN_WIDTH };\n };\n\n private getInputRef = (ref: DateInput | null) => {\n this.input = ref;\n };\n\n private parseValueToDate(value?: Nullable<string>): InternalDate | undefined {\n if (value === undefined || value === null) {\n return undefined;\n }\n const date = new InternalDate({ value });\n if (date.validate({ checks: [InternalDateValidateCheck.NotNull, InternalDateValidateCheck.Native] })) {\n return date;\n }\n return undefined;\n }\n\n private handleFocus = () => {\n if (this.focused) {\n return;\n }\n\n this.focused = true;\n\n this.setState({ opened: true });\n\n if (this.props.onFocus) {\n this.props.onFocus();\n }\n };\n\n private handleBlur = () => {\n if (!this.focused) {\n return;\n }\n\n this.focused = false;\n this.close();\n\n if (this.props.onBlur) {\n this.props.onBlur();\n }\n };\n\n private handlePick = (dateShape: CalendarDateShape) => {\n this.handleSelect(dateShape);\n this.blur();\n };\n\n private handleSelect = ({ date, month, year }: CalendarDateShape) => {\n const value = InternalDateTransformer.dateToInternalString({ date, month: month + 1, year });\n if (this.props.onValueChange) {\n this.props.onValueChange(value);\n }\n };\n\n private isHoliday = ({ date, month, year, isWeekend }: CalendarDateShape & { isWeekend: boolean }) => {\n const dateString = InternalDateTransformer.dateToInternalString({ date, month: month + 1, year });\n return this.props.isHoliday(dateString, isWeekend);\n };\n}\n"]}
|
|
@@ -28,10 +28,10 @@ export declare class DropdownContainer extends React.PureComponent<DropdownConta
|
|
|
28
28
|
offsetX: number;
|
|
29
29
|
offsetY: number;
|
|
30
30
|
};
|
|
31
|
-
state: DropdownContainerState;
|
|
32
31
|
private getProps;
|
|
33
32
|
private dom;
|
|
34
33
|
private layoutSub;
|
|
34
|
+
constructor(props: DropdownContainerProps);
|
|
35
35
|
componentDidMount(): void;
|
|
36
36
|
componentWillUnmount(): void;
|
|
37
37
|
render(): JSX.Element;
|
|
@@ -33,7 +33,7 @@ var _DropdownContainer = require("./DropdownContainer.styles");var
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
DropdownContainer = /*#__PURE__*/function (_React$PureComponent) {(0, _inheritsLoose2.default)(DropdownContainer, _React$PureComponent);
|
|
36
|
+
DropdownContainer = /*#__PURE__*/function (_React$PureComponent) {(0, _inheritsLoose2.default)(DropdownContainer, _React$PureComponent);
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
@@ -43,22 +43,13 @@ DropdownContainer = /*#__PURE__*/function (_React$PureComponent) {(0, _inheritsL
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
state = {
|
|
47
|
-
position: null,
|
|
48
|
-
minWidth: 0,
|
|
49
|
-
isDocumentElementRoot: true };_this.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
getProps = (0, _createPropsGetter.createPropsGetter)(DropdownContainer.defaultProps);_this.
|
|
53
|
-
|
|
54
|
-
dom = void 0;_this.
|
|
55
|
-
layoutSub = void 0;_this.
|
|
56
|
-
|
|
57
46
|
|
|
58
47
|
|
|
59
48
|
|
|
60
49
|
|
|
61
50
|
|
|
51
|
+
function DropdownContainer(props) {var _this;
|
|
52
|
+
_this = _React$PureComponent.call(this, props) || this;_this.getProps = (0, _createPropsGetter.createPropsGetter)(DropdownContainer.defaultProps);_this.dom = void 0;_this.layoutSub = void 0;_this.
|
|
62
53
|
|
|
63
54
|
|
|
64
55
|
|
|
@@ -207,4 +198,15 @@ DropdownContainer = /*#__PURE__*/function (_React$PureComponent) {(0, _inheritsL
|
|
|
207
198
|
left: offsetX,
|
|
208
199
|
right: null };
|
|
209
200
|
|
|
210
|
-
};return _this;}var _proto = DropdownContainer.prototype;_proto.componentDidMount = function componentDidMount() {this.position();this.layoutSub = LayoutEvents.addListener(this.position);
|
|
201
|
+
};_this.state = { position: null, minWidth: 0, isDocumentElementRoot: getIsDocumentElementRoot() };return _this;}var _proto = DropdownContainer.prototype;_proto.componentDidMount = function componentDidMount() {this.position();this.layoutSub = LayoutEvents.addListener(this.position);};_proto.componentWillUnmount = function componentWillUnmount() {if (this.layoutSub) {this.layoutSub.remove();}};_proto.render = function render() {var _cx;var style = { position: 'absolute', top: '0' };if (this.state.position) {var _this$state$position = this.state.position,top = _this$state$position.top,bottom = _this$state$position.bottom,left = _this$state$position.left,right = _this$state$position.right;style = (0, _extends2.default)({}, style, { top: top !== null ? top : undefined, bottom: bottom !== null ? bottom : undefined, left: left !== null ? left : undefined, right: right !== null ? right : undefined, minWidth: this.state.minWidth, maxWidth: this.props.hasFixedWidth ? this.state.minWidth : undefined });}var content = /*#__PURE__*/_react.default.createElement(_ZIndex.ZIndex, { priority: 'DropdownContainer', wrapperRef: this.ZIndexRef, style: style, className: (0, _Emotion.cx)((_cx = {}, _cx[_DropdownContainer.styles.alignRight()] = this.props.align === 'right' && !_client.isIE11, _cx)) }, this.props.children);return this.props.disablePortal ? content : /*#__PURE__*/_react.default.createElement(_RenderContainer.RenderContainer, null, content);};return DropdownContainer;}(_react.default.PureComponent);exports.DropdownContainer = DropdownContainer;DropdownContainer.__KONTUR_REACT_UI__ = 'DropdownContainer';DropdownContainer.defaultProps = { align: 'left', disablePortal: false, offsetX: 0, offsetY: -1 };
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
var getIsDocumentElementRoot = function getIsDocumentElementRoot() {var _document2 =
|
|
205
|
+
document,body = _document2.body,documentElement = _document2.documentElement;
|
|
206
|
+
var htmlPosition = getComputedStyle(documentElement).position;
|
|
207
|
+
var bodyPosition = getComputedStyle(body).position;
|
|
208
|
+
|
|
209
|
+
var hasLimitedHeightRoot = body.scrollHeight > body.clientHeight;
|
|
210
|
+
var hasStaticRoot = htmlPosition === 'static' && bodyPosition === 'static';
|
|
211
|
+
return hasLimitedHeightRoot || hasStaticRoot;
|
|
212
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DropdownContainer.tsx"],"names":["DropdownContainer","state","position","minWidth","isDocumentElementRoot","getProps","defaultProps","dom","layoutSub","ZIndexRef","element","isElement","node","Element","target","props","getParent","targetRect","getBoundingClientRect","document","body","docEl","documentElement","Error","scrollX","window","pageXOffset","scrollLeft","scrollY","pageYOffset","scrollTop","left","right","align","docWidth","offsetWidth","offsetX","offsetY","bottom","top","distanceToBottom","clientHeight","dropdownHeight","getHeight","scrollHeight","setState","getMinWidth","disablePortal","convertToRelativePosition","child","children","item","height","width","targetHeight","componentDidMount","LayoutEvents","addListener","htmlPosition","getComputedStyle","bodyPosition","hasLimitedHeightRoot","hasStaticRoot","componentWillUnmount","remove","render","style","undefined","maxWidth","hasFixedWidth","content","styles","alignRight","isIE11","React","PureComponent","__KONTUR_REACT_UI__"],"mappings":"saAAA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAE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2B,KAAK,EAAE,MADoB,EAE3Bc,aAAa,EAAE,KAFY,EAG3BX,OAAO,EAAE,CAHkB,EAI3BC,OAAO,EAAE,CAAC,CAJiB,E","sourcesContent":["import React from 'react';\n\nimport * as LayoutEvents from '../../lib/LayoutEvents';\nimport { RenderContainer } from '../RenderContainer';\nimport { ZIndex } from '../ZIndex';\nimport { createPropsGetter } from '../../lib/createPropsGetter';\nimport { Nullable } from '../../typings/utility-types';\nimport { cx } from '../../lib/theming/Emotion';\nimport { isIE11 } from '../../lib/client';\n\nimport { styles } from './DropdownContainer.styles';\n\nexport interface DropdownContainerPosition {\n top: Nullable<number>;\n bottom: Nullable<number>;\n left: Nullable<number>;\n right: Nullable<number>;\n}\n\nexport interface DropdownContainerProps {\n align?: 'left' | 'right';\n getParent: () => Nullable<HTMLElement>;\n children?: React.ReactNode;\n disablePortal?: boolean;\n offsetY?: number;\n offsetX?: number;\n hasFixedWidth?: boolean;\n}\n\nexport interface DropdownContainerState {\n position: Nullable<DropdownContainerPosition>;\n minWidth: number;\n isDocumentElementRoot?: boolean;\n}\n\nexport class DropdownContainer extends React.PureComponent<DropdownContainerProps, DropdownContainerState> {\n public static __KONTUR_REACT_UI__ = 'DropdownContainer';\n\n public static defaultProps = {\n align: 'left',\n disablePortal: false,\n offsetX: 0,\n offsetY: -1,\n };\n\n public state: DropdownContainerState = {\n position: null,\n minWidth: 0,\n isDocumentElementRoot: true,\n };\n\n private getProps = createPropsGetter(DropdownContainer.defaultProps);\n\n private dom: Nullable<HTMLDivElement>;\n private layoutSub: Nullable<ReturnType<typeof LayoutEvents.addListener>>;\n\n public componentDidMount() {\n this.position();\n this.layoutSub = LayoutEvents.addListener(this.position);\n\n const { body, documentElement: docEl } = document;\n const htmlPosition = getComputedStyle(docEl).position;\n const bodyPosition = getComputedStyle(body).position;\n\n const hasLimitedHeightRoot = body.scrollHeight > body.clientHeight;\n const hasStaticRoot = htmlPosition === 'static' && bodyPosition === 'static';\n\n this.setState({ isDocumentElementRoot: hasLimitedHeightRoot || hasStaticRoot });\n }\n\n public componentWillUnmount() {\n if (this.layoutSub) {\n this.layoutSub.remove();\n }\n }\n\n public render() {\n let style: React.CSSProperties = {\n position: 'absolute',\n top: '0',\n };\n if (this.state.position) {\n const { top, bottom, left, right } = this.state.position;\n style = {\n ...style,\n top: top !== null ? top : undefined,\n bottom: bottom !== null ? bottom : undefined,\n left: left !== null ? left : undefined,\n right: right !== null ? right : undefined,\n minWidth: this.state.minWidth,\n maxWidth: this.props.hasFixedWidth ? this.state.minWidth : undefined,\n };\n }\n\n const content = (\n <ZIndex\n priority={'DropdownContainer'}\n wrapperRef={this.ZIndexRef}\n style={style}\n className={cx({\n [styles.alignRight()]: this.props.align === 'right' && !isIE11,\n })}\n >\n {this.props.children}\n </ZIndex>\n );\n\n return this.props.disablePortal ? content : <RenderContainer>{content}</RenderContainer>;\n }\n\n private ZIndexRef = (element: Nullable<HTMLDivElement>) => {\n this.dom = element;\n };\n\n private isElement = (node: Nullable<Element>): node is Element => {\n return node instanceof Element;\n };\n\n public position = () => {\n const target = this.props.getParent();\n const dom = this.dom;\n\n if (target && this.isElement(target) && dom) {\n const targetRect = target.getBoundingClientRect();\n const { body, documentElement: docEl } = document;\n\n if (!docEl) {\n throw Error('There is no \"documentElement\" in \"document\"');\n }\n\n const scrollX = window.pageXOffset || docEl.scrollLeft || 0;\n const scrollY = window.pageYOffset || docEl.scrollTop || 0;\n\n let left = null;\n let right = null;\n\n if (this.props.align === 'right') {\n const docWidth = docEl.offsetWidth || 0;\n right = docWidth - (targetRect.right + scrollX) + this.getProps().offsetX;\n } else {\n left = targetRect.left + scrollX + this.getProps().offsetX;\n }\n\n const { offsetY = 0 } = this.props;\n let bottom = null;\n let top: number | null = targetRect.bottom + scrollY + offsetY;\n\n const distanceToBottom = docEl.clientHeight - targetRect.bottom;\n const dropdownHeight = this.getHeight();\n\n if (distanceToBottom < dropdownHeight && targetRect.top > dropdownHeight) {\n const clientHeight = this.state.isDocumentElementRoot ? docEl.clientHeight : body.scrollHeight;\n\n top = null;\n bottom = clientHeight + offsetY - scrollY - targetRect.top;\n }\n\n const position = {\n top,\n left,\n right,\n bottom,\n };\n\n this.setState({\n minWidth: this.getMinWidth(),\n position: this.props.disablePortal ? this.convertToRelativePosition(position) : position,\n });\n }\n };\n\n private getHeight = () => {\n if (!this.isElement(this.dom)) {\n return 0;\n }\n const child = this.dom.children.item(0);\n if (!child) {\n return 0;\n }\n return child.getBoundingClientRect().height;\n };\n\n private getMinWidth = () => {\n const target = this.props.getParent();\n if (!target || !this.isElement(target)) {\n return 0;\n }\n return target.getBoundingClientRect().width;\n };\n\n private convertToRelativePosition = (position: DropdownContainerPosition): DropdownContainerPosition => {\n const target = this.props.getParent();\n const { offsetX = 0, offsetY = 0 } = this.props;\n const { top, bottom, left, right } = position;\n if (target && this.isElement(target)) {\n const targetHeight = target.getBoundingClientRect().height;\n return {\n top: top !== null ? targetHeight + offsetY : null,\n bottom: bottom !== null ? targetHeight + offsetY : null,\n left: left !== null ? offsetX : null,\n right: right !== null ? offsetX : null,\n };\n }\n return {\n top: offsetY,\n bottom: null,\n left: offsetX,\n right: null,\n };\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["DropdownContainer.tsx"],"names":["DropdownContainer","props","getProps","defaultProps","dom","layoutSub","ZIndexRef","element","isElement","node","Element","position","target","getParent","targetRect","getBoundingClientRect","document","body","docEl","documentElement","Error","scrollX","window","pageXOffset","scrollLeft","scrollY","pageYOffset","scrollTop","left","right","align","docWidth","offsetWidth","offsetX","offsetY","bottom","top","distanceToBottom","clientHeight","dropdownHeight","getHeight","state","isDocumentElementRoot","scrollHeight","setState","minWidth","getMinWidth","disablePortal","convertToRelativePosition","child","children","item","height","width","targetHeight","getIsDocumentElementRoot","componentDidMount","LayoutEvents","addListener","componentWillUnmount","remove","render","style","undefined","maxWidth","hasFixedWidth","content","styles","alignRight","isIE11","React","PureComponent","__KONTUR_REACT_UI__","htmlPosition","getComputedStyle","bodyPosition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6B,CACvBE,eADuB,cACvBA,eADuB;AAErC,MAAMsD,YAAY,GAAGC,gBAAgB,CAACvD,eAAD,CAAhB,CAAkCR,QAAvD;AACA,MAAMgE,YAAY,GAAGD,gBAAgB,CAACzD,IAAD,CAAhB,CAAuBN,QAA5C;;AAEA,MAAMiE,oBAAoB,GAAG3D,IAAI,CAAC0B,YAAL,GAAoB1B,IAAI,CAACqB,YAAtD;AACA,MAAMuC,aAAa,GAAGJ,YAAY,KAAK,QAAjB,IAA6BE,YAAY,KAAK,QAApE;AACA,SAAOC,oBAAoB,IAAIC,aAA/B;AACD,CARD","sourcesContent":["import React from 'react';\n\nimport * as LayoutEvents from '../../lib/LayoutEvents';\nimport { RenderContainer } from '../RenderContainer';\nimport { ZIndex } from '../ZIndex';\nimport { createPropsGetter } from '../../lib/createPropsGetter';\nimport { Nullable } from '../../typings/utility-types';\nimport { cx } from '../../lib/theming/Emotion';\nimport { isIE11 } from '../../lib/client';\n\nimport { styles } from './DropdownContainer.styles';\n\nexport interface DropdownContainerPosition {\n top: Nullable<number>;\n bottom: Nullable<number>;\n left: Nullable<number>;\n right: Nullable<number>;\n}\n\nexport interface DropdownContainerProps {\n align?: 'left' | 'right';\n getParent: () => Nullable<HTMLElement>;\n children?: React.ReactNode;\n disablePortal?: boolean;\n offsetY?: number;\n offsetX?: number;\n hasFixedWidth?: boolean;\n}\n\nexport interface DropdownContainerState {\n position: Nullable<DropdownContainerPosition>;\n minWidth: number;\n isDocumentElementRoot?: boolean;\n}\n\nexport class DropdownContainer extends React.PureComponent<DropdownContainerProps, DropdownContainerState> {\n public static __KONTUR_REACT_UI__ = 'DropdownContainer';\n\n public static defaultProps = {\n align: 'left',\n disablePortal: false,\n offsetX: 0,\n offsetY: -1,\n };\n\n private getProps = createPropsGetter(DropdownContainer.defaultProps);\n\n private dom: Nullable<HTMLDivElement>;\n private layoutSub: Nullable<ReturnType<typeof LayoutEvents.addListener>>;\n\n constructor(props: DropdownContainerProps) {\n super(props);\n\n this.state = { position: null, minWidth: 0, isDocumentElementRoot: getIsDocumentElementRoot() };\n }\n\n public componentDidMount() {\n this.position();\n this.layoutSub = LayoutEvents.addListener(this.position);\n }\n\n public componentWillUnmount() {\n if (this.layoutSub) {\n this.layoutSub.remove();\n }\n }\n\n public render() {\n let style: React.CSSProperties = {\n position: 'absolute',\n top: '0',\n };\n if (this.state.position) {\n const { top, bottom, left, right } = this.state.position;\n style = {\n ...style,\n top: top !== null ? top : undefined,\n bottom: bottom !== null ? bottom : undefined,\n left: left !== null ? left : undefined,\n right: right !== null ? right : undefined,\n minWidth: this.state.minWidth,\n maxWidth: this.props.hasFixedWidth ? this.state.minWidth : undefined,\n };\n }\n\n const content = (\n <ZIndex\n priority={'DropdownContainer'}\n wrapperRef={this.ZIndexRef}\n style={style}\n className={cx({\n [styles.alignRight()]: this.props.align === 'right' && !isIE11,\n })}\n >\n {this.props.children}\n </ZIndex>\n );\n\n return this.props.disablePortal ? content : <RenderContainer>{content}</RenderContainer>;\n }\n\n private ZIndexRef = (element: Nullable<HTMLDivElement>) => {\n this.dom = element;\n };\n\n private isElement = (node: Nullable<Element>): node is Element => {\n return node instanceof Element;\n };\n\n public position = () => {\n const target = this.props.getParent();\n const dom = this.dom;\n\n if (target && this.isElement(target) && dom) {\n const targetRect = target.getBoundingClientRect();\n const { body, documentElement: docEl } = document;\n\n if (!docEl) {\n throw Error('There is no \"documentElement\" in \"document\"');\n }\n\n const scrollX = window.pageXOffset || docEl.scrollLeft || 0;\n const scrollY = window.pageYOffset || docEl.scrollTop || 0;\n\n let left = null;\n let right = null;\n\n if (this.props.align === 'right') {\n const docWidth = docEl.offsetWidth || 0;\n right = docWidth - (targetRect.right + scrollX) + this.getProps().offsetX;\n } else {\n left = targetRect.left + scrollX + this.getProps().offsetX;\n }\n\n const { offsetY = 0 } = this.props;\n let bottom = null;\n let top: number | null = targetRect.bottom + scrollY + offsetY;\n\n const distanceToBottom = docEl.clientHeight - targetRect.bottom;\n const dropdownHeight = this.getHeight();\n\n if (distanceToBottom < dropdownHeight && targetRect.top > dropdownHeight) {\n const clientHeight = this.state.isDocumentElementRoot ? docEl.clientHeight : body.scrollHeight;\n\n top = null;\n bottom = clientHeight + offsetY - scrollY - targetRect.top;\n }\n\n const position = {\n top,\n left,\n right,\n bottom,\n };\n\n this.setState({\n minWidth: this.getMinWidth(),\n position: this.props.disablePortal ? this.convertToRelativePosition(position) : position,\n });\n }\n };\n\n private getHeight = () => {\n if (!this.isElement(this.dom)) {\n return 0;\n }\n const child = this.dom.children.item(0);\n if (!child) {\n return 0;\n }\n return child.getBoundingClientRect().height;\n };\n\n private getMinWidth = () => {\n const target = this.props.getParent();\n if (!target || !this.isElement(target)) {\n return 0;\n }\n return target.getBoundingClientRect().width;\n };\n\n private convertToRelativePosition = (position: DropdownContainerPosition): DropdownContainerPosition => {\n const target = this.props.getParent();\n const { offsetX = 0, offsetY = 0 } = this.props;\n const { top, bottom, left, right } = position;\n if (target && this.isElement(target)) {\n const targetHeight = target.getBoundingClientRect().height;\n return {\n top: top !== null ? targetHeight + offsetY : null,\n bottom: bottom !== null ? targetHeight + offsetY : null,\n left: left !== null ? offsetX : null,\n right: right !== null ? offsetX : null,\n };\n }\n return {\n top: offsetY,\n bottom: null,\n left: offsetX,\n right: null,\n };\n };\n}\n\nconst getIsDocumentElementRoot = () => {\n const { body, documentElement } = document;\n const htmlPosition = getComputedStyle(documentElement).position;\n const bodyPosition = getComputedStyle(body).position;\n\n const hasLimitedHeightRoot = body.scrollHeight > body.clientHeight;\n const hasStaticRoot = htmlPosition === 'static' && bodyPosition === 'static';\n return hasLimitedHeightRoot || hasStaticRoot;\n};\n"]}
|
|
@@ -46,14 +46,26 @@ export var DatePicker = rootNode(_class = (_temp = _class2 = /*#__PURE__*/functi
|
|
|
46
46
|
};
|
|
47
47
|
_this.input = null;
|
|
48
48
|
_this.focused = false;
|
|
49
|
-
_this.internalDate = _this.parseValueToDate(_this.props.value);
|
|
50
|
-
_this.minDate = _this.parseValueToDate(_this.props.minDate);
|
|
51
|
-
_this.maxDate = _this.parseValueToDate(_this.props.maxDate);
|
|
52
49
|
_this.setRootNode = void 0;
|
|
53
50
|
|
|
54
51
|
_this.renderMain = function (props) {
|
|
55
52
|
var picker = null;
|
|
56
|
-
var
|
|
53
|
+
var _this$props = _this.props,
|
|
54
|
+
value = _this$props.value,
|
|
55
|
+
minDate = _this$props.minDate,
|
|
56
|
+
maxDate = _this$props.maxDate;
|
|
57
|
+
|
|
58
|
+
var internalDate = _this.parseValueToDate(value);
|
|
59
|
+
|
|
60
|
+
var date = internalDate ? internalDate.toNativeFormat() : null;
|
|
61
|
+
|
|
62
|
+
var parsedMinDate = _this.parseValueToDate(minDate);
|
|
63
|
+
|
|
64
|
+
var formattedMinDate = parsedMinDate && parsedMinDate.toNativeFormat() || undefined;
|
|
65
|
+
|
|
66
|
+
var parsedMaxDate = _this.parseValueToDate(maxDate);
|
|
67
|
+
|
|
68
|
+
var formattedMaxDate = parsedMaxDate && parsedMaxDate.toNativeFormat() || undefined;
|
|
57
69
|
|
|
58
70
|
if (_this.state.opened) {
|
|
59
71
|
picker = /*#__PURE__*/React.createElement(DropdownContainer, {
|
|
@@ -62,8 +74,8 @@ export var DatePicker = rootNode(_class = (_temp = _class2 = /*#__PURE__*/functi
|
|
|
62
74
|
align: _this.props.menuAlign
|
|
63
75
|
}, /*#__PURE__*/React.createElement(Picker, {
|
|
64
76
|
value: date,
|
|
65
|
-
minDate:
|
|
66
|
-
maxDate:
|
|
77
|
+
minDate: formattedMinDate,
|
|
78
|
+
maxDate: formattedMaxDate,
|
|
67
79
|
onPick: _this.handlePick,
|
|
68
80
|
onSelect: _this.handleSelect,
|
|
69
81
|
enableTodayLink: _this.props.enableTodayLink,
|
|
@@ -195,20 +207,12 @@ export var DatePicker = rootNode(_class = (_temp = _class2 = /*#__PURE__*/functi
|
|
|
195
207
|
};
|
|
196
208
|
|
|
197
209
|
_proto.componentDidUpdate = function componentDidUpdate() {
|
|
198
|
-
var
|
|
199
|
-
disabled = _this$props.disabled,
|
|
200
|
-
value = _this$props.value,
|
|
201
|
-
minDate = _this$props.minDate,
|
|
202
|
-
maxDate = _this$props.maxDate;
|
|
210
|
+
var disabled = this.props.disabled;
|
|
203
211
|
var opened = this.state.opened;
|
|
204
212
|
|
|
205
213
|
if (disabled && opened) {
|
|
206
214
|
this.close();
|
|
207
215
|
}
|
|
208
|
-
|
|
209
|
-
this.internalDate = this.parseValueToDate(value);
|
|
210
|
-
this.minDate = this.parseValueToDate(minDate);
|
|
211
|
-
this.maxDate = this.parseValueToDate(maxDate);
|
|
212
216
|
}
|
|
213
217
|
/**
|
|
214
218
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DatePicker.tsx"],"names":["PropTypes","React","InternalDate","InternalDateTransformer","MAX_FULLDATE","MIN_FULLDATE","InternalDateOrder","InternalDateSeparator","InternalDateValidateCheck","DateInput","DropdownContainer","filterProps","CommonWrapper","isMobile","NativeDateInput","getRootNode","rootNode","isNonNullable","Picker","styles","INPUT_PASS_PROPS","autoFocus","disabled","warning","error","size","onKeyDown","MIN_WIDTH","DatePicker","state","opened","canUseMobileNativeDatePicker","input","focused","internalDate","parseValueToDate","props","value","minDate","maxDate","setRootNode","renderMain","picker","date","toNativeFormat","getParent","menuAlign","undefined","handlePick","handleSelect","enableTodayLink","isHoliday","root","getRootStyle","onMouseEnter","onMouseLeave","onMouseOver","getInputRef","handleBlur","handleFocus","onValueChange","width","minWidth","ref","setState","onFocus","close","onBlur","dateShape","blur","month","year","dateToInternalString","isWeekend","dateString","componentDidMount","useMobileNativeDatePicker","focus","componentDidUpdate","render","validate","checks","NotNull","Native","PureComponent","__KONTUR_REACT_UI__","propTypes","bool","string","isRequired","oneOf","oneOfType","number","func","defaultProps","_day","range","order","DMY","separator","Dot","setRangeStart","setRangeEnd","parseValue","Number","Limits","Range"],"mappings":"iPAAA,OAAOA,SAAP,MAAsB,YAAtB;AACA,OAAOC,KAAP,MAAkB,O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AI,CAAC3D,KAAL,EAAY,CACV,OAAO,KAAP,CACD,CAHuG,aAK7C2D,KAL6C,yBAKhG1D,OALgG,CAKhGA,OALgG,+BAKtFjC,YALsF,0CAKxEkC,OALwE,CAKxEA,OALwE,+BAK9DnC,YAL8D,kBAMxG,IAAM8B,YAAY,GAAG,IAAIhC,YAAJ,CAAiB,EACpC+F,KAAK,EAAE3F,iBAAiB,CAAC4F,GADW,EAEpCC,SAAS,EAAE5F,qBAAqB,CAAC6F,GAFG,EAAjB,EAIlBC,aAJkB,CAIJ,IAAInG,YAAJ,CAAiB,EAAEmC,KAAK,EAAEC,OAAT,EAAjB,CAJI,EAKlBgE,WALkB,CAKN,IAAIpG,YAAJ,CAAiB,EAAEmC,KAAK,EAAEE,OAAT,EAAjB,CALM,EAMlBgE,UANkB,CAMPlE,KANO,CAArB,CAQA,OAAOH,YAAY,CAAC8C,QAAb,CAAsB,EAC3BC,MAAM,EAAE,CACNzE,yBAAyB,CAAC0E,OADpB,EAEN1E,yBAAyB,CAACgG,MAFpB,EAGNhG,yBAAyB,CAAC2E,MAHpB,EAIN3E,yBAAyB,CAACiG,MAJpB,EAKNjG,yBAAyB,CAACkG,KALpB,CADmB,EAAtB,CAAP,CASD,CAlFH","sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nimport { InternalDate } from '../../lib/date/InternalDate';\nimport { InternalDateTransformer } from '../../lib/date/InternalDateTransformer';\nimport { MAX_FULLDATE, MIN_FULLDATE } from '../../lib/date/constants';\nimport { InternalDateOrder, InternalDateSeparator, InternalDateValidateCheck } from '../../lib/date/types';\nimport { Nullable } from '../../typings/utility-types';\nimport { CalendarDateShape } from '../../internal/Calendar';\nimport { DateInput } from '../DateInput';\nimport { DropdownContainer } from '../../internal/DropdownContainer';\nimport { filterProps } from '../../lib/filterProps';\nimport { CommonWrapper, CommonProps, CommonWrapperRestProps } from '../../internal/CommonWrapper';\nimport { isMobile } from '../../lib/client';\nimport { NativeDateInput } from '../../internal/NativeDateInput';\nimport { getRootNode, rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { isNonNullable } from '../../lib/utils';\n\nimport { Picker } from './Picker';\nimport { styles } from './DatePicker.styles';\n\nconst INPUT_PASS_PROPS = {\n autoFocus: true,\n disabled: true,\n warning: true,\n error: true,\n size: true,\n onKeyDown: true,\n};\n\nexport const MIN_WIDTH = 120;\n\nexport interface DatePickerProps<T> extends CommonProps {\n autoFocus?: boolean;\n disabled?: boolean;\n enableTodayLink?: boolean;\n /**\n * Cостояние валидации при ошибке.\n */\n error?: boolean;\n minDate: T;\n maxDate: T;\n menuAlign?: 'left' | 'right';\n size?: 'small' | 'medium' | 'large';\n value?: T | null;\n /**\n * Cостояние валидации при предупреждении.\n */\n warning?: boolean;\n width?: number | string;\n onBlur?: () => void;\n /**\n * Вызывается при изменении `value`\n *\n * @param value - строка в формате `dd.mm.yyyy`.\n */\n onValueChange: (value: T) => void;\n onFocus?: () => void;\n onKeyDown?: (e: React.KeyboardEvent<any>) => void;\n onMouseEnter?: (e: React.MouseEvent<any>) => void;\n onMouseLeave?: (e: React.MouseEvent<any>) => void;\n onMouseOver?: (e: React.MouseEvent<any>) => void;\n /**\n * Использовать на мобильных устройствах нативный календарь для выбора дат.\n *\n * - На iOS нативный календарь не умеет работать с minDate и maxDate\n */\n useMobileNativeDatePicker?: boolean;\n\n /**\n * Функция для определения праздничных дней\n * @default (_day, isWeekend) => isWeekend\n * @param {T} day - строка в формате `dd.mm.yyyy`\n * @param {boolean} isWeekend - флаг выходного (суббота или воскресенье)\n *\n * @returns {boolean} `true` для выходного или `false` для рабочего дня\n */\n isHoliday: (day: T, isWeekend: boolean) => boolean;\n}\n\nexport interface DatePickerState {\n opened: boolean;\n canUseMobileNativeDatePicker: boolean;\n}\n\ntype DatePickerValue = string;\n\n@rootNode\nexport class DatePicker extends React.PureComponent<DatePickerProps<DatePickerValue>, DatePickerState> {\n public static __KONTUR_REACT_UI__ = 'DatePicker';\n\n public static propTypes = {\n autoFocus: PropTypes.bool,\n\n disabled: PropTypes.bool,\n\n /**\n * Включает кнопку сегодня в календаре\n */\n enableTodayLink: PropTypes.bool,\n\n error: PropTypes.bool,\n\n /**\n * Максимальная дата в календаре.\n */\n maxDate: PropTypes.string.isRequired,\n\n menuAlign: PropTypes.oneOf(['left', 'right'] as Array<'left' | 'right'>),\n\n /**\n * Минимальная дата в календаре.\n */\n minDate: PropTypes.string.isRequired,\n\n /**\n * Строка формата `dd.mm.yyyy`\n */\n value: PropTypes.string,\n\n warning: PropTypes.bool,\n\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,\n\n onBlur: PropTypes.func,\n\n onValueChange: PropTypes.func.isRequired,\n\n onFocus: PropTypes.func,\n\n onKeyDown: PropTypes.func,\n\n onMouseEnter: PropTypes.func,\n\n onMouseLeave: PropTypes.func,\n\n onMouseOver: PropTypes.func,\n\n isHoliday: PropTypes.func.isRequired,\n };\n\n public static defaultProps = {\n minDate: MIN_FULLDATE,\n maxDate: MAX_FULLDATE,\n isHoliday: (_day: DatePickerValue, isWeekend: boolean) => isWeekend,\n };\n\n public static validate = (value: Nullable<string>, range: { minDate?: string; maxDate?: string } = {}) => {\n if (!value) {\n return false;\n }\n\n const { minDate = MIN_FULLDATE, maxDate = MAX_FULLDATE } = range;\n const internalDate = new InternalDate({\n order: InternalDateOrder.DMY,\n separator: InternalDateSeparator.Dot,\n })\n .setRangeStart(new InternalDate({ value: minDate }))\n .setRangeEnd(new InternalDate({ value: maxDate }))\n .parseValue(value);\n\n return internalDate.validate({\n checks: [\n InternalDateValidateCheck.NotNull,\n InternalDateValidateCheck.Number,\n InternalDateValidateCheck.Native,\n InternalDateValidateCheck.Limits,\n InternalDateValidateCheck.Range,\n ],\n });\n };\n\n public state: DatePickerState = { opened: false, canUseMobileNativeDatePicker: false };\n\n private input: DateInput | null = null;\n private focused = false;\n private internalDate?: InternalDate = this.parseValueToDate(this.props.value);\n private minDate?: InternalDate = this.parseValueToDate(this.props.minDate);\n private maxDate?: InternalDate = this.parseValueToDate(this.props.maxDate);\n private setRootNode!: TSetRootNode;\n\n public componentDidMount() {\n if (this.props.useMobileNativeDatePicker && isMobile) {\n this.setState({\n canUseMobileNativeDatePicker: true,\n });\n }\n if (this.props.autoFocus) {\n this.focus();\n }\n }\n\n public componentDidUpdate() {\n const { disabled, value, minDate, maxDate } = this.props;\n const { opened } = this.state;\n if (disabled && opened) {\n this.close();\n }\n this.internalDate = this.parseValueToDate(value);\n this.minDate = this.parseValueToDate(minDate);\n this.maxDate = this.parseValueToDate(maxDate);\n }\n\n /**\n * @public\n */\n public blur() {\n if (this.input) {\n this.input.blur();\n }\n this.handleBlur();\n }\n\n /**\n * @public\n */\n public focus() {\n if (this.props.disabled) {\n return;\n }\n if (this.input) {\n this.input.focus();\n }\n this.handleFocus();\n }\n\n /**\n * Закрывает выпадашку выбора дня\n * @public\n */\n public close() {\n this.setState({ opened: false });\n }\n\n public render() {\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n {this.renderMain}\n </CommonWrapper>\n );\n }\n\n public renderMain = (props: CommonWrapperRestProps<DatePickerProps<DatePickerValue>>) => {\n let picker = null;\n const date = this.internalDate ? this.internalDate.toNativeFormat() : null;\n if (this.state.opened) {\n picker = (\n <DropdownContainer getParent={this.getParent} offsetY={2} align={this.props.menuAlign}>\n <Picker\n value={date}\n minDate={(this.minDate && this.minDate.toNativeFormat()) || undefined}\n maxDate={(this.maxDate && this.maxDate.toNativeFormat()) || undefined}\n onPick={this.handlePick}\n onSelect={this.handleSelect}\n enableTodayLink={this.props.enableTodayLink}\n isHoliday={this.isHoliday}\n />\n </DropdownContainer>\n );\n }\n\n return (\n <label\n className={styles.root()}\n style={this.getRootStyle()}\n onMouseEnter={this.props.onMouseEnter}\n onMouseLeave={this.props.onMouseLeave}\n onMouseOver={this.props.onMouseOver}\n >\n <DateInput\n {...filterProps(props, INPUT_PASS_PROPS)}\n ref={this.getInputRef}\n value={this.props.value || ''}\n width=\"100%\"\n withIcon\n minDate={this.props.minDate}\n maxDate={this.props.maxDate}\n onBlur={this.handleBlur}\n onFocus={this.handleFocus}\n onValueChange={this.props.onValueChange}\n />\n {this.state.canUseMobileNativeDatePicker && (\n <NativeDateInput\n onValueChange={this.props.onValueChange}\n value={this.props.value || ''}\n minDate={this.props.minDate}\n maxDate={this.props.maxDate}\n disabled={this.props.disabled}\n />\n )}\n {!this.state.canUseMobileNativeDatePicker && picker}\n </label>\n );\n };\n\n public getParent = () => {\n return getRootNode(this);\n };\n\n private getRootStyle = () => {\n const { width } = this.props;\n return isNonNullable(width) ? { width } : { minWidth: MIN_WIDTH };\n };\n\n private getInputRef = (ref: DateInput | null) => {\n this.input = ref;\n };\n\n private parseValueToDate(value?: Nullable<string>): InternalDate | undefined {\n if (value === undefined || value === null) {\n return undefined;\n }\n const date = new InternalDate({ value });\n if (date.validate({ checks: [InternalDateValidateCheck.NotNull, InternalDateValidateCheck.Native] })) {\n return date;\n }\n return undefined;\n }\n\n private handleFocus = () => {\n if (this.focused) {\n return;\n }\n\n this.focused = true;\n\n this.setState({ opened: true });\n\n if (this.props.onFocus) {\n this.props.onFocus();\n }\n };\n\n private handleBlur = () => {\n if (!this.focused) {\n return;\n }\n\n this.focused = false;\n this.close();\n\n if (this.props.onBlur) {\n this.props.onBlur();\n }\n };\n\n private handlePick = (dateShape: CalendarDateShape) => {\n this.handleSelect(dateShape);\n this.blur();\n };\n\n private handleSelect = ({ date, month, year }: CalendarDateShape) => {\n const value = InternalDateTransformer.dateToInternalString({ date, month: month + 1, year });\n if (this.props.onValueChange) {\n this.props.onValueChange(value);\n }\n };\n\n private isHoliday = ({ date, month, year, isWeekend }: CalendarDateShape & { isWeekend: boolean }) => {\n const dateString = InternalDateTransformer.dateToInternalString({ date, month: month + 1, year });\n return this.props.isHoliday(dateString, isWeekend);\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["DatePicker.tsx"],"names":["PropTypes","React","InternalDate","InternalDateTransformer","MAX_FULLDATE","MIN_FULLDATE","InternalDateOrder","InternalDateSeparator","InternalDateValidateCheck","DateInput","DropdownContainer","filterProps","CommonWrapper","isMobile","NativeDateInput","getRootNode","rootNode","isNonNullable","Picker","styles","INPUT_PASS_PROPS","autoFocus","disabled","warning","error","size","onKeyDown","MIN_WIDTH","DatePicker","state","opened","canUseMobileNativeDatePicker","input","focused","setRootNode","renderMain","props","picker","value","minDate","maxDate","internalDate","parseValueToDate","date","toNativeFormat","parsedMinDate","formattedMinDate","undefined","parsedMaxDate","formattedMaxDate","getParent","menuAlign","handlePick","handleSelect","enableTodayLink","isHoliday","root","getRootStyle","onMouseEnter","onMouseLeave","onMouseOver","getInputRef","handleBlur","handleFocus","onValueChange","width","minWidth","ref","setState","onFocus","close","onBlur","dateShape","blur","month","year","dateToInternalString","isWeekend","dateString","componentDidMount","useMobileNativeDatePicker","focus","componentDidUpdate","render","validate","checks","NotNull","Native","PureComponent","__KONTUR_REACT_UI__","propTypes","bool","string","isRequired","oneOf","oneOfType","number","func","defaultProps","_day","range","order","DMY","separator","Dot","setRangeStart","setRangeEnd","parseValue","Number","Limits","Range"],"mappings":"iPAAA,OAAOA,SAAP,MAAsB,YAAtB;AACA,OAAOC,KAAP,MAAkB,OAAlB;;AAEA,SAASC,YAAT,QAA6B,6BAA7B;AACA,SAASC,uBAAT,QAAwC,wCAAxC;AACA,SAASC,YAAT,EAAuBC,YAAvB,QAA2C,0BAA3C;AACA,SAASC,iBAAT,EAA4BC,qBAA5B,EAAmDC,yBAAnD,QAAoF,sBAApF;;;AAGA,SAASC,SAAT,QAA0B,cAA1B;AACA,SAASC,iBAAT,QAAkC,kCAAlC;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC,aAAT,QAAmE,8BAAnE;AACA,SAASC,QAAT,QAAyB,kBAAzB;AACA,SAASC,eAAT,QAAgC,gCAAhC;AACA,SAASC,WAAT,EAAsBC,QAAtB,QAAoD,oBAApD;AACA,SAASC,aAAT,QAA8B,iBAA9B;;AAEA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BAAyB,CAAC+E,MAHpB,EAIN/E,yBAAyB,CAACqG,MAJpB,EAKNrG,yBAAyB,CAACsG,KALpB,CADmB,EAAtB,CAAP,CASD,CAlFH","sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nimport { InternalDate } from '../../lib/date/InternalDate';\nimport { InternalDateTransformer } from '../../lib/date/InternalDateTransformer';\nimport { MAX_FULLDATE, MIN_FULLDATE } from '../../lib/date/constants';\nimport { InternalDateOrder, InternalDateSeparator, InternalDateValidateCheck } from '../../lib/date/types';\nimport { Nullable } from '../../typings/utility-types';\nimport { CalendarDateShape } from '../../internal/Calendar';\nimport { DateInput } from '../DateInput';\nimport { DropdownContainer } from '../../internal/DropdownContainer';\nimport { filterProps } from '../../lib/filterProps';\nimport { CommonWrapper, CommonProps, CommonWrapperRestProps } from '../../internal/CommonWrapper';\nimport { isMobile } from '../../lib/client';\nimport { NativeDateInput } from '../../internal/NativeDateInput';\nimport { getRootNode, rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { isNonNullable } from '../../lib/utils';\n\nimport { Picker } from './Picker';\nimport { styles } from './DatePicker.styles';\n\nconst INPUT_PASS_PROPS = {\n autoFocus: true,\n disabled: true,\n warning: true,\n error: true,\n size: true,\n onKeyDown: true,\n};\n\nexport const MIN_WIDTH = 120;\n\nexport interface DatePickerProps<T> extends CommonProps {\n autoFocus?: boolean;\n disabled?: boolean;\n enableTodayLink?: boolean;\n /**\n * Cостояние валидации при ошибке.\n */\n error?: boolean;\n minDate: T;\n maxDate: T;\n menuAlign?: 'left' | 'right';\n size?: 'small' | 'medium' | 'large';\n value?: T | null;\n /**\n * Cостояние валидации при предупреждении.\n */\n warning?: boolean;\n width?: number | string;\n onBlur?: () => void;\n /**\n * Вызывается при изменении `value`\n *\n * @param value - строка в формате `dd.mm.yyyy`.\n */\n onValueChange: (value: T) => void;\n onFocus?: () => void;\n onKeyDown?: (e: React.KeyboardEvent<any>) => void;\n onMouseEnter?: (e: React.MouseEvent<any>) => void;\n onMouseLeave?: (e: React.MouseEvent<any>) => void;\n onMouseOver?: (e: React.MouseEvent<any>) => void;\n /**\n * Использовать на мобильных устройствах нативный календарь для выбора дат.\n *\n * - На iOS нативный календарь не умеет работать с minDate и maxDate\n */\n useMobileNativeDatePicker?: boolean;\n\n /**\n * Функция для определения праздничных дней\n * @default (_day, isWeekend) => isWeekend\n * @param {T} day - строка в формате `dd.mm.yyyy`\n * @param {boolean} isWeekend - флаг выходного (суббота или воскресенье)\n *\n * @returns {boolean} `true` для выходного или `false` для рабочего дня\n */\n isHoliday: (day: T, isWeekend: boolean) => boolean;\n}\n\nexport interface DatePickerState {\n opened: boolean;\n canUseMobileNativeDatePicker: boolean;\n}\n\ntype DatePickerValue = string;\n\n@rootNode\nexport class DatePicker extends React.PureComponent<DatePickerProps<DatePickerValue>, DatePickerState> {\n public static __KONTUR_REACT_UI__ = 'DatePicker';\n\n public static propTypes = {\n autoFocus: PropTypes.bool,\n\n disabled: PropTypes.bool,\n\n /**\n * Включает кнопку сегодня в календаре\n */\n enableTodayLink: PropTypes.bool,\n\n error: PropTypes.bool,\n\n /**\n * Максимальная дата в календаре.\n */\n maxDate: PropTypes.string.isRequired,\n\n menuAlign: PropTypes.oneOf(['left', 'right'] as Array<'left' | 'right'>),\n\n /**\n * Минимальная дата в календаре.\n */\n minDate: PropTypes.string.isRequired,\n\n /**\n * Строка формата `dd.mm.yyyy`\n */\n value: PropTypes.string,\n\n warning: PropTypes.bool,\n\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,\n\n onBlur: PropTypes.func,\n\n onValueChange: PropTypes.func.isRequired,\n\n onFocus: PropTypes.func,\n\n onKeyDown: PropTypes.func,\n\n onMouseEnter: PropTypes.func,\n\n onMouseLeave: PropTypes.func,\n\n onMouseOver: PropTypes.func,\n\n isHoliday: PropTypes.func.isRequired,\n };\n\n public static defaultProps = {\n minDate: MIN_FULLDATE,\n maxDate: MAX_FULLDATE,\n isHoliday: (_day: DatePickerValue, isWeekend: boolean) => isWeekend,\n };\n\n public static validate = (value: Nullable<string>, range: { minDate?: string; maxDate?: string } = {}) => {\n if (!value) {\n return false;\n }\n\n const { minDate = MIN_FULLDATE, maxDate = MAX_FULLDATE } = range;\n const internalDate = new InternalDate({\n order: InternalDateOrder.DMY,\n separator: InternalDateSeparator.Dot,\n })\n .setRangeStart(new InternalDate({ value: minDate }))\n .setRangeEnd(new InternalDate({ value: maxDate }))\n .parseValue(value);\n\n return internalDate.validate({\n checks: [\n InternalDateValidateCheck.NotNull,\n InternalDateValidateCheck.Number,\n InternalDateValidateCheck.Native,\n InternalDateValidateCheck.Limits,\n InternalDateValidateCheck.Range,\n ],\n });\n };\n\n public state: DatePickerState = { opened: false, canUseMobileNativeDatePicker: false };\n\n private input: DateInput | null = null;\n private focused = false;\n private setRootNode!: TSetRootNode;\n\n public componentDidMount() {\n if (this.props.useMobileNativeDatePicker && isMobile) {\n this.setState({\n canUseMobileNativeDatePicker: true,\n });\n }\n if (this.props.autoFocus) {\n this.focus();\n }\n }\n\n public componentDidUpdate() {\n const { disabled } = this.props;\n const { opened } = this.state;\n if (disabled && opened) {\n this.close();\n }\n }\n\n /**\n * @public\n */\n public blur() {\n if (this.input) {\n this.input.blur();\n }\n this.handleBlur();\n }\n\n /**\n * @public\n */\n public focus() {\n if (this.props.disabled) {\n return;\n }\n if (this.input) {\n this.input.focus();\n }\n this.handleFocus();\n }\n\n /**\n * Закрывает выпадашку выбора дня\n * @public\n */\n public close() {\n this.setState({ opened: false });\n }\n\n public render() {\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n {this.renderMain}\n </CommonWrapper>\n );\n }\n\n public renderMain = (props: CommonWrapperRestProps<DatePickerProps<DatePickerValue>>) => {\n let picker = null;\n\n const { value, minDate, maxDate } = this.props;\n\n const internalDate = this.parseValueToDate(value);\n const date = internalDate ? internalDate.toNativeFormat() : null;\n\n const parsedMinDate = this.parseValueToDate(minDate);\n const formattedMinDate = (parsedMinDate && parsedMinDate.toNativeFormat()) || undefined;\n\n const parsedMaxDate = this.parseValueToDate(maxDate);\n const formattedMaxDate = (parsedMaxDate && parsedMaxDate.toNativeFormat()) || undefined;\n\n if (this.state.opened) {\n picker = (\n <DropdownContainer getParent={this.getParent} offsetY={2} align={this.props.menuAlign}>\n <Picker\n value={date}\n minDate={formattedMinDate}\n maxDate={formattedMaxDate}\n onPick={this.handlePick}\n onSelect={this.handleSelect}\n enableTodayLink={this.props.enableTodayLink}\n isHoliday={this.isHoliday}\n />\n </DropdownContainer>\n );\n }\n\n return (\n <label\n className={styles.root()}\n style={this.getRootStyle()}\n onMouseEnter={this.props.onMouseEnter}\n onMouseLeave={this.props.onMouseLeave}\n onMouseOver={this.props.onMouseOver}\n >\n <DateInput\n {...filterProps(props, INPUT_PASS_PROPS)}\n ref={this.getInputRef}\n value={this.props.value || ''}\n width=\"100%\"\n withIcon\n minDate={this.props.minDate}\n maxDate={this.props.maxDate}\n onBlur={this.handleBlur}\n onFocus={this.handleFocus}\n onValueChange={this.props.onValueChange}\n />\n {this.state.canUseMobileNativeDatePicker && (\n <NativeDateInput\n onValueChange={this.props.onValueChange}\n value={this.props.value || ''}\n minDate={this.props.minDate}\n maxDate={this.props.maxDate}\n disabled={this.props.disabled}\n />\n )}\n {!this.state.canUseMobileNativeDatePicker && picker}\n </label>\n );\n };\n\n public getParent = () => {\n return getRootNode(this);\n };\n\n private getRootStyle = () => {\n const { width } = this.props;\n return isNonNullable(width) ? { width } : { minWidth: MIN_WIDTH };\n };\n\n private getInputRef = (ref: DateInput | null) => {\n this.input = ref;\n };\n\n private parseValueToDate(value?: Nullable<string>): InternalDate | undefined {\n if (value === undefined || value === null) {\n return undefined;\n }\n const date = new InternalDate({ value });\n if (date.validate({ checks: [InternalDateValidateCheck.NotNull, InternalDateValidateCheck.Native] })) {\n return date;\n }\n return undefined;\n }\n\n private handleFocus = () => {\n if (this.focused) {\n return;\n }\n\n this.focused = true;\n\n this.setState({ opened: true });\n\n if (this.props.onFocus) {\n this.props.onFocus();\n }\n };\n\n private handleBlur = () => {\n if (!this.focused) {\n return;\n }\n\n this.focused = false;\n this.close();\n\n if (this.props.onBlur) {\n this.props.onBlur();\n }\n };\n\n private handlePick = (dateShape: CalendarDateShape) => {\n this.handleSelect(dateShape);\n this.blur();\n };\n\n private handleSelect = ({ date, month, year }: CalendarDateShape) => {\n const value = InternalDateTransformer.dateToInternalString({ date, month: month + 1, year });\n if (this.props.onValueChange) {\n this.props.onValueChange(value);\n }\n };\n\n private isHoliday = ({ date, month, year, isWeekend }: CalendarDateShape & { isWeekend: boolean }) => {\n const dateString = InternalDateTransformer.dateToInternalString({ date, month: month + 1, year });\n return this.props.isHoliday(dateString, isWeekend);\n };\n}\n"]}
|
|
@@ -100,9 +100,6 @@ export declare class DatePicker extends React.PureComponent<DatePickerProps<Date
|
|
|
100
100
|
state: DatePickerState;
|
|
101
101
|
private input;
|
|
102
102
|
private focused;
|
|
103
|
-
private internalDate?;
|
|
104
|
-
private minDate?;
|
|
105
|
-
private maxDate?;
|
|
106
103
|
private setRootNode;
|
|
107
104
|
componentDidMount(): void;
|
|
108
105
|
componentDidUpdate(): void;
|
|
@@ -11,19 +11,10 @@ import { styles } from "../DropdownContainer.styles";
|
|
|
11
11
|
export var DropdownContainer = /*#__PURE__*/function (_React$PureComponent) {
|
|
12
12
|
_inheritsLoose(DropdownContainer, _React$PureComponent);
|
|
13
13
|
|
|
14
|
-
function DropdownContainer() {
|
|
14
|
+
function DropdownContainer(props) {
|
|
15
15
|
var _this;
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
args[_key] = arguments[_key];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
_this = _React$PureComponent.call.apply(_React$PureComponent, [this].concat(args)) || this;
|
|
22
|
-
_this.state = {
|
|
23
|
-
position: null,
|
|
24
|
-
minWidth: 0,
|
|
25
|
-
isDocumentElementRoot: true
|
|
26
|
-
};
|
|
17
|
+
_this = _React$PureComponent.call(this, props) || this;
|
|
27
18
|
_this.getProps = createPropsGetter(DropdownContainer.defaultProps);
|
|
28
19
|
_this.dom = void 0;
|
|
29
20
|
_this.layoutSub = void 0;
|
|
@@ -146,6 +137,11 @@ export var DropdownContainer = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
146
137
|
};
|
|
147
138
|
};
|
|
148
139
|
|
|
140
|
+
_this.state = {
|
|
141
|
+
position: null,
|
|
142
|
+
minWidth: 0,
|
|
143
|
+
isDocumentElementRoot: getIsDocumentElementRoot()
|
|
144
|
+
};
|
|
149
145
|
return _this;
|
|
150
146
|
}
|
|
151
147
|
|
|
@@ -154,16 +150,6 @@ export var DropdownContainer = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
154
150
|
_proto.componentDidMount = function componentDidMount() {
|
|
155
151
|
this.position();
|
|
156
152
|
this.layoutSub = LayoutEvents.addListener(this.position);
|
|
157
|
-
var _document2 = document,
|
|
158
|
-
body = _document2.body,
|
|
159
|
-
docEl = _document2.documentElement;
|
|
160
|
-
var htmlPosition = getComputedStyle(docEl).position;
|
|
161
|
-
var bodyPosition = getComputedStyle(body).position;
|
|
162
|
-
var hasLimitedHeightRoot = body.scrollHeight > body.clientHeight;
|
|
163
|
-
var hasStaticRoot = htmlPosition === 'static' && bodyPosition === 'static';
|
|
164
|
-
this.setState({
|
|
165
|
-
isDocumentElementRoot: hasLimitedHeightRoot || hasStaticRoot
|
|
166
|
-
});
|
|
167
153
|
};
|
|
168
154
|
|
|
169
155
|
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
@@ -213,4 +199,15 @@ DropdownContainer.defaultProps = {
|
|
|
213
199
|
disablePortal: false,
|
|
214
200
|
offsetX: 0,
|
|
215
201
|
offsetY: -1
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
var getIsDocumentElementRoot = function getIsDocumentElementRoot() {
|
|
205
|
+
var _document2 = document,
|
|
206
|
+
body = _document2.body,
|
|
207
|
+
documentElement = _document2.documentElement;
|
|
208
|
+
var htmlPosition = getComputedStyle(documentElement).position;
|
|
209
|
+
var bodyPosition = getComputedStyle(body).position;
|
|
210
|
+
var hasLimitedHeightRoot = body.scrollHeight > body.clientHeight;
|
|
211
|
+
var hasStaticRoot = htmlPosition === 'static' && bodyPosition === 'static';
|
|
212
|
+
return hasLimitedHeightRoot || hasStaticRoot;
|
|
216
213
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DropdownContainer.tsx"],"names":["React","LayoutEvents","RenderContainer","ZIndex","createPropsGetter","cx","isIE11","styles","DropdownContainer","state","position","minWidth","isDocumentElementRoot","getProps","defaultProps","dom","layoutSub","ZIndexRef","element","isElement","node","Element","target","props","getParent","targetRect","getBoundingClientRect","document","body","docEl","documentElement","Error","scrollX","window","pageXOffset","scrollLeft","scrollY","pageYOffset","scrollTop","left","right","align","docWidth","offsetWidth","offsetX","offsetY","bottom","top","distanceToBottom","clientHeight","dropdownHeight","getHeight","scrollHeight","setState","getMinWidth","disablePortal","convertToRelativePosition","child","children","item","height","width","targetHeight","componentDidMount","addListener","htmlPosition","getComputedStyle","bodyPosition","hasLimitedHeightRoot","hasStaticRoot","componentWillUnmount","remove","render","style","undefined","maxWidth","hasFixedWidth","content","alignRight","PureComponent","__KONTUR_REACT_UI__"],"mappings":"gIAAA,OAAOA,KAAP,MAAkB,OAAlB;;AAEA,OAAO,KAAKC,YAAZ,MAA8B,wBAA9B;AACA,SAASC,eAAT,QAAgC,oBAAhC;AACA,SAASC,MAAT,QAAuB,WAAvB;AACA,SAASC,iBAAT,QAAkC,6BAAlC;;AAEA,SAASC,EAAT,QAAmB,2BAAnB;AACA,SAASC,MAAT,QAAuB,kBAAvB;;AAEA,SAASC,MAAT,QAAuB,4BAAvB;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,WAAaC,iBAAb;;;;;;;;;;AAUSC,IAAAA,KAVT,GAUyC;AACrCC,MAAAA,QAAQ,EAAE,IAD2B;AAErCC,MAAAA,QAAQ,EAAE,CAF2B;AAGrCC,MA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,EAC3B2B,KAAK,EAAE,MADoB,EAE3Bc,aAAa,EAAE,KAFY,EAG3BX,OAAO,EAAE,CAHkB,EAI3BC,OAAO,EAAE,CAAC,CAJiB,E","sourcesContent":["import React from 'react';\n\nimport * as LayoutEvents from '../../lib/LayoutEvents';\nimport { RenderContainer } from '../RenderContainer';\nimport { ZIndex } from '../ZIndex';\nimport { createPropsGetter } from '../../lib/createPropsGetter';\nimport { Nullable } from '../../typings/utility-types';\nimport { cx } from '../../lib/theming/Emotion';\nimport { isIE11 } from '../../lib/client';\n\nimport { styles } from './DropdownContainer.styles';\n\nexport interface DropdownContainerPosition {\n top: Nullable<number>;\n bottom: Nullable<number>;\n left: Nullable<number>;\n right: Nullable<number>;\n}\n\nexport interface DropdownContainerProps {\n align?: 'left' | 'right';\n getParent: () => Nullable<HTMLElement>;\n children?: React.ReactNode;\n disablePortal?: boolean;\n offsetY?: number;\n offsetX?: number;\n hasFixedWidth?: boolean;\n}\n\nexport interface DropdownContainerState {\n position: Nullable<DropdownContainerPosition>;\n minWidth: number;\n isDocumentElementRoot?: boolean;\n}\n\nexport class DropdownContainer extends React.PureComponent<DropdownContainerProps, DropdownContainerState> {\n public static __KONTUR_REACT_UI__ = 'DropdownContainer';\n\n public static defaultProps = {\n align: 'left',\n disablePortal: false,\n offsetX: 0,\n offsetY: -1,\n };\n\n public state: DropdownContainerState = {\n position: null,\n minWidth: 0,\n isDocumentElementRoot: true,\n };\n\n private getProps = createPropsGetter(DropdownContainer.defaultProps);\n\n private dom: Nullable<HTMLDivElement>;\n private layoutSub: Nullable<ReturnType<typeof LayoutEvents.addListener>>;\n\n public componentDidMount() {\n this.position();\n this.layoutSub = LayoutEvents.addListener(this.position);\n\n const { body, documentElement: docEl } = document;\n const htmlPosition = getComputedStyle(docEl).position;\n const bodyPosition = getComputedStyle(body).position;\n\n const hasLimitedHeightRoot = body.scrollHeight > body.clientHeight;\n const hasStaticRoot = htmlPosition === 'static' && bodyPosition === 'static';\n\n this.setState({ isDocumentElementRoot: hasLimitedHeightRoot || hasStaticRoot });\n }\n\n public componentWillUnmount() {\n if (this.layoutSub) {\n this.layoutSub.remove();\n }\n }\n\n public render() {\n let style: React.CSSProperties = {\n position: 'absolute',\n top: '0',\n };\n if (this.state.position) {\n const { top, bottom, left, right } = this.state.position;\n style = {\n ...style,\n top: top !== null ? top : undefined,\n bottom: bottom !== null ? bottom : undefined,\n left: left !== null ? left : undefined,\n right: right !== null ? right : undefined,\n minWidth: this.state.minWidth,\n maxWidth: this.props.hasFixedWidth ? this.state.minWidth : undefined,\n };\n }\n\n const content = (\n <ZIndex\n priority={'DropdownContainer'}\n wrapperRef={this.ZIndexRef}\n style={style}\n className={cx({\n [styles.alignRight()]: this.props.align === 'right' && !isIE11,\n })}\n >\n {this.props.children}\n </ZIndex>\n );\n\n return this.props.disablePortal ? content : <RenderContainer>{content}</RenderContainer>;\n }\n\n private ZIndexRef = (element: Nullable<HTMLDivElement>) => {\n this.dom = element;\n };\n\n private isElement = (node: Nullable<Element>): node is Element => {\n return node instanceof Element;\n };\n\n public position = () => {\n const target = this.props.getParent();\n const dom = this.dom;\n\n if (target && this.isElement(target) && dom) {\n const targetRect = target.getBoundingClientRect();\n const { body, documentElement: docEl } = document;\n\n if (!docEl) {\n throw Error('There is no \"documentElement\" in \"document\"');\n }\n\n const scrollX = window.pageXOffset || docEl.scrollLeft || 0;\n const scrollY = window.pageYOffset || docEl.scrollTop || 0;\n\n let left = null;\n let right = null;\n\n if (this.props.align === 'right') {\n const docWidth = docEl.offsetWidth || 0;\n right = docWidth - (targetRect.right + scrollX) + this.getProps().offsetX;\n } else {\n left = targetRect.left + scrollX + this.getProps().offsetX;\n }\n\n const { offsetY = 0 } = this.props;\n let bottom = null;\n let top: number | null = targetRect.bottom + scrollY + offsetY;\n\n const distanceToBottom = docEl.clientHeight - targetRect.bottom;\n const dropdownHeight = this.getHeight();\n\n if (distanceToBottom < dropdownHeight && targetRect.top > dropdownHeight) {\n const clientHeight = this.state.isDocumentElementRoot ? docEl.clientHeight : body.scrollHeight;\n\n top = null;\n bottom = clientHeight + offsetY - scrollY - targetRect.top;\n }\n\n const position = {\n top,\n left,\n right,\n bottom,\n };\n\n this.setState({\n minWidth: this.getMinWidth(),\n position: this.props.disablePortal ? this.convertToRelativePosition(position) : position,\n });\n }\n };\n\n private getHeight = () => {\n if (!this.isElement(this.dom)) {\n return 0;\n }\n const child = this.dom.children.item(0);\n if (!child) {\n return 0;\n }\n return child.getBoundingClientRect().height;\n };\n\n private getMinWidth = () => {\n const target = this.props.getParent();\n if (!target || !this.isElement(target)) {\n return 0;\n }\n return target.getBoundingClientRect().width;\n };\n\n private convertToRelativePosition = (position: DropdownContainerPosition): DropdownContainerPosition => {\n const target = this.props.getParent();\n const { offsetX = 0, offsetY = 0 } = this.props;\n const { top, bottom, left, right } = position;\n if (target && this.isElement(target)) {\n const targetHeight = target.getBoundingClientRect().height;\n return {\n top: top !== null ? targetHeight + offsetY : null,\n bottom: bottom !== null ? targetHeight + offsetY : null,\n left: left !== null ? offsetX : null,\n right: right !== null ? offsetX : null,\n };\n }\n return {\n top: offsetY,\n bottom: null,\n left: offsetX,\n right: null,\n };\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["DropdownContainer.tsx"],"names":["React","LayoutEvents","RenderContainer","ZIndex","createPropsGetter","cx","isIE11","styles","DropdownContainer","props","getProps","defaultProps","dom","layoutSub","ZIndexRef","element","isElement","node","Element","position","target","getParent","targetRect","getBoundingClientRect","document","body","docEl","documentElement","Error","scrollX","window","pageXOffset","scrollLeft","scrollY","pageYOffset","scrollTop","left","right","align","docWidth","offsetWidth","offsetX","offsetY","bottom","top","distanceToBottom","clientHeight","dropdownHeight","getHeight","state","isDocumentElementRoot","scrollHeight","setState","minWidth","getMinWidth","disablePortal","convertToRelativePosition","child","children","item","height","width","targetHeight","getIsDocumentElementRoot","componentDidMount","addListener","componentWillUnmount","remove","render","style","undefined","maxWidth","hasFixedWidth","content","alignRight","PureComponent","__KONTUR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CAA5C,CACD,CAhEH,4BAAuCzE,KAAK,CAAC2E,aAA7C,EAAanE,iB,CACGoE,mB,GAAsB,mB,CADzBpE,iB,CAGGG,Y,GAAe,EAC3B2B,KAAK,EAAE,MADoB,EAE3BiB,aAAa,EAAE,KAFY,EAG3Bd,OAAO,EAAE,CAHkB,EAI3BC,OAAO,EAAE,CAAC,CAJiB,E;;;AAqK/B,IAAMqB,wBAAwB,GAAG,SAA3BA,wBAA2B,GAAM;AACHvC,EAAAA,QADG,CAC7BC,IAD6B,cAC7BA,IAD6B,CACvBE,eADuB,cACvBA,eADuB;AAErC,MAAMkD,YAAY,GAAGC,gBAAgB,CAACnD,eAAD,CAAhB,CAAkCR,QAAvD;AACA,MAAM4D,YAAY,GAAGD,gBAAgB,CAACrD,IAAD,CAAhB,CAAuBN,QAA5C;;AAEA,MAAM6D,oBAAoB,GAAGvD,IAAI,CAAC0B,YAAL,GAAoB1B,IAAI,CAACqB,YAAtD;AACA,MAAMmC,aAAa,GAAGJ,YAAY,KAAK,QAAjB,IAA6BE,YAAY,KAAK,QAApE;AACA,SAAOC,oBAAoB,IAAIC,aAA/B;AACD,CARD","sourcesContent":["import React from 'react';\n\nimport * as LayoutEvents from '../../lib/LayoutEvents';\nimport { RenderContainer } from '../RenderContainer';\nimport { ZIndex } from '../ZIndex';\nimport { createPropsGetter } from '../../lib/createPropsGetter';\nimport { Nullable } from '../../typings/utility-types';\nimport { cx } from '../../lib/theming/Emotion';\nimport { isIE11 } from '../../lib/client';\n\nimport { styles } from './DropdownContainer.styles';\n\nexport interface DropdownContainerPosition {\n top: Nullable<number>;\n bottom: Nullable<number>;\n left: Nullable<number>;\n right: Nullable<number>;\n}\n\nexport interface DropdownContainerProps {\n align?: 'left' | 'right';\n getParent: () => Nullable<HTMLElement>;\n children?: React.ReactNode;\n disablePortal?: boolean;\n offsetY?: number;\n offsetX?: number;\n hasFixedWidth?: boolean;\n}\n\nexport interface DropdownContainerState {\n position: Nullable<DropdownContainerPosition>;\n minWidth: number;\n isDocumentElementRoot?: boolean;\n}\n\nexport class DropdownContainer extends React.PureComponent<DropdownContainerProps, DropdownContainerState> {\n public static __KONTUR_REACT_UI__ = 'DropdownContainer';\n\n public static defaultProps = {\n align: 'left',\n disablePortal: false,\n offsetX: 0,\n offsetY: -1,\n };\n\n private getProps = createPropsGetter(DropdownContainer.defaultProps);\n\n private dom: Nullable<HTMLDivElement>;\n private layoutSub: Nullable<ReturnType<typeof LayoutEvents.addListener>>;\n\n constructor(props: DropdownContainerProps) {\n super(props);\n\n this.state = { position: null, minWidth: 0, isDocumentElementRoot: getIsDocumentElementRoot() };\n }\n\n public componentDidMount() {\n this.position();\n this.layoutSub = LayoutEvents.addListener(this.position);\n }\n\n public componentWillUnmount() {\n if (this.layoutSub) {\n this.layoutSub.remove();\n }\n }\n\n public render() {\n let style: React.CSSProperties = {\n position: 'absolute',\n top: '0',\n };\n if (this.state.position) {\n const { top, bottom, left, right } = this.state.position;\n style = {\n ...style,\n top: top !== null ? top : undefined,\n bottom: bottom !== null ? bottom : undefined,\n left: left !== null ? left : undefined,\n right: right !== null ? right : undefined,\n minWidth: this.state.minWidth,\n maxWidth: this.props.hasFixedWidth ? this.state.minWidth : undefined,\n };\n }\n\n const content = (\n <ZIndex\n priority={'DropdownContainer'}\n wrapperRef={this.ZIndexRef}\n style={style}\n className={cx({\n [styles.alignRight()]: this.props.align === 'right' && !isIE11,\n })}\n >\n {this.props.children}\n </ZIndex>\n );\n\n return this.props.disablePortal ? content : <RenderContainer>{content}</RenderContainer>;\n }\n\n private ZIndexRef = (element: Nullable<HTMLDivElement>) => {\n this.dom = element;\n };\n\n private isElement = (node: Nullable<Element>): node is Element => {\n return node instanceof Element;\n };\n\n public position = () => {\n const target = this.props.getParent();\n const dom = this.dom;\n\n if (target && this.isElement(target) && dom) {\n const targetRect = target.getBoundingClientRect();\n const { body, documentElement: docEl } = document;\n\n if (!docEl) {\n throw Error('There is no \"documentElement\" in \"document\"');\n }\n\n const scrollX = window.pageXOffset || docEl.scrollLeft || 0;\n const scrollY = window.pageYOffset || docEl.scrollTop || 0;\n\n let left = null;\n let right = null;\n\n if (this.props.align === 'right') {\n const docWidth = docEl.offsetWidth || 0;\n right = docWidth - (targetRect.right + scrollX) + this.getProps().offsetX;\n } else {\n left = targetRect.left + scrollX + this.getProps().offsetX;\n }\n\n const { offsetY = 0 } = this.props;\n let bottom = null;\n let top: number | null = targetRect.bottom + scrollY + offsetY;\n\n const distanceToBottom = docEl.clientHeight - targetRect.bottom;\n const dropdownHeight = this.getHeight();\n\n if (distanceToBottom < dropdownHeight && targetRect.top > dropdownHeight) {\n const clientHeight = this.state.isDocumentElementRoot ? docEl.clientHeight : body.scrollHeight;\n\n top = null;\n bottom = clientHeight + offsetY - scrollY - targetRect.top;\n }\n\n const position = {\n top,\n left,\n right,\n bottom,\n };\n\n this.setState({\n minWidth: this.getMinWidth(),\n position: this.props.disablePortal ? this.convertToRelativePosition(position) : position,\n });\n }\n };\n\n private getHeight = () => {\n if (!this.isElement(this.dom)) {\n return 0;\n }\n const child = this.dom.children.item(0);\n if (!child) {\n return 0;\n }\n return child.getBoundingClientRect().height;\n };\n\n private getMinWidth = () => {\n const target = this.props.getParent();\n if (!target || !this.isElement(target)) {\n return 0;\n }\n return target.getBoundingClientRect().width;\n };\n\n private convertToRelativePosition = (position: DropdownContainerPosition): DropdownContainerPosition => {\n const target = this.props.getParent();\n const { offsetX = 0, offsetY = 0 } = this.props;\n const { top, bottom, left, right } = position;\n if (target && this.isElement(target)) {\n const targetHeight = target.getBoundingClientRect().height;\n return {\n top: top !== null ? targetHeight + offsetY : null,\n bottom: bottom !== null ? targetHeight + offsetY : null,\n left: left !== null ? offsetX : null,\n right: right !== null ? offsetX : null,\n };\n }\n return {\n top: offsetY,\n bottom: null,\n left: offsetX,\n right: null,\n };\n };\n}\n\nconst getIsDocumentElementRoot = () => {\n const { body, documentElement } = document;\n const htmlPosition = getComputedStyle(documentElement).position;\n const bodyPosition = getComputedStyle(body).position;\n\n const hasLimitedHeightRoot = body.scrollHeight > body.clientHeight;\n const hasStaticRoot = htmlPosition === 'static' && bodyPosition === 'static';\n return hasLimitedHeightRoot || hasStaticRoot;\n};\n"]}
|
|
@@ -28,10 +28,10 @@ export declare class DropdownContainer extends React.PureComponent<DropdownConta
|
|
|
28
28
|
offsetX: number;
|
|
29
29
|
offsetY: number;
|
|
30
30
|
};
|
|
31
|
-
state: DropdownContainerState;
|
|
32
31
|
private getProps;
|
|
33
32
|
private dom;
|
|
34
33
|
private layoutSub;
|
|
34
|
+
constructor(props: DropdownContainerProps);
|
|
35
35
|
componentDidMount(): void;
|
|
36
36
|
componentWillUnmount(): void;
|
|
37
37
|
render(): JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skbkontur/react-ui",
|
|
3
|
-
"version": "3.12.
|
|
3
|
+
"version": "3.12.2",
|
|
4
4
|
"description": "UI Components",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "index.js",
|
|
7
7
|
"sideEffects": false,
|
|
8
|
-
"homepage": "https://tech.skbkontur.ru/react-ui/3.12.
|
|
8
|
+
"homepage": "https://tech.skbkontur.ru/react-ui/3.12.2/",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "git@github.com:skbkontur/retail-ui.git"
|