@skbkontur/react-ui 4.1.1 → 4.1.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 +19 -0
- package/cjs/components/Checkbox/Checkbox.d.ts +5 -0
- package/cjs/components/Checkbox/Checkbox.js +29 -1
- package/cjs/components/Checkbox/Checkbox.js.map +1 -1
- package/cjs/components/Checkbox/Checkbox.styles.d.ts +1 -0
- package/cjs/components/Checkbox/Checkbox.styles.js +23 -17
- package/cjs/components/Checkbox/Checkbox.styles.js.map +1 -1
- package/cjs/components/DateInput/DateInput.js +5 -1
- package/cjs/components/DateInput/DateInput.js.map +1 -1
- package/cjs/components/DateInput/helpers/InternalDateMediator.d.ts +2 -2
- package/cjs/components/DateInput/helpers/InternalDateMediator.js +7 -3
- package/cjs/components/DateInput/helpers/InternalDateMediator.js.map +1 -1
- package/cjs/components/DateInput/helpers/inputNumber.d.ts +1 -1
- package/cjs/components/DateInput/helpers/inputNumber.js +45 -12
- package/cjs/components/DateInput/helpers/inputNumber.js.map +1 -1
- package/cjs/components/Gapped/Gapped.js +2 -1
- package/cjs/components/Gapped/Gapped.js.map +1 -1
- package/cjs/components/GlobalLoader/GlobalLoaderView.styles.js +5 -7
- package/cjs/components/GlobalLoader/GlobalLoaderView.styles.js.map +1 -1
- package/cjs/components/PasswordInput/PasswordInput.d.ts +1 -1
- package/cjs/components/PasswordInput/PasswordInput.js +8 -10
- package/cjs/components/PasswordInput/PasswordInput.js.map +1 -1
- package/cjs/components/PasswordInput/PasswordInputIcon.js +5 -1
- package/cjs/components/PasswordInput/PasswordInputIcon.js.map +1 -1
- package/cjs/components/Select/Select.js +4 -4
- package/cjs/components/Select/Select.js.map +1 -1
- package/cjs/components/TokenInput/TokenInput.d.ts +10 -0
- package/cjs/components/TokenInput/TokenInput.js +17 -2
- package/cjs/components/TokenInput/TokenInput.js.map +1 -1
- package/cjs/internal/InternalMenu/InternalMenu.js +1 -5
- package/cjs/internal/InternalMenu/InternalMenu.js.map +1 -1
- package/cjs/internal/MaskedInput/MaskedInput.js +4 -2
- package/cjs/internal/MaskedInput/MaskedInput.js.map +1 -1
- package/cjs/internal/Menu/Menu.js +2 -5
- package/cjs/internal/Menu/Menu.js.map +1 -1
- package/cjs/lib/date/InternalDateGetter.d.ts +1 -1
- package/cjs/lib/date/InternalDateGetter.js +4 -1
- package/cjs/lib/date/InternalDateGetter.js.map +1 -1
- package/cjs/lib/date/InternalDateValidator.js +32 -22
- package/cjs/lib/date/InternalDateValidator.js.map +1 -1
- package/cjs/lib/date/types.d.ts +4 -0
- package/cjs/lib/date/types.js.map +1 -1
- package/cjs/lib/events/MouseDrag.js +5 -1
- package/cjs/lib/events/MouseDrag.js.map +1 -1
- package/components/Checkbox/Checkbox/Checkbox.js +29 -2
- package/components/Checkbox/Checkbox/Checkbox.js.map +1 -1
- package/components/Checkbox/Checkbox.d.ts +5 -0
- package/components/Checkbox/Checkbox.styles/Checkbox.styles.js +20 -17
- package/components/Checkbox/Checkbox.styles/Checkbox.styles.js.map +1 -1
- package/components/Checkbox/Checkbox.styles.d.ts +1 -0
- package/components/DateInput/DateInput/DateInput.js +9 -1
- package/components/DateInput/DateInput/DateInput.js.map +1 -1
- package/components/DateInput/helpers/InternalDateMediator/InternalDateMediator.js +9 -3
- package/components/DateInput/helpers/InternalDateMediator/InternalDateMediator.js.map +1 -1
- package/components/DateInput/helpers/InternalDateMediator.d.ts +2 -2
- package/components/DateInput/helpers/inputNumber/inputNumber.js +53 -16
- package/components/DateInput/helpers/inputNumber/inputNumber.js.map +1 -1
- package/components/DateInput/helpers/inputNumber.d.ts +1 -1
- package/components/Gapped/Gapped/Gapped.js +2 -1
- package/components/Gapped/Gapped/Gapped.js.map +1 -1
- package/components/GlobalLoader/GlobalLoaderView.styles/GlobalLoaderView.styles.js +1 -2
- package/components/GlobalLoader/GlobalLoaderView.styles/GlobalLoaderView.styles.js.map +1 -1
- package/components/PasswordInput/PasswordInput/PasswordInput.js +12 -13
- package/components/PasswordInput/PasswordInput/PasswordInput.js.map +1 -1
- package/components/PasswordInput/PasswordInput.d.ts +1 -1
- package/components/PasswordInput/PasswordInputIcon/PasswordInputIcon.js +8 -3
- package/components/PasswordInput/PasswordInputIcon/PasswordInputIcon.js.map +1 -1
- package/components/Select/Select/Select.js +5 -3
- package/components/Select/Select/Select.js.map +1 -1
- package/components/TokenInput/TokenInput/TokenInput.js +6 -2
- package/components/TokenInput/TokenInput/TokenInput.js.map +1 -1
- package/components/TokenInput/TokenInput.d.ts +10 -0
- package/internal/InternalMenu/InternalMenu/InternalMenu.js +2 -6
- package/internal/InternalMenu/InternalMenu/InternalMenu.js.map +1 -1
- package/internal/MaskedInput/MaskedInput/MaskedInput.js +4 -2
- package/internal/MaskedInput/MaskedInput/MaskedInput.js.map +1 -1
- package/internal/Menu/Menu/Menu.js +2 -5
- package/internal/Menu/Menu/Menu.js.map +1 -1
- package/lib/date/InternalDateGetter/InternalDateGetter.js +3 -1
- package/lib/date/InternalDateGetter/InternalDateGetter.js.map +1 -1
- package/lib/date/InternalDateGetter.d.ts +1 -1
- package/lib/date/InternalDateValidator/InternalDateValidator.js +55 -41
- package/lib/date/InternalDateValidator/InternalDateValidator.js.map +1 -1
- package/lib/date/types/types.js.map +1 -1
- package/lib/date/types.d.ts +4 -0
- package/lib/events/MouseDrag/MouseDrag.js +5 -1
- package/lib/events/MouseDrag/MouseDrag.js.map +1 -1
- package/package.json +3 -2
|
@@ -5,6 +5,11 @@ var _types = require("../../../lib/date/types");
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
8
13
|
var _inputNumber2 = require("./inputNumber");var
|
|
9
14
|
|
|
10
15
|
InternalDateMediator = /*#__PURE__*/function () {function InternalDateMediator() {var _this = this;this.
|
|
@@ -63,7 +68,6 @@ InternalDateMediator = /*#__PURE__*/function () {function InternalDateMediator()
|
|
|
63
68
|
|
|
64
69
|
|
|
65
70
|
|
|
66
|
-
|
|
67
71
|
paste = function (pasted) {
|
|
68
72
|
_this.iDate.parseValue(pasted).restore().cutOffExcess();
|
|
69
73
|
return _this;
|
|
@@ -161,7 +165,7 @@ InternalDateMediator = /*#__PURE__*/function () {function InternalDateMediator()
|
|
|
161
165
|
|
|
162
166
|
getLeftmostType = function () {return _this.getTypesOrder()[0];};this.
|
|
163
167
|
|
|
164
|
-
getRightmostType = function () {return _this.getTypesOrder()[2];};}var _proto = InternalDateMediator.prototype;_proto.inputKey = function inputKey(key, type, inputMode) {var prevValue = this.iDate.get(type);if (type === null) {var leftMostType = this.getLeftmostType();this.clear(leftMostType);}if (type !== _types.InternalDateComponentType.Year) {this.iDate.cutOffExcess(type);} else {this.iDate.restore(type);}var _inputNumber = (0, _inputNumber2.inputNumber)(type, prevValue, key, inputMode),nextValue = _inputNumber.nextValue,nextInputMode = _inputNumber.nextInputMode;this.iDate.set(type, nextValue);return nextInputMode;};_proto.shiftDateComponent = function shiftDateComponent(type, step) {var calculatedType = type != null ? type : this.getLeftmostType();var iDate = this.iDate.clone();var start = iDate.getRangeStart();var end = iDate.getRangeEnd();var isValidRange = iDate.validate({ checks: [_types.InternalDateValidateCheck.Range] });if (!isValidRange) {// Удерживаем дату в заданном диапазоне
|
|
165
|
-
if (start && _InternalDateGetter.InternalDateGetter.max([iDate, start]) === start) {iDate.duplicateOf(start);} else if (end && _InternalDateGetter.InternalDateGetter.min([iDate, end]) === end) {iDate.duplicateOf(end);}} else {var clone = iDate.clone().shift(calculatedType, step, { isRange: false, isLoop: true });if (clone.validate({ checks: [_types.InternalDateValidateCheck.Range] })) {iDate.duplicateOf(clone);}}var changed = !this.iDate.isEqualComponentDate(calculatedType, iDate);this.iDate = iDate;return changed;};_proto.getShiftedType = function getShiftedType(type, step) {var typesOrder = this.getTypesOrder();var index = type === null ? 0 : typesOrder.indexOf(type);var nextIndex = index + step; // Если выделено всё поле, то в завимости от направления перемещения, выделям крайний компонент
|
|
168
|
+
getRightmostType = function () {return _this.getTypesOrder()[2];};}var _proto = InternalDateMediator.prototype;_proto.inputKey = function inputKey(key, type, inputMode) {var prevValue = this.iDate.get(type);if (type === null) {var leftMostType = this.getLeftmostType();this.clear(leftMostType);}if (type !== _types.InternalDateComponentType.Year) {this.iDate.cutOffExcess(type);} else {this.iDate.restore(type);}var maxValue = _InternalDateGetter.InternalDateGetter.getDefaultMax(type, this.iDate.getComponentsLikeNumber());var _inputNumber = (0, _inputNumber2.inputNumber)(type, prevValue, key, inputMode, maxValue),nextValue = _inputNumber.nextValue,nextInputMode = _inputNumber.nextInputMode;this.iDate.set(type, nextValue);return { inputMode: nextInputMode, changed: nextValue !== prevValue };};_proto.shiftDateComponent = function shiftDateComponent(type, step) {var calculatedType = type != null ? type : this.getLeftmostType();var iDate = this.iDate.clone();var start = iDate.getRangeStart();var end = iDate.getRangeEnd();var isValidRange = iDate.validate({ checks: [_types.InternalDateValidateCheck.Range] });if (!isValidRange) {// Удерживаем дату в заданном диапазоне
|
|
169
|
+
if (start && _InternalDateGetter.InternalDateGetter.max([iDate, start]) === start) {iDate.duplicateOf(start);} else if (end && _InternalDateGetter.InternalDateGetter.min([iDate, end]) === end) {iDate.duplicateOf(end);}} else {var clone = iDate.clone().shift(calculatedType, step, { isRange: false, isLoop: true, isCutFeb: true });if (clone.validate({ checks: [_types.InternalDateValidateCheck.Range] })) {iDate.duplicateOf(clone);}}var changed = !this.iDate.isEqualComponentDate(calculatedType, iDate);this.iDate = iDate;return changed;};_proto.getShiftedType = function getShiftedType(type, step) {var typesOrder = this.getTypesOrder();var index = type === null ? 0 : typesOrder.indexOf(type);var nextIndex = index + step; // Если выделено всё поле, то в завимости от направления перемещения, выделям крайний компонент
|
|
166
170
|
if (type === _types.InternalDateComponentType.All) {return step < 0 ? typesOrder[0] : typesOrder[2];} // Если текущий компонент "год", и он не пуст, то при перемещении выделения "восстанавливаем" значение года
|
|
167
171
|
if (type === _types.InternalDateComponentType.Year && this.iDate.getYear() !== null) {this.iDate.restore(type);}var shiftedType = typesOrder[nextIndex];return typeof shiftedType === 'number' ? shiftedType : type;};return InternalDateMediator;}();exports.InternalDateMediator = InternalDateMediator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["InternalDateMediator.ts"],"names":["InternalDateMediator","iDate","InternalDate","update","props","locale","start","getRangeStart","min","toInternalString","end","getRangeEnd","max","order","separator","setOrder","setSeparator","minDate","setRangeStart","value","maxDate","setRangeEnd","parseInternalValue","paste","pasted","parseValue","restore","cutOffExcess","isIncomplete","restored","clone","isEqual","duplicateOf","getFragments","toFragments","withSeparator","withPad","deleteOneCharRight","type","inputMode","prev","get","String","InternalDateTransformer","padDateComponent","next","replace","set","isChangedLocale","getOrder","getSeparator","isNull","isEmpty","clear","validateString","parseValueToDate","getString","toString","getInternalString","getTypesOrder","map","getLeftmostType","getRightmostType","inputKey","key","prevValue","leftMostType","InternalDateComponentType","Year","nextValue","nextInputMode","shiftDateComponent","step","calculatedType","isValidRange","validate","checks","InternalDateValidateCheck","Range","InternalDateGetter","shift","isRange","isLoop","changed","isEqualComponentDate","getShiftedType","typesOrder","index","indexOf","nextIndex","All","getYear","shiftedType"],"mappings":"6EAAA;AACA;AACA;AACA;;;;AAIA,6C;;AAEaA,oB;AACJC,IAAAA,K,GAAsB,IAAIC,0BAAJ,E;;AAEtBC,IAAAA,M,GAAS,UAACC,KAAD,EAAwBC,MAAxB,EAA2E;AACzF,UAAMC,KAAK,GAAG,KAAI,CAACL,KAAL,CAAWM,aAAX,EAAd;AACA,UAAMC,GAAG,GAAGF,KAAK,IAAIA,KAAK,CAACG,gBAAN,EAArB;AACA,UAAMC,GAAG,GAAG,KAAI,CAACT,KAAL,CAAWU,WAAX,EAAZ;AACA,UAAMC,GAAG,GAAGF,GAAG,IAAIA,GAAG,CAACD,gBAAJ,EAAnB;AACA,UAAQI,KAAR,GAA6BR,MAA7B,CAAQQ,KAAR,CAAeC,SAAf,GAA6BT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Date';\nimport { InternalDateGetter } from '../../../lib/date/InternalDateGetter';\nimport { InternalDateTransformer } from '../../../lib/date/InternalDateTransformer';\nimport { InternalDateComponentType, InternalDateTypesOrder, InternalDateValidateCheck } from '../../../lib/date/types';\nimport { DatePickerLocale } from '../../DatePicker/locale';\nimport { DateInputProps } from '../DateInput';\n\nimport { inputNumber } from './inputNumber';\n\nexport class InternalDateMediator {\n public iDate: InternalDate = new InternalDate();\n\n public update = (props: DateInputProps, locale: DatePickerLocale): InternalDateMediator => {\n const start = this.iDate.getRangeStart();\n const min = start && start.toInternalString();\n const end = this.iDate.getRangeEnd();\n const max = end && end.toInternalString();\n const { order, separator } = locale;\n this.iDate.setOrder(order).setSeparator(separator);\n if (props.minDate !== min) {\n this.iDate.setRangeStart(\n props.minDate\n ? new InternalDate({\n order,\n separator,\n value: props.minDate,\n })\n : null,\n );\n }\n if (props.maxDate !== max) {\n this.iDate.setRangeEnd(\n props.maxDate\n ? new InternalDate({\n order,\n separator,\n value: props.maxDate,\n })\n : null,\n );\n }\n if (!props.value || props.value !== this.iDate.toInternalString()) {\n this.iDate.parseInternalValue(props.value);\n }\n return this;\n };\n\n public inputKey(key: string, type: InternalDateComponentType | null, inputMode: boolean): boolean {\n const prevValue = this.iDate.get(type);\n if (type === null) {\n const leftMostType = this.getLeftmostType();\n this.clear(leftMostType);\n }\n\n if (type !== InternalDateComponentType.Year) {\n this.iDate.cutOffExcess(type);\n } else {\n this.iDate.restore(type);\n }\n\n const { nextValue, nextInputMode } = inputNumber(type, prevValue, key, inputMode);\n this.iDate.set(type, nextValue);\n\n return nextInputMode;\n }\n\n public paste = (pasted: string): InternalDateMediator => {\n this.iDate.parseValue(pasted).restore().cutOffExcess();\n return this;\n };\n\n public restore = (): boolean => {\n if (this.iDate.isIncomplete()) {\n const restored = this.iDate.clone().restore();\n if (!this.iDate.isEqual(restored)) {\n this.iDate.duplicateOf(restored);\n }\n return true;\n }\n return false;\n };\n\n public shiftDateComponent(type: InternalDateComponentType | null, step: number): boolean {\n const calculatedType = type ?? this.getLeftmostType();\n\n const iDate = this.iDate.clone();\n const start = iDate.getRangeStart();\n const end = iDate.getRangeEnd();\n\n const isValidRange = iDate.validate({ checks: [InternalDateValidateCheck.Range] });\n if (!isValidRange) {\n // Удерживаем дату в заданном диапазоне\n if (start && InternalDateGetter.max([iDate, start]) === start) {\n iDate.duplicateOf(start);\n } else if (end && InternalDateGetter.min([iDate, end]) === end) {\n iDate.duplicateOf(end);\n }\n } else {\n const clone = iDate.clone().shift(calculatedType, step, { isRange: false, isLoop: true });\n if (clone.validate({ checks: [InternalDateValidateCheck.Range] })) {\n iDate.duplicateOf(clone);\n }\n }\n\n const changed = !this.iDate.isEqualComponentDate(calculatedType, iDate);\n this.iDate = iDate;\n return changed;\n }\n\n public getShiftedType(type: InternalDateComponentType | null, step: number): InternalDateComponentType | null {\n const typesOrder = this.getTypesOrder();\n const index = type === null ? 0 : typesOrder.indexOf(type);\n const nextIndex = index + step;\n\n // Если выделено всё поле, то в завимости от направления перемещения, выделям крайний компонент\n if (type === InternalDateComponentType.All) {\n return step < 0 ? typesOrder[0] : typesOrder[2];\n }\n\n // Если текущий компонент \"год\", и он не пуст, то при перемещении выделения \"восстанавливаем\" значение года\n if (type === InternalDateComponentType.Year && this.iDate.getYear() !== null) {\n this.iDate.restore(type);\n }\n\n const shiftedType = typesOrder[nextIndex];\n return typeof shiftedType === 'number' ? shiftedType : type;\n }\n\n public getFragments = () =>\n this.iDate.toFragments({\n withSeparator: true,\n withPad: true,\n });\n\n public deleteOneCharRight = (type: InternalDateComponentType, inputMode: boolean) => {\n let prev = this.iDate.get(type);\n prev = String(inputMode ? prev : InternalDateTransformer.padDateComponent(type, prev));\n const next = prev.replace(/.$/, '') || null;\n this.iDate.set(type, next);\n };\n\n public isChangedLocale = (locale: DatePickerLocale): boolean =>\n locale.order !== this.iDate.getOrder() || locale.separator !== this.iDate.getSeparator();\n\n public isNull = (type: InternalDateComponentType | null): boolean => this.iDate.get(type) === null;\n\n public isEmpty = (): boolean => this.iDate.isEmpty();\n\n public get = (type: InternalDateComponentType | null) => this.iDate.get(type);\n\n public clear = (type: InternalDateComponentType | null): InternalDate => this.iDate.set(type, null);\n\n public validateString = (value: string): boolean =>\n InternalDateTransformer.parseValueToDate(value, this.iDate.getOrder()) !== null;\n\n public getString = (): string => (this.iDate.isEmpty() ? '' : this.iDate.toString());\n\n public getInternalString = (): string => (this.iDate.isEmpty() ? '' : this.iDate.toInternalString());\n\n public getTypesOrder = () => this.iDate.toFragments().map(({ type }) => type) as InternalDateTypesOrder;\n\n public getLeftmostType = (): InternalDateComponentType => this.getTypesOrder()[0];\n\n public getRightmostType = (): InternalDateComponentType => this.getTypesOrder()[2];\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["InternalDateMediator.ts"],"names":["InternalDateMediator","iDate","InternalDate","update","props","locale","start","getRangeStart","min","toInternalString","end","getRangeEnd","max","order","separator","setOrder","setSeparator","minDate","setRangeStart","value","maxDate","setRangeEnd","parseInternalValue","paste","pasted","parseValue","restore","cutOffExcess","isIncomplete","restored","clone","isEqual","duplicateOf","getFragments","toFragments","withSeparator","withPad","deleteOneCharRight","type","inputMode","prev","get","String","InternalDateTransformer","padDateComponent","next","replace","set","isChangedLocale","getOrder","getSeparator","isNull","isEmpty","clear","validateString","parseValueToDate","getString","toString","getInternalString","getTypesOrder","map","getLeftmostType","getRightmostType","inputKey","key","prevValue","leftMostType","InternalDateComponentType","Year","maxValue","InternalDateGetter","getDefaultMax","getComponentsLikeNumber","nextValue","nextInputMode","changed","shiftDateComponent","step","calculatedType","isValidRange","validate","checks","InternalDateValidateCheck","Range","shift","isRange","isLoop","isCutFeb","isEqualComponentDate","getShiftedType","typesOrder","index","indexOf","nextIndex","All","getYear","shiftedType"],"mappings":"6EAAA;AACA;AACA;AACA;;;;;;;;;AASA,6C;;AAEaA,oB;AACJC,IAAAA,K,GAAsB,IAAIC,0BAAJ,E;;AAEtBC,IAAAA,M,GAAS,UAACC,KAA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mBtD,IAAnB,CAAlC,CACA,IAAMuD,SAAS,GAAGF,KAAK,GAAGd,IAA1B,CAH4G,CAK5G;AACA,QAAIvC,IAAI,KAAK6B,iCAA0B2B,GAAvC,EAA4C,CAC1C,OAAOjB,IAAI,GAAG,CAAP,GAAWa,UAAU,CAAC,CAAD,CAArB,GAA2BA,UAAU,CAAC,CAAD,CAA5C,CACD,CAR2G,CAU5G;AACA,QAAIpD,IAAI,KAAK6B,iCAA0BC,IAAnC,IAA2C,KAAKnE,KAAL,CAAW8F,OAAX,OAAyB,IAAxE,EAA8E,CAC5E,KAAK9F,KAAL,CAAWyB,OAAX,CAAmBY,IAAnB,EACD,CAED,IAAM0D,WAAW,GAAGN,UAAU,CAACG,SAAD,CAA9B,CACA,OAAO,OAAOG,WAAP,KAAuB,QAAvB,GAAkCA,WAAlC,GAAgD1D,IAAvD,CACD,C","sourcesContent":["import { InternalDate } from '../../../lib/date/InternalDate';\nimport { InternalDateGetter } from '../../../lib/date/InternalDateGetter';\nimport { InternalDateTransformer } from '../../../lib/date/InternalDateTransformer';\nimport {\n InputKeyResult,\n InternalDateComponentType,\n InternalDateTypesOrder,\n InternalDateValidateCheck,\n} from '../../../lib/date/types';\nimport { DatePickerLocale } from '../../DatePicker/locale';\nimport { DateInputProps } from '../DateInput';\n\nimport { inputNumber } from './inputNumber';\n\nexport class InternalDateMediator {\n public iDate: InternalDate = new InternalDate();\n\n public update = (props: DateInputProps, locale: DatePickerLocale): InternalDateMediator => {\n const start = this.iDate.getRangeStart();\n const min = start && start.toInternalString();\n const end = this.iDate.getRangeEnd();\n const max = end && end.toInternalString();\n const { order, separator } = locale;\n this.iDate.setOrder(order).setSeparator(separator);\n if (props.minDate !== min) {\n this.iDate.setRangeStart(\n props.minDate\n ? new InternalDate({\n order,\n separator,\n value: props.minDate,\n })\n : null,\n );\n }\n if (props.maxDate !== max) {\n this.iDate.setRangeEnd(\n props.maxDate\n ? new InternalDate({\n order,\n separator,\n value: props.maxDate,\n })\n : null,\n );\n }\n if (!props.value || props.value !== this.iDate.toInternalString()) {\n this.iDate.parseInternalValue(props.value);\n }\n return this;\n };\n\n public inputKey(key: string, type: InternalDateComponentType | null, inputMode: boolean): InputKeyResult {\n const prevValue = this.iDate.get(type);\n if (type === null) {\n const leftMostType = this.getLeftmostType();\n this.clear(leftMostType);\n }\n\n if (type !== InternalDateComponentType.Year) {\n this.iDate.cutOffExcess(type);\n } else {\n this.iDate.restore(type);\n }\n const maxValue = InternalDateGetter.getDefaultMax(type, this.iDate.getComponentsLikeNumber());\n const { nextValue, nextInputMode } = inputNumber(type, prevValue, key, inputMode, maxValue);\n this.iDate.set(type, nextValue);\n return { inputMode: nextInputMode, changed: nextValue !== prevValue };\n }\n\n public paste = (pasted: string): InternalDateMediator => {\n this.iDate.parseValue(pasted).restore().cutOffExcess();\n return this;\n };\n\n public restore = (): boolean => {\n if (this.iDate.isIncomplete()) {\n const restored = this.iDate.clone().restore();\n if (!this.iDate.isEqual(restored)) {\n this.iDate.duplicateOf(restored);\n }\n return true;\n }\n return false;\n };\n\n public shiftDateComponent(type: InternalDateComponentType | null, step: number): boolean {\n const calculatedType = type ?? this.getLeftmostType();\n\n const iDate = this.iDate.clone();\n const start = iDate.getRangeStart();\n const end = iDate.getRangeEnd();\n\n const isValidRange = iDate.validate({ checks: [InternalDateValidateCheck.Range] });\n if (!isValidRange) {\n // Удерживаем дату в заданном диапазоне\n if (start && InternalDateGetter.max([iDate, start]) === start) {\n iDate.duplicateOf(start);\n } else if (end && InternalDateGetter.min([iDate, end]) === end) {\n iDate.duplicateOf(end);\n }\n } else {\n const clone = iDate.clone().shift(calculatedType, step, { isRange: false, isLoop: true, isCutFeb: true });\n if (clone.validate({ checks: [InternalDateValidateCheck.Range] })) {\n iDate.duplicateOf(clone);\n }\n }\n\n const changed = !this.iDate.isEqualComponentDate(calculatedType, iDate);\n this.iDate = iDate;\n return changed;\n }\n\n public getShiftedType(type: InternalDateComponentType | null, step: number): InternalDateComponentType | null {\n const typesOrder = this.getTypesOrder();\n const index = type === null ? 0 : typesOrder.indexOf(type);\n const nextIndex = index + step;\n\n // Если выделено всё поле, то в завимости от направления перемещения, выделям крайний компонент\n if (type === InternalDateComponentType.All) {\n return step < 0 ? typesOrder[0] : typesOrder[2];\n }\n\n // Если текущий компонент \"год\", и он не пуст, то при перемещении выделения \"восстанавливаем\" значение года\n if (type === InternalDateComponentType.Year && this.iDate.getYear() !== null) {\n this.iDate.restore(type);\n }\n\n const shiftedType = typesOrder[nextIndex];\n return typeof shiftedType === 'number' ? shiftedType : type;\n }\n\n public getFragments = () =>\n this.iDate.toFragments({\n withSeparator: true,\n withPad: true,\n });\n\n public deleteOneCharRight = (type: InternalDateComponentType, inputMode: boolean) => {\n let prev = this.iDate.get(type);\n prev = String(inputMode ? prev : InternalDateTransformer.padDateComponent(type, prev));\n const next = prev.replace(/.$/, '') || null;\n this.iDate.set(type, next);\n };\n\n public isChangedLocale = (locale: DatePickerLocale): boolean =>\n locale.order !== this.iDate.getOrder() || locale.separator !== this.iDate.getSeparator();\n\n public isNull = (type: InternalDateComponentType | null): boolean => this.iDate.get(type) === null;\n\n public isEmpty = (): boolean => this.iDate.isEmpty();\n\n public get = (type: InternalDateComponentType | null) => this.iDate.get(type);\n\n public clear = (type: InternalDateComponentType | null): InternalDate => this.iDate.set(type, null);\n\n public validateString = (value: string): boolean =>\n InternalDateTransformer.parseValueToDate(value, this.iDate.getOrder()) !== null;\n\n public getString = (): string => (this.iDate.isEmpty() ? '' : this.iDate.toString());\n\n public getInternalString = (): string => (this.iDate.isEmpty() ? '' : this.iDate.toInternalString());\n\n public getTypesOrder = () => this.iDate.toFragments().map(({ type }) => type) as InternalDateTypesOrder;\n\n public getLeftmostType = (): InternalDateComponentType => this.getTypesOrder()[0];\n\n public getRightmostType = (): InternalDateComponentType => this.getTypesOrder()[2];\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InternalDateComponentRaw, InternalDateComponentType } from '../../../lib/date/types';
|
|
2
|
-
export declare const inputNumber: (type: InternalDateComponentType | null, prev: InternalDateComponentRaw, key: string, inputMode: boolean) => {
|
|
2
|
+
export declare const inputNumber: (type: InternalDateComponentType | null, prev: InternalDateComponentRaw, key: string, inputMode: boolean, maxValue: number) => {
|
|
3
3
|
nextValue: InternalDateComponentRaw;
|
|
4
4
|
nextInputMode: boolean;
|
|
5
5
|
};
|
|
@@ -5,26 +5,59 @@ var inputNumber = function inputNumber(
|
|
|
5
5
|
type,
|
|
6
6
|
prev,
|
|
7
7
|
key,
|
|
8
|
-
inputMode
|
|
8
|
+
inputMode,
|
|
9
|
+
maxValue)
|
|
9
10
|
{
|
|
10
11
|
var nextInputMode = false;
|
|
11
12
|
var nextValue;
|
|
13
|
+
var firstDigits = getFirstDigits(type, maxValue);
|
|
14
|
+
var maxLength = getMaxLength(type);
|
|
15
|
+
|
|
16
|
+
if (!inputMode) {
|
|
17
|
+
nextValue = key;
|
|
18
|
+
nextInputMode = Number(key) <= firstDigits;
|
|
19
|
+
} else {
|
|
20
|
+
nextValue = addKey(prev, key, maxLength);
|
|
21
|
+
nextInputMode = nextValue.length < maxLength;
|
|
22
|
+
if (!isCorrectDate(nextValue, maxValue, maxLength)) {
|
|
23
|
+
nextValue = prev + '';
|
|
24
|
+
nextInputMode = true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return { nextValue: nextValue, nextInputMode: nextInputMode };
|
|
29
|
+
};exports.inputNumber = inputNumber;
|
|
30
|
+
|
|
31
|
+
function addKey(prev, key, length) {
|
|
32
|
+
var value = key;
|
|
33
|
+
if (prev !== null) {
|
|
34
|
+
value = "" + prev + key;
|
|
35
|
+
}
|
|
36
|
+
return value.slice(-length);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function isCorrectDate(value, maxValue, length) {
|
|
40
|
+
return Number(value) <= maxValue && (Number(value) !== 0 || value.length !== length);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function getFirstDigits(type, maxValue) {
|
|
12
44
|
var first = 10;
|
|
13
|
-
var length = _constants.LENGTH_YEAR;
|
|
14
45
|
if (type === _types.InternalDateComponentType.Month) {
|
|
15
46
|
first = 1;
|
|
47
|
+
}
|
|
48
|
+
if (type === _types.InternalDateComponentType.Date) {
|
|
49
|
+
first = Math.floor(maxValue / 10);
|
|
50
|
+
}
|
|
51
|
+
return first;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function getMaxLength(type) {
|
|
55
|
+
var length = _constants.LENGTH_YEAR;
|
|
56
|
+
if (type === _types.InternalDateComponentType.Month) {
|
|
16
57
|
length = _constants.LENGTH_MONTH;
|
|
17
58
|
}
|
|
18
59
|
if (type === _types.InternalDateComponentType.Date) {
|
|
19
|
-
first = 3;
|
|
20
60
|
length = _constants.LENGTH_DATE;
|
|
21
61
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
nextInputMode = Number(key) <= first;
|
|
25
|
-
} else {
|
|
26
|
-
nextValue = ("" + (prev === null ? '' : prev) + key).slice(-length);
|
|
27
|
-
nextInputMode = nextValue.length < length;
|
|
28
|
-
}
|
|
29
|
-
return { nextValue: nextValue, nextInputMode: nextInputMode };
|
|
30
|
-
};exports.inputNumber = inputNumber;
|
|
62
|
+
return length;
|
|
63
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["inputNumber.tsx"],"names":["inputNumber","type","prev","key","inputMode","nextInputMode","nextValue","
|
|
1
|
+
{"version":3,"sources":["inputNumber.tsx"],"names":["inputNumber","type","prev","key","inputMode","maxValue","nextInputMode","nextValue","firstDigits","getFirstDigits","maxLength","getMaxLength","Number","addKey","length","isCorrectDate","value","slice","first","InternalDateComponentType","Month","Date","Math","floor","LENGTH_YEAR","LENGTH_MONTH","LENGTH_DATE"],"mappings":"oEAAA;AACA;;AAEO,IAAMA,WAAW,GAAG,SAAdA,WAAc;AACzBC,IADyB;AAEzBC,IAFyB;AAGzBC,GAHyB;AAIzBC,SAJy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,CAAwBR,IAAxB,EAAgEI,QAAhE,EAAkF;AAChF,MAAIa,KAAK,GAAG,EAAZ;AACA,MAAIjB,IAAI,KAAKkB,iCAA0BC,KAAvC,EAA8C;AAC5CF,IAAAA,KAAK,GAAG,CAAR;AACD;AACD,MAAIjB,IAAI,KAAKkB,iCAA0BE,IAAvC,EAA6C;AAC3CH,IAAAA,KAAK,GAAGI,IAAI,CAACC,KAAL,CAAWlB,QAAQ,GAAG,EAAtB,CAAR;AACD;AACD,SAAOa,KAAP;AACD;;AAED,SAASP,YAAT,CAAsBV,IAAtB,EAA8D;AAC5D,MAAIa,MAAM,GAAGU,sBAAb;AACA,MAAIvB,IAAI,KAAKkB,iCAA0BC,KAAvC,EAA8C;AAC5CN,IAAAA,MAAM,GAAGW,uBAAT;AACD;AACD,MAAIxB,IAAI,KAAKkB,iCAA0BE,IAAvC,EAA6C;AAC3CP,IAAAA,MAAM,GAAGY,sBAAT;AACD;AACD,SAAOZ,MAAP;AACD","sourcesContent":["import { LENGTH_DATE, LENGTH_MONTH, LENGTH_YEAR } from '../../../lib/date/constants';\nimport { InternalDateComponentRaw, InternalDateComponentType } from '../../../lib/date/types';\n\nexport const inputNumber = (\n type: InternalDateComponentType | null,\n prev: InternalDateComponentRaw,\n key: string,\n inputMode: boolean,\n maxValue: number,\n): { nextValue: InternalDateComponentRaw; nextInputMode: boolean } => {\n let nextInputMode = false;\n let nextValue;\n const firstDigits = getFirstDigits(type, maxValue);\n const maxLength = getMaxLength(type);\n\n if (!inputMode) {\n nextValue = key;\n nextInputMode = Number(key) <= firstDigits;\n } else {\n nextValue = addKey(prev, key, maxLength);\n nextInputMode = nextValue.length < maxLength;\n if (!isCorrectDate(nextValue, maxValue, maxLength)) {\n nextValue = prev + '';\n nextInputMode = true;\n }\n }\n\n return { nextValue, nextInputMode };\n};\n\nfunction addKey(prev: InternalDateComponentRaw, key: string, length: number) {\n let value = key;\n if (prev !== null) {\n value = `${prev}${key}`;\n }\n return value.slice(-length);\n}\n\nfunction isCorrectDate(value: string, maxValue: number, length: number) {\n return Number(value) <= maxValue && (Number(value) !== 0 || value.length !== length);\n}\n\nfunction getFirstDigits(type: InternalDateComponentType | null, maxValue: number) {\n let first = 10;\n if (type === InternalDateComponentType.Month) {\n first = 1;\n }\n if (type === InternalDateComponentType.Date) {\n first = Math.floor(maxValue / 10);\n }\n return first;\n}\n\nfunction getMaxLength(type: InternalDateComponentType | null) {\n let length = LENGTH_YEAR;\n if (type === InternalDateComponentType.Month) {\n length = LENGTH_MONTH;\n }\n if (type === InternalDateComponentType.Date) {\n length = LENGTH_DATE;\n }\n return length;\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.Gapped = void 0;var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));var _react = _interopRequireDefault(require("react"));
|
|
2
2
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
3
3
|
|
|
4
|
+
var _utils = require("../../lib/utils");
|
|
4
5
|
var _CommonWrapper = require("../../internal/CommonWrapper");
|
|
5
6
|
var _rootNode = require("../../lib/rootNode");var _class, _class2, _temp;
|
|
6
7
|
|
|
@@ -71,7 +72,7 @@ Gapped = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*/functi
|
|
|
71
72
|
getGapValue = function getGapValue() {
|
|
72
73
|
// DEPRECATED remove in 4.0
|
|
73
74
|
var propsGap = this.props.gap;
|
|
74
|
-
if (
|
|
75
|
+
if ((0, _utils.isNonNullable)(propsGap)) {
|
|
75
76
|
return propsGap;
|
|
76
77
|
}
|
|
77
78
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Gapped.tsx"],"names":["Gapped","rootNode","render","setRootNode","props","vertical","renderVertical","renderHorizontal","getGapValue","propsGap","gap","
|
|
1
|
+
{"version":3,"sources":["Gapped.tsx"],"names":["Gapped","rootNode","render","setRootNode","props","vertical","renderVertical","renderHorizontal","getGapValue","propsGap","gap","subsequentItemStyle","paddingTop","children","React","Children","toArray","filter","filterChildren","map","child","index","style","undefined","verticalAlign","wrap","itemStyle","display","marginLeft","marginTop","rootStyle","contStyle","whiteSpace","Boolean","Component","__KONTUR_REACT_UI__","propTypes","PropTypes","number","bool","oneOf","defaultProps"],"mappings":"oUAAA;AACA;;AAEA;AACA;AACA,8C;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA;AACA;AACA,G;;AAEaA,M,OADZC,kB;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BQC,EAAAA,M,GAAP,kBAAgB;AACd;AACE,mCAAC,4BAAD,2BAAe,WAAW,EAAE,KAAKC,WAAjC,IAAkD,KAAKC,KAAvD;AACG,WAAKA,KAAL,CAAWC,QAAX,GAAsB,KAAKC,cAAL,EAAtB,GAA8C,KAAKC,gBAAL,EADjD,CADF;;;AAKD,G;;AAEOC,EAAAA,W,GAAR,uBAAsB;AACpB;AACA,QAAaC,QAAb,GAA0B,KAAKL,KAA/B,CAAQM,GAAR;AACA,QAAI,0BAAcD,QAAd,CAAJ,EAA6B;AAC3B,aAAOA,QAAP;AACD;;AAED,WAAO,CAAP;AACD,G;;AAEOH,EAAAA,c,GAAR,0BAAyB;AACvB,QAAMK,mBAAwC,GAAG;AAC/CC,MAAAA,UAAU,EAAE,KAAKJ,WAAL,EADmC,EAAjD;;AAGA,QAAMK,QAAQ,GAAGC,eAAMC,QAAN,CAAeC,OAAf,CAAuB,KAAKZ,KAAL,CAAWS,QAAlC;AACdI,IAAAA,MADc,CACP,KAAKC,cADE;AAEdC,IAAAA,GAFc,CAEV,UAACC,KAAD,EAAQC,KAAR,EAAkB;AACrB,UAAMC,KAAK,GAAGD,KAAK,KAAK,CAAV,GAAcE,SAAd,GAA0BZ,mBAAxC;AACA;AACE,8CAAK,KAAK,EAAEW,KAAZ,EAAmB,GAA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AuBE,KAAvB,EAAwD;AACtD,WAAOa,OAAO,CAACb,KAAD,CAAP,IAAkB,OAAOA,KAAP,KAAiB,QAA1C;AACD,G,iBA/FyBN,eAAMoB,S,WAClBC,mB,GAAsB,Q,UAEtBC,S,GAAY,EACxB;AACJ;AACA,KACI1B,GAAG,EAAE2B,mBAAUC,MAJS,EAMxB;AACJ;AACA,KACIjC,QAAQ,EAAEgC,mBAAUE,IATI,EAWxB;AACJ;AACA,KACIf,aAAa,EAAEa,mBAAUG,KAAV,CAAgB,CAAC,KAAD,EAAQ,QAAR,EAAkB,UAAlB,EAA8B,QAA9B,CAAhB,CAdS,E,UAmBZC,Y,GAAe,EAC3BhB,IAAI,EAAE,KADqB,EAE3BpB,QAAQ,EAAE,KAFiB,EAG3BmB,aAAa,EAAE,UAHY,E","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nimport { isNonNullable } from '../../lib/utils';\nimport { CommonWrapper, CommonProps } from '../../internal/CommonWrapper';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\n\nexport interface GappedProps extends CommonProps {\n /**\n * Расстояние между элементами в пикселях\n * @default 8\n */\n gap?: number;\n /**\n * Вертикальное выравнивание\n * @default \"baseline\"\n */\n verticalAlign: 'top' | 'middle' | 'baseline' | 'bottom';\n /**\n * Расположение элементов по вертикали\n * @default false\n */\n vertical: boolean;\n /**\n * Перенос элементов на новую строку при горизонтальном расположении\n * @default false\n */\n wrap: boolean;\n children: React.ReactNode;\n}\n\n/**\n * Контейнер, расстояние между элементами в котором равно `gap`.\n */\n@rootNode\nexport class Gapped extends React.Component<GappedProps> {\n public static __KONTUR_REACT_UI__ = 'Gapped';\n\n public static propTypes = {\n /**\n * Расстояние между элементами.\n */\n gap: PropTypes.number,\n\n /**\n * Располагать элементы вертикально.\n */\n vertical: PropTypes.bool,\n\n /**\n * Вертикальное выравнивание элементов.\n */\n verticalAlign: PropTypes.oneOf(['top', 'middle', 'baseline', 'bottom']),\n };\n\n private setRootNode!: TSetRootNode;\n\n public static defaultProps = {\n wrap: false,\n vertical: false,\n verticalAlign: 'baseline',\n };\n\n public render() {\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n {this.props.vertical ? this.renderVertical() : this.renderHorizontal()}\n </CommonWrapper>\n );\n }\n\n private getGapValue() {\n // DEPRECATED remove in 4.0\n const { gap: propsGap } = this.props;\n if (isNonNullable(propsGap)) {\n return propsGap;\n }\n\n return 8;\n }\n\n private renderVertical() {\n const subsequentItemStyle: React.CSSProperties = {\n paddingTop: this.getGapValue(),\n };\n const children = React.Children.toArray(this.props.children)\n .filter(this.filterChildren)\n .map((child, index) => {\n const style = index === 0 ? undefined : subsequentItemStyle;\n return (\n <div style={style} key={index}>\n {child}\n </div>\n );\n });\n\n return <div>{children}</div>;\n }\n\n private renderHorizontal() {\n const { children, verticalAlign, wrap } = this.props;\n const gap = this.getGapValue();\n const itemStyle: React.CSSProperties = {\n display: 'inline-block',\n verticalAlign,\n ...(wrap ? { marginLeft: gap, marginTop: gap } : {}),\n };\n const rootStyle: React.CSSProperties = wrap ? { paddingTop: 1 } : {};\n const contStyle: React.CSSProperties = wrap ? { marginTop: -gap - 1, marginLeft: -gap } : { whiteSpace: 'nowrap' };\n\n return (\n <div style={rootStyle}>\n <div style={contStyle}>\n {React.Children.toArray(children)\n .filter(this.filterChildren)\n .map((child, index) => {\n const marginLeft = index === 0 ? undefined : gap;\n return (\n <span key={index} style={{ marginLeft, ...itemStyle }}>\n {child}\n </span>\n );\n })}\n </div>\n </div>\n );\n }\n\n private filterChildren(child: React.ReactNode): boolean {\n return Boolean(child) || typeof child === 'number';\n }\n}\n"]}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.styles = exports.animations = void 0;var _taggedTemplateLiteralLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteralLoose"));var
|
|
2
|
-
|
|
3
|
-
var _Emotion = require("../../lib/theming/Emotion");var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15;
|
|
1
|
+
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.styles = exports.animations = void 0;var _taggedTemplateLiteralLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteralLoose"));var _Emotion = require("../../lib/theming/Emotion");var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15;
|
|
4
2
|
|
|
5
3
|
|
|
6
4
|
var styles = (0, _Emotion.memoizeStyle)({
|
|
@@ -47,7 +45,7 @@ var styles = (0, _Emotion.memoizeStyle)({
|
|
|
47
45
|
} });exports.styles = styles;
|
|
48
46
|
|
|
49
47
|
|
|
50
|
-
var moveToRightAnimation = (0,
|
|
48
|
+
var moveToRightAnimation = (0, _Emotion.keyframes)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteralLoose2.default)(["\n 0% {\n left: 0;\n width: 100%;\n }\n 50% {\n left: 50%;\n width: 50%;\n }\n 100% {\n left: 99%;\n width: 1%\n }\n"])));
|
|
51
49
|
|
|
52
50
|
|
|
53
51
|
|
|
@@ -61,7 +59,7 @@ var moveToRightAnimation = (0, _css.keyframes)(_templateObject6 || (_templateObj
|
|
|
61
59
|
|
|
62
60
|
|
|
63
61
|
|
|
64
|
-
var spinnerAnimation = (0,
|
|
62
|
+
var spinnerAnimation = (0, _Emotion.keyframes)(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteralLoose2.default)(["\n 0% {\n transform: translateX(50%) scaleX(.005);\n animation-timing-function: cubic-bezier(.895,.03,.685,.22);\n }\n 50% {\n transform: translateX(0) scaleX(.35);\n animation-timing-function: cubic-bezier(.165,.84,.44,1);\n }\n 100% {\n transform: translateX(-50%) scaleX(.005);\n }\n"])));
|
|
65
63
|
|
|
66
64
|
|
|
67
65
|
|
|
@@ -74,11 +72,11 @@ var spinnerAnimation = (0, _css.keyframes)(_templateObject7 || (_templateObject7
|
|
|
74
72
|
|
|
75
73
|
|
|
76
74
|
|
|
77
|
-
var linearProgressAnimation = (0,
|
|
75
|
+
var linearProgressAnimation = (0, _Emotion.keyframes)(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteralLoose2.default)(["\n from { width: 0; }\n to { width: 80% }\n"])));
|
|
78
76
|
|
|
79
77
|
|
|
80
78
|
|
|
81
|
-
var slowProgressAnimation = (0,
|
|
79
|
+
var slowProgressAnimation = (0, _Emotion.keyframes)(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteralLoose2.default)(["\n from { width: 80%; }\n to { width: 90% }\n"])));
|
|
82
80
|
|
|
83
81
|
|
|
84
82
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["GlobalLoaderView.styles.ts"],"names":["styles","outer","t","css","globalLoaderWidth","globalLoaderHeight","globalLoaderBackgroundColor","globalLoaderPosition","globalLoaderLeft","globalLoaderTop","globalLoaderRight","globalLoaderBottom","inner","globalLoaderColor","standardWithoutAnimation","successWithoutAnimation","errorWithoutAnimation","moveToRightAnimation","keyframes","spinnerAnimation","linearProgressAnimation","slowProgressAnimation","animations","successAnimation","delayBeforeHide","width","left","errorAnimation","transitionDuration","parseInt","globalLoaderTransitionToSpinnerDuration","spinnerAnimationDuration","globalLoaderSpinnerAnimationDuration","standardAnimation","expectedTime","slowProgressAnimationTime","globalLoaderSlowAnimationDuration","acceptAnimation","startWidth","transitionTime","globalLoaderTransitionFromSpinnerDuration","slowAcceptAnimation","acceptWithoutAnimation"],"mappings":"iSAAA
|
|
1
|
+
{"version":3,"sources":["GlobalLoaderView.styles.ts"],"names":["styles","outer","t","css","globalLoaderWidth","globalLoaderHeight","globalLoaderBackgroundColor","globalLoaderPosition","globalLoaderLeft","globalLoaderTop","globalLoaderRight","globalLoaderBottom","inner","globalLoaderColor","standardWithoutAnimation","successWithoutAnimation","errorWithoutAnimation","moveToRightAnimation","keyframes","spinnerAnimation","linearProgressAnimation","slowProgressAnimation","animations","successAnimation","delayBeforeHide","width","left","errorAnimation","transitionDuration","parseInt","globalLoaderTransitionToSpinnerDuration","spinnerAnimationDuration","globalLoaderSpinnerAnimationDuration","standardAnimation","expectedTime","slowProgressAnimationTime","globalLoaderSlowAnimationDuration","acceptAnimation","startWidth","transitionTime","globalLoaderTransitionFromSpinnerDuration","slowAcceptAnimation","acceptWithoutAnimation"],"mappings":"iSAAA,oD;;;AAGO,IAAMA,MAAM,GAAG,2BAAa;AACjCC,EAAAA,KADiC,iBAC3BC,CAD2B,EACjB;AACd,eAAOC,YAAP;AACWD,IAAAA,CAAC,CAACE,iBADb;AAEYF,IAAAA,CAAC,CAACG,kBAFd;AAGsBH,IAAAA,CAAC,CAACI,2BAHxB;AAIcJ,IAAAA,CAAC,CAACK,oBAJhB;AAKUL,IAAAA,CAAC,CAACM,gBALZ;AAMSN,IAAAA,CAAC,CAACO,eANX;AAOWP,IAAAA,CAAC,CAACQ,iBAPb;AAQYR,IAAAA,CAAC,CAACS,kBARd;;;AAWD,GAbgC;AAcjCC,EAAAA,KAdiC,iBAc3BV,CAd2B,EAcjB;AACd,eAAOC,YAAP;AACsBD,IAAAA,CAAC,CAACW,iBADxB;;AAGYX,IAAAA,CAAC,CAACG,kBAHd;;;;;AAQD,GAvBgC;AAwBjCS,EAAAA,wBAxBiC,sCAwBN;AACzB,eAAOX,YAAP;;;;AAID,GA7BgC;AA8BjCY,EAAAA,uBA9BiC,qCA8BP;AACxB,eAAOZ,YAAP;;;;AAID,GAnCgC;AAoCjCa,EAAAA,qBApCiC,mCAoCT;AACtB,eAAOb,YAAP;;;;AAID,GAzCgC,EAAb,CAAf,C;;;AA4CP,IAAMc,oBAAoB,OAAGC,kBA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,CAAC3B,CAAC,CAACkC,iCAAH,CAA1C;AACA,eAAOjC,YAAP;;AAEmCoC,IAAAA,cAFnC;AAGML,IAAAA,YAHN,EAGwCK,cAHxC;AAIMJ,IAAAA,yBAJN,EAIqCd,qBAJrC,EAI8Da,YAAY,GAAGK,cAJ7E;;;AAOed,IAAAA,KAPf;AAQcC,IAAAA,IARd;;;AAWeY,IAAAA,UAXf;;;;;;AAiBeA,IAAAA,UAjBf;;;;;;;AAwBD,GA1EuB;AA2ExBG,EAAAA,mBA3EwB,+BA2EJvC,CA3EI,EA2EMoC,UA3EN,EA2E0Bb,KA3E1B,EA2EyCC,IA3EzC,EA2EuD;AAC7E,QAAMa,cAAc,GAAGV,QAAQ,CAAC3B,CAAC,CAACsC,yCAAH,CAA/B;AACA,QAAML,yBAAyB,GAAGN,QAAQ,CAAC3B,CAAC,CAACkC,iCAAH,CAA1C;AACA,eAAOjC,YAAP;;AAEmCoC,IAAAA,cAFnC;AAGMJ,IAAAA,yBAHN,EAGqDI,cAHrD;;;AAMed,IAAAA,KANf;AAOcC,IAAAA,IAPd;;;AAUeY,IAAAA,UAVf;;;;;;AAgBeA,IAAAA,UAhBf;;;;;;;AAuBD,GArGuB;AAsGxBI,EAAAA,sBAtGwB,kCAsGDJ,UAtGC,EAsGmB;AACzC,eAAOnC,YAAP;AACWmC,IAAAA,UADX;;AAGD,GA1GuB,EAAnB,C","sourcesContent":["import { css, memoizeStyle, keyframes } from '../../lib/theming/Emotion';\nimport { Theme } from '../../lib/theming/Theme';\n\nexport const styles = memoizeStyle({\n outer(t: Theme) {\n return css`\n width: ${t.globalLoaderWidth};\n height: ${t.globalLoaderHeight};\n background-color: ${t.globalLoaderBackgroundColor};\n position: ${t.globalLoaderPosition};\n left: ${t.globalLoaderLeft};\n top: ${t.globalLoaderTop};\n right: ${t.globalLoaderRight};\n bottom: ${t.globalLoaderBottom};\n overflow: hidden;\n `;\n },\n inner(t: Theme) {\n return css`\n background-color: ${t.globalLoaderColor};\n width: 0;\n height: ${t.globalLoaderHeight};\n position: absolute;\n left: 0;\n overflow: hidden;\n `;\n },\n standardWithoutAnimation() {\n return css`\n left: 0;\n width: 90%;\n `;\n },\n successWithoutAnimation() {\n return css`\n left: 0;\n width: 100%;\n `;\n },\n errorWithoutAnimation() {\n return css`\n left: 40%;\n width: 20%;\n `;\n },\n});\n\nconst moveToRightAnimation = keyframes`\n 0% {\n left: 0;\n width: 100%;\n }\n 50% {\n left: 50%;\n width: 50%;\n }\n 100% {\n left: 99%;\n width: 1%\n }\n`;\nconst spinnerAnimation = keyframes`\n 0% {\n transform: translateX(50%) scaleX(.005);\n animation-timing-function: cubic-bezier(.895,.03,.685,.22);\n }\n 50% {\n transform: translateX(0) scaleX(.35);\n animation-timing-function: cubic-bezier(.165,.84,.44,1);\n }\n 100% {\n transform: translateX(-50%) scaleX(.005);\n }\n`;\nconst linearProgressAnimation = keyframes`\n from { width: 0; }\n to { width: 80% }\n`;\nconst slowProgressAnimation = keyframes`\n from { width: 80%; }\n to { width: 90% }\n`;\n\nexport const animations = {\n successAnimation(delayBeforeHide: number, width: number, left: number) {\n return css`\n animation: successAnimation;\n animation-duration: ${delayBeforeHide}ms;\n @keyframes successAnimation {\n 0% {\n width: ${width}px;\n left: ${left}px;\n opacity: 1;\n }\n 20% {\n width: 100%;\n left: 0;\n opacity: 1;\n }\n 80% {\n width: 100%;\n left: 0;\n opacity: 1;\n }\n 100% {\n width: 100%;\n opacity: 0;\n }\n }\n `;\n },\n errorAnimation(t: Theme) {\n const transitionDuration = parseInt(t.globalLoaderTransitionToSpinnerDuration);\n const spinnerAnimationDuration = parseInt(t.globalLoaderSpinnerAnimationDuration);\n\n return css`\n left: 0;\n width: 100%;\n animation: ${moveToRightAnimation} ${transitionDuration}ms linear,\n ${spinnerAnimationDuration}ms ${spinnerAnimation} ${transitionDuration}ms infinite alternate;\n `;\n },\n standardAnimation(t: Theme, expectedTime: number) {\n const slowProgressAnimationTime = parseInt(t.globalLoaderSlowAnimationDuration);\n return css`\n width: 90%;\n animation: ${linearProgressAnimation} ${expectedTime}ms cubic-bezier(0, 0.4, 0.4, 1),\n ${slowProgressAnimationTime}ms ${slowProgressAnimation} ${expectedTime}ms linear;\n `;\n },\n acceptAnimation(t: Theme, startWidth: number, expectedTime: number, width: number, left: number) {\n const transitionTime = parseInt(t.globalLoaderTransitionFromSpinnerDuration);\n const slowProgressAnimationTime = parseInt(t.globalLoaderSlowAnimationDuration);\n return css`\n width: 90%;\n animation: transitionAnimation ${transitionTime}ms linear,\n ${expectedTime}ms acceptAnimation ${transitionTime}ms cubic-bezier(0, 0.4, 0.4, 1),\n ${slowProgressAnimationTime}ms ${slowProgressAnimation} ${expectedTime + transitionTime}ms linear;\n @keyframes transitionAnimation {\n from {\n width: ${width}px;\n left: ${left}px;\n }\n to {\n width: ${startWidth}px;\n left: 0;\n }\n }\n @keyframes acceptAnimation {\n from {\n width: ${startWidth}px;\n }\n to {\n width: 80%;\n }\n }\n `;\n },\n slowAcceptAnimation(t: Theme, startWidth: number, width: number, left: number) {\n const transitionTime = parseInt(t.globalLoaderTransitionFromSpinnerDuration);\n const slowProgressAnimationTime = parseInt(t.globalLoaderSlowAnimationDuration);\n return css`\n width: 90%;\n animation: transitionAnimation ${transitionTime}ms linear,\n ${slowProgressAnimationTime}ms acceptAnimation ${transitionTime}ms linear;\n @keyframes transitionAnimation {\n from {\n width: ${width}px;\n left: ${left}px;\n }\n to {\n width: ${startWidth}px;\n left: 0;\n }\n }\n @keyframes acceptAnimation {\n from {\n width: ${startWidth}px;\n }\n to {\n width: 90%;\n }\n }\n `;\n },\n acceptWithoutAnimation(startWidth: number) {\n return css`\n width: ${startWidth}px;\n `;\n },\n};\n"]}
|
|
@@ -43,9 +43,9 @@ export declare class PasswordInput extends React.PureComponent<PasswordInputProp
|
|
|
43
43
|
private handleToggleVisibility;
|
|
44
44
|
private handleFocus;
|
|
45
45
|
private handleBlur;
|
|
46
|
-
private onBlur;
|
|
47
46
|
private getEyeWrapperClassname;
|
|
48
47
|
private renderEye;
|
|
49
48
|
private refInput;
|
|
49
|
+
private hideSymbols;
|
|
50
50
|
private renderMain;
|
|
51
51
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.PasswordInput = void 0;var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));var _react = _interopRequireDefault(require("react"));
|
|
2
2
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
3
3
|
|
|
4
|
+
var _RenderLayer = require("../../internal/RenderLayer");
|
|
4
5
|
var _utils = require("../../lib/utils");
|
|
5
6
|
var _identifiers = require("../../lib/events/keyboard/identifiers");
|
|
6
7
|
var _KeyboardEventCodes = require("../../lib/events/keyboard/KeyboardEventCodes");
|
|
@@ -156,14 +157,6 @@ PasswordInput = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*
|
|
|
156
157
|
}
|
|
157
158
|
};_this.
|
|
158
159
|
|
|
159
|
-
onBlur = function (e) {
|
|
160
|
-
if (_this.props.onBlur) {
|
|
161
|
-
_this.props.onBlur(e);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
_this.setState({ visible: false });
|
|
165
|
-
};_this.
|
|
166
|
-
|
|
167
160
|
|
|
168
161
|
|
|
169
162
|
|
|
@@ -197,19 +190,24 @@ PasswordInput = (0, _rootNode.rootNode)(_class = (_temp = _class2 = /*#__PURE__*
|
|
|
197
190
|
_this.input = element;
|
|
198
191
|
};_this.
|
|
199
192
|
|
|
193
|
+
hideSymbols = function () {
|
|
194
|
+
_this.setState({ visible: false });
|
|
195
|
+
};_this.
|
|
196
|
+
|
|
200
197
|
renderMain = function (props) {
|
|
201
198
|
var detectCapsLock = props.detectCapsLock,rest = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
202
199
|
var inputProps = (0, _extends2.default)({},
|
|
203
200
|
rest, {
|
|
204
|
-
onBlur: _this.onBlur,
|
|
205
201
|
onKeyDown: _this.handleKeydown,
|
|
206
202
|
onKeyPress: _this.handleKeyPress,
|
|
207
203
|
rightIcon: _this.renderEye() });
|
|
208
204
|
|
|
209
205
|
|
|
210
206
|
return /*#__PURE__*/(
|
|
207
|
+
_react.default.createElement(_RenderLayer.RenderLayer, { onFocusOutside: _this.hideSymbols, onClickOutside: _this.hideSymbols }, /*#__PURE__*/
|
|
211
208
|
_react.default.createElement("div", { className: _PasswordInput.styles.root() }, /*#__PURE__*/
|
|
212
|
-
_react.default.createElement(_Input.Input, (0, _extends2.default)({ ref: _this.refInput, type: _this.state.visible ? 'text' : 'password' }, inputProps))));
|
|
209
|
+
_react.default.createElement(_Input.Input, (0, _extends2.default)({ ref: _this.refInput, type: _this.state.visible ? 'text' : 'password' }, inputProps)))));
|
|
210
|
+
|
|
213
211
|
|
|
214
212
|
|
|
215
213
|
};return _this;}var _proto = PasswordInput.prototype;_proto.componentDidMount = function componentDidMount() {if (this.props.detectCapsLock) {this.setState({ capsLockEnabled: null });} // @ts-ignore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["PasswordInput.tsx"],"names":["PasswordInput","rootNode","state","visible","capsLockEnabled","focus","input","blur","handleBlur","handleKeyPress","e","props","onKeyPress","detectCapsLock","getModifierState","Codes","CapsLock","setState","handleKeydown","onKeyDown","handleToggleVisibility","prevState","handleFocus","onBlur","renderEye","styles","iconWrapper","capsLockDetector","toggleVisibility","theme","getEyeWrapperClassname","disabled","refInput","element","renderMain","rest","inputProps","rightIcon","root","componentDidMount","isIE11","window","document","msCapsLockWarningOff","getDerivedStateFromProps","render","setRootNode","right","size","eyeWrapperLarge","eyeWrapperMedium","eyeWrapperSmall","React","PureComponent","__KONTUR_REACT_UI__","propTypes","PropTypes","bool","defaultProps"],"mappings":"qjBAAA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,wD;;;;;;;;;;;AAWA;AACA;AACA,G;;AAEaA,a,OADZC,kB;;;;;;;;;;;;;;AAeQC,IAAAA,K,GAA4B;AACjCC,MAAAA,OAAO,EAAE,KADwB;AAEjCC,MAAAA,eAAe,EAAE,KAFgB,E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiD5BC,IAAAA,K,GAAQ,YAAM;AACnB,UAAI,MAAKC,KAAT,EAAgB;AACd,cAAKA,KAAL,CAAWD,KAAX;AACD;AACF,K;;;;;AAKME,IAAAA,I,GAAO,YAAM;AAClB,YAAKC,UAAL;AACD,K;;AAEOC,IAAAA,c,GAAiB,UAACC,CAAD,EAA8C;AACrE,wBAAuC,MAAKC,KAA5C,CAAQC,UAAR,eAAQA,UAAR,CAAoBC,cAApB,eAAoBA,cAApB;;AAEA,UAAID,UAAJ,EAAgB;AACdA,QAAAA,UAAU,CAACF,CAAD,CAAV;AACD;;AAED,UAAI,CAACG,cAAL,EAAqB;AACnB;AACD;;AAED,UAAMT,eAAe,GAAGM,CAAC,CAACI,gBAAF,CAAmBC,uCAAMC,QAAzB,CAAxB;;AAEA,YAAKC,QAAL,CAAc,EAAEb,eAAe,EAAfA,eAAF,EAAd;AACD,K;;AAEOc,IAAAA,a,GAAgB,UAACR,CAAD,EAA8C;AACpE;AACEC,MAAAA,KADF,CACWE,cADX,0BACWA,cADX,CAC2BM,SAD3B,0BAC2BA,SAD3B;AAEWf,MAAAA,eAFX,yBAEEF,KAFF,CAEWE,eAFX;;;AAKA,UAAIe,SAAJ,EAAe;AACbA,QAAAA,SAAS,CAACT,CAAD,CAAT;AACD;;AAED,UAAI,CAACG,cAAL,EAAqB;AACnB;AACD;;AAED,UAAI,gCAAcH,CAAd,K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UAAChB,KAAD,EAAW,CACV,MAAI,CAACA,KAAL,GAAaA,KAAb,CACA,oBACE,6BAAC,4BAAD,2BAAe,WAAW,EAAE,MAAI,CAACiB,WAAjC,IAAkD,MAAI,CAACnC,KAAvD,GACG,MAAI,CAACuB,UADR,CADF,CAKD,CARH,CADF,CAYD,C,CAED;AACF;AACA,K,QAyEUJ,sB,GAAR,gCAA+BiB,KAA/B,EAA8C,KAAfA,KAAe,cAAfA,KAAe,GAAP,KAAO,EAC5C,QAAQ,KAAKpC,KAAL,CAAWqC,IAAnB,GACE,KAAK,OAAL,CACE,OAAOvB,sBAAOwB,eAAP,CAAuB,KAAKpB,KAA5B,CAAP,CACF,KAAK,QAAL,CACE,OAAOJ,sBAAOyB,gBAAP,CAAwB,KAAKrB,KAA7B,CAAP,CACF,KAAK,OAAL,CACA,QACE,OAAOJ,sBAAO0B,eAAP,CAAuB,KAAKtB,KAA5B,CAAP,CAPJ,CASD,C,wBAjJgCuB,eAAMC,a,WACzBC,mB,GAAsB,e,UAEtBC,S,GAAY,EACxB;AACJ;AACA,KACI1C,cAAc,EAAE2C,mBAAUC,IAJF,E,UAOZC,Y,GAAe,EAC3BV,IAAI,EAAE,OADqB,E","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nimport { isNonNullable } from '../../lib/utils';\nimport { isKeyCapsLock } from '../../lib/events/keyboard/identifiers';\nimport { KeyboardEventCodes as Codes } from '../../lib/events/keyboard/KeyboardEventCodes';\nimport { Input, InputProps } from '../Input';\nimport { Nullable } from '../../typings/utility-types';\nimport { isIE11 } from '../../lib/client';\nimport { CommonWrapper, CommonProps, CommonWrapperRestProps } from '../../internal/CommonWrapper';\nimport { Theme } from '../../lib/theming/Theme';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { cx } from '../../lib/theming/Emotion';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\n\nimport { styles } from './PasswordInput.styles';\nimport { PasswordInputIcon } from './PasswordInputIcon';\n\nexport interface PasswordInputProps extends CommonProps, InputProps {\n detectCapsLock?: boolean;\n}\n\nexport interface PasswordInputState {\n visible: boolean;\n capsLockEnabled?: boolean | null;\n}\n\n/**\n * Компонент для ввода пароля\n */\n@rootNode\nexport class PasswordInput extends React.PureComponent<PasswordInputProps, PasswordInputState> {\n public static __KONTUR_REACT_UI__ = 'PasswordInput';\n\n public static propTypes = {\n /**\n * Включает CapsLock детектор\n */\n detectCapsLock: PropTypes.bool,\n };\n\n public static defaultProps = {\n size: 'small',\n };\n\n public state: PasswordInputState = {\n visible: false,\n capsLockEnabled: false,\n };\n\n private theme!: Theme;\n\n private input: Nullable<Input>;\n private setRootNode!: TSetRootNode;\n\n public componentDidMount() {\n if (this.props.detectCapsLock) {\n this.setState({ capsLockEnabled: null });\n }\n\n // @ts-ignore\n if (isIE11 && !window.document.msCapsLockWarningOff) {\n // turns off default ie capslock warning\n // @ts-ignore\n window.document.msCapsLockWarningOff = true;\n }\n }\n\n public static getDerivedStateFromProps(props: PasswordInputProps, state: PasswordInputState) {\n if (props.disabled) {\n return { visible: false };\n }\n\n return state;\n }\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n {this.renderMain}\n </CommonWrapper>\n );\n }}\n </ThemeContext.Consumer>\n );\n }\n\n /**\n * @public\n */\n public focus = () => {\n if (this.input) {\n this.input.focus();\n }\n };\n\n /**\n * @public\n */\n public blur = () => {\n this.handleBlur();\n };\n\n private handleKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {\n const { onKeyPress, detectCapsLock } = this.props;\n\n if (onKeyPress) {\n onKeyPress(e);\n }\n\n if (!detectCapsLock) {\n return;\n }\n\n const capsLockEnabled = e.getModifierState(Codes.CapsLock);\n\n this.setState({ capsLockEnabled });\n };\n\n private handleKeydown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n const {\n props: { detectCapsLock, onKeyDown },\n state: { capsLockEnabled },\n } = this;\n\n if (onKeyDown) {\n onKeyDown(e);\n }\n\n if (!detectCapsLock) {\n return;\n }\n\n if (isKeyCapsLock(e) && isNonNullable(capsLockEnabled)) {\n this.setState({ capsLockEnabled: !capsLockEnabled });\n }\n };\n\n private handleToggleVisibility = () => {\n this.setState((prevState) => ({ visible: !prevState.visible }), this.handleFocus);\n };\n\n private handleFocus = () => {\n if (this.input) {\n this.input.focus();\n }\n };\n\n private handleBlur = () => {\n if (this.input) {\n this.input.blur();\n }\n };\n\n private onBlur = (e: React.FocusEvent<HTMLInputElement, Element>) => {\n if (this.props.onBlur) {\n this.props.onBlur(e);\n }\n\n this.setState({ visible: false });\n };\n\n private getEyeWrapperClassname(right = false) {\n switch (this.props.size) {\n case 'large':\n return styles.eyeWrapperLarge(this.theme);\n case 'medium':\n return styles.eyeWrapperMedium(this.theme);\n case 'small':\n default:\n return styles.eyeWrapperSmall(this.theme);\n }\n }\n\n private renderEye = () => {\n const { capsLockEnabled } = this.state;\n\n return (\n <span className={styles.iconWrapper()}>\n {capsLockEnabled && <span className={styles.capsLockDetector()} data-tid=\"PasswordInputCapsLockDetector\" />}\n <span\n data-tid=\"PasswordInputEyeIcon\"\n className={cx(styles.toggleVisibility(this.theme), this.getEyeWrapperClassname())}\n onClick={this.handleToggleVisibility}\n >\n {!this.props.disabled && <PasswordInputIcon visible={this.state.visible} />}\n </span>\n </span>\n );\n };\n\n private refInput = (element: Input) => {\n this.input = element;\n };\n\n private renderMain = (props: CommonWrapperRestProps<PasswordInputProps>) => {\n const { detectCapsLock, ...rest } = props;\n const inputProps = {\n ...rest,\n onBlur: this.onBlur,\n onKeyDown: this.handleKeydown,\n onKeyPress: this.handleKeyPress,\n rightIcon: this.renderEye(),\n };\n\n return (\n <div className={styles.root()}>\n <Input ref={this.refInput} type={this.state.visible ? 'text' : 'password'} {...inputProps} />\n </div>\n );\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["PasswordInput.tsx"],"names":["PasswordInput","rootNode","state","visible","capsLockEnabled","focus","input","blur","handleBlur","handleKeyPress","e","props","onKeyPress","detectCapsLock","getModifierState","Codes","CapsLock","setState","handleKeydown","onKeyDown","handleToggleVisibility","prevState","handleFocus","renderEye","styles","iconWrapper","capsLockDetector","toggleVisibility","theme","getEyeWrapperClassname","disabled","refInput","element","hideSymbols","renderMain","rest","inputProps","rightIcon","root","componentDidMount","isIE11","window","document","msCapsLockWarningOff","getDerivedStateFromProps","render","setRootNode","right","size","eyeWrapperLarge","eyeWrapperMedium","eyeWrapperSmall","React","PureComponent","__KONTUR_REACT_UI__","propTypes","PropTypes","bool","defaultProps"],"mappings":"qjBAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,wD;;;;;;;;;;;AAWA;AACA;AACA,G;;AAEaA,a,OADZC,kB;;;;;;;;;;;;;;AAeQC,IAAAA,K,GAA4B;AACjCC,MAAAA,OAAO,EAAE,KADwB;AAEjCC,MAAAA,eAAe,EAAE,KAFgB,E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiD5BC,IAAAA,K,GAAQ,YAAM;AACnB,UAAI,MAAKC,KAAT,EAAgB;AACd,cAAKA,KAAL,CAAWD,KAAX;AACD;AACF,K;;;;;AAKME,IAAAA,I,GAAO,YAAM;AAClB,YAAKC,UAAL;AACD,K;;AAEOC,IAAAA,c,GAAiB,UAACC,CAAD,EAA8C;AACrE,wBAAuC,MAAKC,KAA5C,CAAQC,UAAR,eAAQA,UAAR,CAAoBC,cAApB,eAAoBA,cAApB;;AAEA,UAAID,UAAJ,EAAgB;AACdA,QAAAA,UAAU,CAACF,CAAD,CAAV;AACD;;AAED,UAAI,CAACG,cAAL,EAAqB;AACnB;AACD;;AAED,UAAMT,eAAe,GAAGM,CAAC,CAACI,gBAAF,CAAmBC,uCAAMC,QAAzB,CAAxB;;AAEA,YAAKC,QAAL,CAAc,EAAEb,eAAe,EAAfA,eAAF,EAAd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AAvC,CACD,CACF,C,eAEaC,wB,GAAd,kCAAuCjC,KAAvC,EAAkET,KAAlE,EAA6F,CAC3F,IAAIS,KAAK,CAACmB,QAAV,EAAoB,CAClB,OAAO,EAAE3B,OAAO,EAAE,KAAX,EAAP,CACD,CAED,OAAOD,KAAP,CACD,C,QAEM2C,M,GAAP,kBAAgB,mBACd,oBACE,6BAAC,0BAAD,CAAc,QAAd,QACG,UAACjB,KAAD,EAAW,CACV,MAAI,CAACA,KAAL,GAAaA,KAAb,CACA,oBACE,6BAAC,4BAAD,2BAAe,WAAW,EAAE,MAAI,CAACkB,WAAjC,IAAkD,MAAI,CAACnC,KAAvD,GACG,MAAI,CAACuB,UADR,CADF,CAKD,CARH,CADF,CAYD,C,CAED;AACF;AACA,K,QAiEUL,sB,GAAR,gCAA+BkB,KAA/B,EAA8C,KAAfA,KAAe,cAAfA,KAAe,GAAP,KAAO,EAC5C,QAAQ,KAAKpC,KAAL,CAAWqC,IAAnB,GACE,KAAK,OAAL,CACE,OAAOxB,sBAAOyB,eAAP,CAAuB,KAAKrB,KAA5B,CAAP,CACF,KAAK,QAAL,CACE,OAAOJ,sBAAO0B,gBAAP,CAAwB,KAAKtB,KAA7B,CAAP,CACF,KAAK,OAAL,CACA,QACE,OAAOJ,sBAAO2B,eAAP,CAAuB,KAAKvB,KAA5B,CAAP,CAPJ,CASD,C,wBAzIgCwB,eAAMC,a,WACzBC,mB,GAAsB,e,UAEtBC,S,GAAY,EACxB;AACJ;AACA,KACI1C,cAAc,EAAE2C,mBAAUC,IAJF,E,UAOZC,Y,GAAe,EAC3BV,IAAI,EAAE,OADqB,E","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nimport { RenderLayer } from '../../internal/RenderLayer';\nimport { isNonNullable } from '../../lib/utils';\nimport { isKeyCapsLock } from '../../lib/events/keyboard/identifiers';\nimport { KeyboardEventCodes as Codes } from '../../lib/events/keyboard/KeyboardEventCodes';\nimport { Input, InputProps } from '../Input';\nimport { Nullable } from '../../typings/utility-types';\nimport { isIE11 } from '../../lib/client';\nimport { CommonWrapper, CommonProps, CommonWrapperRestProps } from '../../internal/CommonWrapper';\nimport { Theme } from '../../lib/theming/Theme';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { cx } from '../../lib/theming/Emotion';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\n\nimport { styles } from './PasswordInput.styles';\nimport { PasswordInputIcon } from './PasswordInputIcon';\n\nexport interface PasswordInputProps extends CommonProps, InputProps {\n detectCapsLock?: boolean;\n}\n\nexport interface PasswordInputState {\n visible: boolean;\n capsLockEnabled?: boolean | null;\n}\n\n/**\n * Компонент для ввода пароля\n */\n@rootNode\nexport class PasswordInput extends React.PureComponent<PasswordInputProps, PasswordInputState> {\n public static __KONTUR_REACT_UI__ = 'PasswordInput';\n\n public static propTypes = {\n /**\n * Включает CapsLock детектор\n */\n detectCapsLock: PropTypes.bool,\n };\n\n public static defaultProps = {\n size: 'small',\n };\n\n public state: PasswordInputState = {\n visible: false,\n capsLockEnabled: false,\n };\n\n private theme!: Theme;\n\n private input: Nullable<Input>;\n private setRootNode!: TSetRootNode;\n\n public componentDidMount() {\n if (this.props.detectCapsLock) {\n this.setState({ capsLockEnabled: null });\n }\n\n // @ts-ignore\n if (isIE11 && !window.document.msCapsLockWarningOff) {\n // turns off default ie capslock warning\n // @ts-ignore\n window.document.msCapsLockWarningOff = true;\n }\n }\n\n public static getDerivedStateFromProps(props: PasswordInputProps, state: PasswordInputState) {\n if (props.disabled) {\n return { visible: false };\n }\n\n return state;\n }\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n {this.renderMain}\n </CommonWrapper>\n );\n }}\n </ThemeContext.Consumer>\n );\n }\n\n /**\n * @public\n */\n public focus = () => {\n if (this.input) {\n this.input.focus();\n }\n };\n\n /**\n * @public\n */\n public blur = () => {\n this.handleBlur();\n };\n\n private handleKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {\n const { onKeyPress, detectCapsLock } = this.props;\n\n if (onKeyPress) {\n onKeyPress(e);\n }\n\n if (!detectCapsLock) {\n return;\n }\n\n const capsLockEnabled = e.getModifierState(Codes.CapsLock);\n\n this.setState({ capsLockEnabled });\n };\n\n private handleKeydown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n const {\n props: { detectCapsLock, onKeyDown },\n state: { capsLockEnabled },\n } = this;\n\n if (onKeyDown) {\n onKeyDown(e);\n }\n\n if (!detectCapsLock) {\n return;\n }\n\n if (isKeyCapsLock(e) && isNonNullable(capsLockEnabled)) {\n this.setState({ capsLockEnabled: !capsLockEnabled });\n }\n };\n\n private handleToggleVisibility = () => {\n this.setState((prevState) => ({ visible: !prevState.visible }), this.handleFocus);\n };\n\n private handleFocus = () => {\n if (this.input) {\n this.input.focus();\n }\n };\n\n private handleBlur = () => {\n if (this.input) {\n this.input.blur();\n }\n };\n\n private getEyeWrapperClassname(right = false) {\n switch (this.props.size) {\n case 'large':\n return styles.eyeWrapperLarge(this.theme);\n case 'medium':\n return styles.eyeWrapperMedium(this.theme);\n case 'small':\n default:\n return styles.eyeWrapperSmall(this.theme);\n }\n }\n\n private renderEye = () => {\n const { capsLockEnabled } = this.state;\n\n return (\n <span className={styles.iconWrapper()}>\n {capsLockEnabled && <span className={styles.capsLockDetector()} data-tid=\"PasswordInputCapsLockDetector\" />}\n <span\n data-tid=\"PasswordInputEyeIcon\"\n className={cx(styles.toggleVisibility(this.theme), this.getEyeWrapperClassname())}\n onClick={this.handleToggleVisibility}\n >\n {!this.props.disabled && <PasswordInputIcon visible={this.state.visible} />}\n </span>\n </span>\n );\n };\n\n private refInput = (element: Input) => {\n this.input = element;\n };\n\n private hideSymbols = () => {\n this.setState({ visible: false });\n };\n\n private renderMain = (props: CommonWrapperRestProps<PasswordInputProps>) => {\n const { detectCapsLock, ...rest } = props;\n const inputProps = {\n ...rest,\n onKeyDown: this.handleKeydown,\n onKeyPress: this.handleKeyPress,\n rightIcon: this.renderEye(),\n };\n\n return (\n <RenderLayer onFocusOutside={this.hideSymbols} onClickOutside={this.hideSymbols}>\n <div className={styles.root()}>\n <Input ref={this.refInput} type={this.state.visible ? 'text' : 'password'} {...inputProps} />\n </div>\n </RenderLayer>\n );\n };\n}\n"]}
|
|
@@ -7,5 +7,9 @@ var _px = require("../../internal/icons/16px");
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var PasswordInputIcon = function PasswordInputIcon(_ref) {var visible = _ref.visible;
|
|
10
|
-
|
|
10
|
+
if (visible) {
|
|
11
|
+
return /*#__PURE__*/_react.default.createElement(_px.EyeClosedIcon, { size: 14 });
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return /*#__PURE__*/_react.default.createElement(_px.EyeOpenedIcon, { size: 14 });
|
|
11
15
|
};exports.PasswordInputIcon = PasswordInputIcon;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["PasswordInputIcon.tsx"],"names":["PasswordInputIcon","visible"],"mappings":"+JAAA;;AAEA;;;;;;AAMO,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB,OAAyC,KAAtCC,OAAsC,QAAtCA,OAAsC;AACxE,
|
|
1
|
+
{"version":3,"sources":["PasswordInputIcon.tsx"],"names":["PasswordInputIcon","visible"],"mappings":"+JAAA;;AAEA;;;;;;AAMO,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB,OAAyC,KAAtCC,OAAsC,QAAtCA,OAAsC;AACxE,MAAIA,OAAJ,EAAa;AACX,wBAAO,6BAAC,iBAAD,IAAe,IAAI,EAAE,EAArB,GAAP;AACD;;AAED,sBAAO,6BAAC,iBAAD,IAAe,IAAI,EAAE,EAArB,GAAP;AACD,CANM,C","sourcesContent":["import React from 'react';\n\nimport { EyeClosedIcon, EyeOpenedIcon } from '../../internal/icons/16px';\n\nimport { PasswordInputState } from './PasswordInput';\n\nexport type PasswordInputIconProps = Pick<PasswordInputState, 'visible'>;\n\nexport const PasswordInputIcon = ({ visible }: PasswordInputIconProps) => {\n if (visible) {\n return <EyeClosedIcon size={14} />;\n }\n\n return <EyeOpenedIcon size={14} />;\n};\n"]}
|
|
@@ -242,8 +242,6 @@ Select = (_dec = (0, _decorators.locale)('Select', _locale.SelectLocaleHelper),
|
|
|
242
242
|
|
|
243
243
|
|
|
244
244
|
|
|
245
|
-
|
|
246
|
-
|
|
247
245
|
|
|
248
246
|
|
|
249
247
|
|
|
@@ -484,6 +482,8 @@ Select = (_dec = (0, _decorators.locale)('Select', _locale.SelectLocaleHelper),
|
|
|
484
482
|
|
|
485
483
|
|
|
486
484
|
|
|
485
|
+
|
|
486
|
+
|
|
487
487
|
|
|
488
488
|
|
|
489
489
|
|
|
@@ -671,9 +671,9 @@ Select = (_dec = (0, _decorators.locale)('Select', _locale.SelectLocaleHelper),
|
|
|
671
671
|
onBlur: _this.props.onBlur }) :
|
|
672
672
|
|
|
673
673
|
buttonElement;
|
|
674
|
-
};return _this;}var _proto = Select.prototype;_proto.componentDidUpdate = function componentDidUpdate(_prevProps, prevState) {if (!prevState.opened && this.state.opened) {window.addEventListener('popstate', this.close);}if (prevState.opened && !this.state.opened) {window.removeEventListener('popstate', this.close);}};_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {_this2.theme = theme;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Provider, { value:
|
|
674
|
+
};return _this;}var _proto = Select.prototype;_proto.componentDidUpdate = function componentDidUpdate(_prevProps, prevState) {if (!prevState.opened && this.state.opened) {window.addEventListener('popstate', this.close);}if (prevState.opened && !this.state.opened) {window.removeEventListener('popstate', this.close);}};_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {_this2.theme = theme;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Provider, { value: _this2.theme }, _this2.renderMain());});} /**
|
|
675
675
|
* @public
|
|
676
|
-
*/;_proto.getMenuRenderer = function getMenuRenderer() {if (this.props.disabled) {return null;}if (this.isMobileLayout) {return this.renderMobileMenu();}if (this.state.opened) {return this.renderMenu();}return null;};_proto.renderMain = function renderMain() {var _cx2;var buttonParams = this.getDefaultButtonParams();var button = this.getButton(buttonParams);var isMobile = this.isMobileLayout;var style = { width: this.props.width, maxWidth: this.props.maxWidth || undefined };var root = /*#__PURE__*/_react.default.createElement("span", { className: (0, _Emotion.cx)((_cx2 = {}, _cx2[_Select.styles.root()] = true, _cx2[_Select.styles.rootMobile(this.theme)] = isMobile, _cx2)), style: style }, button, this.getMenuRenderer());return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, (0, _extends2.default)({ rootNodeRef: this.setRootNode }, this.props), /*#__PURE__*/_react.default.createElement(_RenderLayer.RenderLayer, { onClickOutside: this.close, onFocusOutside: this.close, active: isMobile ? false : this.state.opened }, root));};_proto.renderLabel = function renderLabel() {var _this$locale;var value = this.getValue();var item = this.getItemByValue(value);if ((0, _utils.isNonNullable)(value)) {return { label: this.getProps().renderValue(value, item), isPlaceholder: false };}return { label: /*#__PURE__*/_react.default.createElement("span", null, this.props.placeholder || ((_this$locale = this.locale) == null ? void 0 : _this$locale.placeholder)), isPlaceholder: true };};_proto.getLeftIconClass = function getLeftIconClass(size) {if (this.props.use === 'link') {return _Select.styles.leftIconLink(this.theme);}switch (size) {case 'large':return _Select.styles.leftIconLarge(this.theme);case 'medium':return _Select.styles.leftIconMedium(this.theme);case 'small':default:return _Select.styles.leftIconSmall(this.theme);}};_proto.renderDefaultButton = function renderDefaultButton(params) {var _cx3, _cx4;var buttonProps = (0, _extends2.default)({}, (0, _filterProps.filterProps)(this.props, PASS_BUTTON_PROPS), { align: 'left', disabled: this.props.disabled, width: '100%', onClick: params.onClick, onKeyDown: params.onKeyDown, active: params.opened });var labelProps = { className: (0, _Emotion.cx)((_cx3 = {}, _cx3[_Select.styles.label()] = this.props.use !== 'link', _cx3[_Select.styles.placeholder(this.theme)] = params.isPlaceholder, _cx3[_Select.styles.customUsePlaceholder()] = params.isPlaceholder && this.props.use !== 'default', _cx3[_Select.styles.placeholderDisabled(this.theme)] = params.isPlaceholder && this.props.disabled, _cx3)), style: { paddingRight: this.getSelectIconGap() } };var useIsCustom = this.props.use !== 'default';return /*#__PURE__*/_react.default.createElement(_Button.Button, buttonProps, /*#__PURE__*/_react.default.createElement("div", { className: _Select.styles.selectButtonContainer() }, this.props._icon && /*#__PURE__*/_react.default.createElement("div", { className: this.getLeftIconClass(this.props.size) }, this.props._icon), /*#__PURE__*/_react.default.createElement("span", labelProps, params.label), /*#__PURE__*/_react.default.createElement("div", { className: (0, _Emotion.cx)(_Select.styles.arrowWrap(this.theme), (_cx4 = {}, _cx4[_Select.styles.arrowDisabled(this.theme)] = this.props.disabled, _cx4[_Select.styles.customUseArrow()] = useIsCustom, _cx4)) }, /*#__PURE__*/_react.default.createElement(_px.ArrowChevronDownIcon, null))));};_proto.getSelectIconGap = function getSelectIconGap() {var _this3 = this;var getArrowPadding = function getArrowPadding() {switch (_this3.props.size) {case 'large':return _this3.theme.selectIconGapLarge;case 'medium':return _this3.theme.selectIconGapMedium;case 'small':default:return _this3.theme.selectIconGapSmall;}};var arrowLeftPadding = parseFloat(getArrowPadding()) || 0;return arrowLeftPadding;};_proto.renderMenu = function renderMenu() {var search = this.props.search ? /*#__PURE__*/_react.default.createElement("div", { className: _Select.styles.search(), onKeyDown: this.handleKey }, /*#__PURE__*/_react.default.createElement(_Input.Input, { ref: this.focusInput, onValueChange: this.handleSearch, width: "100%" })) : null;var value = this.getValue();var hasFixedWidth = !!this.props.menuWidth && this.props.menuWidth !== 'auto';return /*#__PURE__*/_react.default.createElement(_DropdownContainer.DropdownContainer, { getParent: this.dropdownContainerGetParent, offsetY: -1, align: this.props.menuAlign, disablePortal: this.props.disablePortal, hasFixedWidth: hasFixedWidth }, /*#__PURE__*/_react.default.createElement(_Menu.Menu, { ref: this.refMenu, width: this.props.menuWidth, onItemClick: this.close, maxHeight: this.props.maxMenuHeight, align: this.props.menuAlign }, search, this.getMenuItems(value)));};_proto.renderMobileMenu = function renderMobileMenu() {var search = this.props.search ? this.getSearch(true) : null;var value = this.getValue();var isWithSearch = Boolean(search);return /*#__PURE__*/_react.default.createElement(_MobilePopup.MobilePopup, { headerChildComponent: search, caption: this.props.mobileMenuHeaderText, useFullHeight: isWithSearch, onCloseRequest: this.close, opened: this.state.opened }, /*#__PURE__*/_react.default.createElement(_Menu.Menu, { hasShadow: false, onItemClick: this.close, disableScrollContainer: true, maxHeight: 'auto' }, this.getMenuItems(value)));};_proto.select = function select(value) {this.focus();this.setState({ opened: false, value: value });if (!this.areValuesEqual(this.getValue(), value)) {var _this$props$onValueCh, _this$props;(_this$props$onValueCh = (_this$props = this.props).onValueChange) == null ? void 0 : _this$props$onValueCh.call(_this$props, value);}};_proto.getValue = function getValue() {if (this.props.value !== undefined) {return this.props.value;}return this.state.value;};_proto.mapItems = function mapItems(fn) {var items = this.props.items;if (!items) {return [];}var pattern = this.state.searchPattern && this.state.searchPattern.toLowerCase();var result = [];var index = 0;for (var _iterator = _createForOfIteratorHelperLoose(items), _step; !(_step = _iterator()).done;) {var entry = _step.value;var _normalizeEntry = normalizeEntry(entry),_value = _normalizeEntry[0],_item = _normalizeEntry[1],_comment = _normalizeEntry[2];if (!pattern || this.getProps().filterItem(_value, _item, pattern)) {result.push(fn(_value, _item, index, _comment));++index;}}return result;};_proto.getItemByValue = function getItemByValue(value) {if (value === null || value === undefined) {return null;}var items = this.props.items || [];for (var _iterator2 = _createForOfIteratorHelperLoose(items), _step2; !(_step2 = _iterator2()).done;) {var entry = _step2.value;var _normalizeEntry2 = normalizeEntry(entry),itemValue = _normalizeEntry2[0],_item2 = _normalizeEntry2[1];if (this.areValuesEqual(itemValue, value)) {return _item2;}}return null;};_proto.areValuesEqual = function areValuesEqual(value1, value2) {return (0, _utils.isNonNullable)(value1) && (0, _utils.isNonNullable)(value2) && this.getProps().areValuesEqual(value1, value2);};return Select;}(_react.default.Component), _class2.__KONTUR_REACT_UI__ = 'Select', _class2.propTypes = { areValuesEqual: _propTypes.default.func, defaultValue: _propTypes.default.any, disablePortal: _propTypes.default.bool, disabled: _propTypes.default.bool, error: _propTypes.default.bool, filterItem: _propTypes.default.func, items: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object]), maxMenuHeight: _propTypes.default.number, maxWidth: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]), placeholder: _propTypes.default.node, renderItem: _propTypes.default.func, renderValue: _propTypes.default.func, search: _propTypes.default.bool, value: _propTypes.default.any, width: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]), onValueChange: _propTypes.default.func, onMouseEnter: _propTypes.default.func, onMouseLeave: _propTypes.default.func, onMouseOver: _propTypes.default.func, onKeyDown: _propTypes.default.func }, _class2.defaultProps = { renderValue: renderValue, renderItem: renderItem, areValuesEqual: areValuesEqual, filterItem: filterItem, use: 'default' }, _class2.Item = _Item.Item, _class2.SEP = function () {return /*#__PURE__*/_react.default.createElement(_MenuSeparator.MenuSeparator, null);}, _class2.static = function (element) {(0, _invariant.default)( /*#__PURE__*/_react.default.isValidElement(element) || typeof element === 'function', 'Select.static(element) expects element to be a valid react element.');return element;}, _temp)) || _class) || _class) || _class);exports.Select = Select;
|
|
676
|
+
*/;_proto.getMenuRenderer = function getMenuRenderer() {if (this.props.disabled) {return null;}if (this.isMobileLayout) {return this.renderMobileMenu();}if (this.state.opened) {return this.renderMenu();}return null;};_proto.renderMain = function renderMain() {var _cx2;var buttonParams = this.getDefaultButtonParams();var button = this.getButton(buttonParams);var isMobile = this.isMobileLayout;var style = { width: this.props.width, maxWidth: this.props.maxWidth || undefined };var root = /*#__PURE__*/_react.default.createElement("span", { className: (0, _Emotion.cx)((_cx2 = {}, _cx2[_Select.styles.root()] = true, _cx2[_Select.styles.rootMobile(this.theme)] = isMobile, _cx2)), style: style }, button, this.getMenuRenderer());return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, (0, _extends2.default)({ rootNodeRef: this.setRootNode }, this.props), /*#__PURE__*/_react.default.createElement(_RenderLayer.RenderLayer, { onClickOutside: this.close, onFocusOutside: this.close, active: isMobile ? false : this.state.opened }, root));};_proto.renderLabel = function renderLabel() {var _this$locale;var value = this.getValue();var item = this.getItemByValue(value);if ((0, _utils.isNonNullable)(value)) {return { label: this.getProps().renderValue(value, item), isPlaceholder: false };}return { label: /*#__PURE__*/_react.default.createElement("span", null, this.props.placeholder || ((_this$locale = this.locale) == null ? void 0 : _this$locale.placeholder)), isPlaceholder: true };};_proto.getLeftIconClass = function getLeftIconClass(size) {if (this.props.use === 'link') {return _Select.styles.leftIconLink(this.theme);}switch (size) {case 'large':return _Select.styles.leftIconLarge(this.theme);case 'medium':return _Select.styles.leftIconMedium(this.theme);case 'small':default:return _Select.styles.leftIconSmall(this.theme);}};_proto.renderDefaultButton = function renderDefaultButton(params) {var _cx3, _cx4;var buttonProps = (0, _extends2.default)({}, (0, _filterProps.filterProps)(this.props, PASS_BUTTON_PROPS), { align: 'left', disabled: this.props.disabled, width: '100%', onClick: params.onClick, onKeyDown: params.onKeyDown, active: params.opened });var labelProps = { className: (0, _Emotion.cx)((_cx3 = {}, _cx3[_Select.styles.label()] = this.props.use !== 'link', _cx3[_Select.styles.placeholder(this.theme)] = params.isPlaceholder, _cx3[_Select.styles.customUsePlaceholder()] = params.isPlaceholder && this.props.use !== 'default', _cx3[_Select.styles.placeholderDisabled(this.theme)] = params.isPlaceholder && this.props.disabled, _cx3)), style: { paddingRight: this.getSelectIconGap() } };var useIsCustom = this.props.use !== 'default';return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Provider, { value: (0, _selectTheme.getSelectTheme)(this.theme, this.props) }, /*#__PURE__*/_react.default.createElement(_Button.Button, buttonProps, /*#__PURE__*/_react.default.createElement("div", { className: _Select.styles.selectButtonContainer() }, this.props._icon && /*#__PURE__*/_react.default.createElement("div", { className: this.getLeftIconClass(this.props.size) }, this.props._icon), /*#__PURE__*/_react.default.createElement("span", labelProps, params.label), /*#__PURE__*/_react.default.createElement("div", { className: (0, _Emotion.cx)(_Select.styles.arrowWrap(this.theme), (_cx4 = {}, _cx4[_Select.styles.arrowDisabled(this.theme)] = this.props.disabled, _cx4[_Select.styles.customUseArrow()] = useIsCustom, _cx4)) }, /*#__PURE__*/_react.default.createElement(_px.ArrowChevronDownIcon, null)))));};_proto.getSelectIconGap = function getSelectIconGap() {var _this3 = this;var getArrowPadding = function getArrowPadding() {switch (_this3.props.size) {case 'large':return _this3.theme.selectIconGapLarge;case 'medium':return _this3.theme.selectIconGapMedium;case 'small':default:return _this3.theme.selectIconGapSmall;}};var arrowLeftPadding = parseFloat(getArrowPadding()) || 0;return arrowLeftPadding;};_proto.renderMenu = function renderMenu() {var search = this.props.search ? /*#__PURE__*/_react.default.createElement("div", { className: _Select.styles.search(), onKeyDown: this.handleKey }, /*#__PURE__*/_react.default.createElement(_Input.Input, { ref: this.focusInput, onValueChange: this.handleSearch, width: "100%" })) : null;var value = this.getValue();var hasFixedWidth = !!this.props.menuWidth && this.props.menuWidth !== 'auto';return /*#__PURE__*/_react.default.createElement(_DropdownContainer.DropdownContainer, { getParent: this.dropdownContainerGetParent, offsetY: -1, align: this.props.menuAlign, disablePortal: this.props.disablePortal, hasFixedWidth: hasFixedWidth }, /*#__PURE__*/_react.default.createElement(_Menu.Menu, { ref: this.refMenu, width: this.props.menuWidth, onItemClick: this.close, maxHeight: this.props.maxMenuHeight, align: this.props.menuAlign }, search, this.getMenuItems(value)));};_proto.renderMobileMenu = function renderMobileMenu() {var search = this.props.search ? this.getSearch(true) : null;var value = this.getValue();var isWithSearch = Boolean(search);return /*#__PURE__*/_react.default.createElement(_MobilePopup.MobilePopup, { headerChildComponent: search, caption: this.props.mobileMenuHeaderText, useFullHeight: isWithSearch, onCloseRequest: this.close, opened: this.state.opened }, /*#__PURE__*/_react.default.createElement(_Menu.Menu, { hasShadow: false, onItemClick: this.close, disableScrollContainer: true, maxHeight: 'auto' }, this.getMenuItems(value)));};_proto.select = function select(value) {this.focus();this.setState({ opened: false, value: value });if (!this.areValuesEqual(this.getValue(), value)) {var _this$props$onValueCh, _this$props;(_this$props$onValueCh = (_this$props = this.props).onValueChange) == null ? void 0 : _this$props$onValueCh.call(_this$props, value);}};_proto.getValue = function getValue() {if (this.props.value !== undefined) {return this.props.value;}return this.state.value;};_proto.mapItems = function mapItems(fn) {var items = this.props.items;if (!items) {return [];}var pattern = this.state.searchPattern && this.state.searchPattern.toLowerCase();var result = [];var index = 0;for (var _iterator = _createForOfIteratorHelperLoose(items), _step; !(_step = _iterator()).done;) {var entry = _step.value;var _normalizeEntry = normalizeEntry(entry),_value = _normalizeEntry[0],_item = _normalizeEntry[1],_comment = _normalizeEntry[2];if (!pattern || this.getProps().filterItem(_value, _item, pattern)) {result.push(fn(_value, _item, index, _comment));++index;}}return result;};_proto.getItemByValue = function getItemByValue(value) {if (value === null || value === undefined) {return null;}var items = this.props.items || [];for (var _iterator2 = _createForOfIteratorHelperLoose(items), _step2; !(_step2 = _iterator2()).done;) {var entry = _step2.value;var _normalizeEntry2 = normalizeEntry(entry),itemValue = _normalizeEntry2[0],_item2 = _normalizeEntry2[1];if (this.areValuesEqual(itemValue, value)) {return _item2;}}return null;};_proto.areValuesEqual = function areValuesEqual(value1, value2) {return (0, _utils.isNonNullable)(value1) && (0, _utils.isNonNullable)(value2) && this.getProps().areValuesEqual(value1, value2);};return Select;}(_react.default.Component), _class2.__KONTUR_REACT_UI__ = 'Select', _class2.propTypes = { areValuesEqual: _propTypes.default.func, defaultValue: _propTypes.default.any, disablePortal: _propTypes.default.bool, disabled: _propTypes.default.bool, error: _propTypes.default.bool, filterItem: _propTypes.default.func, items: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object]), maxMenuHeight: _propTypes.default.number, maxWidth: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]), placeholder: _propTypes.default.node, renderItem: _propTypes.default.func, renderValue: _propTypes.default.func, search: _propTypes.default.bool, value: _propTypes.default.any, width: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]), onValueChange: _propTypes.default.func, onMouseEnter: _propTypes.default.func, onMouseLeave: _propTypes.default.func, onMouseOver: _propTypes.default.func, onKeyDown: _propTypes.default.func }, _class2.defaultProps = { renderValue: renderValue, renderItem: renderItem, areValuesEqual: areValuesEqual, filterItem: filterItem, use: 'default' }, _class2.Item = _Item.Item, _class2.SEP = function () {return /*#__PURE__*/_react.default.createElement(_MenuSeparator.MenuSeparator, null);}, _class2.static = function (element) {(0, _invariant.default)( /*#__PURE__*/_react.default.isValidElement(element) || typeof element === 'function', 'Select.static(element) expects element to be a valid react element.');return element;}, _temp)) || _class) || _class) || _class);exports.Select = Select;
|
|
677
677
|
function renderValue(value, item) {
|
|
678
678
|
return item;
|
|
679
679
|
}
|