@skbkontur/react-ui 4.10.0 → 4.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/cjs/components/Autocomplete/Autocomplete.d.ts +2 -1
  3. package/cjs/components/Autocomplete/Autocomplete.js +8 -1
  4. package/cjs/components/Autocomplete/Autocomplete.js.map +1 -1
  5. package/cjs/components/ComboBox/ComboBox.d.ts +2 -1
  6. package/cjs/components/ComboBox/ComboBox.js +1 -0
  7. package/cjs/components/ComboBox/ComboBox.js.map +1 -1
  8. package/cjs/components/DatePicker/DatePicker.d.ts +2 -1
  9. package/cjs/components/DatePicker/DatePicker.js +1 -0
  10. package/cjs/components/DatePicker/DatePicker.js.map +1 -1
  11. package/cjs/components/Modal/Modal.styles.js +1 -1
  12. package/cjs/components/Modal/Modal.styles.js.map +1 -1
  13. package/cjs/components/Select/Select.d.ts +2 -1
  14. package/cjs/components/Select/Select.js +2 -1
  15. package/cjs/components/Select/Select.js.map +1 -1
  16. package/cjs/internal/CustomComboBox/ComboBoxView.d.ts +2 -1
  17. package/cjs/internal/CustomComboBox/ComboBoxView.js +2 -1
  18. package/cjs/internal/CustomComboBox/ComboBoxView.js.map +1 -1
  19. package/cjs/internal/CustomComboBox/CustomComboBox.d.ts +2 -1
  20. package/cjs/internal/CustomComboBox/CustomComboBox.js +3 -1
  21. package/cjs/internal/CustomComboBox/CustomComboBox.js.map +1 -1
  22. package/cjs/internal/DropdownContainer/DropdownContainer.d.ts +4 -0
  23. package/cjs/internal/DropdownContainer/DropdownContainer.js +11 -6
  24. package/cjs/internal/DropdownContainer/DropdownContainer.js.map +1 -1
  25. package/cjs/internal/DropdownContainer/getManualPosition.d.ts +19 -0
  26. package/cjs/internal/DropdownContainer/getManualPosition.js +41 -0
  27. package/cjs/internal/DropdownContainer/getManualPosition.js.map +1 -0
  28. package/cjs/lib/theming/ThemeFactory.js +7 -0
  29. package/cjs/lib/theming/ThemeFactory.js.map +1 -1
  30. package/cjs/lib/theming/ThemeHelpers.d.ts +12 -3
  31. package/cjs/lib/theming/ThemeHelpers.js +24 -5
  32. package/cjs/lib/theming/ThemeHelpers.js.map +1 -1
  33. package/cjs/lib/theming/themes/DarkTheme.js +1 -1
  34. package/cjs/lib/theming/themes/DarkTheme.js.map +1 -1
  35. package/cjs/lib/theming/themes/Theme2022Dark.d.ts +1 -1
  36. package/cjs/lib/theming/themes/Theme2022Dark.js +4 -3
  37. package/cjs/lib/theming/themes/Theme2022Dark.js.map +1 -1
  38. package/components/Autocomplete/Autocomplete/Autocomplete.js +4 -2
  39. package/components/Autocomplete/Autocomplete/Autocomplete.js.map +1 -1
  40. package/components/Autocomplete/Autocomplete.d.ts +2 -1
  41. package/components/ComboBox/ComboBox/ComboBox.js.map +1 -1
  42. package/components/ComboBox/ComboBox.d.ts +2 -1
  43. package/components/DatePicker/DatePicker/DatePicker.js +1 -0
  44. package/components/DatePicker/DatePicker/DatePicker.js.map +1 -1
  45. package/components/DatePicker/DatePicker.d.ts +2 -1
  46. package/components/Modal/Modal.styles/Modal.styles.js +1 -1
  47. package/components/Modal/Modal.styles/Modal.styles.js.map +1 -1
  48. package/components/Select/Select/Select.js +2 -1
  49. package/components/Select/Select/Select.js.map +1 -1
  50. package/components/Select/Select.d.ts +2 -1
  51. package/internal/CustomComboBox/ComboBoxView/ComboBoxView.js +3 -1
  52. package/internal/CustomComboBox/ComboBoxView/ComboBoxView.js.map +1 -1
  53. package/internal/CustomComboBox/ComboBoxView.d.ts +2 -1
  54. package/internal/CustomComboBox/CustomComboBox/CustomComboBox.js +1 -0
  55. package/internal/CustomComboBox/CustomComboBox/CustomComboBox.js.map +1 -1
  56. package/internal/CustomComboBox/CustomComboBox.d.ts +2 -1
  57. package/internal/DropdownContainer/DropdownContainer/DropdownContainer.js +17 -4
  58. package/internal/DropdownContainer/DropdownContainer/DropdownContainer.js.map +1 -1
  59. package/internal/DropdownContainer/DropdownContainer.d.ts +4 -0
  60. package/internal/DropdownContainer/getManualPosition/getManualPosition.js +36 -0
  61. package/internal/DropdownContainer/getManualPosition/getManualPosition.js.map +1 -0
  62. package/internal/DropdownContainer/getManualPosition/package.json +6 -0
  63. package/internal/DropdownContainer/getManualPosition.d.ts +19 -0
  64. package/lib/theming/ThemeFactory/ThemeFactory.js +7 -1
  65. package/lib/theming/ThemeFactory/ThemeFactory.js.map +1 -1
  66. package/lib/theming/ThemeHelpers/ThemeHelpers.js +18 -4
  67. package/lib/theming/ThemeHelpers/ThemeHelpers.js.map +1 -1
  68. package/lib/theming/ThemeHelpers.d.ts +12 -3
  69. package/lib/theming/themes/DarkTheme/DarkTheme.js +2 -2
  70. package/lib/theming/themes/DarkTheme/DarkTheme.js.map +1 -1
  71. package/lib/theming/themes/Theme2022Dark/Theme2022Dark.js +2 -1
  72. package/lib/theming/themes/Theme2022Dark/Theme2022Dark.js.map +1 -1
  73. package/lib/theming/themes/Theme2022Dark.d.ts +1 -1
  74. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["CustomComboBox.tsx"],"names":["React","CancelationError","taskWithDelay","fixClickFocusIE","CommonWrapper","responsiveLayout","rootNode","ComboBoxRequestStatus","reducer","ComboBoxView","DELAY_BEFORE_SHOW_LOADER","LOADER_SHOW_TIME","DefaultState","inputChanged","editing","items","loading","opened","focused","textValue","repeatRequest","undefined","requestStatus","Unknown","CustomComboBoxDataTids","comboBoxView","CustomComboBox","state","requestId","cancelationToken","cancelLoaderDelay","focus","props","disabled","input","inputLikeText","selectInputText","selectAll","blur","handleBlur","dispatch","action","effects","nextState","setState","stateAndEffect","Array","forEach","handleEffect","effect","getState","getProps","handleValueChange","value","type","keepFocus","isMobileLayout","handleFocus","handleClickOutside","e","close","setTimeout","handleInputBlur","handleInputClick","search","query","getItems","cancelPromise","Promise","_","reject","expectingId","loaderShowDelay","resolve","cancelLoader","race","code","cancelSearch","open","render","viewProps","align","borderless","disablePortal","error","menuAlign","drawArrow","placeholder","size","totalCount","warning","width","maxLength","maxMenuHeight","leftIcon","rightIcon","inputMode","onValueChange","onClickOutside","onFocus","onFocusOutside","onInputBlur","onInputValueChange","onInputFocus","onInputClick","onInputKeyDown","event","persist","onMouseEnter","onMouseOver","onMouseLeave","renderItem","renderNotFound","itemWrapper","renderValue","renderTotalCount","renderAddButton","refInput","refMenu","menu","refInputLikeText","setRootNode","componentDidMount","autoFocus","componentDidUpdate","prevProps","prevState","reset","PureComponent","__KONTUR_REACT_UI__"],"mappings":"0XAAA,OAAOA,KAAP,MAAkB,OAAlB;;;;;;;AAOA,SAASC,gBAAT,EAA2BC,aAA3B,QAAgD,iBAAhD;AACA,SAASC,eAAT,QAAgC,kCAAhC;AACA,SAAsBC,aAAtB,QAA2C,8BAA3C;AACA,SAASC,gBAAT,QAAiC,6CAAjC;AACA,SAASC,QAAT,QAAuC,oBAAvC;;AAEA,SAASC,qBAAT,QAAsC,uBAAtC;AACA,SAAqDC,OAArD,QAAoE,yBAApE;AACA,SAASC,YAAT,QAA6B,gBAA7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,OAAO,IAAMC,wBAAwB,GAAG,GAAjC;AACP,OAAO,IAAMC,gBAAgB,GAAG,IAAzB;;AAEP,OAAO,IAAMC,YAAY,GAAG;AAC1BC,EAAAA,YAAY,EAAE,KADY;AAE1BC,EAAAA,OAAO,EAAE,KAFiB;AAG1BC,EAAAA,KAAK,EAAE,IAHmB;AAI1BC,EAAAA,OAAO,EAAE,KAJiB;AAK1BC,EAAAA,MAAM,EAAE,KALkB;AAM1BC,EAAAA,OAAO,EAAE,KANiB;AAO1BC,EAAAA,SAAS,EAAE,EAPe;AAQ1BC,EAAAA,aAAa,EAAE,iCAAMC,SAAN,EARW;AAS1BC,EAAAA,aAAa,EAAEf,qBAAqB,CAACgB,OATX,EAArB;;;AAYP,OAAO,IAAMC,sBAAsB,GAAG;AACpCC,EAAA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D,CAnOH,yBAAuCtD,KAAK,CAACgI,aAA7C,WACgBC,mBADhB,GACsC,gBADtC","sourcesContent":["import React from 'react';\n\nimport { Nullable } from '../../typings/utility-types';\nimport { Input, InputIconType } from '../../components/Input';\nimport { Menu } from '../Menu';\nimport { InputLikeText } from '../InputLikeText';\nimport { MenuItemState } from '../../components/MenuItem';\nimport { CancelationError, taskWithDelay } from '../../lib/utils';\nimport { fixClickFocusIE } from '../../lib/events/fixClickFocusIE';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { responsiveLayout } from '../../components/ResponsiveLayout/decorator';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\n\nimport { ComboBoxRequestStatus } from './CustomComboBoxTypes';\nimport { CustomComboBoxAction, CustomComboBoxEffect, reducer } from './CustomComboBoxReducer';\nimport { ComboBoxView } from './ComboBoxView';\n\nexport interface CustomComboBoxProps<T> extends CommonProps {\n align?: 'left' | 'center' | 'right';\n autoFocus?: boolean;\n borderless?: boolean;\n disablePortal?: boolean;\n disabled?: boolean;\n /**\n * Cостояние валидации при ошибке.\n */\n error?: boolean;\n maxLength?: number;\n menuAlign?: 'left' | 'right';\n drawArrow?: boolean;\n leftIcon?: InputIconType;\n rightIcon?: InputIconType;\n searchOnFocus?: boolean;\n onValueChange?: (value: T) => void;\n onInputValueChange?: (value: string) => Nullable<string> | void;\n onUnexpectedInput?: (value: string) => void | null | T;\n onFocus?: () => void;\n onBlur?: () => void;\n onMouseEnter?: (e: React.MouseEvent) => void;\n onMouseOver?: (e: React.MouseEvent) => void;\n onMouseLeave?: (e: React.MouseEvent) => void;\n onInputKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => void;\n placeholder?: string;\n size?: 'small' | 'medium' | 'large';\n totalCount?: number;\n value?: Nullable<T>;\n /**\n * Cостояние валидации при предупреждении.\n */\n warning?: boolean;\n width?: string | number;\n maxMenuHeight?: number | string;\n renderNotFound?: () => React.ReactNode;\n renderTotalCount?: (found: number, total: number) => React.ReactNode;\n renderItem: (item: T, state?: MenuItemState) => React.ReactNode;\n itemWrapper?: (item?: T) => React.ComponentType<unknown>;\n renderValue: (value: T) => React.ReactNode;\n renderAddButton?: (query?: string) => React.ReactNode;\n valueToString: (value: T) => string;\n itemToValue: (item: T) => string | number;\n getItems: (query: string) => Promise<T[]>;\n inputMode?: React.HTMLAttributes<HTMLInputElement>['inputMode'];\n}\n\nexport interface CustomComboBoxState<T> {\n editing: boolean;\n loading: boolean;\n opened: boolean;\n textValue: string;\n items: Nullable<T[]>;\n inputChanged: boolean;\n focused: boolean;\n repeatRequest: () => void;\n requestStatus: ComboBoxRequestStatus;\n}\n\nexport const DELAY_BEFORE_SHOW_LOADER = 300;\nexport const LOADER_SHOW_TIME = 1000;\n\nexport const DefaultState = {\n inputChanged: false,\n editing: false,\n items: null,\n loading: false,\n opened: false,\n focused: false,\n textValue: '',\n repeatRequest: () => undefined,\n requestStatus: ComboBoxRequestStatus.Unknown,\n};\n\nexport const CustomComboBoxDataTids = {\n comboBoxView: 'ComboBoxView__root',\n} as const;\n\n@responsiveLayout\n@rootNode\nexport class CustomComboBox<T> extends React.PureComponent<CustomComboBoxProps<T>, CustomComboBoxState<T>> {\n public static __KONTUR_REACT_UI__ = 'CustomComboBox';\n\n public state: CustomComboBoxState<T> = DefaultState;\n public input: Nullable<Input>;\n public menu: Nullable<Menu>;\n public inputLikeText: Nullable<InputLikeText>;\n public requestId = 0;\n public loaderShowDelay: Nullable<Promise<void>>;\n private focused = false;\n private cancelationToken: Nullable<(reason?: Error) => void> = null;\n private isMobileLayout!: boolean;\n\n private reducer = reducer;\n public cancelLoaderDelay: () => void = () => null;\n\n /**\n * @public\n */\n public focus = () => {\n if (this.props.disabled) {\n return;\n }\n\n if (this.input) {\n this.input.focus();\n } else if (this.inputLikeText) {\n this.inputLikeText.focus();\n }\n };\n\n /**\n * @public\n */\n public selectInputText = () => {\n if (this.props.disabled) {\n return;\n }\n if (this.input) {\n this.input.selectAll();\n }\n };\n\n /**\n * @public\n */\n public blur = () => {\n if (this.props.disabled) {\n return;\n }\n\n this.handleBlur();\n };\n private setRootNode!: TSetRootNode;\n\n /**\n * @public\n */\n public async search(query: string = this.state.textValue) {\n const { getItems } = this.props;\n\n const cancelPromise: Promise<never> = new Promise((_, reject) => (this.cancelationToken = reject));\n this.requestId += 1;\n const expectingId = this.requestId;\n\n if (!this.loaderShowDelay) {\n this.loaderShowDelay = new Promise<void>((resolve) => {\n const cancelLoader = taskWithDelay(() => {\n this.dispatch({ type: 'RequestItems' });\n setTimeout(resolve, LOADER_SHOW_TIME);\n }, DELAY_BEFORE_SHOW_LOADER);\n\n cancelPromise.catch(() => cancelLoader());\n\n this.cancelLoaderDelay = () => {\n cancelLoader();\n resolve();\n };\n });\n }\n\n try {\n const items = await Promise.race([getItems(query), cancelPromise]);\n if (this.state.loading) {\n await Promise.race([this.loaderShowDelay, cancelPromise]);\n }\n if (expectingId === this.requestId) {\n this.dispatch({\n type: 'ReceiveItems',\n items,\n });\n }\n } catch (error) {\n if (error && error.code === 'CancelationError') {\n this.dispatch({ type: 'CancelRequest' });\n } else if (expectingId === this.requestId) {\n this.dispatch({\n type: 'RequestFailure',\n repeatRequest: () => {\n this.search(query);\n if (this.input) {\n this.input.focus();\n }\n },\n });\n }\n } finally {\n if (expectingId === this.requestId) {\n if (!this.state.loading) {\n this.cancelLoaderDelay();\n }\n this.cancelationToken = null;\n this.loaderShowDelay = null;\n }\n }\n }\n\n /**\n * @public\n */\n public cancelSearch() {\n if (this.cancelationToken) {\n this.cancelationToken(new CancelationError());\n }\n }\n\n /**\n * @public\n */\n public open() {\n this.dispatch({ type: 'Open' });\n }\n\n /**\n * @public\n */\n public close() {\n this.dispatch({ type: 'Close' });\n }\n\n public render() {\n const viewProps = {\n align: this.props.align,\n borderless: this.props.borderless,\n disabled: this.props.disabled,\n disablePortal: this.props.disablePortal,\n editing: this.state.editing,\n error: this.props.error,\n items: this.state.items,\n loading: this.state.loading,\n menuAlign: this.props.menuAlign,\n opened: this.state.opened,\n drawArrow: this.props.drawArrow,\n placeholder: this.props.placeholder,\n size: this.props.size,\n textValue: this.state.textValue,\n totalCount: this.props.totalCount,\n value: this.props.value,\n warning: this.props.warning,\n width: this.props.width,\n maxLength: this.props.maxLength,\n maxMenuHeight: this.props.maxMenuHeight,\n leftIcon: this.props.leftIcon,\n rightIcon: this.props.rightIcon,\n inputMode: this.props.inputMode,\n\n onValueChange: this.handleValueChange,\n onClickOutside: this.handleClickOutside,\n onFocus: this.handleFocus,\n onFocusOutside: this.handleBlur,\n onInputBlur: this.handleInputBlur,\n onInputValueChange: (value: string) => this.dispatch({ type: 'TextChange', value }),\n onInputFocus: this.handleFocus,\n onInputClick: this.handleInputClick,\n onInputKeyDown: (event: React.KeyboardEvent) => {\n event.persist();\n this.dispatch({ type: 'KeyPress', event });\n },\n onMouseEnter: this.props.onMouseEnter,\n onMouseOver: this.props.onMouseOver,\n onMouseLeave: this.props.onMouseLeave,\n renderItem: this.props.renderItem,\n renderNotFound: this.props.renderNotFound,\n itemWrapper: this.props.itemWrapper,\n renderValue: this.props.renderValue,\n renderTotalCount: this.props.renderTotalCount,\n renderAddButton: this.props.renderAddButton,\n repeatRequest: this.state.repeatRequest,\n requestStatus: this.state.requestStatus,\n\n refInput: (input: Nullable<Input>) => {\n this.input = input;\n },\n refMenu: (menu: Nullable<Menu>) => {\n this.menu = menu;\n },\n refInputLikeText: (inputLikeText: Nullable<InputLikeText>) => {\n this.inputLikeText = inputLikeText;\n },\n };\n\n return (\n <CommonWrapper {...this.props}>\n <ComboBoxView {...viewProps} ref={this.setRootNode} />\n </CommonWrapper>\n );\n }\n\n public componentDidMount() {\n this.dispatch({ type: 'Mount' });\n if (this.props.autoFocus) {\n this.focus();\n }\n }\n\n public componentDidUpdate(prevProps: CustomComboBoxProps<T>, prevState: CustomComboBoxState<T>) {\n if (prevState.editing && !this.state.editing) {\n this.handleBlur();\n }\n this.dispatch({ type: 'DidUpdate', prevProps, prevState });\n }\n\n /**\n * @public\n */\n public reset() {\n this.dispatch({ type: 'Reset' });\n }\n\n private dispatch = (action: CustomComboBoxAction<T>) => {\n let effects: Array<CustomComboBoxEffect<T>>;\n let nextState: Pick<CustomComboBoxState<T>, never>;\n\n this.setState(\n (state) => {\n const stateAndEffect = this.reducer(state, this.props, action);\n\n [nextState, effects] = stateAndEffect instanceof Array ? stateAndEffect : [stateAndEffect, []];\n\n return nextState;\n },\n () => {\n effects.forEach(this.handleEffect);\n },\n );\n };\n\n private handleEffect = (effect: CustomComboBoxEffect<T>) => {\n effect(this.dispatch, this.getState, this.getProps, () => this);\n };\n\n private getProps = () => this.props;\n\n private getState = () => this.state;\n\n private handleValueChange = (value: T) => {\n this.dispatch({\n type: 'ValueChange',\n value,\n keepFocus: !this.isMobileLayout,\n });\n };\n\n private handleFocus = () => {\n if (this.focused) {\n return;\n }\n this.focused = true;\n this.dispatch({ type: 'Focus' });\n };\n\n private handleClickOutside = (e: Event) => {\n fixClickFocusIE(e);\n this.handleBlur();\n };\n\n private handleBlur = () => {\n if (!this.focused) {\n if (this.state.opened) {\n this.close();\n }\n return;\n }\n\n this.focused = false;\n // workaround for the similar bug with focusout\n // in Firefox, Chrome and IE\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1363964\n setTimeout(() => {\n this.dispatch({ type: 'Blur' });\n });\n };\n\n private handleInputBlur = () => {\n // If menu opened, RenderLayer is active and\n // it would call handleFocusOutside\n // In that way handleBlur would be called\n\n // TODO: add check for mobile layout, to call `handleBlur`\n\n if (this.state.opened) {\n return;\n }\n this.handleBlur();\n };\n\n private handleInputClick = () => {\n if (!this.cancelationToken) {\n this.dispatch({ type: 'InputClick' });\n }\n };\n}\n"]}
1
+ {"version":3,"sources":["CustomComboBox.tsx"],"names":["React","CancelationError","taskWithDelay","fixClickFocusIE","CommonWrapper","responsiveLayout","rootNode","ComboBoxRequestStatus","reducer","ComboBoxView","DELAY_BEFORE_SHOW_LOADER","LOADER_SHOW_TIME","DefaultState","inputChanged","editing","items","loading","opened","focused","textValue","repeatRequest","undefined","requestStatus","Unknown","CustomComboBoxDataTids","comboBoxView","CustomComboBox","state","requestId","cancelationToken","cancelLoaderDelay","focus","props","disabled","input","inputLikeText","selectInputText","selectAll","blur","handleBlur","dispatch","action","effects","nextState","setState","stateAndEffect","Array","forEach","handleEffect","effect","getState","getProps","handleValueChange","value","type","keepFocus","isMobileLayout","handleFocus","handleClickOutside","e","close","setTimeout","handleInputBlur","handleInputClick","search","query","getItems","cancelPromise","Promise","_","reject","expectingId","loaderShowDelay","resolve","cancelLoader","race","code","cancelSearch","open","render","viewProps","align","borderless","disablePortal","error","menuAlign","drawArrow","menuPos","placeholder","size","totalCount","warning","width","maxLength","maxMenuHeight","leftIcon","rightIcon","inputMode","onValueChange","onClickOutside","onFocus","onFocusOutside","onInputBlur","onInputValueChange","onInputFocus","onInputClick","onInputKeyDown","event","persist","onMouseEnter","onMouseOver","onMouseLeave","renderItem","renderNotFound","itemWrapper","renderValue","renderTotalCount","renderAddButton","refInput","refMenu","menu","refInputLikeText","setRootNode","componentDidMount","autoFocus","componentDidUpdate","prevProps","prevState","reset","PureComponent","__KONTUR_REACT_UI__"],"mappings":"0XAAA,OAAOA,KAAP,MAAkB,OAAlB;;;;;;;AAOA,SAASC,gBAAT,EAA2BC,aAA3B,QAAgD,iBAAhD;AACA,SAASC,eAAT,QAAgC,kCAAhC;AACA,SAAsBC,aAAtB,QAA2C,8BAA3C;AACA,SAASC,gBAAT,QAAiC,6CAAjC;AACA,SAASC,QAAT,QAAuC,oBAAvC;;;AAGA,SAASC,qBAAT,QAAsC,uBAAtC;AACA,SAAqDC,OAArD,QAAoE,yBAApE;AACA,SAASC,YAAT,QAA6B,gBAA7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,OAAO,IAAMC,wBAAwB,GAAG,GAAjC;AACP,OAAO,IAAMC,gBAAgB,GAAG,IAAzB;;AAEP,OAAO,IAAMC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F,SAAf,EAA0B,CACxB,KAAK7F,KAAL,GACD,CACF,CAtNH,QAwNS8F,kBAxNT,GAwNE,4BAA0BC,SAA1B,EAA6DC,SAA7D,EAAgG,CAC9F,IAAIA,SAAS,CAACjH,OAAV,IAAqB,CAAC,KAAKa,KAAL,CAAWb,OAArC,EAA8C,CAC5C,KAAKyB,UAAL,GACD,CACD,KAAKC,QAAL,CAAc,EAAEc,IAAI,EAAE,WAAR,EAAqBwE,SAAS,EAATA,SAArB,EAAgCC,SAAS,EAATA,SAAhC,EAAd,EACD,CA7NH,CA+NE;AACF;AACA,KAjOA,QAkOSC,KAlOT,GAkOE,iBAAe,CACb,KAAKxF,QAAL,CAAc,EAAEc,IAAI,EAAE,OAAR,EAAd,EACD,CApOH,yBAAuCtD,KAAK,CAACiI,aAA7C,WACgBC,mBADhB,GACsC,gBADtC","sourcesContent":["import React from 'react';\n\nimport { Nullable } from '../../typings/utility-types';\nimport { Input, InputIconType } from '../../components/Input';\nimport { Menu } from '../Menu';\nimport { InputLikeText } from '../InputLikeText';\nimport { MenuItemState } from '../../components/MenuItem';\nimport { CancelationError, taskWithDelay } from '../../lib/utils';\nimport { fixClickFocusIE } from '../../lib/events/fixClickFocusIE';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { responsiveLayout } from '../../components/ResponsiveLayout/decorator';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { DropdownContainerProps } from '../DropdownContainer';\n\nimport { ComboBoxRequestStatus } from './CustomComboBoxTypes';\nimport { CustomComboBoxAction, CustomComboBoxEffect, reducer } from './CustomComboBoxReducer';\nimport { ComboBoxView } from './ComboBoxView';\n\nexport interface CustomComboBoxProps<T> extends Pick<DropdownContainerProps, 'menuPos'>, CommonProps {\n align?: 'left' | 'center' | 'right';\n autoFocus?: boolean;\n borderless?: boolean;\n disablePortal?: boolean;\n disabled?: boolean;\n /**\n * Cостояние валидации при ошибке.\n */\n error?: boolean;\n maxLength?: number;\n menuAlign?: 'left' | 'right';\n drawArrow?: boolean;\n leftIcon?: InputIconType;\n rightIcon?: InputIconType;\n searchOnFocus?: boolean;\n onValueChange?: (value: T) => void;\n onInputValueChange?: (value: string) => Nullable<string> | void;\n onUnexpectedInput?: (value: string) => void | null | T;\n onFocus?: () => void;\n onBlur?: () => void;\n onMouseEnter?: (e: React.MouseEvent) => void;\n onMouseOver?: (e: React.MouseEvent) => void;\n onMouseLeave?: (e: React.MouseEvent) => void;\n onInputKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => void;\n placeholder?: string;\n size?: 'small' | 'medium' | 'large';\n totalCount?: number;\n value?: Nullable<T>;\n /**\n * Cостояние валидации при предупреждении.\n */\n warning?: boolean;\n width?: string | number;\n maxMenuHeight?: number | string;\n renderNotFound?: () => React.ReactNode;\n renderTotalCount?: (found: number, total: number) => React.ReactNode;\n renderItem: (item: T, state?: MenuItemState) => React.ReactNode;\n itemWrapper?: (item?: T) => React.ComponentType<unknown>;\n renderValue: (value: T) => React.ReactNode;\n renderAddButton?: (query?: string) => React.ReactNode;\n valueToString: (value: T) => string;\n itemToValue: (item: T) => string | number;\n getItems: (query: string) => Promise<T[]>;\n inputMode?: React.HTMLAttributes<HTMLInputElement>['inputMode'];\n}\n\nexport interface CustomComboBoxState<T> {\n editing: boolean;\n loading: boolean;\n opened: boolean;\n textValue: string;\n items: Nullable<T[]>;\n inputChanged: boolean;\n focused: boolean;\n repeatRequest: () => void;\n requestStatus: ComboBoxRequestStatus;\n}\n\nexport const DELAY_BEFORE_SHOW_LOADER = 300;\nexport const LOADER_SHOW_TIME = 1000;\n\nexport const DefaultState = {\n inputChanged: false,\n editing: false,\n items: null,\n loading: false,\n opened: false,\n focused: false,\n textValue: '',\n repeatRequest: () => undefined,\n requestStatus: ComboBoxRequestStatus.Unknown,\n};\n\nexport const CustomComboBoxDataTids = {\n comboBoxView: 'ComboBoxView__root',\n} as const;\n\n@responsiveLayout\n@rootNode\nexport class CustomComboBox<T> extends React.PureComponent<CustomComboBoxProps<T>, CustomComboBoxState<T>> {\n public static __KONTUR_REACT_UI__ = 'CustomComboBox';\n\n public state: CustomComboBoxState<T> = DefaultState;\n public input: Nullable<Input>;\n public menu: Nullable<Menu>;\n public inputLikeText: Nullable<InputLikeText>;\n public requestId = 0;\n public loaderShowDelay: Nullable<Promise<void>>;\n private focused = false;\n private cancelationToken: Nullable<(reason?: Error) => void> = null;\n private isMobileLayout!: boolean;\n\n private reducer = reducer;\n public cancelLoaderDelay: () => void = () => null;\n\n /**\n * @public\n */\n public focus = () => {\n if (this.props.disabled) {\n return;\n }\n\n if (this.input) {\n this.input.focus();\n } else if (this.inputLikeText) {\n this.inputLikeText.focus();\n }\n };\n\n /**\n * @public\n */\n public selectInputText = () => {\n if (this.props.disabled) {\n return;\n }\n if (this.input) {\n this.input.selectAll();\n }\n };\n\n /**\n * @public\n */\n public blur = () => {\n if (this.props.disabled) {\n return;\n }\n\n this.handleBlur();\n };\n private setRootNode!: TSetRootNode;\n\n /**\n * @public\n */\n public async search(query: string = this.state.textValue) {\n const { getItems } = this.props;\n\n const cancelPromise: Promise<never> = new Promise((_, reject) => (this.cancelationToken = reject));\n this.requestId += 1;\n const expectingId = this.requestId;\n\n if (!this.loaderShowDelay) {\n this.loaderShowDelay = new Promise<void>((resolve) => {\n const cancelLoader = taskWithDelay(() => {\n this.dispatch({ type: 'RequestItems' });\n setTimeout(resolve, LOADER_SHOW_TIME);\n }, DELAY_BEFORE_SHOW_LOADER);\n\n cancelPromise.catch(() => cancelLoader());\n\n this.cancelLoaderDelay = () => {\n cancelLoader();\n resolve();\n };\n });\n }\n\n try {\n const items = await Promise.race([getItems(query), cancelPromise]);\n if (this.state.loading) {\n await Promise.race([this.loaderShowDelay, cancelPromise]);\n }\n if (expectingId === this.requestId) {\n this.dispatch({\n type: 'ReceiveItems',\n items,\n });\n }\n } catch (error) {\n if (error && error.code === 'CancelationError') {\n this.dispatch({ type: 'CancelRequest' });\n } else if (expectingId === this.requestId) {\n this.dispatch({\n type: 'RequestFailure',\n repeatRequest: () => {\n this.search(query);\n if (this.input) {\n this.input.focus();\n }\n },\n });\n }\n } finally {\n if (expectingId === this.requestId) {\n if (!this.state.loading) {\n this.cancelLoaderDelay();\n }\n this.cancelationToken = null;\n this.loaderShowDelay = null;\n }\n }\n }\n\n /**\n * @public\n */\n public cancelSearch() {\n if (this.cancelationToken) {\n this.cancelationToken(new CancelationError());\n }\n }\n\n /**\n * @public\n */\n public open() {\n this.dispatch({ type: 'Open' });\n }\n\n /**\n * @public\n */\n public close() {\n this.dispatch({ type: 'Close' });\n }\n\n public render() {\n const viewProps = {\n align: this.props.align,\n borderless: this.props.borderless,\n disabled: this.props.disabled,\n disablePortal: this.props.disablePortal,\n editing: this.state.editing,\n error: this.props.error,\n items: this.state.items,\n loading: this.state.loading,\n menuAlign: this.props.menuAlign,\n opened: this.state.opened,\n drawArrow: this.props.drawArrow,\n menuPos: this.props.menuPos,\n placeholder: this.props.placeholder,\n size: this.props.size,\n textValue: this.state.textValue,\n totalCount: this.props.totalCount,\n value: this.props.value,\n warning: this.props.warning,\n width: this.props.width,\n maxLength: this.props.maxLength,\n maxMenuHeight: this.props.maxMenuHeight,\n leftIcon: this.props.leftIcon,\n rightIcon: this.props.rightIcon,\n inputMode: this.props.inputMode,\n\n onValueChange: this.handleValueChange,\n onClickOutside: this.handleClickOutside,\n onFocus: this.handleFocus,\n onFocusOutside: this.handleBlur,\n onInputBlur: this.handleInputBlur,\n onInputValueChange: (value: string) => this.dispatch({ type: 'TextChange', value }),\n onInputFocus: this.handleFocus,\n onInputClick: this.handleInputClick,\n onInputKeyDown: (event: React.KeyboardEvent) => {\n event.persist();\n this.dispatch({ type: 'KeyPress', event });\n },\n onMouseEnter: this.props.onMouseEnter,\n onMouseOver: this.props.onMouseOver,\n onMouseLeave: this.props.onMouseLeave,\n renderItem: this.props.renderItem,\n renderNotFound: this.props.renderNotFound,\n itemWrapper: this.props.itemWrapper,\n renderValue: this.props.renderValue,\n renderTotalCount: this.props.renderTotalCount,\n renderAddButton: this.props.renderAddButton,\n repeatRequest: this.state.repeatRequest,\n requestStatus: this.state.requestStatus,\n\n refInput: (input: Nullable<Input>) => {\n this.input = input;\n },\n refMenu: (menu: Nullable<Menu>) => {\n this.menu = menu;\n },\n refInputLikeText: (inputLikeText: Nullable<InputLikeText>) => {\n this.inputLikeText = inputLikeText;\n },\n };\n\n return (\n <CommonWrapper {...this.props}>\n <ComboBoxView {...viewProps} ref={this.setRootNode} />\n </CommonWrapper>\n );\n }\n\n public componentDidMount() {\n this.dispatch({ type: 'Mount' });\n if (this.props.autoFocus) {\n this.focus();\n }\n }\n\n public componentDidUpdate(prevProps: CustomComboBoxProps<T>, prevState: CustomComboBoxState<T>) {\n if (prevState.editing && !this.state.editing) {\n this.handleBlur();\n }\n this.dispatch({ type: 'DidUpdate', prevProps, prevState });\n }\n\n /**\n * @public\n */\n public reset() {\n this.dispatch({ type: 'Reset' });\n }\n\n private dispatch = (action: CustomComboBoxAction<T>) => {\n let effects: Array<CustomComboBoxEffect<T>>;\n let nextState: Pick<CustomComboBoxState<T>, never>;\n\n this.setState(\n (state) => {\n const stateAndEffect = this.reducer(state, this.props, action);\n\n [nextState, effects] = stateAndEffect instanceof Array ? stateAndEffect : [stateAndEffect, []];\n\n return nextState;\n },\n () => {\n effects.forEach(this.handleEffect);\n },\n );\n };\n\n private handleEffect = (effect: CustomComboBoxEffect<T>) => {\n effect(this.dispatch, this.getState, this.getProps, () => this);\n };\n\n private getProps = () => this.props;\n\n private getState = () => this.state;\n\n private handleValueChange = (value: T) => {\n this.dispatch({\n type: 'ValueChange',\n value,\n keepFocus: !this.isMobileLayout,\n });\n };\n\n private handleFocus = () => {\n if (this.focused) {\n return;\n }\n this.focused = true;\n this.dispatch({ type: 'Focus' });\n };\n\n private handleClickOutside = (e: Event) => {\n fixClickFocusIE(e);\n this.handleBlur();\n };\n\n private handleBlur = () => {\n if (!this.focused) {\n if (this.state.opened) {\n this.close();\n }\n return;\n }\n\n this.focused = false;\n // workaround for the similar bug with focusout\n // in Firefox, Chrome and IE\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1363964\n setTimeout(() => {\n this.dispatch({ type: 'Blur' });\n });\n };\n\n private handleInputBlur = () => {\n // If menu opened, RenderLayer is active and\n // it would call handleFocusOutside\n // In that way handleBlur would be called\n\n // TODO: add check for mobile layout, to call `handleBlur`\n\n if (this.state.opened) {\n return;\n }\n this.handleBlur();\n };\n\n private handleInputClick = () => {\n if (!this.cancelationToken) {\n this.dispatch({ type: 'InputClick' });\n }\n };\n}\n"]}
@@ -5,8 +5,9 @@ import { Menu } from '../Menu';
5
5
  import { InputLikeText } from '../InputLikeText';
6
6
  import { MenuItemState } from '../../components/MenuItem';
7
7
  import { CommonProps } from '../../internal/CommonWrapper';
8
+ import { DropdownContainerProps } from '../DropdownContainer';
8
9
  import { ComboBoxRequestStatus } from './CustomComboBoxTypes';
9
- export interface CustomComboBoxProps<T> extends CommonProps {
10
+ export interface CustomComboBoxProps<T> extends Pick<DropdownContainerProps, 'menuPos'>, CommonProps {
10
11
  align?: 'left' | 'center' | 'right';
11
12
  autoFocus?: boolean;
12
13
  borderless?: boolean;
@@ -9,6 +9,7 @@ import { cx } from "../../../lib/theming/Emotion";
9
9
  import { isIE11 } from "../../../lib/client";
10
10
  import { getDOMRect } from "../../../lib/dom/getDOMRect";
11
11
  import { styles } from "../DropdownContainer.styles";
12
+ import { getManualPosition, getTopAlignment } from "../getManualPosition";
12
13
  export var DropdownContainer = /*#__PURE__*/function (_React$PureComponent) {
13
14
  _inheritsLoose(DropdownContainer, _React$PureComponent);
14
15
 
@@ -60,18 +61,30 @@ export var DropdownContainer = /*#__PURE__*/function (_React$PureComponent) {
60
61
 
61
62
  var dropdownHeight = _this.getHeight();
62
63
 
64
+ var clientHeight = _this.state.isDocumentElementRoot ? docEl.clientHeight : body.scrollHeight;
65
+
63
66
  if (distanceToBottom < dropdownHeight && targetRect.top > dropdownHeight) {
64
- var clientHeight = _this.state.isDocumentElementRoot ? docEl.clientHeight : body.scrollHeight;
65
67
  top = null;
66
- bottom = clientHeight + offsetY - scrollY - targetRect.top;
68
+ bottom = getTopAlignment({
69
+ clientHeight: clientHeight,
70
+ offsetY: offsetY,
71
+ scrollY: scrollY,
72
+ target: target
73
+ });
67
74
  }
68
75
 
69
- var position = {
76
+ var position = _extends({
70
77
  top: top,
71
78
  left: left,
72
79
  right: right,
73
80
  bottom: bottom
74
- };
81
+ }, getManualPosition({
82
+ menuPos: _this.props.menuPos,
83
+ target: target,
84
+ offsetY: offsetY,
85
+ clientHeight: clientHeight,
86
+ scrollY: scrollY
87
+ }));
75
88
 
76
89
  _this.setState({
77
90
  minWidth: _this.getMinWidth(),
@@ -1 +1 @@
1
- {"version":3,"sources":["DropdownContainer.tsx"],"names":["React","LayoutEvents","RenderContainer","ZIndex","createPropsGetter","cx","isIE11","getDOMRect","styles","DropdownContainer","props","getProps","defaultProps","ZIndexRef","element","dom","isElement","node","Element","position","target","getParent","targetRect","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","layoutSub","addListener","componentWillUnmount","remove","render","style","undefined","maxWidth","hasFixedWidth","content","alignRight","PureComponent","__KONTUR_REACT_UI__","htmlPosition","getComputedStyle","bodyPosition","hasLimitedHeightRoot","hasStaticRoot"],"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,M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B,CAAkCP,QAAvD;AACA,MAAM4D,YAAY,GAAGD,gBAAgB,CAACtD,IAAD,CAAhB,CAAuBL,QAA5C;;AAEA,MAAM6D,oBAAoB,GAAGxD,IAAI,CAAC0B,YAAL,GAAoB1B,IAAI,CAACqB,YAAtD;AACA,MAAMoC,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';\nimport { getDOMRect } from '../../lib/dom/getDOMRect';\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<Element>;\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\ntype DefaultProps = Required<Pick<DropdownContainerProps, 'align' | 'disablePortal' | 'offsetY' | 'offsetX'>>;\n\nexport class DropdownContainer extends React.PureComponent<DropdownContainerProps, DropdownContainerState> {\n public static __KONTUR_REACT_UI__ = 'DropdownContainer';\n\n public static defaultProps: 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.getProps().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 = getDOMRect(target);\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.getProps().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 = this.getProps().offsetY || 0;\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.getProps().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 return getDOMRect(child).height;\n };\n\n private getMinWidth = () => {\n const target = this.props.getParent();\n return getDOMRect(target).width;\n };\n\n private convertToRelativePosition = (position: DropdownContainerPosition): DropdownContainerPosition => {\n const target = this.props.getParent();\n const offsetX = this.getProps().offsetX || 0;\n const offsetY = this.getProps().offsetY || 0;\n const { top, bottom, left, right } = position;\n if (target && this.isElement(target)) {\n const targetHeight = getDOMRect(target).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"]}
1
+ {"version":3,"sources":["DropdownContainer.tsx"],"names":["React","LayoutEvents","RenderContainer","ZIndex","createPropsGetter","cx","isIE11","getDOMRect","styles","getManualPosition","getTopAlignment","DropdownContainer","props","getProps","defaultProps","ZIndexRef","element","dom","isElement","node","Element","position","target","getParent","targetRect","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","menuPos","setState","minWidth","getMinWidth","disablePortal","convertToRelativePosition","child","children","item","height","width","targetHeight","getIsDocumentElementRoot","componentDidMount","layoutSub","addListener","componentWillUnmount","remove","render","style","undefined","maxWidth","hasFixedWidth","content","alignRight","PureComponent","__KONTUR_REACT_UI__","htmlPosition","getComputedStyle","bodyPosition","hasLimitedHeightRoot","hasStaticRoot"],"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;AACA,SAASC,UAAT,QAA2B,0BAA3B;;AAEA,SAASC,MAAT,QAAuB,4BAAvB;AACA,SAASC,iBAAT,EAA4BC,eAA5B,QAAmD,qBAAnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,WAAaC,iBAAb;;;;;;;;;;;;;;;AAeE,6BAAYC,KAAZ,EAA2C;AACzC,4CAAMA,KAAN,UADyC,MALnCC,QAKmC,GALxBT,iBAAiB,CAACO,iBAAiB,CAACG,YAAnB,CAKO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDnCC,IAAAA,SAnDmC,GAmDvB,UAACC,OAAD,EAAuC;AACzD,YAAKC,GAAL,GAAWD,OAAX;AACD,KArD0C;;AAuDnCE,IAAAA,SAvDmC,GAuDvB,UAACC,IAAD,EAA8C;AAChE,aAAOA,IAAI,YAAYC,OAAvB;AACD,KAzD0C;;AA2DpCC,IAAAA,QA3DoC,GA2DzB,YAAM;AACtB,UAAMC,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import * 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';\nimport { getDOMRect } from '../../lib/dom/getDOMRect';\n\nimport { styles } from './DropdownContainer.styles';\nimport { getManualPosition, getTopAlignment } from './getManualPosition';\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<Element>;\n children?: React.ReactNode;\n disablePortal?: boolean;\n offsetY?: number;\n offsetX?: number;\n hasFixedWidth?: boolean;\n /**\n * Позволяет вручную задать текущую позицию выпадающего окна\n */\n menuPos?: 'top' | 'bottom';\n}\n\nexport interface DropdownContainerState {\n position: Nullable<DropdownContainerPosition>;\n minWidth: number;\n isDocumentElementRoot?: boolean;\n}\n\ntype DefaultProps = Required<Pick<DropdownContainerProps, 'align' | 'disablePortal' | 'offsetY' | 'offsetX'>>;\n\nexport class DropdownContainer extends React.PureComponent<DropdownContainerProps, DropdownContainerState> {\n public static __KONTUR_REACT_UI__ = 'DropdownContainer';\n\n public static defaultProps: 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.getProps().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 = getDOMRect(target);\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.getProps().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 = this.getProps().offsetY || 0;\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 const clientHeight = this.state.isDocumentElementRoot ? docEl.clientHeight : body.scrollHeight;\n if (distanceToBottom < dropdownHeight && targetRect.top > dropdownHeight) {\n top = null;\n bottom = getTopAlignment({ clientHeight, offsetY, scrollY, target });\n }\n\n const position = {\n top,\n left,\n right,\n bottom,\n ...getManualPosition({ menuPos: this.props.menuPos, target, offsetY, clientHeight, scrollY }),\n };\n\n this.setState({\n minWidth: this.getMinWidth(),\n position: this.getProps().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 return getDOMRect(child).height;\n };\n\n private getMinWidth = () => {\n const target = this.props.getParent();\n return getDOMRect(target).width;\n };\n\n private convertToRelativePosition = (position: DropdownContainerPosition): DropdownContainerPosition => {\n const target = this.props.getParent();\n const offsetX = this.getProps().offsetX || 0;\n const offsetY = this.getProps().offsetY || 0;\n const { top, bottom, left, right } = position;\n if (target && this.isElement(target)) {\n const targetHeight = getDOMRect(target).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"]}
@@ -14,6 +14,10 @@ export interface DropdownContainerProps {
14
14
  offsetY?: number;
15
15
  offsetX?: number;
16
16
  hasFixedWidth?: boolean;
17
+ /**
18
+ * Позволяет вручную задать текущую позицию выпадающего окна
19
+ */
20
+ menuPos?: 'top' | 'bottom';
17
21
  }
18
22
  export interface DropdownContainerState {
19
23
  position: Nullable<DropdownContainerPosition>;
@@ -0,0 +1,36 @@
1
+ import { getDOMRect } from "../../../lib/dom/getDOMRect";
2
+ export var getTopAlignment = function getTopAlignment(_ref) {
3
+ var clientHeight = _ref.clientHeight,
4
+ offsetY = _ref.offsetY,
5
+ scrollY = _ref.scrollY,
6
+ target = _ref.target;
7
+ return clientHeight + offsetY - scrollY - getDOMRect(target).top;
8
+ };
9
+ export var getManualPosition = function getManualPosition(_ref2) {
10
+ var menuPos = _ref2.menuPos,
11
+ target = _ref2.target,
12
+ offsetY = _ref2.offsetY,
13
+ clientHeight = _ref2.clientHeight;
14
+
15
+ if (!menuPos) {
16
+ return undefined;
17
+ }
18
+
19
+ if (menuPos === 'top') {
20
+ return {
21
+ top: null,
22
+ bottom: getTopAlignment({
23
+ clientHeight: clientHeight,
24
+ offsetY: offsetY,
25
+ scrollY: scrollY,
26
+ target: target
27
+ })
28
+ };
29
+ }
30
+
31
+ if (menuPos === 'bottom') {
32
+ return {
33
+ top: scrollY + getDOMRect(target).top + target.clientHeight + offsetY
34
+ };
35
+ }
36
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["getManualPosition.ts"],"names":["getDOMRect","getTopAlignment","clientHeight","offsetY","scrollY","target","top","getManualPosition","menuPos","undefined","bottom"],"mappings":"AAAA,SAASA,UAAT,QAA2B,0BAA3B;;;;AAIA,OAAO,IAAMC,eAAe,GAAG,SAAlBA,eAAkB;;;;;;;;;AASzB,KARJC,YAQI,QARJA,YAQI,CAPJC,OAOI,QAPJA,OAOI,CANJC,OAMI,QANJA,OAMI,CALJC,MAKI,QALJA,MAKI;AACJ,SAAOH,YAAY,GAAGC,OAAf,GAAyBC,OAAzB,GAAmCJ,UAAU,CAACK,MAAD,CAAV,CAAmBC,GAA7D;AACD,CAXM;;;;;;;;;;AAqBP,OAAO,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,QAAwE,KAArEC,OAAqE,SAArEA,OAAqE,CAA5DH,MAA4D,SAA5DA,MAA4D,CAApDF,OAAoD,SAApDA,OAAoD,CAA3CD,YAA2C,SAA3CA,YAA2C;AACvG,MAAI,CAACM,OAAL,EAAc;AACZ,WAAOC,SAAP;AACD;;AAED,MAAID,OAAO,KAAK,KAAhB,EAAuB;AACrB,WAAO;AACLF,MAAAA,GAAG,EAAE,IADA;AAELI,MAAAA,MAAM,EAAET,eAAe,CAAC,EAAEC,YAAY,EAAZA,YAAF,EAAgBC,OAAO,EAAPA,OAAhB,EAAyBC,OAAO,EAAPA,OAAzB,EAAkCC,MAAM,EAANA,MAAlC,EAAD,CAFlB,EAAP;;AAID;;AAED,MAAIG,OAAO,KAAK,QAAhB,EAA0B;AACxB,WAAO,EAAEF,GAAG,EAAEF,OAAO,GAAGJ,UAAU,CAACK,MAAD,CAAV,CAAmBC,GAA7B,GAAmCD,MAAM,CAACH,YAA1C,GAAyDC,OAAhE,EAAP;AACD;AACF,CAfM","sourcesContent":["import { getDOMRect } from '../../lib/dom/getDOMRect';\n\nimport { DropdownContainerProps } from './DropdownContainer';\n\nexport const getTopAlignment = ({\n clientHeight,\n offsetY,\n scrollY,\n target,\n}: Required<Pick<DropdownContainerProps, 'offsetY'>> & {\n clientHeight: number;\n scrollY: number;\n target: Element;\n}) => {\n return clientHeight + offsetY - scrollY - getDOMRect(target).top;\n};\n\ninterface ManualPositionFuncArgs\n extends Required<Pick<DropdownContainerProps, 'offsetY'>>,\n Pick<DropdownContainerProps, 'menuPos'> {\n target: Element;\n clientHeight: number;\n scrollY: number;\n}\n\nexport const getManualPosition = ({ menuPos, target, offsetY, clientHeight }: ManualPositionFuncArgs) => {\n if (!menuPos) {\n return undefined;\n }\n\n if (menuPos === 'top') {\n return {\n top: null,\n bottom: getTopAlignment({ clientHeight, offsetY, scrollY, target }),\n };\n }\n\n if (menuPos === 'bottom') {\n return { top: scrollY + getDOMRect(target).top + target.clientHeight + offsetY };\n }\n};\n"]}
@@ -0,0 +1,6 @@
1
+ {
2
+ "main": "../../../cjs/internal/DropdownContainer/getManualPosition.js",
3
+ "module": "getManualPosition",
4
+ "types": "../getManualPosition.d.ts",
5
+ "sideEffects": false
6
+ }
@@ -0,0 +1,19 @@
1
+ import { DropdownContainerProps } from './DropdownContainer';
2
+ export declare const getTopAlignment: ({ clientHeight, offsetY, scrollY, target, }: Required<Pick<DropdownContainerProps, "offsetY">> & {
3
+ clientHeight: number;
4
+ scrollY: number;
5
+ target: Element;
6
+ }) => number;
7
+ interface ManualPositionFuncArgs extends Required<Pick<DropdownContainerProps, 'offsetY'>>, Pick<DropdownContainerProps, 'menuPos'> {
8
+ target: Element;
9
+ clientHeight: number;
10
+ scrollY: number;
11
+ }
12
+ export declare const getManualPosition: ({ menuPos, target, offsetY, clientHeight }: ManualPositionFuncArgs) => {
13
+ top: null;
14
+ bottom: number;
15
+ } | {
16
+ top: number;
17
+ bottom?: undefined;
18
+ } | undefined;
19
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { DefaultThemeInternal } from "../../../internal/themes/DefaultTheme";
2
2
  import { isNonNullable } from "../../utils";
3
- import { findPropertyDescriptor } from "../ThemeHelpers";
3
+ import { findPropertyDescriptor, REACT_UI_THEME_MARKERS } from "../ThemeHelpers";
4
4
  export var ThemeFactory = /*#__PURE__*/function () {
5
5
  function ThemeFactory() {}
6
6
 
@@ -10,9 +10,15 @@ export var ThemeFactory = /*#__PURE__*/function () {
10
10
  };
11
11
 
12
12
  ThemeFactory.overrideDefaultTheme = function overrideDefaultTheme(theme) {
13
+ // copying theme variables
13
14
  ThemeFactory.getKeys(DefaultThemeInternal).forEach(function (variableName) {
14
15
  var descriptor = findPropertyDescriptor(theme, variableName);
15
16
  Object.defineProperty(DefaultThemeInternal, variableName, descriptor);
17
+ }); // copying theme markers
18
+
19
+ Object.values(REACT_UI_THEME_MARKERS).forEach(function (marker) {
20
+ var descriptor = findPropertyDescriptor(theme, marker.key);
21
+ Object.defineProperty(DefaultThemeInternal, marker.key, descriptor);
16
22
  });
17
23
  };
18
24
 
@@ -1 +1 @@
1
- {"version":3,"sources":["ThemeFactory.ts"],"names":["DefaultThemeInternal","isNonNullable","findPropertyDescriptor","ThemeFactory","create","theme","baseTheme","base","constructTheme","overrideDefaultTheme","getKeys","forEach","variableName","descriptor","Object","defineProperty","keys","key","includes","push","getProtot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QAAMiB,QAAQ,GAAGR,MAAM,CAACV,MAAP,CAAcG,IAAd,CAAjB;AACAO,IAAAA,MAAM,CAACE,IAAP,CAAYX,KAAZ,EAAmBM,OAAnB,CAA2B,UAACY,QAAD,EAAc;AACvC,UAAMV,UAAU,GAAGC,MAAM,CAACU,wBAAP,CAAgCnB,KAAhC,EAAuCkB,QAAvC,CAAnB;AACA,UAAIV,UAAJ,EAAgB;AACdC,QAAAA,MAAM,CAACC,cAAP,CAAsBO,QAAtB,EAAgCC,QAAhC,EAA0CV,UAA1C;AACD;AACF,KALD;;AAOA,WAAOC,MAAM,CAACW,MAAP,CAAcH,QAAd,CAAP;AACD,GAvCH","sourcesContent":["import { DefaultThemeInternal } from '../../internal/themes/DefaultTheme';\nimport { isNonNullable } from '../utils';\n\nimport { Theme, ThemeIn } from './Theme';\nimport { findPropertyDescriptor } from './ThemeHelpers';\n\nexport class ThemeFactory {\n public static create<T extends unknown>(theme: ThemeIn & T, baseTheme?: Theme): Readonly<Theme & T> {\n const base = baseTheme || DefaultThemeInternal;\n return this.constructTheme(base, theme);\n }\n\n public static overrideDefaultTheme(theme: Theme) {\n ThemeFactory.getKeys(DefaultThemeInternal).forEach((variableName) => {\n const descriptor = findPropertyDescriptor(theme, variableName);\n Object.defineProperty(DefaultThemeInternal, variableName, descriptor);\n });\n }\n\n public static getKeys<T extends Theme>(theme: T) {\n const keys: Array<keyof T> = [];\n while (isNonNullable(theme)) {\n (Object.keys(theme) as typeof keys).forEach((key) => {\n if (!keys.includes(key)) {\n keys.push(key);\n }\n });\n // TODO: Enable `no-param-reassign` rule.\n // eslint-disable-next-line no-param-reassign\n theme = Object.getPrototypeOf(theme);\n }\n\n return keys.sort();\n }\n\n private static constructTheme(base: Theme, theme: ThemeIn) {\n const newTheme = Object.create(base);\n Object.keys(theme).forEach((propName) => {\n const descriptor = Object.getOwnPropertyDescriptor(theme, propName);\n if (descriptor) {\n Object.defineProperty(newTheme, propName, descriptor);\n }\n });\n\n return Object.freeze(newTheme);\n }\n}\n"]}
1
+ {"version":3,"sources":["ThemeFactory.ts"],"names":["DefaultThemeInternal","isNonNullable","findPropertyDescriptor","REACT_UI_THEME_MARKERS","ThemeFactory","create","theme","baseTheme","base","constructTheme","overrideDefaultTheme","getKeys","forEach","variableName","descriptor","Object","defineProperty","values","marker","key","keys","includes","push","getPrototypeOf","sort","newTheme","propName","getOwnPropertyDescriptor","freeze"],"mappings":"AAAA,SAASA,oBAAT,QAAqC,oCAArC;AACA,SAASC,aAAT,QAA8B,UAA9B;;;AAGA,SAASC,sBAAT,EAAiCC,sBAAjC,QAA+D,gBAA/D;;AAEA,WAAaC,YAAb;AACgBC,EAAAA,MADhB,GACE,gBAAwCC,KAAxC,EAA4DC,SAA5D,EAAoG;AAClG,QAAMC,IAAI,GAAGD,SAAS,IAAIP,oBAA1B;AACA,WAAO,KAAKS,cAAL,CAAoBD,IAApB,EAA0BF,KAA1B,CAAP;AACD,GAJH;;AAMgBI,EAAAA,oBANhB,GAME,8BAAmCJ,KAAnC,EAAiD;AAC/C;AACAF,IAAAA,YAAY,CAACO,OAAb,CAAqBX,oBAArB,EAA2CY,OAA3C,CAAmD,UAACC,YAAD,EAAkB;AACnE,UAAMC,UAAU,GAAGZ,sBAAsB,CAACI,KAAD,EAAQO,YAAR,CAAzC;AACAE,MAAAA,MAAM,CAACC,cAAP,CAAsBhB,oBAAtB,EAA4Ca,YAA5C,EAA0DC,UAA1D;AACD,KAHD;;AAKA;AACAC,IAAAA,MAAM,CAACE,MAAP,CAAcd,sBAAd,EAAsCS,OAAtC,CAA8C,UAACM,MAAD,EAAY;AACxD,UAAMJ,UAAU,GAAGZ,sBAAsB,CAACI,KAAD,EAAQY,MAAM,CAACC,GAAf,CAAzC;AACAJ,MAAAA,MAAM,CAACC,cAAP,CAAsBhB,oBAAtB,EAA4CkB,MAAM,CAACC,GAAnD,EAAwDL,UAAxD;AACD,KAHD;AAID,GAlBH;;AAoBgBH,EAAAA,OApBhB,GAoBE,iBAAuCL,KAAvC,EAAiD;AAC/C,QAAMc,IAAoB,GAAG,EAA7B;AACA,WAAOnB,aAAa,CAACK,KAAD,CAApB,EAA6B;AAC1BS,MAAAA,MAAM,CAACK,IAAP,CAAYd,KAAZ,CAAD,CAAoCM,OAApC,CAA4C,UAACO,GAAD,EAAS;AACnD,YAAI,CAACC,IAAI,CAACC,QAAL,CAAcF,GAAd,CAAL,EAAyB;AACvBC,UAAAA,IAAI,CAACE,IAAL,CAAUH,GAAV;AACD;AACF,OAJD;AAKA;AACA;AACAb,MAAAA,KAAK,GAAGS,MAAM,CAACQ,cAAP,CAAsBjB,KAAtB,CAAR;AACD;;AAED,WAAOc,IAAI,CAACI,IAAL,EAAP;AACD,GAlCH;;AAoCiBf,EAAAA,cApCjB,GAoCE,wBAA8BD,IAA9B,EAA2CF,KAA3C,EAA2D;AACzD,QAAMmB,QAAQ,GAAGV,MAAM,CAACV,MAAP,CAAcG,IAAd,CAAjB;AACAO,IAAAA,MAAM,CAACK,IAAP,CAAYd,KAAZ,EAAmBM,OAAnB,CAA2B,UAACc,QAAD,EAAc;AACvC,UAAMZ,UAAU,GAAGC,MAAM,CAACY,wBAAP,CAAgCrB,KAAhC,EAAuCoB,QAAvC,CAAnB;AACA,UAAIZ,UAAJ,EAAgB;AACdC,QAAAA,MAAM,CAACC,cAAP,CAAsBS,QAAtB,EAAgCC,QAAhC,EAA0CZ,UAA1C;AACD;AACF,KALD;;AAOA,WAAOC,MAAM,CAACa,MAAP,CAAcH,QAAd,CAAP;AACD,GA9CH","sourcesContent":["import { DefaultThemeInternal } from '../../internal/themes/DefaultTheme';\nimport { isNonNullable } from '../utils';\n\nimport { Theme, ThemeIn } from './Theme';\nimport { findPropertyDescriptor, REACT_UI_THEME_MARKERS } from './ThemeHelpers';\n\nexport class ThemeFactory {\n public static create<T extends unknown>(theme: ThemeIn & T, baseTheme?: Theme): Readonly<Theme & T> {\n const base = baseTheme || DefaultThemeInternal;\n return this.constructTheme(base, theme);\n }\n\n public static overrideDefaultTheme(theme: Theme) {\n // copying theme variables\n ThemeFactory.getKeys(DefaultThemeInternal).forEach((variableName) => {\n const descriptor = findPropertyDescriptor(theme, variableName);\n Object.defineProperty(DefaultThemeInternal, variableName, descriptor);\n });\n\n // copying theme markers\n Object.values(REACT_UI_THEME_MARKERS).forEach((marker) => {\n const descriptor = findPropertyDescriptor(theme, marker.key);\n Object.defineProperty(DefaultThemeInternal, marker.key, descriptor);\n });\n }\n\n public static getKeys<T extends Theme>(theme: T) {\n const keys: Array<keyof T> = [];\n while (isNonNullable(theme)) {\n (Object.keys(theme) as typeof keys).forEach((key) => {\n if (!keys.includes(key)) {\n keys.push(key);\n }\n });\n // TODO: Enable `no-param-reassign` rule.\n // eslint-disable-next-line no-param-reassign\n theme = Object.getPrototypeOf(theme);\n }\n\n return keys.sort();\n }\n\n private static constructTheme(base: Theme, theme: ThemeIn) {\n const newTheme = Object.create(base);\n Object.keys(theme).forEach((propName) => {\n const descriptor = Object.getOwnPropertyDescriptor(theme, propName);\n if (descriptor) {\n Object.defineProperty(newTheme, propName, descriptor);\n }\n });\n\n return Object.freeze(newTheme);\n }\n}\n"]}
@@ -11,16 +11,23 @@ export var exposeGetters = function exposeGetters(theme) {
11
11
  });
12
12
  return theme;
13
13
  };
14
- export var REACT_UI_DARK_THEME_KEY = '__IS_REACT_UI_DARK_THEME__';
14
+ export var REACT_UI_THEME_MARKERS = {
15
+ darkTheme: {
16
+ key: '__IS_REACT_UI_DARK_THEME__',
17
+ value: true
18
+ }
19
+ }; // backward compatible
20
+
21
+ export var REACT_UI_DARK_THEME_KEY = REACT_UI_THEME_MARKERS.darkTheme.key;
15
22
  export var isDarkTheme = function isDarkTheme(theme) {
16
23
  // @ts-expect-error: internal value.
17
- return theme[REACT_UI_DARK_THEME_KEY] === true;
24
+ return theme[REACT_UI_THEME_MARKERS.darkTheme.key] === REACT_UI_THEME_MARKERS.darkTheme.value;
18
25
  };
19
26
  export var markAsDarkTheme = function markAsDarkTheme(theme) {
20
27
  var _Object$create;
21
28
 
22
- return Object.create(theme, (_Object$create = {}, _Object$create[REACT_UI_DARK_THEME_KEY] = {
23
- value: true,
29
+ return Object.create(theme, (_Object$create = {}, _Object$create[REACT_UI_THEME_MARKERS.darkTheme.key] = {
30
+ value: REACT_UI_THEME_MARKERS.darkTheme.value,
24
31
  writable: false,
25
32
  enumerable: false,
26
33
  configurable: false
@@ -37,4 +44,11 @@ export function findPropertyDescriptor(theme, propName) {
37
44
  }
38
45
 
39
46
  return {};
47
+ }
48
+ export function applyMarkers(theme, markers) {
49
+ var markedTheme = theme;
50
+ markers.forEach(function (marker) {
51
+ markedTheme = marker(theme);
52
+ });
53
+ return markedTheme;
40
54
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["ThemeHelpers.ts"],"names":["isNonNullable","exposeGetters","theme","descriptors","Object","getOwnPropertyDescriptors","keys","forEach","key","descriptor","get","configurable","enumerable","defineProperty","REACT_UI_DARK_THEME_KEY","isDarkTheme","markAsDarkTheme","create","value","writable","findPropertyDescriptor","propName","getPrototypeOf","prototype","hasOwnProperty","call","getOwnPropertyDescriptor"],"mappings":"AAAA,SAASA,aAAT,QAA8B,UAA9B;;;;AAIA,OAAO,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAAgCC,KAAhC,EAAgD;AAC3E,MAAMC,WAAW,GAAGC,MAAM,CAACC,yBAAP,CAAiCH,KAAjC,CAApB;AACAE,EAAAA,MAAM,CAACE,IAAP,CAAYH,WAAZ,EAAyBI,OAAzB,CAAiC,UAACC,GAAD,EAAS;AACxC,QAAMC,UAAU,GAAGN,WAAW,CAACK,GAAD,CAA9B;AACA,QAAI,OAAOC,UAAU,CAACC,GAAlB,KAA0B,UAA1B,IAAwCD,UAAU,CAACE,YAAvD,EAAqE;AACnEF,MAAAA,UAAU,CAACG,UAAX,GAAwB,IAAxB;AACAR,MAAAA,MAAM,CAACS,cAAP,CAAsBX,KAAtB,EAA6BM,GAA7B,EAAkCC,UAAlC;AACD;AACF,GAND;AAOA,SAAOP,KAAP;AACD,CAVM;;AAYP,OAAO,IAAMY,uBAAuB,GAAG,4BAAhC;;AAEP,OAAO,IAAMC,WAAW,GAAG,SAAdA,WAAc,CAACb,KAAD,EAAqC;AAC9D;AACA,SAAOA,KAAK,CAACY,uBAAD,CAAL,KAAmC,IAA1C;AACD,CAHM;;AAKP,OAAO,IAAME,eAAe,GAAG,SAAlBA,eAAkB,CAAgCd,KAAhC,EAAgD;AAC7E,SAAOE,MAAM,CAACa,MAAP,CAAcf,KAAd;AACJY,EAAAA,uBADI,IACsB;AACzBI,IAAAA,KAAK,EAAE,IADkB;AAEzBC,IAAAA,QAAQ,EAAE,KAFe;AAGzBP,IAAAA,UAAU,EAAE,KAHa;AAIzBD,IAAAA,YAAY,EAAE,KAJW,EADtB,kBAAP;;;AAQD,CATM;;AAWP,OAAO,SAASS,sBAAT,CAAgClB,KAAhC,EAA8CmB,QAA9C,EAAqE;AAC1E;AACA;AACA;AACA,SAAOrB,aAAa,CAACE,KAAD,CAApB,EAA6BA,KAAK,GAAGE,MAAM,CAACkB,cAAP,CAAsBpB,KAAtB,CAArC,EAAmE;AACjE,QAAIE,MAAM,CAACmB,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCvB,KAArC,EAA4CmB,QAA5C,CAAJ,EAA2D;AACzD,aAAOjB,MAAM,CAACsB,wBAAP,CAAgCxB,KAAhC,EAAuCmB,QAAvC,KAAoD,EAA3D;AACD;AACF;AACD,SAAO,EAAP;AACD","sourcesContent":["import { isNonNullable } from '../utils';\n\nimport { Theme, ThemeIn } from './Theme';\n\nexport const exposeGetters = <T extends Record<string, any>>(theme: T): T => {\n const descriptors = Object.getOwnPropertyDescriptors(theme);\n Object.keys(descriptors).forEach((key) => {\n const descriptor = descriptors[key];\n if (typeof descriptor.get === 'function' && descriptor.configurable) {\n descriptor.enumerable = true;\n Object.defineProperty(theme, key, descriptor);\n }\n });\n return theme;\n};\n\nexport const REACT_UI_DARK_THEME_KEY = '__IS_REACT_UI_DARK_THEME__';\n\nexport const isDarkTheme = (theme: Theme | ThemeIn): boolean => {\n // @ts-expect-error: internal value.\n return theme[REACT_UI_DARK_THEME_KEY] === true;\n};\n\nexport const markAsDarkTheme = <T extends Record<string, any>>(theme: T): T => {\n return Object.create(theme, {\n [REACT_UI_DARK_THEME_KEY]: {\n value: true,\n writable: false,\n enumerable: false,\n configurable: false,\n },\n });\n};\n\nexport function findPropertyDescriptor(theme: Theme, propName: keyof Theme) {\n // TODO: Rewrite for loop.\n // TODO: Enable `no-param-reassign` rule.\n // eslint-disable-next-line no-param-reassign\n for (; isNonNullable(theme); theme = Object.getPrototypeOf(theme)) {\n if (Object.prototype.hasOwnProperty.call(theme, propName)) {\n return Object.getOwnPropertyDescriptor(theme, propName) || {};\n }\n }\n return {};\n}\n"]}
1
+ {"version":3,"sources":["ThemeHelpers.ts"],"names":["isNonNullable","exposeGetters","theme","descriptors","Object","getOwnPropertyDescriptors","keys","forEach","key","descriptor","get","configurable","enumerable","defineProperty","REACT_UI_THEME_MARKERS","darkTheme","value","REACT_UI_DARK_THEME_KEY","isDarkTheme","markAsDarkTheme","create","writable","findPropertyDescriptor","propName","getPrototypeOf","prototype","hasOwnProperty","call","getOwnPropertyDescriptor","applyMarkers","markers","markedTheme","marker"],"mappings":"AAAA,SAASA,aAAT,QAA8B,UAA9B;;;;;;;AAOA,OAAO,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAAgCC,KAAhC,EAAgD;AAC3E,MAAMC,WAAW,GAAGC,MAAM,CAACC,yBAAP,CAAiCH,KAAjC,CAApB;AACAE,EAAAA,MAAM,CAACE,IAAP,CAAYH,WAAZ,EAAyBI,OAAzB,CAAiC,UAACC,GAAD,EAAS;AACxC,QAAMC,UAAU,GAAGN,WAAW,CAACK,GAAD,CAA9B;AACA,QAAI,OAAOC,UAAU,CAACC,GAAlB,KAA0B,UAA1B,IAAwCD,UAAU,CAACE,YAAvD,EAAqE;AACnEF,MAAAA,UAAU,C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AACzD,aAAOnB,MAAM,CAACwB,wBAAP,CAAgC1B,KAAhC,EAAuCqB,QAAvC,KAAoD,EAA3D;AACD;AACF;AACD,SAAO,EAAP;AACD;;AAED,OAAO,SAASM,YAAT,CAAsB3B,KAAtB,EAA8C4B,OAA9C,EAAgE;AACrE,MAAIC,WAA4B,GAAG7B,KAAnC;AACA4B,EAAAA,OAAO,CAACvB,OAAR,CAAgB,UAACyB,MAAD,EAAY;AAC1BD,IAAAA,WAAW,GAAGC,MAAM,CAAC9B,KAAD,CAApB;AACD,GAFD;AAGA,SAAO6B,WAAP;AACD","sourcesContent":["import { isNonNullable } from '../utils';\n\nimport { Theme, ThemeIn } from './Theme';\n\nexport type Marker = (theme: Readonly<Theme>) => Readonly<Theme>;\nexport type Markers = Marker[];\n\nexport const exposeGetters = <T extends Record<string, any>>(theme: T): T => {\n const descriptors = Object.getOwnPropertyDescriptors(theme);\n Object.keys(descriptors).forEach((key) => {\n const descriptor = descriptors[key];\n if (typeof descriptor.get === 'function' && descriptor.configurable) {\n descriptor.enumerable = true;\n Object.defineProperty(theme, key, descriptor);\n }\n });\n return theme;\n};\n\nexport const REACT_UI_THEME_MARKERS = {\n darkTheme: {\n key: '__IS_REACT_UI_DARK_THEME__',\n value: true,\n },\n};\n\n// backward compatible\nexport const REACT_UI_DARK_THEME_KEY = REACT_UI_THEME_MARKERS.darkTheme.key;\n\nexport const isDarkTheme = (theme: Theme | ThemeIn): boolean => {\n // @ts-expect-error: internal value.\n return theme[REACT_UI_THEME_MARKERS.darkTheme.key] === REACT_UI_THEME_MARKERS.darkTheme.value;\n};\n\nexport const markAsDarkTheme: Marker = (theme) => {\n return Object.create(theme, {\n [REACT_UI_THEME_MARKERS.darkTheme.key]: {\n value: REACT_UI_THEME_MARKERS.darkTheme.value,\n writable: false,\n enumerable: false,\n configurable: false,\n },\n });\n};\n\nexport function findPropertyDescriptor(theme: Theme, propName: string) {\n // TODO: Rewrite for loop.\n // TODO: Enable `no-param-reassign` rule.\n // eslint-disable-next-line no-param-reassign\n for (; isNonNullable(theme); theme = Object.getPrototypeOf(theme)) {\n if (Object.prototype.hasOwnProperty.call(theme, propName)) {\n return Object.getOwnPropertyDescriptor(theme, propName) || {};\n }\n }\n return {};\n}\n\nexport function applyMarkers(theme: Readonly<Theme>, markers: Markers) {\n let markedTheme: Readonly<Theme> = theme;\n markers.forEach((marker) => {\n markedTheme = marker(theme);\n });\n return markedTheme;\n}\n"]}
@@ -1,6 +1,15 @@
1
1
  import { Theme, ThemeIn } from './Theme';
2
+ export declare type Marker = (theme: Readonly<Theme>) => Readonly<Theme>;
3
+ export declare type Markers = Marker[];
2
4
  export declare const exposeGetters: <T extends Record<string, any>>(theme: T) => T;
3
- export declare const REACT_UI_DARK_THEME_KEY = "__IS_REACT_UI_DARK_THEME__";
5
+ export declare const REACT_UI_THEME_MARKERS: {
6
+ darkTheme: {
7
+ key: string;
8
+ value: boolean;
9
+ };
10
+ };
11
+ export declare const REACT_UI_DARK_THEME_KEY: string;
4
12
  export declare const isDarkTheme: (theme: Theme | ThemeIn) => boolean;
5
- export declare const markAsDarkTheme: <T extends Record<string, any>>(theme: T) => T;
6
- export declare function findPropertyDescriptor(theme: Theme, propName: keyof Theme): PropertyDescriptor;
13
+ export declare const markAsDarkTheme: Marker;
14
+ export declare function findPropertyDescriptor(theme: Theme, propName: string): PropertyDescriptor;
15
+ export declare function applyMarkers(theme: Readonly<Theme>, markers: Markers): Readonly<Readonly<typeof import("../../internal/themes/DefaultTheme").DefaultTheme>>;
@@ -1,4 +1,4 @@
1
1
  import { DarkThemeInternal } from "../../../../internal/themes/DarkTheme";
2
2
  import { ThemeFactory } from "../../ThemeFactory";
3
- import { markAsDarkTheme } from "../../ThemeHelpers";
4
- export var DARK_THEME = ThemeFactory.create({}, markAsDarkTheme(DarkThemeInternal));
3
+ import { applyMarkers, markAsDarkTheme } from "../../ThemeHelpers";
4
+ export var DARK_THEME = applyMarkers(ThemeFactory.create({}, DarkThemeInternal), [markAsDarkTheme]);
@@ -1 +1 @@
1
- {"version":3,"sources":["DarkTheme.ts"],"names":["DarkThemeInternal","ThemeFactory","markAsDarkTheme","DARK_THEME","create"],"mappings":"AAAA,SAASA,iBAAT,QAAkC,oCAAlC;AACA,SAASC,YAAT,QAA6B,iBAA7B;AACA,SAASC,eAAT,QAAgC,iBAAhC;;AAEA,OAAO,IAAMC,UAAU,GAAGF,YAAY,CAACG,MAAb,CAAoB,EAApB,EAAwBF,eAAe,CAACF,iBAAD,CAAvC,CAAnB","sourcesContent":["import { DarkThemeInternal } from '../../../internal/themes/DarkTheme';\nimport { ThemeFactory } from '../ThemeFactory';\nimport { markAsDarkTheme } from '../ThemeHelpers';\n\nexport const DARK_THEME = ThemeFactory.create({}, markAsDarkTheme(DarkThemeInternal));\n"]}
1
+ {"version":3,"sources":["DarkTheme.ts"],"names":["DarkThemeInternal","ThemeFactory","applyMarkers","markAsDarkTheme","DARK_THEME","create"],"mappings":"AAAA,SAASA,iBAAT,QAAkC,oCAAlC;AACA,SAASC,YAAT,QAA6B,iBAA7B;AACA,SAASC,YAAT,EAAuBC,eAAvB,QAA8C,iBAA9C;;AAEA,OAAO,IAAMC,UAAU,GAAGF,YAAY,CAACD,YAAY,CAACI,MAAb,CAAoB,EAApB,EAAwBL,iBAAxB,CAAD,EAA6C,CAACG,eAAD,CAA7C,CAA/B","sourcesContent":["import { DarkThemeInternal } from '../../../internal/themes/DarkTheme';\nimport { ThemeFactory } from '../ThemeFactory';\nimport { applyMarkers, markAsDarkTheme } from '../ThemeHelpers';\n\nexport const DARK_THEME = applyMarkers(ThemeFactory.create({}, DarkThemeInternal), [markAsDarkTheme]);\n"]}
@@ -1,5 +1,6 @@
1
1
  import { ThemeFactory } from "../../ThemeFactory";
2
2
  import { Theme2022DarkInternal } from "../../../../internal/themes/Theme2022Dark";
3
3
  import { Theme2022Internal } from "../../../../internal/themes/Theme2022";
4
+ import { applyMarkers, markAsDarkTheme } from "../../ThemeHelpers";
4
5
  import { DARK_THEME } from "../DarkTheme";
5
- export var THEME_2022_DARK = ThemeFactory.create(Theme2022DarkInternal, ThemeFactory.create(Theme2022Internal, DARK_THEME));
6
+ export var THEME_2022_DARK = applyMarkers(ThemeFactory.create(Theme2022DarkInternal, ThemeFactory.create(Theme2022Internal, DARK_THEME)), [markAsDarkTheme]);
@@ -1 +1 @@
1
- {"version":3,"sources":["Theme2022Dark.ts"],"names":["ThemeFactory","Theme2022DarkInternal","Theme2022Internal","DARK_THEME","THEME_2022_DARK","create"],"mappings":"AAAA,SAASA,YAAT,QAA6B,iBAA7B;AACA,SAASC,qBAAT,QAAsC,wCAAtC;AACA,SAASC,iBAAT,QAAkC,oCAAlC;;AAEA,SAASC,UAAT,QAA2B,aAA3B;;AAEA,OAAO,IAAMC,eAAe,GAAGJ,YAAY,CAACK,MAAb;AAC7BJ,qBAD6B;AAE7BD,YAAY,CAACK,MAAb,CAAoBH,iBAApB,EAAuCC,UAAvC,CAF6B,CAAxB","sourcesContent":["import { ThemeFactory } from '../ThemeFactory';\nimport { Theme2022DarkInternal } from '../../../internal/themes/Theme2022Dark';\nimport { Theme2022Internal } from '../../../internal/themes/Theme2022';\n\nimport { DARK_THEME } from './DarkTheme';\n\nexport const THEME_2022_DARK = ThemeFactory.create(\n Theme2022DarkInternal,\n ThemeFactory.create(Theme2022Internal, DARK_THEME),\n);\n"]}
1
+ {"version":3,"sources":["Theme2022Dark.ts"],"names":["ThemeFactory","Theme2022DarkInternal","Theme2022Internal","applyMarkers","markAsDarkTheme","DARK_THEME","THEME_2022_DARK","create"],"mappings":"AAAA,SAASA,YAAT,QAA6B,iBAA7B;AACA,SAASC,qBAAT,QAAsC,wCAAtC;AACA,SAASC,iBAAT,QAAkC,oCAAlC;AACA,SAASC,YAAT,EAAuBC,eAAvB,QAA8C,iBAA9C;;AAEA,SAASC,UAAT,QAA2B,aAA3B;;AAEA,OAAO,IAAMC,eAAe,GAAGH,YAAY;AACzCH,YAAY,CAACO,MAAb,CAAoBN,qBAApB,EAA2CD,YAAY,CAACO,MAAb,CAAoBL,iBAApB,EAAuCG,UAAvC,CAA3C,CADyC;AAEzC,CAACD,eAAD,CAFyC,CAApC","sourcesContent":["import { ThemeFactory } from '../ThemeFactory';\nimport { Theme2022DarkInternal } from '../../../internal/themes/Theme2022Dark';\nimport { Theme2022Internal } from '../../../internal/themes/Theme2022';\nimport { applyMarkers, markAsDarkTheme } from '../ThemeHelpers';\n\nimport { DARK_THEME } from './DarkTheme';\n\nexport const THEME_2022_DARK = applyMarkers(\n ThemeFactory.create(Theme2022DarkInternal, ThemeFactory.create(Theme2022Internal, DARK_THEME)),\n [markAsDarkTheme],\n);\n"]}
@@ -1 +1 @@
1
- export declare const THEME_2022_DARK: Readonly<Readonly<typeof import("../../../internal/themes/DefaultTheme").DefaultTheme> & typeof import("../../../internal/themes/Theme2022Dark").Theme2022Dark>;
1
+ export declare const THEME_2022_DARK: Readonly<Readonly<typeof import("../../../internal/themes/DefaultTheme").DefaultTheme>>;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@skbkontur/react-ui",
3
- "version": "4.10.0",
3
+ "version": "4.11.0",
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/4.10.0/",
8
+ "homepage": "https://tech.skbkontur.ru/react-ui/4.11.0/",
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "git@github.com:skbkontur/retail-ui.git"