@redneckz/wildless-cms-uni-blocks 0.9.11 → 0.9.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/migrateContentUnit.js +1 -1
- package/bundle/blocks.schema.json +1 -1
- package/bundle/bundle.umd.js +131 -56
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/Calculator/CalculatorContent.d.ts +18 -17
- package/bundle/components/Calculator/DepositCalculatorForm.d.ts +2 -2
- package/bundle/components/Calculator/rangeHelpers.d.ts +1 -0
- package/bundle/components/Calculator/renderMonthsInput.d.ts +1 -0
- package/bundle/components/Calculator/useDepositCalculatorParams.d.ts +3 -1
- package/bundle/components/CarouselRecommendationCard/CarouselRecommendationCardContent.d.ts +2 -6
- package/bundle/components/Footer/MediaButton.d.ts +3 -4
- package/bundle/content-page-repository/ContentPageRepository.d.ts +1 -5
- package/bundle/content-page-repository/alignImg.d.ts +9 -0
- package/bundle/content-page-repository/computeImgOutputPath.d.ts +3 -0
- package/bundle/content-page-repository/resizeImg.d.ts +3 -0
- package/bundle/content-page-repository/transformContentPage.d.ts +1 -0
- package/bundle/content-page-repository/transformImg.d.ts +6 -5
- package/bundle/content-page-repository/transformPicture.d.ts +1 -1
- package/bundle/ui-kit/InputListRange/InputListRange.d.ts +2 -0
- package/bundle/ui-kit/InputListRange/InputListRangeProps.d.ts +10 -0
- package/bundle/utils/arrayByRange.d.ts +1 -0
- package/bundle/utils/isPictureSizeEmpty.d.ts +2 -2
- package/bundle/utils/mergeIntervals.d.ts +1 -0
- package/dist/components/Calculator/CalculatorContent.d.ts +18 -17
- package/dist/components/Calculator/CreditCalculatorForm.js.map +1 -1
- package/dist/components/Calculator/DepositCalculatorForm.d.ts +2 -2
- package/dist/components/Calculator/DepositCalculatorForm.js +21 -11
- package/dist/components/Calculator/DepositCalculatorForm.js.map +1 -1
- package/dist/components/Calculator/constants.js +1 -1
- package/dist/components/Calculator/constants.js.map +1 -1
- package/dist/components/Calculator/rangeHelpers.d.ts +1 -0
- package/dist/components/Calculator/rangeHelpers.js +4 -1
- package/dist/components/Calculator/rangeHelpers.js.map +1 -1
- package/dist/components/Calculator/renderMonthsInput.d.ts +1 -0
- package/dist/components/Calculator/renderMonthsInput.js +3 -2
- package/dist/components/Calculator/renderMonthsInput.js.map +1 -1
- package/dist/components/Calculator/useCreditCalculatorParams.js +27 -29
- package/dist/components/Calculator/useCreditCalculatorParams.js.map +1 -1
- package/dist/components/Calculator/useDepositCalculatorParams.d.ts +3 -1
- package/dist/components/Calculator/useDepositCalculatorParams.js +22 -6
- package/dist/components/Calculator/useDepositCalculatorParams.js.map +1 -1
- package/dist/components/CarouselRecommendationCard/CarouselRecommendationCardContent.d.ts +2 -6
- package/dist/components/Footer/MediaButton.d.ts +3 -4
- package/dist/components/Footer/MediaButton.js.map +1 -1
- package/dist/content-page-repository/ContentPageRepository.d.ts +1 -5
- package/dist/content-page-repository/ContentPageRepository.js +7 -25
- package/dist/content-page-repository/ContentPageRepository.js.map +1 -1
- package/dist/content-page-repository/alignImg.d.ts +9 -0
- package/dist/content-page-repository/alignImg.js +23 -0
- package/dist/content-page-repository/alignImg.js.map +1 -0
- package/dist/content-page-repository/computeImgOutputPath.d.ts +3 -0
- package/dist/content-page-repository/computeImgOutputPath.js +18 -0
- package/dist/content-page-repository/computeImgOutputPath.js.map +1 -0
- package/dist/content-page-repository/resizeImg.d.ts +3 -0
- package/dist/content-page-repository/resizeImg.js +19 -0
- package/dist/content-page-repository/resizeImg.js.map +1 -0
- package/dist/content-page-repository/transformContentPage.d.ts +1 -0
- package/dist/content-page-repository/transformContentPage.js +25 -19
- package/dist/content-page-repository/transformContentPage.js.map +1 -1
- package/dist/content-page-repository/transformImg.d.ts +6 -5
- package/dist/content-page-repository/transformImg.js +26 -76
- package/dist/content-page-repository/transformImg.js.map +1 -1
- package/dist/content-page-repository/transformPicture.d.ts +1 -1
- package/dist/content-page-repository/transformPicture.js +8 -16
- package/dist/content-page-repository/transformPicture.js.map +1 -1
- package/dist/ui-kit/InputListRange/InputListRange.d.ts +2 -0
- package/dist/ui-kit/InputListRange/InputListRange.js +41 -0
- package/dist/ui-kit/InputListRange/InputListRange.js.map +1 -0
- package/dist/ui-kit/InputListRange/InputListRangeProps.d.ts +10 -0
- package/dist/ui-kit/InputListRange/InputListRangeProps.js +2 -0
- package/dist/ui-kit/InputListRange/InputListRangeProps.js.map +1 -0
- package/dist/ui-kit/Select/Select.js +2 -1
- package/dist/ui-kit/Select/Select.js.map +1 -1
- package/dist/utils/arrayByRange.d.ts +1 -0
- package/dist/utils/arrayByRange.js +5 -0
- package/dist/utils/arrayByRange.js.map +1 -0
- package/dist/utils/isPictureSizeEmpty.d.ts +2 -2
- package/dist/utils/isPictureSizeEmpty.js +1 -1
- package/dist/utils/isPictureSizeEmpty.js.map +1 -1
- package/dist/utils/mergeIntervals.d.ts +1 -0
- package/dist/utils/mergeIntervals.js +20 -0
- package/dist/utils/mergeIntervals.js.map +1 -0
- package/lib/common.css +1 -1
- package/lib/components/Calculator/CalculatorContent.d.ts +18 -17
- package/lib/components/Calculator/CreditCalculatorForm.js.map +1 -1
- package/lib/components/Calculator/DepositCalculatorForm.d.ts +2 -2
- package/lib/components/Calculator/DepositCalculatorForm.js +22 -12
- package/lib/components/Calculator/DepositCalculatorForm.js.map +1 -1
- package/lib/components/Calculator/constants.js +1 -1
- package/lib/components/Calculator/constants.js.map +1 -1
- package/lib/components/Calculator/rangeHelpers.d.ts +1 -0
- package/lib/components/Calculator/rangeHelpers.js +2 -0
- package/lib/components/Calculator/rangeHelpers.js.map +1 -1
- package/lib/components/Calculator/renderMonthsInput.d.ts +1 -0
- package/lib/components/Calculator/renderMonthsInput.js +3 -2
- package/lib/components/Calculator/renderMonthsInput.js.map +1 -1
- package/lib/components/Calculator/useCreditCalculatorParams.js +27 -29
- package/lib/components/Calculator/useCreditCalculatorParams.js.map +1 -1
- package/lib/components/Calculator/useDepositCalculatorParams.d.ts +3 -1
- package/lib/components/Calculator/useDepositCalculatorParams.js +22 -6
- package/lib/components/Calculator/useDepositCalculatorParams.js.map +1 -1
- package/lib/components/CarouselRecommendationCard/CarouselRecommendationCardContent.d.ts +2 -6
- package/lib/components/Footer/MediaButton.d.ts +3 -4
- package/lib/components/Footer/MediaButton.js.map +1 -1
- package/lib/content-page-repository/ContentPageRepository.d.ts +1 -5
- package/lib/content-page-repository/ContentPageRepository.js +8 -26
- package/lib/content-page-repository/ContentPageRepository.js.map +1 -1
- package/lib/content-page-repository/alignImg.d.ts +9 -0
- package/lib/content-page-repository/alignImg.js +17 -0
- package/lib/content-page-repository/alignImg.js.map +1 -0
- package/lib/content-page-repository/computeImgOutputPath.d.ts +3 -0
- package/lib/content-page-repository/computeImgOutputPath.js +12 -0
- package/lib/content-page-repository/computeImgOutputPath.js.map +1 -0
- package/lib/content-page-repository/resizeImg.d.ts +3 -0
- package/lib/content-page-repository/resizeImg.js +13 -0
- package/lib/content-page-repository/resizeImg.js.map +1 -0
- package/lib/content-page-repository/transformContentPage.d.ts +1 -0
- package/lib/content-page-repository/transformContentPage.js +23 -18
- package/lib/content-page-repository/transformContentPage.js.map +1 -1
- package/lib/content-page-repository/transformImg.d.ts +6 -5
- package/lib/content-page-repository/transformImg.js +26 -76
- package/lib/content-page-repository/transformImg.js.map +1 -1
- package/lib/content-page-repository/transformPicture.d.ts +1 -1
- package/lib/content-page-repository/transformPicture.js +8 -16
- package/lib/content-page-repository/transformPicture.js.map +1 -1
- package/lib/ui-kit/InputListRange/InputListRange.d.ts +2 -0
- package/lib/ui-kit/InputListRange/InputListRange.js +39 -0
- package/lib/ui-kit/InputListRange/InputListRange.js.map +1 -0
- package/lib/ui-kit/InputListRange/InputListRangeProps.d.ts +10 -0
- package/lib/ui-kit/InputListRange/InputListRangeProps.js +2 -0
- package/lib/ui-kit/InputListRange/InputListRangeProps.js.map +1 -0
- package/lib/ui-kit/Select/Select.js +2 -1
- package/lib/ui-kit/Select/Select.js.map +1 -1
- package/lib/utils/arrayByRange.d.ts +1 -0
- package/lib/utils/arrayByRange.js +2 -0
- package/lib/utils/arrayByRange.js.map +1 -0
- package/lib/utils/isPictureSizeEmpty.d.ts +2 -2
- package/lib/utils/isPictureSizeEmpty.js +1 -1
- package/lib/utils/isPictureSizeEmpty.js.map +1 -1
- package/lib/utils/mergeIntervals.d.ts +1 -0
- package/lib/utils/mergeIntervals.js +17 -0
- package/lib/utils/mergeIntervals.js.map +1 -0
- package/mobile/bundle/bundle.umd.js +1 -1
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/Calculator/CalculatorContent.d.ts +18 -17
- package/mobile/bundle/components/Calculator/DepositCalculatorForm.d.ts +2 -2
- package/mobile/bundle/components/Calculator/rangeHelpers.d.ts +1 -0
- package/mobile/bundle/components/Calculator/renderMonthsInput.d.ts +1 -0
- package/mobile/bundle/components/Calculator/useDepositCalculatorParams.d.ts +3 -1
- package/mobile/bundle/components/CarouselRecommendationCard/CarouselRecommendationCardContent.d.ts +2 -6
- package/mobile/bundle/components/Footer/MediaButton.d.ts +3 -4
- package/mobile/bundle/content-page-repository/ContentPageRepository.d.ts +1 -5
- package/mobile/bundle/content-page-repository/alignImg.d.ts +9 -0
- package/mobile/bundle/content-page-repository/computeImgOutputPath.d.ts +3 -0
- package/mobile/bundle/content-page-repository/resizeImg.d.ts +3 -0
- package/mobile/bundle/content-page-repository/transformContentPage.d.ts +1 -0
- package/mobile/bundle/content-page-repository/transformImg.d.ts +6 -5
- package/mobile/bundle/content-page-repository/transformPicture.d.ts +1 -1
- package/mobile/bundle/ui-kit/InputListRange/InputListRange.d.ts +2 -0
- package/mobile/bundle/ui-kit/InputListRange/InputListRangeProps.d.ts +10 -0
- package/mobile/bundle/utils/arrayByRange.d.ts +1 -0
- package/mobile/bundle/utils/isPictureSizeEmpty.d.ts +2 -2
- package/mobile/bundle/utils/mergeIntervals.d.ts +1 -0
- package/mobile/dist/components/Calculator/CalculatorContent.d.ts +18 -17
- package/mobile/dist/components/Calculator/CreditCalculatorForm.js.map +1 -1
- package/mobile/dist/components/Calculator/DepositCalculatorForm.d.ts +2 -2
- package/mobile/dist/components/Calculator/DepositCalculatorForm.js +21 -11
- package/mobile/dist/components/Calculator/DepositCalculatorForm.js.map +1 -1
- package/mobile/dist/components/Calculator/constants.js +1 -1
- package/mobile/dist/components/Calculator/constants.js.map +1 -1
- package/mobile/dist/components/Calculator/rangeHelpers.d.ts +1 -0
- package/mobile/dist/components/Calculator/rangeHelpers.js +4 -1
- package/mobile/dist/components/Calculator/rangeHelpers.js.map +1 -1
- package/mobile/dist/components/Calculator/renderMonthsInput.d.ts +1 -0
- package/mobile/dist/components/Calculator/renderMonthsInput.js +3 -2
- package/mobile/dist/components/Calculator/renderMonthsInput.js.map +1 -1
- package/mobile/dist/components/Calculator/useCreditCalculatorParams.js +27 -29
- package/mobile/dist/components/Calculator/useCreditCalculatorParams.js.map +1 -1
- package/mobile/dist/components/Calculator/useDepositCalculatorParams.d.ts +3 -1
- package/mobile/dist/components/Calculator/useDepositCalculatorParams.js +22 -6
- package/mobile/dist/components/Calculator/useDepositCalculatorParams.js.map +1 -1
- package/mobile/dist/components/CarouselRecommendationCard/CarouselRecommendationCardContent.d.ts +2 -6
- package/mobile/dist/components/Footer/MediaButton.d.ts +3 -4
- package/mobile/dist/components/Footer/MediaButton.js.map +1 -1
- package/mobile/dist/content-page-repository/ContentPageRepository.d.ts +1 -5
- package/mobile/dist/content-page-repository/ContentPageRepository.js +7 -25
- package/mobile/dist/content-page-repository/ContentPageRepository.js.map +1 -1
- package/mobile/dist/content-page-repository/alignImg.d.ts +9 -0
- package/mobile/dist/content-page-repository/alignImg.js +23 -0
- package/mobile/dist/content-page-repository/alignImg.js.map +1 -0
- package/mobile/dist/content-page-repository/computeImgOutputPath.d.ts +3 -0
- package/mobile/dist/content-page-repository/computeImgOutputPath.js +18 -0
- package/mobile/dist/content-page-repository/computeImgOutputPath.js.map +1 -0
- package/mobile/dist/content-page-repository/resizeImg.d.ts +3 -0
- package/mobile/dist/content-page-repository/resizeImg.js +19 -0
- package/mobile/dist/content-page-repository/resizeImg.js.map +1 -0
- package/mobile/dist/content-page-repository/transformContentPage.d.ts +1 -0
- package/mobile/dist/content-page-repository/transformContentPage.js +25 -19
- package/mobile/dist/content-page-repository/transformContentPage.js.map +1 -1
- package/mobile/dist/content-page-repository/transformImg.d.ts +6 -5
- package/mobile/dist/content-page-repository/transformImg.js +26 -76
- package/mobile/dist/content-page-repository/transformImg.js.map +1 -1
- package/mobile/dist/content-page-repository/transformPicture.d.ts +1 -1
- package/mobile/dist/content-page-repository/transformPicture.js +8 -16
- package/mobile/dist/content-page-repository/transformPicture.js.map +1 -1
- package/mobile/dist/ui-kit/InputListRange/InputListRange.d.ts +2 -0
- package/mobile/dist/ui-kit/InputListRange/InputListRange.js +41 -0
- package/mobile/dist/ui-kit/InputListRange/InputListRange.js.map +1 -0
- package/mobile/dist/ui-kit/InputListRange/InputListRangeProps.d.ts +10 -0
- package/mobile/dist/ui-kit/InputListRange/InputListRangeProps.js +2 -0
- package/mobile/dist/ui-kit/InputListRange/InputListRangeProps.js.map +1 -0
- package/mobile/dist/ui-kit/Select/Select.js +2 -1
- package/mobile/dist/ui-kit/Select/Select.js.map +1 -1
- package/mobile/dist/utils/arrayByRange.d.ts +1 -0
- package/mobile/dist/utils/arrayByRange.js +5 -0
- package/mobile/dist/utils/arrayByRange.js.map +1 -0
- package/mobile/dist/utils/isPictureSizeEmpty.d.ts +2 -2
- package/mobile/dist/utils/isPictureSizeEmpty.js +1 -1
- package/mobile/dist/utils/isPictureSizeEmpty.js.map +1 -1
- package/mobile/dist/utils/mergeIntervals.d.ts +1 -0
- package/mobile/dist/utils/mergeIntervals.js +20 -0
- package/mobile/dist/utils/mergeIntervals.js.map +1 -0
- package/mobile/lib/components/Calculator/CalculatorContent.d.ts +18 -17
- package/mobile/lib/components/Calculator/CreditCalculatorForm.js.map +1 -1
- package/mobile/lib/components/Calculator/DepositCalculatorForm.d.ts +2 -2
- package/mobile/lib/components/Calculator/DepositCalculatorForm.js +22 -12
- package/mobile/lib/components/Calculator/DepositCalculatorForm.js.map +1 -1
- package/mobile/lib/components/Calculator/constants.js +1 -1
- package/mobile/lib/components/Calculator/constants.js.map +1 -1
- package/mobile/lib/components/Calculator/rangeHelpers.d.ts +1 -0
- package/mobile/lib/components/Calculator/rangeHelpers.js +2 -0
- package/mobile/lib/components/Calculator/rangeHelpers.js.map +1 -1
- package/mobile/lib/components/Calculator/renderMonthsInput.d.ts +1 -0
- package/mobile/lib/components/Calculator/renderMonthsInput.js +3 -2
- package/mobile/lib/components/Calculator/renderMonthsInput.js.map +1 -1
- package/mobile/lib/components/Calculator/useCreditCalculatorParams.js +27 -29
- package/mobile/lib/components/Calculator/useCreditCalculatorParams.js.map +1 -1
- package/mobile/lib/components/Calculator/useDepositCalculatorParams.d.ts +3 -1
- package/mobile/lib/components/Calculator/useDepositCalculatorParams.js +22 -6
- package/mobile/lib/components/Calculator/useDepositCalculatorParams.js.map +1 -1
- package/mobile/lib/components/CarouselRecommendationCard/CarouselRecommendationCardContent.d.ts +2 -6
- package/mobile/lib/components/Footer/MediaButton.d.ts +3 -4
- package/mobile/lib/components/Footer/MediaButton.js.map +1 -1
- package/mobile/lib/content-page-repository/ContentPageRepository.d.ts +1 -5
- package/mobile/lib/content-page-repository/ContentPageRepository.js +8 -26
- package/mobile/lib/content-page-repository/ContentPageRepository.js.map +1 -1
- package/mobile/lib/content-page-repository/alignImg.d.ts +9 -0
- package/mobile/lib/content-page-repository/alignImg.js +17 -0
- package/mobile/lib/content-page-repository/alignImg.js.map +1 -0
- package/mobile/lib/content-page-repository/computeImgOutputPath.d.ts +3 -0
- package/mobile/lib/content-page-repository/computeImgOutputPath.js +12 -0
- package/mobile/lib/content-page-repository/computeImgOutputPath.js.map +1 -0
- package/mobile/lib/content-page-repository/resizeImg.d.ts +3 -0
- package/mobile/lib/content-page-repository/resizeImg.js +13 -0
- package/mobile/lib/content-page-repository/resizeImg.js.map +1 -0
- package/mobile/lib/content-page-repository/transformContentPage.d.ts +1 -0
- package/mobile/lib/content-page-repository/transformContentPage.js +23 -18
- package/mobile/lib/content-page-repository/transformContentPage.js.map +1 -1
- package/mobile/lib/content-page-repository/transformImg.d.ts +6 -5
- package/mobile/lib/content-page-repository/transformImg.js +26 -76
- package/mobile/lib/content-page-repository/transformImg.js.map +1 -1
- package/mobile/lib/content-page-repository/transformPicture.d.ts +1 -1
- package/mobile/lib/content-page-repository/transformPicture.js +8 -16
- package/mobile/lib/content-page-repository/transformPicture.js.map +1 -1
- package/mobile/lib/ui-kit/InputListRange/InputListRange.d.ts +2 -0
- package/mobile/lib/ui-kit/InputListRange/InputListRange.js +39 -0
- package/mobile/lib/ui-kit/InputListRange/InputListRange.js.map +1 -0
- package/mobile/lib/ui-kit/InputListRange/InputListRangeProps.d.ts +10 -0
- package/mobile/lib/ui-kit/InputListRange/InputListRangeProps.js +2 -0
- package/mobile/lib/ui-kit/InputListRange/InputListRangeProps.js.map +1 -0
- package/mobile/lib/ui-kit/Select/Select.js +2 -1
- package/mobile/lib/ui-kit/Select/Select.js.map +1 -1
- package/mobile/lib/utils/arrayByRange.d.ts +1 -0
- package/mobile/lib/utils/arrayByRange.js +2 -0
- package/mobile/lib/utils/arrayByRange.js.map +1 -0
- package/mobile/lib/utils/isPictureSizeEmpty.d.ts +2 -2
- package/mobile/lib/utils/isPictureSizeEmpty.js +1 -1
- package/mobile/lib/utils/isPictureSizeEmpty.js.map +1 -1
- package/mobile/lib/utils/mergeIntervals.d.ts +1 -0
- package/mobile/lib/utils/mergeIntervals.js +17 -0
- package/mobile/lib/utils/mergeIntervals.js.map +1 -0
- package/mobile/src/components/Calculator/Calculator.example.json +3 -1
- package/mobile/src/components/Calculator/CalculatorContent.ts +20 -19
- package/mobile/src/components/Calculator/CreditCalculatorForm.tsx +6 -7
- package/mobile/src/components/Calculator/DepositCalculatorForm.tsx +48 -15
- package/mobile/src/components/Calculator/constants.ts +1 -1
- package/mobile/src/components/Calculator/rangeHelpers.ts +10 -0
- package/mobile/src/components/Calculator/renderMonthsInput.tsx +13 -2
- package/mobile/src/components/Calculator/useCreditCalculatorParams.ts +8 -10
- package/mobile/src/components/Calculator/useDepositCalculatorParams.ts +36 -9
- package/mobile/src/components/CarouselRecommendationCard/CarouselRecommendationCard.example.json +1 -2
- package/mobile/src/components/CarouselRecommendationCard/CarouselRecommendationCardContent.ts +2 -8
- package/mobile/src/components/Footer/MediaButton.tsx +3 -5
- package/mobile/src/content-page-repository/ContentPageRepository.ts +8 -40
- package/mobile/src/content-page-repository/alignImg.ts +32 -0
- package/mobile/src/content-page-repository/computeImgOutputPath.ts +20 -0
- package/mobile/src/content-page-repository/resizeImg.ts +18 -0
- package/mobile/src/content-page-repository/transformContentPage.ts +25 -18
- package/mobile/src/content-page-repository/transformImg.ts +49 -121
- package/mobile/src/content-page-repository/transformPicture.ts +9 -21
- package/mobile/src/ui-kit/InputListRange/InputListRange.tsx +99 -0
- package/mobile/src/ui-kit/InputListRange/InputListRangeProps.ts +11 -0
- package/mobile/src/ui-kit/Select/Select.tsx +8 -1
- package/mobile/src/utils/arrayByRange.ts +4 -0
- package/mobile/src/utils/isPictureSizeEmpty.ts +3 -3
- package/mobile/src/utils/mergeIntervals.ts +19 -0
- package/package.json +1 -1
- package/src/components/Calculator/Calculator.example.json +3 -1
- package/src/components/Calculator/Calculator.fixture.tsx +4 -0
- package/src/components/Calculator/CalculatorContent.ts +20 -19
- package/src/components/Calculator/CreditCalculatorForm.tsx +6 -7
- package/src/components/Calculator/DepositCalculatorForm.tsx +48 -15
- package/src/components/Calculator/constants.ts +1 -1
- package/src/components/Calculator/rangeHelpers.ts +10 -0
- package/src/components/Calculator/renderMonthsInput.tsx +13 -2
- package/src/components/Calculator/useCreditCalculatorParams.ts +8 -10
- package/src/components/Calculator/useDepositCalculatorParams.ts +36 -9
- package/src/components/CarouselRecommendationCard/CarouselRecommendationCard.example.json +1 -2
- package/src/components/CarouselRecommendationCard/CarouselRecommendationCard.fixture.tsx +0 -9
- package/src/components/CarouselRecommendationCard/CarouselRecommendationCardContent.ts +2 -8
- package/src/components/Footer/MediaButton.tsx +3 -5
- package/src/content-page-repository/ContentPageRepository.ts +8 -40
- package/src/content-page-repository/alignImg.ts +32 -0
- package/src/content-page-repository/computeImgOutputPath.ts +20 -0
- package/src/content-page-repository/resizeImg.ts +18 -0
- package/src/content-page-repository/transformContentPage.ts +25 -18
- package/src/content-page-repository/transformImg.ts +49 -121
- package/src/content-page-repository/transformPicture.ts +9 -21
- package/src/ui-kit/InputListRange/InputListRange.tsx +99 -0
- package/src/ui-kit/InputListRange/InputListRangeProps.ts +11 -0
- package/src/ui-kit/Select/Select.tsx +8 -1
- package/src/utils/arrayByRange.ts +4 -0
- package/src/utils/isPictureSizeEmpty.ts +3 -3
- package/src/utils/mergeIntervals.ts +19 -0
- package/bundle/content-page-repository/transformImgPath.d.ts +0 -8
- package/dist/content-page-repository/transformImgPath.d.ts +0 -8
- package/dist/content-page-repository/transformImgPath.js +0 -22
- package/dist/content-page-repository/transformImgPath.js.map +0 -1
- package/lib/content-page-repository/transformImgPath.d.ts +0 -8
- package/lib/content-page-repository/transformImgPath.js +0 -16
- package/lib/content-page-repository/transformImgPath.js.map +0 -1
- package/mobile/bundle/content-page-repository/transformImgPath.d.ts +0 -8
- package/mobile/dist/content-page-repository/transformImgPath.d.ts +0 -8
- package/mobile/dist/content-page-repository/transformImgPath.js +0 -22
- package/mobile/dist/content-page-repository/transformImgPath.js.map +0 -1
- package/mobile/lib/content-page-repository/transformImgPath.d.ts +0 -8
- package/mobile/lib/content-page-repository/transformImgPath.js +0 -16
- package/mobile/lib/content-page-repository/transformImgPath.js.map +0 -1
- package/mobile/src/content-page-repository/transformImgPath.ts +0 -30
- package/src/content-page-repository/transformImgPath.ts +0 -30
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { InputListRange } from '../../ui-kit/InputListRange/InputListRange';
|
|
1
2
|
import { InputRange } from '../../ui-kit/InputRange/InputRange';
|
|
2
3
|
import { clamp } from '../../utils/clamp';
|
|
3
4
|
|
|
@@ -7,6 +8,7 @@ interface RenderMonthsInputParams {
|
|
|
7
8
|
minMonths: number;
|
|
8
9
|
maxMonths: number;
|
|
9
10
|
monthsValue: number;
|
|
11
|
+
availableMonths?: Array<number>;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
export function renderMonthsInput(
|
|
@@ -14,14 +16,23 @@ export function renderMonthsInput(
|
|
|
14
16
|
params: RenderMonthsInputParams,
|
|
15
17
|
callback?: (value: number) => void,
|
|
16
18
|
) {
|
|
17
|
-
const { minMonths, maxMonths, monthsValue } = params;
|
|
19
|
+
const { minMonths, maxMonths, monthsValue, availableMonths } = params;
|
|
18
20
|
const monthText = (month: number) => {
|
|
19
21
|
const text = Number(month) % 10 === 1 ? 'месяца' : 'месяцев';
|
|
20
22
|
|
|
21
23
|
return `${month} ${text}`;
|
|
22
24
|
};
|
|
23
25
|
|
|
24
|
-
return (
|
|
26
|
+
return availableMonths?.length ? (
|
|
27
|
+
<InputListRange
|
|
28
|
+
className="mt-7"
|
|
29
|
+
title={title}
|
|
30
|
+
items={[`От ${monthText(minMonths)}`, `До ${monthText(maxMonths)}`]}
|
|
31
|
+
list={availableMonths}
|
|
32
|
+
value={clamp(monthsValue, minMonths, maxMonths)}
|
|
33
|
+
onChange={callback}
|
|
34
|
+
/>
|
|
35
|
+
) : (
|
|
25
36
|
<InputRange
|
|
26
37
|
className="mt-7"
|
|
27
38
|
title={title}
|
|
@@ -41,14 +41,13 @@ export const useCreditCalculatorParams = (
|
|
|
41
41
|
): CreditCalculatorParams => {
|
|
42
42
|
const { moneyValue, monthsValue } = userInputParams;
|
|
43
43
|
const data = useCalculatorParams<CreditCalculatorData>(sourceBookDir || CREDIT_CALC_DEFAULT_DIR);
|
|
44
|
+
const isExcludeSalaryClient = !paramsViewSettings?.isShowSalaryClient;
|
|
45
|
+
const isExcludeStateEmployee = !paramsViewSettings?.isShowStateEmployee;
|
|
46
|
+
const isExcludePensionClient = !paramsViewSettings?.isShowPensionClient;
|
|
47
|
+
const isExcludeInsurance = !paramsViewSettings?.isShowInsurance;
|
|
44
48
|
const creditCalculatorSourceBookParams =
|
|
45
|
-
data?.rows?.find(
|
|
46
|
-
|
|
47
|
-
const isExcludeStateEmployee = !paramsViewSettings?.isShowStateEmployee;
|
|
48
|
-
const isExcludePensionClient = !paramsViewSettings?.isShowPensionClient;
|
|
49
|
-
const isExcludeInsurance = !paramsViewSettings?.isShowInsurance;
|
|
50
|
-
|
|
51
|
-
return (
|
|
49
|
+
data?.rows?.find(
|
|
50
|
+
(row) =>
|
|
52
51
|
checkRowByParam({
|
|
53
52
|
row,
|
|
54
53
|
userInputParams,
|
|
@@ -74,9 +73,8 @@ export const useCreditCalculatorParams = (
|
|
|
74
73
|
isExclude: isExcludeInsurance,
|
|
75
74
|
}) &&
|
|
76
75
|
checkRangeByKeys(moneyValue, ['minSum', 'maxSum'], row) &&
|
|
77
|
-
checkRangeByKeys(monthsValue, ['minMonths', 'maxMonths'], row)
|
|
78
|
-
|
|
79
|
-
}) || DEFAULT_CREDIT_CALCULATOR_PARAMS;
|
|
76
|
+
checkRangeByKeys(monthsValue, ['minMonths', 'maxMonths'], row),
|
|
77
|
+
) || DEFAULT_CREDIT_CALCULATOR_PARAMS;
|
|
80
78
|
|
|
81
79
|
const { rate } = creditCalculatorSourceBookParams;
|
|
82
80
|
const monthlyPayment = getMonthlyPayment(rate, userInputParams);
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { arrayByRange } from '../../utils/arrayByRange';
|
|
2
|
+
import { mergeIntervals } from '../../utils/mergeIntervals';
|
|
3
|
+
import { DepositCalculatorParamsViewSettings } from './CalculatorContent';
|
|
1
4
|
import { DEFAULT_DEPOSIT_CALCULATOR_PARAMS, DEPOSIT_CALC_DEFAULT_DIR } from './constants';
|
|
2
5
|
import { checkRangeByKeys, getRangeByKeys } from './rangeHelpers';
|
|
3
6
|
import { useCalculatorParams } from './useCalculatorParams';
|
|
@@ -23,6 +26,7 @@ export interface DepositCalculatorUserInputParams extends CommonDepositParams {
|
|
|
23
26
|
export interface DepositCalculatorParams
|
|
24
27
|
extends DepositCalculatorSourceBookParams,
|
|
25
28
|
DepositCalculatorUserInputParams {
|
|
29
|
+
availableMonths: number[];
|
|
26
30
|
income: number;
|
|
27
31
|
finalSum: number;
|
|
28
32
|
}
|
|
@@ -34,21 +38,31 @@ export type DepositCalculatorData = {
|
|
|
34
38
|
export const useDepositCalculatorParams = (
|
|
35
39
|
userInputParams: DepositCalculatorUserInputParams,
|
|
36
40
|
sourceBookDir?: string,
|
|
41
|
+
paramsViewSettings?: DepositCalculatorParamsViewSettings,
|
|
37
42
|
): DepositCalculatorParams => {
|
|
38
|
-
const {
|
|
39
|
-
userInputParams;
|
|
40
|
-
|
|
43
|
+
const { moneyValue, monthsValue } = userInputParams;
|
|
41
44
|
const data = useCalculatorParams<DepositCalculatorData>(
|
|
42
45
|
sourceBookDir || DEPOSIT_CALC_DEFAULT_DIR,
|
|
43
46
|
);
|
|
44
|
-
|
|
47
|
+
const isExcludeMonthlyInterestPayment = !paramsViewSettings?.isShowMonthlyInterestPayment;
|
|
48
|
+
const isExcludeRemoteRegistration = !paramsViewSettings?.isShowRemoteRegistration;
|
|
45
49
|
const depositCalculatorSourceBookParams =
|
|
46
50
|
data?.rows?.find(
|
|
47
|
-
(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
(row) =>
|
|
52
|
+
checkRowByParam({
|
|
53
|
+
row,
|
|
54
|
+
userInputParams,
|
|
55
|
+
paramKey: 'isMonthlyInterestPayment',
|
|
56
|
+
isExclude: isExcludeMonthlyInterestPayment,
|
|
57
|
+
}) &&
|
|
58
|
+
checkRowByParam({
|
|
59
|
+
row,
|
|
60
|
+
userInputParams,
|
|
61
|
+
paramKey: 'isRemoteRegistration',
|
|
62
|
+
isExclude: isExcludeRemoteRegistration,
|
|
63
|
+
}) &&
|
|
64
|
+
checkRangeByKeys(moneyValue, ['minSum', 'maxSum'], row) &&
|
|
65
|
+
checkRangeByKeys(monthsValue, ['minMonths', 'maxMonths'], row),
|
|
52
66
|
) || DEFAULT_DEPOSIT_CALCULATOR_PARAMS;
|
|
53
67
|
|
|
54
68
|
const { rate } = depositCalculatorSourceBookParams;
|
|
@@ -60,6 +74,9 @@ export const useDepositCalculatorParams = (
|
|
|
60
74
|
...depositCalculatorSourceBookParams,
|
|
61
75
|
...getRangeByKeys(['minSum', 'maxSum'], sourceBookRows),
|
|
62
76
|
...getRangeByKeys(['minMonths', 'maxMonths'], sourceBookRows),
|
|
77
|
+
availableMonths: mergeIntervals(
|
|
78
|
+
sourceBookRows.map((row) => [row['minMonths'], row['maxMonths']]),
|
|
79
|
+
).flatMap(([start, end]) => arrayByRange(start, end)),
|
|
63
80
|
...userInputParams,
|
|
64
81
|
income,
|
|
65
82
|
finalSum,
|
|
@@ -78,3 +95,13 @@ const getDepositIncome = (rate: number, userInputParams: DepositCalculatorUserIn
|
|
|
78
95
|
return Math.round((moneyValue * rate * 30 * monthsValue) / 365 / 100);
|
|
79
96
|
}
|
|
80
97
|
};
|
|
98
|
+
|
|
99
|
+
interface CheckRowByParamProps {
|
|
100
|
+
row: DepositCalculatorSourceBookParams;
|
|
101
|
+
userInputParams: DepositCalculatorUserInputParams;
|
|
102
|
+
paramKey: string;
|
|
103
|
+
isExclude: boolean;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const checkRowByParam = ({ row, userInputParams, paramKey, isExclude }: CheckRowByParamProps) =>
|
|
107
|
+
isExclude || userInputParams[paramKey] === row[paramKey];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Picture } from '../../model/Picture';
|
|
2
2
|
import '../../setup-fixture';
|
|
3
|
-
import { Icon } from '../../ui-kit/Icon/Icon';
|
|
4
3
|
import { CarouselRecommendationCard } from './CarouselRecommendationCard';
|
|
5
4
|
import type {
|
|
6
5
|
CarouselRecommendationCardContent,
|
|
@@ -17,8 +16,6 @@ const icon: Picture = {
|
|
|
17
16
|
title: 'product-basket',
|
|
18
17
|
};
|
|
19
18
|
|
|
20
|
-
const appendLeft = <Icon name="PlayMarketIcon" iconVersion="color" width="24" height="24" asSVG />;
|
|
21
|
-
|
|
22
19
|
const commonProps: RecommendationSocialMedia = {
|
|
23
20
|
target: '_blank',
|
|
24
21
|
version: 'gray',
|
|
@@ -28,23 +25,17 @@ const commonProps: RecommendationSocialMedia = {
|
|
|
28
25
|
const socialMediaWithText: RecommendationSocialMedia[] = [
|
|
29
26
|
{
|
|
30
27
|
href: 'https://t.me',
|
|
31
|
-
aboveText: 'Доступно в',
|
|
32
28
|
text: 'Telegram',
|
|
33
|
-
appendLeft,
|
|
34
29
|
...commonProps,
|
|
35
30
|
},
|
|
36
31
|
{
|
|
37
32
|
href: 'https://vk.com',
|
|
38
|
-
aboveText: 'Доступно в',
|
|
39
33
|
text: 'Telegram',
|
|
40
|
-
appendLeft,
|
|
41
34
|
...commonProps,
|
|
42
35
|
},
|
|
43
36
|
{
|
|
44
37
|
href: 'https://ok.ru',
|
|
45
|
-
aboveText: 'Доступно в',
|
|
46
38
|
text: 'Telegram',
|
|
47
|
-
appendLeft,
|
|
48
39
|
...commonProps,
|
|
49
40
|
},
|
|
50
41
|
];
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import type { ButtonVersion } from '../../model/ButtonVersion';
|
|
2
1
|
import type { HeadlineCommonProps } from '../../model/HeadlineType';
|
|
3
2
|
import type { UniBlockContent } from '../../model/JSXBlock';
|
|
4
3
|
import type { LinkCommonProps } from '../../model/LinkProps';
|
|
5
4
|
import type { IconProps } from '../../model/Picture';
|
|
6
|
-
import type {
|
|
5
|
+
import type { ButtonProps } from '../../ui-kit/Button/ButtonProps';
|
|
7
6
|
import type { ListContent } from '../../ui-kit/List/ListContent';
|
|
8
7
|
import type { TextAlign } from '../../ui-kit/Text/TextProps';
|
|
9
8
|
|
|
10
|
-
export type RecommendationSocialMedia = LinkCommonProps &
|
|
11
|
-
IconProps &
|
|
12
|
-
ButtonWithIconProps & {
|
|
13
|
-
version: ButtonVersion;
|
|
14
|
-
rounded?: boolean;
|
|
15
|
-
};
|
|
9
|
+
export type RecommendationSocialMedia = LinkCommonProps & IconProps & ButtonProps;
|
|
16
10
|
|
|
17
11
|
/**
|
|
18
12
|
* @title Карточка рекомендаций
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
-
import type {
|
|
3
|
-
import type { Picture } from '../../model/Picture';
|
|
2
|
+
import type { IconProps, Picture } from '../../model/Picture';
|
|
4
3
|
import { Button } from '../../ui-kit/Button/Button';
|
|
5
|
-
import type {
|
|
4
|
+
import type { ButtonProps } from '../../ui-kit/Button/ButtonProps';
|
|
6
5
|
import { Img } from '../../ui-kit/Img/Img';
|
|
7
6
|
import { getIconWithVersion } from '../../utils/getIconWithVersion';
|
|
8
7
|
import { style } from '../../utils/style';
|
|
@@ -46,8 +45,7 @@ const ICONS_MAP: Array<{
|
|
|
46
45
|
|
|
47
46
|
export type ButtonSize = 'default' | 'small';
|
|
48
47
|
|
|
49
|
-
interface MediaButtonProps extends
|
|
50
|
-
iconVersion?: IconVersion;
|
|
48
|
+
interface MediaButtonProps extends ButtonProps, IconProps {
|
|
51
49
|
buttonSize?: ButtonSize;
|
|
52
50
|
}
|
|
53
51
|
|
|
@@ -1,26 +1,16 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
1
2
|
import glob from 'glob';
|
|
2
3
|
import util from 'util';
|
|
3
4
|
import type { ContentPageDef } from '../model/ContentPageDef';
|
|
4
5
|
import type { TransformationOptions } from './TransformationOptions';
|
|
5
|
-
import { transformContentPage } from './transformContentPage';
|
|
6
|
+
import { generatedPagePath, transformContentPage } from './transformContentPage';
|
|
6
7
|
|
|
7
|
-
const INDEX_PAGE_SLUG = 'index';
|
|
8
8
|
const find = util.promisify(glob);
|
|
9
|
-
|
|
10
|
-
const bySlug = (slug: string) => (content: ContentPageDef) => content.slug === slug;
|
|
11
|
-
const byCustomPageType = (type?: string) => (content: ContentPageDef) =>
|
|
12
|
-
type ? content._customPageType === type : !content._customPageType;
|
|
13
|
-
|
|
14
|
-
const not =
|
|
15
|
-
<Arg>(predicate: (_: Arg) => boolean) =>
|
|
16
|
-
(_: Arg) =>
|
|
17
|
-
!predicate(_);
|
|
9
|
+
const readFile = util.promisify(fs.readFile);
|
|
18
10
|
|
|
19
11
|
export class ContentPageRepository {
|
|
20
12
|
public static readonly inst = new ContentPageRepository();
|
|
21
13
|
|
|
22
|
-
private cache: Record<string, ContentPageDef> = {};
|
|
23
|
-
|
|
24
14
|
constructor(
|
|
25
15
|
private readonly options: TransformationOptions = {
|
|
26
16
|
contentDir: 'content',
|
|
@@ -28,37 +18,15 @@ export class ContentPageRepository {
|
|
|
28
18
|
},
|
|
29
19
|
) {}
|
|
30
20
|
|
|
31
|
-
|
|
21
|
+
listAllContentPages(): Promise<string[]> {
|
|
32
22
|
return find(`${this.options.contentDir}/**/*.page.json`);
|
|
33
23
|
}
|
|
34
24
|
|
|
35
|
-
async getAllContentPages(): Promise<ContentPageDef[]> {
|
|
36
|
-
const pagePaths = await this.listAllContentPages();
|
|
37
|
-
|
|
38
|
-
return Promise.all(pagePaths.map((_) => this.readPage(_)));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async getSecondaryContentPages(customPageType?: string): Promise<ContentPageDef[]> {
|
|
42
|
-
const pages = await this.getAllContentPages();
|
|
43
|
-
|
|
44
|
-
return pages.filter(not(bySlug(INDEX_PAGE_SLUG))).filter(byCustomPageType(customPageType));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async getContentPageBySlug(slug: string): Promise<ContentPageDef | undefined> {
|
|
48
|
-
const pages = await this.getAllContentPages();
|
|
49
|
-
|
|
50
|
-
return pages.find(bySlug(slug));
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async getIndexPage(): Promise<ContentPageDef | undefined> {
|
|
54
|
-
return this.getContentPageBySlug(INDEX_PAGE_SLUG);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
25
|
async readPage(filePath: string): Promise<ContentPageDef> {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
26
|
+
return JSON.parse(await readFile(generatedPagePath(filePath), 'utf-8'));
|
|
27
|
+
}
|
|
61
28
|
|
|
62
|
-
|
|
29
|
+
generatePage(filePath: string): Promise<ContentPageDef> {
|
|
30
|
+
return transformContentPage(filePath, this.options);
|
|
63
31
|
}
|
|
64
32
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Sharp } from 'sharp';
|
|
2
|
+
import sharp from 'sharp';
|
|
3
|
+
import type { ImageSize } from '../model/ImageSize';
|
|
4
|
+
import type { ImgAlignment } from '../model/Picture';
|
|
5
|
+
|
|
6
|
+
interface ImgAlignmentParams {
|
|
7
|
+
containerSize?: Partial<ImageSize>;
|
|
8
|
+
alignment?: ImgAlignment;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const alignImg =
|
|
12
|
+
({ containerSize, alignment }: ImgAlignmentParams) =>
|
|
13
|
+
async (chain: Sharp): Promise<Sharp> =>
|
|
14
|
+
containerSize?.width && containerSize?.height && alignment
|
|
15
|
+
? createTransparentBack(containerSize as ImageSize).composite([
|
|
16
|
+
{
|
|
17
|
+
input: await toBuffer(chain),
|
|
18
|
+
gravity: alignment,
|
|
19
|
+
},
|
|
20
|
+
])
|
|
21
|
+
: chain;
|
|
22
|
+
|
|
23
|
+
const toBuffer = async (chain: Sharp) => (await chain.toBuffer({ resolveWithObject: true })).data;
|
|
24
|
+
|
|
25
|
+
function createTransparentBack({ width, height }: ImageSize) {
|
|
26
|
+
const channels = 4;
|
|
27
|
+
const rgbaColor = 0x00000000;
|
|
28
|
+
|
|
29
|
+
const canvas = Buffer.alloc(width * height * channels, rgbaColor);
|
|
30
|
+
|
|
31
|
+
return sharp(canvas, { raw: { width, height, channels } });
|
|
32
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import type { ImgSource } from '../model/Picture';
|
|
3
|
+
import type { TransformationOptions } from './TransformationOptions';
|
|
4
|
+
|
|
5
|
+
export function computeImgOutputPath(
|
|
6
|
+
imgInputPath: string,
|
|
7
|
+
{ contentDir, publicDir, format, size, alignment }: TransformationOptions & ImgSource,
|
|
8
|
+
): string {
|
|
9
|
+
const imgRelativePath = path.relative(contentDir, imgInputPath);
|
|
10
|
+
|
|
11
|
+
const imgDir = path.dirname(imgRelativePath);
|
|
12
|
+
|
|
13
|
+
const inputExt = path.extname(imgRelativePath);
|
|
14
|
+
const fileName = path.basename(imgRelativePath, inputExt);
|
|
15
|
+
const suffixParts = [size?.width, size?.height, alignment].filter(Boolean);
|
|
16
|
+
const suffix = suffixParts.length ? `-${suffixParts.join('-')}` : '';
|
|
17
|
+
const ext = format ? `.${format}` : inputExt;
|
|
18
|
+
|
|
19
|
+
return path.join(publicDir, imgDir, `${fileName}${suffix}${ext}`);
|
|
20
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ResizeOptions, Sharp } from 'sharp';
|
|
2
|
+
import sharp from 'sharp';
|
|
3
|
+
import type { ImageSize } from '../model/ImageSize';
|
|
4
|
+
|
|
5
|
+
export const resizeImg =
|
|
6
|
+
(size?: Partial<ImageSize>, options?: ResizeOptions) =>
|
|
7
|
+
(chain: Sharp): Sharp =>
|
|
8
|
+
size
|
|
9
|
+
? chain.resize(size.width || null, size.height || null, {
|
|
10
|
+
/*
|
|
11
|
+
* Editor behaviour with one dimension present: resize by given dimension maintaining aspect ratio. (fit: contain)
|
|
12
|
+
* With two dimensions present: resize trying to fill given dimensions (fit: fill)
|
|
13
|
+
*/
|
|
14
|
+
fit: size.width && size.height ? sharp.fit.fill : sharp.fit.contain,
|
|
15
|
+
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
|
16
|
+
...options,
|
|
17
|
+
})
|
|
18
|
+
: chain;
|
|
@@ -9,6 +9,9 @@ import { transformMarkdown } from './transformMarkdown';
|
|
|
9
9
|
import { transformPicture } from './transformPicture';
|
|
10
10
|
|
|
11
11
|
const readFile = util.promisify(fs.readFile);
|
|
12
|
+
const writeFile = util.promisify(fs.writeFile);
|
|
13
|
+
|
|
14
|
+
const OUTPUT_SUFFIX = '.static';
|
|
12
15
|
|
|
13
16
|
export async function transformContentPage(
|
|
14
17
|
pagePath: string,
|
|
@@ -17,31 +20,35 @@ export async function transformContentPage(
|
|
|
17
20
|
const content = await readFile(pagePath, 'utf8');
|
|
18
21
|
|
|
19
22
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
20
|
-
|
|
21
|
-
const isMarkdown =
|
|
22
|
-
const isHTML =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return await transformPicture(
|
|
31
|
-
} catch (ex) {
|
|
32
|
-
console.warn('Error while transforming picture on page: %s', pagePath);
|
|
33
|
-
console.error(ex);
|
|
23
|
+
const result = await mapJSON<ContentPageDef>(JSON.parse(content), async (value: any, [key]) => {
|
|
24
|
+
const isMarkdown = isString(value) && key?.endsWith('__md');
|
|
25
|
+
const isHTML = isString(value) && key?.endsWith('__html');
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
if (isMarkdown) {
|
|
29
|
+
return await transformMarkdown(value);
|
|
30
|
+
} else if (isHTML) {
|
|
31
|
+
return await transformHTML(value);
|
|
32
|
+
} else if (isPicture(value)) {
|
|
33
|
+
return await transformPicture(value, pagePath, options);
|
|
34
34
|
}
|
|
35
|
+
} catch (ex) {
|
|
36
|
+
console.warn(`Error while transforming field "${key}" on page: ${pagePath}`);
|
|
37
|
+
console.error(ex);
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
return value;
|
|
38
41
|
});
|
|
39
|
-
}
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
await writeFile(generatedPagePath(pagePath), JSON.stringify(result), 'utf-8');
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
44
47
|
|
|
45
|
-
const
|
|
48
|
+
export const generatedPagePath = (pagePath: string) => `${pagePath}${OUTPUT_SUFFIX}`;
|
|
46
49
|
|
|
47
50
|
const isPicture = (_: any): _ is Picture => Boolean(_ && isLocalPath(_?.src));
|
|
51
|
+
const isLocalPath = (_: any): boolean => isString(_) && _.length < 1024 && !isURL(_);
|
|
52
|
+
const isURL = (src: string) => ['data:', 'https:', 'http:'].some((proto) => src.startsWith(proto));
|
|
53
|
+
|
|
54
|
+
const isString = (_: any): _ is string => Boolean(_ && typeof _ === 'string');
|
|
@@ -1,146 +1,74 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import
|
|
4
|
-
import sharp from 'sharp';
|
|
3
|
+
import sharp, { type Sharp } from 'sharp';
|
|
5
4
|
import util from 'util';
|
|
6
5
|
import type { ImageSize } from '../model/ImageSize';
|
|
7
|
-
import type {
|
|
6
|
+
import type { ImgSource } from '../model/Picture';
|
|
8
7
|
import { isPictureSizeEmpty } from '../utils/isPictureSizeEmpty';
|
|
8
|
+
import { alignImg } from './alignImg';
|
|
9
|
+
import { computeImgOutputPath } from './computeImgOutputPath';
|
|
10
|
+
import { resizeImg } from './resizeImg';
|
|
9
11
|
import type { TransformationOptions } from './TransformationOptions';
|
|
10
|
-
import { transformImgPath } from './transformImgPath';
|
|
11
12
|
|
|
12
13
|
const mkdir = util.promisify(fs.mkdir);
|
|
13
14
|
|
|
14
|
-
type
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
containerSize?: ImageSize;
|
|
18
|
-
transformationOptions: TransformationOptions & ImgSource;
|
|
19
|
-
};
|
|
15
|
+
type ImgOutputPath = string;
|
|
16
|
+
type TransformationTaskKey = ImgOutputPath;
|
|
17
|
+
type TransformationTasksCache = Map<TransformationTaskKey, Promise<ImgOutputPath>>;
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
src,
|
|
24
|
-
containerSize,
|
|
25
|
-
transformationOptions,
|
|
26
|
-
}: TransformImgParams): Promise<string> {
|
|
27
|
-
if (!src) {
|
|
28
|
-
return '';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const { contentDir, publicDir, format, options, size, alignment } = transformationOptions;
|
|
32
|
-
|
|
33
|
-
const pageDir = path.dirname(pagePath);
|
|
34
|
-
const imgPath = `${pageDir}/${src}`;
|
|
35
|
-
let chain = sharp(imgPath);
|
|
36
|
-
|
|
37
|
-
const targetSize = getPictureSize(size, containerSize);
|
|
38
|
-
|
|
39
|
-
if (targetSize) {
|
|
40
|
-
chain = resizeImg(chain, targetSize, getResizeFit(targetSize));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (containerSize) {
|
|
44
|
-
chain = resizeImg(chain, containerSize);
|
|
45
|
-
|
|
46
|
-
// Save intermediate transform result to modify further
|
|
47
|
-
const { data } = await chain.toBuffer({ resolveWithObject: true });
|
|
48
|
-
|
|
49
|
-
chain = resizeImg(
|
|
50
|
-
sharp(data),
|
|
51
|
-
getCompositionResizeSize(containerSize, targetSize),
|
|
52
|
-
getResizeFit(targetSize),
|
|
53
|
-
);
|
|
19
|
+
type TransformImgOptions = TransformationOptions &
|
|
20
|
+
ImgSource & { containerSize?: ImageSize; cache?: TransformationTasksCache };
|
|
54
21
|
|
|
55
|
-
|
|
56
|
-
}
|
|
22
|
+
const defaultTransformationCache: TransformationTasksCache = new Map();
|
|
57
23
|
|
|
58
|
-
|
|
59
|
-
|
|
24
|
+
export function transformImg(
|
|
25
|
+
src: string,
|
|
26
|
+
pagePath: string,
|
|
27
|
+
options: TransformImgOptions,
|
|
28
|
+
): ImgOutputPath | Promise<ImgOutputPath> {
|
|
29
|
+
if (!src) {
|
|
30
|
+
return '';
|
|
60
31
|
}
|
|
61
32
|
|
|
62
|
-
const
|
|
63
|
-
const
|
|
33
|
+
const input = path.join(path.dirname(pagePath), src);
|
|
34
|
+
const output = computeImgOutputPath(input, options);
|
|
64
35
|
|
|
65
|
-
|
|
36
|
+
const { cache = defaultTransformationCache } = options;
|
|
66
37
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
console.error(e);
|
|
38
|
+
const cachedResult = cache.get(output);
|
|
39
|
+
if (cachedResult) {
|
|
40
|
+
return cachedResult;
|
|
71
41
|
}
|
|
72
42
|
|
|
73
|
-
|
|
74
|
-
|
|
43
|
+
const result = (async () => {
|
|
44
|
+
try {
|
|
45
|
+
await mkdir(path.dirname(output), { recursive: true });
|
|
75
46
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
47
|
+
const chain = await computeTransformationChain(options)(sharp(input));
|
|
48
|
+
await chain.toFile(output);
|
|
49
|
+
} catch (e) {
|
|
50
|
+
console.error(e);
|
|
51
|
+
}
|
|
79
52
|
|
|
80
|
-
|
|
53
|
+
return output;
|
|
54
|
+
})();
|
|
55
|
+
cache.set(output, result);
|
|
81
56
|
|
|
82
|
-
return
|
|
57
|
+
return result;
|
|
83
58
|
}
|
|
84
59
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
fit: sharp.fit.fill,
|
|
88
|
-
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
|
89
|
-
...options,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
type CompositeImgParams = {
|
|
94
|
-
chain: Sharp;
|
|
95
|
-
containerSize: ImageSize;
|
|
96
|
-
alignment?: ImgAlignment;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
async function compositeImg({
|
|
100
|
-
chain,
|
|
60
|
+
const computeTransformationChain = ({
|
|
61
|
+
size,
|
|
101
62
|
containerSize,
|
|
102
63
|
alignment,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
function getPictureSize(size: Picture['size'], containerSize?: ImageSize) {
|
|
115
|
-
// If containerSize is undefined intrinsic dimensions of image will be used then.
|
|
116
|
-
return isPictureSizeEmpty(size) ? containerSize : size;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function getCompositionResizeSize(
|
|
120
|
-
containerSize: ImageSize,
|
|
121
|
-
size: Picture['size'] = {},
|
|
122
|
-
): Picture['size'] {
|
|
123
|
-
const { width, height } = size;
|
|
124
|
-
const { width: containerWidth, height: containerHeight } = containerSize;
|
|
125
|
-
|
|
126
|
-
if (!(width || height)) {
|
|
127
|
-
return undefined;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const widthRatio = width ? containerWidth / width : 0;
|
|
131
|
-
const heightRatio = height ? containerHeight / height : 0;
|
|
132
|
-
|
|
133
|
-
return widthRatio > heightRatio
|
|
134
|
-
? { width: Math.min(Number(width), containerWidth) }
|
|
135
|
-
: { height: Math.min(Number(height), containerHeight) };
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function getResizeFit(size: Picture['size']): ResizeOptions {
|
|
139
|
-
/*
|
|
140
|
-
Editor behaviour with one dimension present: resize by given dimension maintaining aspect ratio. (fit: contain)
|
|
141
|
-
With two dimensions present: resize trying to fill given dimensions (fit: fill)
|
|
142
|
-
*/
|
|
143
|
-
return {
|
|
144
|
-
fit: size?.width && size?.height ? sharp.fit.fill : sharp.fit.contain,
|
|
145
|
-
};
|
|
146
|
-
}
|
|
64
|
+
format,
|
|
65
|
+
options,
|
|
66
|
+
}: TransformImgOptions) =>
|
|
67
|
+
pipe(
|
|
68
|
+
resizeImg(isPictureSizeEmpty(size) ? containerSize : size),
|
|
69
|
+
alignImg({ containerSize, alignment }),
|
|
70
|
+
(_) => (format ? _.toFormat(format, options) : _),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const pipe = (...operations: Array<(chain: Sharp) => Promise<Sharp> | Sharp>) =>
|
|
74
|
+
operations.reduce((a, b) => async (chain: Sharp) => b(await a(chain)));
|