diff --git a/.circleci/config.yml b/.circleci/config.yml index 685f9767..9f917c56 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,51 +1,42 @@ +aliases: + - &docker_auth + auth: + username: ${DOCKER_USER} + password: ${DOCKER_PASS} + + - &default-context + context: + - shared-creds + defaults: &defaults docker: - - image: opuscapita/minsk-core-ci:grails-2.4.4-jdk-8u131-nodejs-8.9.4-maven-3.3.9 + - image: opuscapita/minsk-core-ci:4 + <<: *docker_auth working_directory: ~/build -version: 2 -jobs: - build: - <<: *defaults - steps: - - run: - name: Environment inject. - command: env_inject.sh - - - checkout - - restore_cache: - keys: - - react-showroom-{{ .Branch }}-{{ checksum "package.json" }} - - react-showroom-{{ .Branch }} - - react-showroom +version: 2.1 - - run: - name: Installing dependencies. - command: npm install +orbs: + jira: circleci/jira@2.0 - - save_cache: - key: react-showroom-{{ .Branch }}-{{ checksum "package.json" }} +jobs: + init: + docker: + - image: opuscapita/minsk-core-machineuser-env:2 + <<: *docker_auth + steps: + - run: generate_bash_env_exports.sh GH_MAIL GH_NAME CIRCLE_CI_TOKEN > ~/generated_bash_env + - persist_to_workspace: + root: ~/ paths: - - ./node_modules - - ./package-lock.json - - ./yarn.lock - - - run: - name: Running lint. - command: npm run lint - - - run: - name: Running tests. - command: npm test + - generated_bash_env update-gh-pages: - docker: <<: *defaults steps: - - run: - name: Environment inject - command: /bin/env_inject.sh - + - attach_workspace: + at: /workspace + - run: cat /workspace/generated_bash_env >> $BASH_ENV - checkout - restore_cache: keys: @@ -53,15 +44,16 @@ jobs: - react-showroom-{{ .Branch }} - react-showroom + - run: if [ -f /.dockerenv ]; then configure-maven.sh && configure-grails.sh && configure-npm.sh; fi + - run: name: "Installing dependencies." - command: yarn install + command: npm install - save_cache: key: react-showroom-{{ .Branch }}-{{ checksum "package.json" }} paths: - ./node_modules - - ./yarn.lock - run: name: build-gh-pages @@ -70,79 +62,57 @@ jobs: - run: name: deploy-gh-pages command: ./scripts/gh-pages/deploy.sh .gh-pages-tmp - build_release: + build: <<: *defaults steps: - - run: - name: Environment inject - command: /bin/env_inject.sh - + - attach_workspace: + at: /workspace + - run: cat /workspace/generated_bash_env >> $BASH_ENV - checkout - - restore_cache: keys: - react-showroom-{{ .Branch }}-{{ checksum "package.json" }} - react-showroom-{{ .Branch }} - react-showroom - - - run: - name: "Installing dependencies." - command: yarn install - + - run: if [ -f /.dockerenv ]; then configure-maven.sh && configure-grails.sh && configure-npm.sh; fi + - run: npm install - save_cache: key: react-showroom-{{ .Branch }}-{{ checksum "package.json" }} paths: - ./node_modules - - ./yarn.lock - - - run: - name: "Running lint." - command: npm run lint - - - run: - name: "Deploy." - command: npm run publish-release - - - release: - <<: *defaults - steps: - - - run: - name: Environment inject - command: env_inject.sh - - - checkout - + - run: npm run lint - run: - name: Executing release scrtipt. - command: .circleci/release.sh + name: Publish package + command: | + # we do it only if tag is here (release process is run) + if [ ! -z "${CIRCLE_TAG}" ]; then + npm run publish-release + fi workflows: - version: 2 + version: 2.1 release-and-build: jobs: - - release: + - init: + <<: *default-context filters: - branches: - only: release + tags: + only: /.*/ - build: + <<: *default-context filters: + tags: + only: /.*/ branches: - ignore: - - gh-pages - - release + only: /.*/ + requires: + - init + post-steps: + - jira/notify: + pipeline_id: << pipeline.id >> + pipeline_number: << pipeline.number >> + - update-gh-pages: + <<: *default-context requires: - build - filters: - branches: - ignore: - - gh-pages - - release - - build_release: - filters: - tags: - only: /.*/ - branches: - ignore: /.*/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 911668bd..9a4e1091 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,69 @@ +[Release 0.5.16](https://github.com/OpusCapita/react-dates/releases/tag/v0.5.16) Thu Jun 24 2021 15:03:39 GMT+0300 (MSK) +======================================================= + +- (EPROC-20549) Make translation keys unique ([#77](https://github.com/OpusCapita/react-dates/issues/77)) (GitHub dsanko-sc@users.noreply.github.com, 2021-06-24 12:52:56 +0300) + +[Release 0.5.16-EPROC-20549-SNAPSHOT](https://github.com/OpusCapita/react-dates/releases/tag/v0.5.16-EPROC-20549-SNAPSHOT) Thu Jun 10 2021 10:30:28 GMT+0300 (MSK) +======================================================= + +- Make translation keys unique (Dmitriy Sanko dmitriy.sanko@opuscapita.com, 2021-06-10 10:19:00 +0300) + +[Release 0.5.15](https://github.com/OpusCapita/react-dates/releases/tag/v0.5.15) Fri Apr 30 2021 08:58:08 GMT+0300 (MSK) +======================================================= + +- Added Spanish to available languages ([#75](https://github.com/OpusCapita/react-dates/issues/75)) (GitHub santiago_vital@outlook.com, 2021-04-30 00:56:43 -0500) +- (EPROC-20383) Used jdk zulu (GitHub ashestak-sc@users.noreply.github.com, 2021-04-06 16:28:54 +0300) +- (EPROC-20383) Used jdk zulu (GitHub ashestak-sc@users.noreply.github.com, 2021-04-06 13:09:04 +0300) +- (EPROC-20252) Added circleci builds jira integration (GitHub ashestak-sc@users.noreply.github.com, 2021-03-10 16:02:04 +0300) +- Update CI image to opuscapita/minsk-core-ci:grails-2.4.4-jdk-8u192-nodejs-8.17.0-maven-3.3.9 [ci skip] (Egor Stambakio egor.stambakio@opuscapita.com, 2020-05-07 16:14:10 +0300) + +[Release 0.5.14](https://github.com/OpusCapita/react-dates/releases/tag/v0.5.14) Mon Apr 20 2020 09:34:48 GMT+0300 (MSK) +======================================================= + +- Adjusting build process [skip ci] (Alexey Sergeev alexey.sergeev@opuscapita.com, 2020-04-20 09:33:02 +0300) + +[Release 0.5.13](https://github.com/OpusCapita/react-dates/releases/tag/v0.5.13) Mon Apr 20 2020 09:23:41 GMT+0300 (MSK) +======================================================= + +- Lowering z-index of reset button (3 -> 2) (Alexey Sergeev alexey.sergeev@opuscapita.com, 2020-04-20 09:01:35 +0300) + +[Release 0.5.12](https://github.com/OpusCapita/react-dates/releases/tag/v0.5.12) Mon Apr 20 2020 09:03:41 GMT+0300 (MSK) +======================================================= + + +[Release 0.5.11](https://github.com/OpusCapita/react-dates/releases/tag/v0.5.11) Tue Jul 30 2019 14:10:01 GMT+0300 (MSK) +======================================================= + +- Merge branch 'master' of github.com:OpusCapita/react-dates (kvolkovich-sc volkovich@scand.com, 2019-07-30 14:08:39 +0300) +- [#71](https://github.com/OpusCapita/react-dates/issues/71) Fix input placeholder color (kvolkovich-sc volkovich@scand.com, 2019-07-30 14:08:24 +0300) + +[Release 0.5.10](https://github.com/OpusCapita/react-dates/releases/tag/v0.5.10) Mon Jul 29 2019 13:41:42 GMT+0300 (MSK) +======================================================= + +- [#71](https://github.com/OpusCapita/react-dates/issues/71) Fix input placeholder color under IE/Edge (kvolkovich-sc volkovich@scand.com, 2019-07-29 13:38:52 +0300) + +[Release 0.5.9](https://github.com/OpusCapita/react-dates/releases/tag/v0.5.9) Mon May 27 2019 09:32:22 GMT+0300 (MSK) +======================================================= + +- Stick variants picker to the right ([#70](https://github.com/OpusCapita/react-dates/issues/70)) (GitHub 31243790+estambakio-sc@users.noreply.github.com, 2019-05-27 08:21:06 +0200) + +[Release 0.5.8](https://github.com/OpusCapita/react-dates/releases/tag/v0.5.8) Fri Apr 05 2019 19:11:51 GMT+0300 (MSK) +======================================================= + +- Fix z-index conflict with react-select (kvolkovich-sc kirill.volkovich@opuscapita.com, 2019-04-05 19:09:49 +0300) + +[Release 0.5.7](https://github.com/OpusCapita/react-dates/releases/tag/v0.5.7) Thu Apr 04 2019 15:40:46 GMT+0300 (MSK) +======================================================= + +- ([#67](https://github.com/OpusCapita/react-dates/issues/67)) Remove portal usage from drop down popup (Dmitry Divin divin@scand.com, 2019-04-04 15:39:22 +0300) + +[Release 0.5.6](https://github.com/OpusCapita/react-dates/releases/tag/v0.5.6) Mon Nov 12 2018 17:37:47 GMT+0300 (MSK) +======================================================= + +- Components don't work properly inside modal dialog (Issue [#64](https://github.com/OpusCapita/react-dates/issues/64), PR [#65](https://github.com/OpusCapita/react-dates/issues/65)) (GitHub kvolkovich-sc@users.noreply.github.com, 2018-11-12 17:23:21 +0300) +- Using docker image opuscapita/minsk-core-ci tag grails-2.4.4-jdk-8u131-nodejs-6.9.4-maven-3.3.9 [ci skip] (Alexey Sergeev alexey.sergeev@opuscapita.com, 2018-09-07 09:08:30 +0300) + [Release 0.5.5](https://github.com/OpusCapita/react-dates/releases/tag/v0.5.5) Thu Aug 23 2018 16:09:24 GMT+0300 (MSK) ======================================================= diff --git a/external_modules/jcatalog-bootstrap/package.json b/external_modules/jcatalog-bootstrap/package.json index 728dc0c4..2b19e652 100644 --- a/external_modules/jcatalog-bootstrap/package.json +++ b/external_modules/jcatalog-bootstrap/package.json @@ -1,6 +1,6 @@ { "name": "jcatalog-bootstrap", - "version": "0.5.6", + "version": "0.5.17", "description": "Bootstrap npm module customized for jCatalog.", "main": "dist/js/bootstrap.min.js", "files": [ diff --git a/package.json b/package.json index d8549daa..1813d723 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@opuscapita/react-dates", - "version": "0.5.6", + "version": "0.5.17", "description": "Start write new project with no effort.", "keywords": [ "react", @@ -43,8 +43,7 @@ "dayjs": "1.6.4", "lodash": "4.17.4", "prop-types": "15.6.0", - "react-day-picker": "6.1.0", - "react-portal": "4.1.2" + "react-day-picker": "6.1.0" }, "devDependencies": { "@opuscapita/npm-scripts": "2.0.0-beta.2", @@ -83,6 +82,7 @@ "postcss-loader": "1.3.3", "postcss-modules": "0.6.4", "progress-bar-webpack-plugin": "1.10.0", + "react-bootstrap": "0.32.4", "raw-loader": "0.5.1", "react": "16.2.0", "react-dom": "16.2.0", diff --git a/src/client/components/DateInput/DateInput.DOCUMENTATION.md b/src/client/components/DateInput/DateInput.DOCUMENTATION.md index 0a34a1ce..d9e2de75 100644 --- a/src/client/components/DateInput/DateInput.DOCUMENTATION.md +++ b/src/client/components/DateInput/DateInput.DOCUMENTATION.md @@ -28,12 +28,17 @@ Based on configured to OpusCapita defaults [react-day-picker](https://github.com ### Code Example ```jsx - + + + + + +
diff --git a/src/client/components/DateInput/DateInput.SCOPE.react.js b/src/client/components/DateInput/DateInput.SCOPE.react.js index fa192438..682a0dfa 100644 --- a/src/client/components/DateInput/DateInput.SCOPE.react.js +++ b/src/client/components/DateInput/DateInput.SCOPE.react.js @@ -5,7 +5,9 @@ import React, { Component } from 'react'; import { showroomScopeDecorator } from '@opuscapita/react-showroom-client'; +import { Modal } from 'react-bootstrap'; +window.Modal = Modal; @showroomScopeDecorator export default @@ -13,7 +15,8 @@ class DateInputScope extends Component { constructor(props) { super(props); this.state = { - value: null + value: null, + openModal: false }; } @@ -21,6 +24,14 @@ class DateInputScope extends Component { this.setState({ value }); } + handleOpenModal = () => { + this.setState({ openModal: true }); + } + + handleHideModal = () => { + this.setState({ openModal: false }); + } + render() { let value = this.state.value ? this.state.value.toString() : 'not selected yet'; diff --git a/src/client/components/DateInput/DateInput.less b/src/client/components/DateInput/DateInput.less index b84c5712..4c09a6ec 100644 --- a/src/client/components/DateInput/DateInput.less +++ b/src/client/components/DateInput/DateInput.less @@ -33,11 +33,31 @@ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); position: absolute; overflow: hidden; - z-index: 900; + z-index: 9999; + + bottom: -4px; + transform: translate(0, 100%); +} + +.opuscapita_date-input__picker-container { + left: 0; } .opuscapita_date-input__variants-container { white-space: nowrap; + right: 0; + left: auto; +} + +.opuscapita_date-input__variants-container--to-top, +.opuscapita_date-input__picker-container--to-top { + bottom: auto; + top: -4px; + transform: translate(0, -100%); +} + +.opuscapita_date-input__picker-container--to-left { + left: 0; } .opuscapita_date-input__variants-btn { @@ -52,5 +72,5 @@ position: absolute; top: 0; right: 1ch; - z-index: 3; + z-index: 2; } diff --git a/src/client/components/DateInput/DateInput.react.js b/src/client/components/DateInput/DateInput.react.js index a458705c..9fdf89ea 100644 --- a/src/client/components/DateInput/DateInput.react.js +++ b/src/client/components/DateInput/DateInput.react.js @@ -9,8 +9,7 @@ import { spring, presets, Motion } from 'react-motion'; import dayjs from '../../dayjs'; import getMessage from '../translations'; import isEqual from 'lodash/isEqual'; -import { Portal } from 'react-portal'; -import { getCoords, splitProps, zeroTime } from '../utils'; +import { splitProps, zeroTime } from '../utils'; let springPreset = presets.gentle; let easeOutCubic = (t) => (--t) * t * t + 1; // eslint-disable-line no-param-reassign @@ -52,15 +51,15 @@ let defaultProps = { value: null, variants: [ { - getLabel: (locale) => getMessage(locale, 'yesterday'), + getLabel: (locale) => getMessage(locale, 'common.DateInput.yesterday'), getValue: (locale) => dayjs().locale(locale).subtract(1, 'days').toDate() }, { - getLabel: (locale) => getMessage(locale, 'today'), + getLabel: (locale) => getMessage(locale, 'common.DateInput.today'), getValue: (locale) => dayjs().locale(locale).toDate() }, { - getLabel: (locale) => getMessage(locale, 'tomorrow'), + getLabel: (locale) => getMessage(locale, 'common.DateInput.tomorrow'), getValue: (locale) => dayjs().locale(locale).add(1, 'days').toDate() } ] @@ -257,8 +256,10 @@ class DateInput extends Component { /> ); + let showToTopClassName = showToTop ? 'opuscapita_date-input__picker-container--to-top' : ''; + let showToLeftClassName = showToLeft ? 'opuscapita_date-input__picker-container--to-left' : ''; + let hasErrorClassName = (error === null && isValid) ? '' : 'has-error'; - let { top, left, alwaysLeft } = getCoords(this.container, showToTop, showToLeft); let pickerMotionElement = ( {interpolatedStyle => ( - -
(this.pickerContainer = ref)} - className={`opuscapita_date-input__picker-container`} - style={{ - maxHeight: `${interpolatedStyle.x * 640}px`, - opacity: easeOutCubic(interpolatedStyle.x), - top: `${top}px`, - left: `${left}px`, - transform: `translate(${showToLeft ? '-100%' : '0'}, ${showToTop ? '-100%' : '0'})` - }} - > - {pickerElement} -
-
+
(this.pickerContainer = ref)} + className={` +opuscapita_date-input__picker-container +${showToTopClassName} ${showToLeftClassName} + `} + style={{ + maxHeight: `${interpolatedStyle.x * 640}px`, + opacity: easeOutCubic(interpolatedStyle.x) + }} + > + {pickerElement} +
)}
); @@ -291,7 +290,7 @@ class DateInput extends Component { tabIndex="-1" onClick={this.handleReset} disabled={disabled} - title={getMessage(locale, 'clearValue')} + title={getMessage(locale, 'common.DateInput.clearValue')} > ✕ @@ -320,21 +319,19 @@ class DateInput extends Component { style={{ x: showVariants ? spring(1, springPreset) : spring(0, springPreset) }} > {interpolatedStyle => ( - -
(this.variantsContainer = ref)} - className={`opuscapita_date-input__variants-container`} - style={{ - maxHeight: `${interpolatedStyle.x * 640}px`, - opacity: easeOutCubic(interpolatedStyle.x), - top: `${top}px`, - left: `${alwaysLeft}px`, - transform: `translate(-100%, ${showToTop ? '-100%' : '0'})` - }} - > - {variantsElement} -
-
+
(this.variantsContainer = ref)} + className={` + opuscapita_date-input__variants-container + ${showToTop ? 'opuscapita_date-input__variants-container--to-top' : ''} + `} + style={{ + maxHeight: `${interpolatedStyle.x * 640}px`, + opacity: easeOutCubic(interpolatedStyle.x) + }} + > + {variantsElement} +
)} ) : null; diff --git a/src/client/components/DateInputField/DateInputField.less b/src/client/components/DateInputField/DateInputField.less index 249739f3..9fb7798a 100644 --- a/src/client/components/DateInputField/DateInputField.less +++ b/src/client/components/DateInputField/DateInputField.less @@ -7,4 +7,10 @@ &::-ms-clear { display: none !important; } + + &::placeholder { color: #999; } + &::-moz-placeholder { color: #999; } + &::-webkit-input-placeholder { color: #999; } + &:-ms-input-placeholder { color: #999; } + &::-ms-input-placeholder { color: #999; } } diff --git a/src/client/components/DatePicker/DatePicker.DOCUMENTATION.md b/src/client/components/DatePicker/DatePicker.DOCUMENTATION.md index a1d3bc13..260ae42d 100644 --- a/src/client/components/DatePicker/DatePicker.DOCUMENTATION.md +++ b/src/client/components/DatePicker/DatePicker.DOCUMENTATION.md @@ -31,17 +31,6 @@ See react-day-picker [methods reference](http://react-day-picker.js.org/APIMetho ### Code Example ```jsx -
- -
- + + + + + + + ``` ### Component Name diff --git a/src/client/components/DatePicker/DatePicker.SCOPE.react.js b/src/client/components/DatePicker/DatePicker.SCOPE.react.js index 91a7435a..71125bbe 100644 --- a/src/client/components/DatePicker/DatePicker.SCOPE.react.js +++ b/src/client/components/DatePicker/DatePicker.SCOPE.react.js @@ -5,6 +5,9 @@ import React, { Component } from 'react'; import { showroomScopeDecorator } from '@opuscapita/react-showroom-client'; +import { Modal } from 'react-bootstrap'; + +window.Modal = Modal; @showroomScopeDecorator @@ -13,10 +16,19 @@ class DatePickerScope extends Component { constructor(props) { super(props); this.state = { - value: null + value: null, + openModal: false }; } + handleOpenModal = () => { + this.setState({ openModal: true }); + } + + handleHideModal = () => { + this.setState({ openModal: false }); + } + handleChange(value) { this.setState({ value }); } diff --git a/src/client/components/DatePicker/DatePicker.less b/src/client/components/DatePicker/DatePicker.less index 02d430b4..7ba59d59 100644 --- a/src/client/components/DatePicker/DatePicker.less +++ b/src/client/components/DatePicker/DatePicker.less @@ -4,14 +4,28 @@ } .opuscapita_date-picker__picker-container { - display: flex; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); overflow: hidden; position: absolute; - z-index: 999; + z-index: 9999; + + left: 0; + bottom: -4px; + transform: translate(0, 100%); } .opuscapita_date-picker__picker-container:focus { outline: none; } + +.opuscapita_date-picker__picker-container--to-top { + bottom: auto; + top: -4px; + transform: translate(0, -100%); +} + +.opuscapita_date-picker__picker-container--to-left { + left: auto; + right: 0; +} \ No newline at end of file diff --git a/src/client/components/DatePicker/DatePicker.react.js b/src/client/components/DatePicker/DatePicker.react.js index e2dbd966..ab539746 100644 --- a/src/client/components/DatePicker/DatePicker.react.js +++ b/src/client/components/DatePicker/DatePicker.react.js @@ -4,8 +4,7 @@ import './DatePicker.less'; import DayPicker from '../DayPicker'; import { spring, presets, Motion } from 'react-motion'; import isEqual from 'lodash/isEqual'; -import { Portal } from 'react-portal'; -import { getCoords, splitProps, zeroTime } from '../utils'; +import { splitProps, zeroTime } from '../utils'; let springPreset = presets.gentle; let easeOutCubic = (t) => (--t) * t * t + 1; // eslint-disable-line no-param-reassign @@ -48,6 +47,15 @@ class DatePicker extends Component { document.body.addEventListener('keydown', this.handleBodyKeyDown); } + componentWillReceiveProps(nextProps) { + if (this.props.value !== nextProps.value) { + let month = nextProps.value || new Date(); + if (this.reactDayPicker) { + this.reactDayPicker.showMonth(month); + } + } + } + shouldComponentUpdate(nextProps, nextState) { return ( this.state.showPicker !== nextState.showPicker || @@ -63,10 +71,10 @@ class DatePicker extends Component { componentWillUnmount() { document.body.removeEventListener('click', this.handleBodyClick); - document.body.removeEventListener('keydown', this.handlePortalClose); + document.body.removeEventListener('keydown', this.handleKeyDown); } - handlePortalClose = event => { + handleKeyDown = event => { this.hidePicker(); }; @@ -112,6 +120,8 @@ class DatePicker extends Component { }; showPicker() { + let month = this.props.value || new Date(); + this.reactDayPicker.showMonth(month); this.setState({ showPicker: true }); } @@ -152,7 +162,8 @@ class DatePicker extends Component { /> ); - let { top, left } = getCoords(this.container, showToTop, showToLeft); + let showToTopClassName = showToTop ? 'opuscapita_date-picker__picker-container--to-top' : ''; + let showToLeftClassName = showToLeft ? 'opuscapita_date-picker__picker-container--to-left' : ''; let pickerMotionElement = ( {interpolatedStyle => ( - { this.datePickerRef = ref }} + className={` + opuscapita_date-picker__picker-container + ${showToTopClassName} ${showToLeftClassName} + `} + style={{ + maxHeight: `${interpolatedStyle.x * 640}px`, + opacity: easeOutCubic(interpolatedStyle.x) + }} > -
{ this.datePickerRef = ref }} - className={`opuscapita_date-picker__picker-container`} - style={{ - maxHeight: `${interpolatedStyle.x * 640}px`, - opacity: easeOutCubic(interpolatedStyle.x), - top: `${top}px`, - left: `${left}px`, - transform: `translate(${showToLeft ? '-100%' : '0'}, ${showToTop ? '-100%' : '0'})` - }} - > - {pickerElement} -
-
+ {pickerElement} + )}
); @@ -185,6 +191,7 @@ class DatePicker extends Component { return (
(this.container = el)} { ...commonProps } > diff --git a/src/client/components/DatePicker/DatePicker.spec.js b/src/client/components/DatePicker/DatePicker.spec.js index 6062b81d..ef081f0a 100644 --- a/src/client/components/DatePicker/DatePicker.spec.js +++ b/src/client/components/DatePicker/DatePicker.spec.js @@ -22,12 +22,6 @@ describe('', () => { expect(wrapper.hasClass('test-class-name')).to.be.true; }); - it('should have picker-container', () => { - let wrapper = mount(); - let pickerContainers = document.getElementsByClassName('opuscapita_date-picker__picker-container'); - expect(pickerContainers).to.have.lengthOf(1); - }); - it.skip('+ should pass specific DayPicker props to it', () => { let wrapper = mount( + + + + + +
diff --git a/src/client/components/DateRangeInput/DateRangeInput.SCOPE.react.js b/src/client/components/DateRangeInput/DateRangeInput.SCOPE.react.js index 733663f6..3f8f6350 100644 --- a/src/client/components/DateRangeInput/DateRangeInput.SCOPE.react.js +++ b/src/client/components/DateRangeInput/DateRangeInput.SCOPE.react.js @@ -5,6 +5,9 @@ import React, { Component } from 'react'; import { showroomScopeDecorator } from '@opuscapita/react-showroom-client'; +import { Modal } from 'react-bootstrap'; + +window.Modal = Modal; @showroomScopeDecorator @@ -16,10 +19,19 @@ class DateRangeInputScope extends Component { value1: [null, null], value2: [new Date(), new Date()], value3: [null, null], - value4: [null, null] + value4: [null, null], + openModal: false, }; } + handleOpenModal = () => { + this.setState({ openModal: true }); + } + + handleHideModal = () => { + this.setState({ openModal: false }); + } + handleChange1(value) { this.setState({ value1: value }); } diff --git a/src/client/components/DateRangeInput/DateRangeInput.less b/src/client/components/DateRangeInput/DateRangeInput.less index 5359887e..00199a84 100644 --- a/src/client/components/DateRangeInput/DateRangeInput.less +++ b/src/client/components/DateRangeInput/DateRangeInput.less @@ -12,12 +12,22 @@ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); overflow: hidden; position: absolute; - z-index: 900; + z-index: 9999; + + bottom: -4px; + transform: translate(0, 100%); +} + +.opuscapita_date-range-input__picker-container { + left: 0; } .opuscapita_date-range-input__variants-container { + right: 0; + left: auto; white-space: nowrap; } + .opuscapita_date-range-input__picker-container:focus { outline: none; } @@ -31,7 +41,7 @@ position: absolute; top: 0; right: 1ch; - z-index: 10; + z-index: 1; } .opuscapita_date-range-input__input-field { @@ -105,8 +115,20 @@ display: inline-flex; align-items: center; justify-content: center; - z-index: 10; + z-index: 1; pointer-events: none; color: #aaa; padding-right: 24px; } + +.opuscapita_date-range-input__picker-container--to-left { + left: auto; + right: 0; +} + +.opuscapita_date-range-input__picker-container--to-top, +.opuscapita_date-range-input__variants-container--to-top { + bottom: auto; + top: -4px; + transform: translate(0, -100%); +} diff --git a/src/client/components/DateRangeInput/DateRangeInput.react.js b/src/client/components/DateRangeInput/DateRangeInput.react.js index 729e1b6c..627ecc23 100644 --- a/src/client/components/DateRangeInput/DateRangeInput.react.js +++ b/src/client/components/DateRangeInput/DateRangeInput.react.js @@ -9,8 +9,7 @@ import isEqual from 'lodash/isEqual'; import dayjs from '../../dayjs'; import { spring, presets, Motion } from 'react-motion'; import getMessage from '../translations'; -import { Portal } from 'react-portal'; -import { getCoords, splitProps, zeroTime } from '../utils'; +import { splitProps, zeroTime } from '../utils'; let springPreset = presets.gentle; let easeOutCubic = (t) => (--t) * t * t + 1; // eslint-disable-line no-param-reassign @@ -66,7 +65,7 @@ let defaultProps = { value: [null, null], variants: [ { - getLabel: (locale) => getMessage(locale, 'previousWeek'), + getLabel: (locale) => getMessage(locale, 'common.DateRangeInput.previousWeek'), // TODO remove ternary operator below. Monitor this issue: https://github.com/iamkun/dayjs/issues/215 getValue: (locale) => locale === 'en' ? [ dayjs().locale(locale).subtract(7, 'days').startOf('week').toDate(), @@ -77,7 +76,7 @@ let defaultProps = { ] }, { - getLabel: (locale) => getMessage(locale, 'thisWeek'), + getLabel: (locale) => getMessage(locale, 'common.DateRangeInput.thisWeek'), // TODO remove ternary operator below. Monitor this issue: https://github.com/iamkun/dayjs/issues/215 getValue: (locale) => locale === 'en' ? [ dayjs().locale(locale).startOf('week').toDate(), @@ -88,7 +87,7 @@ let defaultProps = { ] }, { - getLabel: (locale) => getMessage(locale, 'nextWeek'), + getLabel: (locale) => getMessage(locale, 'common.DateRangeInput.nextWeek'), // TODO remove ternary operator below. Monitor this issue: https://github.com/iamkun/dayjs/issues/215 getValue: (locale) => locale === 'en' ? [ dayjs().locale(locale).add(7, 'days').startOf('week').toDate(), @@ -99,28 +98,28 @@ let defaultProps = { ] }, { - getLabel: (locale) => getMessage(locale, 'previousMonth'), + getLabel: (locale) => getMessage(locale, 'common.DateRangeInput.previousMonth'), getValue: (locale) => [ dayjs().locale(locale).subtract(1, 'month').startOf('month').toDate(), dayjs().locale(locale).subtract(1, 'month').endOf('month').toDate() ] }, { - getLabel: (locale) => getMessage(locale, 'last30Days'), + getLabel: (locale) => getMessage(locale, 'common.DateRangeInput.last30Days'), getValue: (locale) => [ dayjs().locale(locale).subtract(30, 'days').toDate(), dayjs().locale(locale).toDate() ] }, { - getLabel: (locale) => getMessage(locale, 'thisMonth'), + getLabel: (locale) => getMessage(locale, 'common.DateRangeInput.thisMonth'), getValue: (locale) => [ dayjs().locale(locale).startOf('month').toDate(), dayjs().locale(locale).endOf('month').toDate() ] }, { - getLabel: (locale) => getMessage(locale, 'nextMonth'), + getLabel: (locale) => getMessage(locale, 'common.DateRangeInput.nextMonth'), getValue: (locale) => [ dayjs().locale(locale).add(1, 'month').startOf('month').toDate(), dayjs().locale(locale).add(1, 'month').endOf('month').toDate() @@ -355,6 +354,9 @@ class DateRangeInput extends Component { let { enteredTo, error, focused, showPicker, showVariants } = this.state; let dayjsCompatibleDateFormat = dateFormat.replace(/d/g, 'D').replace(/y/g, 'Y'); + let showToTopClassName = showToTop ? 'opuscapita_date-range-input__picker-container--to-top' : ''; + let showToLeftClassName = showToLeft ? 'opuscapita_date-range-input__picker-container--to-left' : ''; + let pickerElement = ( {interpolatedStyle => ( - -
(this.pickerContainer = ref)} - className={`opuscapita_date-range-input__picker-container`} - style={{ - maxHeight: `${interpolatedStyle.x * 640}px`, - opacity: easeOutCubic(interpolatedStyle.x), - top: `${top}px`, - left: `${left}px`, - transform: `translate(${showToLeft ? '-100%' : '0'}, ${showToTop ? '-100%' : '0'})` - }} - > - {pickerElement} -
-
+
(this.pickerContainer = ref)} + className={`opuscapita_date-range-input__picker-container ${showToTopClassName} ${showToLeftClassName}`} + style={{ + maxHeight: `${interpolatedStyle.x * 640}px`, + opacity: easeOutCubic(interpolatedStyle.x) + }} + > + {pickerElement} +
)} ); @@ -425,21 +420,19 @@ class DateRangeInput extends Component { style={{ x: showVariants ? spring(1, springPreset) : spring(0, springPreset) }} > {interpolatedStyle => ( - -
(this.variantsContainer = ref)} - className={`opuscapita_date-range-input__variants-container`} - style={{ - maxHeight: `${interpolatedStyle.x * 640}px`, - opacity: easeOutCubic(interpolatedStyle.x), - top: `${top}px`, - left: `${alwaysLeft}px`, - transform: `translate(-100%, ${showToTop ? '-100%' : '0'})` - }} - > - {variantsElement} -
-
+
(this.variantsContainer = ref)} + className={` + opuscapita_date-range-input__variants-container + ${showToTop ? 'opuscapita_date-range-input__variants-container--to-top' : ''} + `} + style={{ + maxHeight: `${interpolatedStyle.x * 640}px`, + opacity: easeOutCubic(interpolatedStyle.x) + }} + > + {variantsElement} +
)} ) : null; @@ -450,7 +443,7 @@ class DateRangeInput extends Component { tabIndex="-1" onClick={this.handleReset} disabled={disabled} - title={getMessage(locale, 'clearValue')} + title={getMessage(locale, 'common.DateInput.clearValue')} > ✕ diff --git a/src/client/components/DayPicker/DayPicker.react.js b/src/client/components/DayPicker/DayPicker.react.js index fdf1e87f..306f5cba 100644 --- a/src/client/components/DayPicker/DayPicker.react.js +++ b/src/client/components/DayPicker/DayPicker.react.js @@ -23,7 +23,7 @@ let propTypes = { let defaultProps = { className: '', dayPickerRef: () => {}, - getTodayButtonLabel: (locale) => getMessage(locale, 'today'), + getTodayButtonLabel: (locale) => getMessage(locale, 'common.DateInput.today'), hideTodayButton: false, isRange: false, labels: ReactDayPicker.defaultProps.labels, diff --git a/src/client/components/translations.js b/src/client/components/translations.js index ee238e1e..d7a98143 100644 --- a/src/client/components/translations.js +++ b/src/client/components/translations.js @@ -1,87 +1,81 @@ const translations = { en: { - selectDateRange: 'Select date range', - today: 'Today', - yesterday: 'Yesterday', - tomorrow: 'Tomorrow', - previousWeek: 'Previous week', - nextWeek: 'Next week', - thisWeek: 'This week', - previousMonth: 'Previous month', - last30Days: 'Last 30 days', - thisMonth: 'This month', - nextMonth: 'Next month', - clearValue: 'Clear value' + 'common.DateInput.today': 'Today', + 'common.DateInput.yesterday': 'Yesterday', + 'common.DateInput.tomorrow': 'Tomorrow', + 'common.DateRangeInput.previousWeek': 'Previous week', + 'common.DateRangeInput.nextWeek': 'Next week', + 'common.DateRangeInput.thisWeek': 'This week', + 'common.DateRangeInput.previousMonth': 'Previous month', + 'common.DateRangeInput.last30Days': 'Last 30 days', + 'common.DateRangeInput.thisMonth': 'This month', + 'common.DateRangeInput.nextMonth': 'Next month', + 'common.DateInput.clearValue': 'Clear value' }, de: { - selectDateRange: 'Datumsbereich auswählen', - today: 'Heute', - yesterday: 'Gestern', - tomorrow: 'Morgen', - previousWeek: 'Vorherige Woche', - nextWeek: 'Nächste Woche', - thisWeek: 'Diese Woche', - previousMonth: 'Vorheriger Monat', - last30Days: 'Letzte 30 Tagen', - thisMonth: 'Dieser Monat', - nextMonth: 'Nächster Monat', - clearValue: 'Inhalt löschen' + 'common.DateInput.today': 'Heute', + 'common.DateInput.yesterday': 'Gestern', + 'common.DateInput.tomorrow': 'Morgen', + 'common.DateRangeInput.previousWeek': 'Vorherige Woche', + 'common.DateRangeInput.nextWeek': 'Nächste Woche', + 'common.DateRangeInput.thisWeek': 'Diese Woche', + 'common.DateRangeInput.previousMonth': 'Vorheriger Monat', + 'common.DateRangeInput.last30Days': 'Letzte 30 Tagen', + 'common.DateRangeInput.thisMonth': 'Dieser Monat', + 'common.DateRangeInput.nextMonth': 'Nächster Monat', + 'common.DateInput.clearValue': 'Inhalt löschen' }, ru: { - selectDateRange: 'Выберите диапазон дат', - today: 'Сегодня', - yesterday: 'Вчера', - tomorrow: 'Завтра', - previousWeek: 'Предыдущая неделя', - nextWeek: 'Следующая неделя', - thisWeek: 'Эта неделя', - previousMonth: 'Предыдущий месяц', - last30Days: 'Последние 30 дней', - thisMonth: 'Этот месяц', - nextMonth: 'Следующий месяц', - clearValue: '' + 'common.DateInput.today': 'Сегодня', + 'common.DateInput.yesterday': 'Вчера', + 'common.DateInput.tomorrow': 'Завтра', + 'common.DateRangeInput.previousWeek': 'Предыдущая неделя', + 'common.DateRangeInput.nextWeek': 'Следующая неделя', + 'common.DateRangeInput.thisWeek': 'Эта неделя', + 'common.DateRangeInput.previousMonth': 'Предыдущий месяц', + 'common.DateRangeInput.last30Days': 'Последние 30 дней', + 'common.DateRangeInput.thisMonth': 'Этот месяц', + 'common.DateRangeInput.nextMonth': 'Следующий месяц', + 'common.DateInput.clearValue': '' }, fi: { - selectDateRange: 'Valitse päivämääräväli', - today: 'Tänään', - yesterday: 'Eilen', - tomorrow: 'Huomenna', - previousWeek: 'Edellinen viikko', - nextWeek: 'Seuraava viikko', - thisWeek: 'Tämä viikko', - previousMonth: 'Edellinen kuukausi', - last30Days: 'Edelliset 30 päivää', - thisMonth: 'Tämä kuukausi', - nextMonth: 'Seuraava kuukausi', - clearValue: '' + 'common.DateInput.today': 'Tänään', + 'common.DateInput.yesterday': 'Eilen', + 'common.DateInput.tomorrow': 'Huomenna', + 'common.DateRangeInput.previousWeek': 'Edellinen viikko', + 'common.DateRangeInput.nextWeek': 'Seuraava viikko', + 'common.DateRangeInput.thisWeek': 'Tämä viikko', + 'common.DateRangeInput.previousMonth': 'Edellinen kuukausi', + 'common.DateRangeInput.last30Days': 'Edelliset 30 päivää', + 'common.DateRangeInput.thisMonth': 'Tämä kuukausi', + 'common.DateRangeInput.nextMonth': 'Seuraava kuukausi', + 'common.DateInput.clearValue': '' }, no: { - selectDateRange: 'Velg datoområde', - today: 'I dag', - yesterday: 'I går', - tomorrow: 'I morgen', - previousWeek: 'Forrige uke', - nextWeek: 'Neste uke', - thisWeek: 'Denne uken', - previousMonth: 'Foregående måned', - last30Days: 'Siste 30 dager', - thisMonth: 'Denne måneden', - nextMonth: 'Neste måned', - clearValue: '' + 'common.DateInput.today': 'I dag', + 'common.DateInput.yesterday': 'I går', + 'common.DateInput.tomorrow': 'I morgen', + 'common.DateRangeInput.previousWeek': 'Forrige uke', + 'common.DateRangeInput.nextWeek': 'Neste uke', + 'common.DateRangeInput.thisWeek': 'Denne uken', + 'common.DateRangeInput.previousMonth': 'Foregående måned', + 'common.DateRangeInput.last30Days': 'Siste 30 dager', + 'common.DateRangeInput.thisMonth': 'Denne måneden', + 'common.DateRangeInput.nextMonth': 'Neste måned', + 'common.DateInput.clearValue': '' }, sv: { - selectDateRange: 'Välj datumintervall', - today: 'Idag', - yesterday: 'Igår', - tomorrow: 'Imorgon', - previousWeek: 'Föregående vecka', - nextWeek: 'Nästa vecka', - thisWeek: 'Denna vecka', - previousMonth: 'Föregående månad', - last30Days: 'SSenaste 30 dagarna', - thisMonth: 'Denna månad', - nextMonth: 'Nästa månad', - clearValue: '' + 'common.DateInput.today': 'Idag', + 'common.DateInput.yesterday': 'Igår', + 'common.DateInput.tomorrow': 'Imorgon', + 'common.DateRangeInput.previousWeek': 'Föregående vecka', + 'common.DateRangeInput.nextWeek': 'Nästa vecka', + 'common.DateRangeInput.thisWeek': 'Denna vecka', + 'common.DateRangeInput.previousMonth': 'Föregående månad', + 'common.DateRangeInput.last30Days': 'SSenaste 30 dagarna', + 'common.DateRangeInput.thisMonth': 'Denna månad', + 'common.DateRangeInput.nextMonth': 'Nästa månad', + 'common.DateInput.clearValue': '' } }; diff --git a/src/client/dayjs/index.js b/src/client/dayjs/index.js index 739df2b5..8a86041b 100644 --- a/src/client/dayjs/index.js +++ b/src/client/dayjs/index.js @@ -1,5 +1,6 @@ import dayjs from 'dayjs'; import en from './locales/en'; +import es from './locales/es'; import de from './locales/de'; import fi from './locales/fi'; import no from './locales/no'; @@ -8,6 +9,7 @@ import sv from './locales/sv'; const locales = { en, + es, de, fi, no, diff --git a/src/client/dayjs/locales/es.js b/src/client/dayjs/locales/es.js new file mode 100644 index 00000000..041aade4 --- /dev/null +++ b/src/client/dayjs/locales/es.js @@ -0,0 +1,12 @@ +export default { + name: 'es', + weekdays: 'Domingo_Lunes_Martes_Miércoles_Jueves_Viernes_Sábado'.split('_'), + months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'), + ordinal: n => `${n}°`, + // https://github.com/moment/moment/blob/develop/locale/es.js + weekdaysMin: 'Do_Lu_Ma_Mi_Ju_Vi_Sá'.split('_'), + week: { + dow: 1, // Monday is the first day of the week. + doy: 4 // The week that contains Jan 4th is the first week of the year. + } +}