pcm-shared-components 2.0.41 → 2.0.42

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 (33) hide show
  1. package/README.md +3 -0
  2. package/dist/components/Buttons/DropdownButton/index.js +1 -1
  3. package/dist/components/Buttons/TillButton/index.js +1 -1
  4. package/dist/components/Cards/EventCard/components/OpenEventCardDialog.js +97 -0
  5. package/dist/components/Cards/EventCard/components/OpenEventViewAllImageDialog.js +54 -0
  6. package/dist/components/Cards/EventCard/index.js +101 -0
  7. package/dist/components/Date/{DateRangeCalendar → DatePickerReactStyled/DateCalendar}/css/style.css +5 -0
  8. package/dist/components/Date/DatePickerReactStyled/DateCalendar/index.js +174 -0
  9. package/dist/components/Date/DatePickerReactStyled/DateCalendar/storybook/index.docs.mdx +122 -0
  10. package/dist/components/Date/DatePickerReactStyled/DateCalendar/storybook/index.stories.js +74 -0
  11. package/dist/components/Date/DatePickerReactStyled/DateRangeCalendar/css/style.css +119 -0
  12. package/dist/components/Date/{DateRangeCalendar → DatePickerReactStyled/DateRangeCalendar}/index.js +4 -21
  13. package/dist/components/Date/DatePickerReactStyled/DateRangeCalendar/storybook/index.docs.mdx +122 -0
  14. package/dist/components/Date/DatePickerReactStyled/DateRangeCalendar/storybook/index.stories.js +74 -0
  15. package/dist/components/Date/DatePickerReactStyled/common/theme.js +49 -0
  16. package/dist/components/Date/FancyDate/index.js +28 -0
  17. package/dist/components/Date/PricingCalendar/css/style.css +210 -0
  18. package/dist/components/Date/PricingCalendar/index.js +124 -0
  19. package/dist/components/Dialogs/GenericAppBar/components/GenericAppBarSubMenu.js +0 -1
  20. package/dist/components/Drawing/ImageCanvasDraw/components/Controls.js +0 -1
  21. package/dist/components/Icons/ImageAssets/index.js +61 -0
  22. package/dist/components/Images/HorizontalImageTile/index.js +110 -0
  23. package/dist/components/Images/VerticalImageTile/index.js +55 -0
  24. package/dist/components/Layout/SimpleTab/index.js +1 -3
  25. package/dist/components/Menus/ReusablePopupMenu/index.js +1 -1
  26. package/dist/components/Platform/PlatformPaymentPlans/index.js +1 -1
  27. package/dist/index.js +9 -2
  28. package/dist/languages/en/translations.json +375 -20
  29. package/dist/languages/es/translations.json +374 -19
  30. package/dist/languages/fr/translations.json +375 -20
  31. package/dist/locals/i18n.js +0 -1
  32. package/dist/styles/tailwind.css +1 -1
  33. package/package.json +9 -8
@@ -0,0 +1,124 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { DayPicker } from 'react-day-picker';
4
+ import 'react-day-picker/dist/style.css';
5
+ import './css/style.css';
6
+ import moment from 'moment';
7
+ /**
8
+ *
9
+ * ## Importing the component in your project
10
+ *
11
+ ```js
12
+ import {PricingCalendar} from 'pcm-shared-components';
13
+ ```
14
+ *
15
+ */
16
+ export const PricingCalendar = props => {
17
+ const {
18
+ i18next,
19
+ startDate,
20
+ endDate,
21
+ rateObject,
22
+ RenderDay,
23
+ setCurrentMonth
24
+ } = props;
25
+ const [month, setMonth] = useState(moment().toDate());
26
+ useEffect(() => {
27
+ setMonth(moment(startDate).toDate());
28
+ }, [startDate]);
29
+ useEffect(() => {
30
+ if (setCurrentMonth) {
31
+ setMonth(moment(setCurrentMonth).toDate());
32
+ }
33
+ }, [setCurrentMonth]);
34
+ const DefaultRenderDayComponent = ({
35
+ date,
36
+ foundRate
37
+ }) => {
38
+ let dayStyle;
39
+ if (date.getDay() === 6 || date.getDay() === 0) {
40
+ //Make saturday and sunday a different color
41
+ dayStyle = 'bg-grey-100 hover:bg-indigo-100/25';
42
+ } else {
43
+ dayStyle = 'transparent hover:bg-indigo-100/25';
44
+ }
45
+ return /*#__PURE__*/React.createElement("div", {
46
+ className: `flex flex-col justify-start h-full w-full ${dayStyle}`
47
+ }, /*#__PURE__*/React.createElement("div", {
48
+ className: `flex flex-row m-4 justify-between h-auto w-auto text-left font-800 text-14`
49
+ }, /*#__PURE__*/React.createElement("div", null, date.getDate())), foundRate && /*#__PURE__*/React.createElement("div", {
50
+ className: "w-full text-center my-auto text-1xl font-bold"
51
+ }, Intl.NumberFormat('en-US', {
52
+ style: 'currency',
53
+ currency: 'USD',
54
+ minimumFractionDigits: 0
55
+ }).format(foundRate.rate)));
56
+ };
57
+ function findObjectByDate(objectArray, dateString) {
58
+ // Generated by AI and is much faster then using the .find method.
59
+ // Create a lookup table with date strings as keys
60
+ const lookupTable = {};
61
+ for (const obj of objectArray) {
62
+ const dateStr = obj.date;
63
+ if (!lookupTable[dateStr]) {
64
+ lookupTable[dateStr] = obj;
65
+ }
66
+ }
67
+ // Look up the object by date string
68
+ return lookupTable[dateString] || null;
69
+ }
70
+ const handleDayRender = ({
71
+ date
72
+ }, ...props) => {
73
+ // const foundRate = rateObject.find((item)=> moment(date).isSame(item.date, "day") );
74
+ const foundRate = findObjectByDate(rateObject, moment(date).format('YYYY-MM-DD'));
75
+ if (foundRate && RenderDay) {
76
+ return /*#__PURE__*/React.createElement(RenderDay, {
77
+ date: date,
78
+ foundRate: foundRate
79
+ });
80
+ } else {
81
+ return /*#__PURE__*/React.createElement(DefaultRenderDayComponent, {
82
+ date: date,
83
+ foundRate: foundRate ? foundRate : undefined
84
+ });
85
+ }
86
+ };
87
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(DayPicker, {
88
+ components: {
89
+ Day: handleDayRender
90
+ },
91
+ defaultMonth: moment(startDate).toDate(),
92
+ month: month,
93
+ onMonthChange: setMonth,
94
+ fromDate: moment(startDate).toDate(),
95
+ toDate: moment(endDate).toDate()
96
+
97
+ // captionLayout="dropdown-buttons" fromYear={moment().add(-5,'years').year()} toYear={moment().add(5, 'years').year()}
98
+ // selectedDays={[moment(startDate), { from: moment(startDate).toDate(), to: new moment(endDate).toDate() }]}
99
+ }));
100
+ };
101
+ export default PricingCalendar;
102
+ PricingCalendar.defaultProps = {
103
+ i18next: undefined,
104
+ RenderDay: undefined,
105
+ rateObject: [],
106
+ startDate: moment(),
107
+ endDate: moment().add(1, 'days'),
108
+ i18next: undefined,
109
+ setCurrentMonth: moment().toDate()
110
+ };
111
+ PricingCalendar.propTypes = {
112
+ /** The current month to display */
113
+ setCurrentMonth: PropTypes.instanceOf(Date),
114
+ /** The component to render the day, receives one prop date and the rateObject if a match was found*/
115
+ RenderDay: PropTypes.elementType,
116
+ /** The daily rate object */
117
+ rateObject: PropTypes.array,
118
+ /** The start date of the calendar */
119
+ startDate: PropTypes.instanceOf(Date),
120
+ /** The end date of the calendar */
121
+ endDate: PropTypes.instanceOf(Date),
122
+ /** i18next localization to use for the component. Don't use the library localization or else it won't load properly on the consuming application */
123
+ i18next: PropTypes.any
124
+ };
@@ -21,7 +21,6 @@ const GenericAppBarSubMenu = ({
21
21
  }
22
22
  // handleMobileMenuClose();
23
23
  };
24
-
25
24
  useEffect(() => {
26
25
  setSubMenuOpen(Boolean(anchorSubMenu));
27
26
  }, [anchorSubMenu]);
@@ -162,7 +162,6 @@ const Controls = props => {
162
162
  });
163
163
  // saveableCanvas.current.eraseAll();
164
164
  },
165
-
166
165
  marks: imageScaleMarks,
167
166
  min: 1.5,
168
167
  max: 2.5
@@ -0,0 +1,61 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { ThemeProvider } from '@mui/system';
4
+ import { createTheme, useTheme } from '@mui/material/styles';
5
+ import clsx from 'clsx';
6
+
7
+ /**
8
+ * Simply loads up any image, svg etc into an image object.
9
+ *
10
+ *
11
+ * ### Importing the component
12
+
13
+ ```//PitchCamp shared component
14
+ import {ImageAssets} from 'pcm-shared-components';
15
+ ```
16
+
17
+ *
18
+ */
19
+ export const ImageAssets = props => {
20
+ const {
21
+ className,
22
+ theme,
23
+ imagePath
24
+ } = props;
25
+ const compTheme = theme ? theme : useTheme();
26
+ const defaultTheme = createTheme(compTheme);
27
+ const Image = () => {
28
+ // get the filename from the path and remove the extension
29
+ try {
30
+ const filename = imagePath.split('/').pop().split('.')[0];
31
+ return /*#__PURE__*/React.createElement("img", {
32
+ className: clsx(className),
33
+ src: imagePath,
34
+ alt: filename
35
+ });
36
+ } catch (err) {
37
+ console.log(err);
38
+ }
39
+ return null;
40
+ };
41
+ return /*#__PURE__*/React.createElement(ThemeProvider, {
42
+ theme: defaultTheme
43
+ }, /*#__PURE__*/React.createElement(Image, null));
44
+ };
45
+ export default ImageAssets;
46
+ ImageAssets.defaultProps = {
47
+ className: '',
48
+ tooltipText: 'say something',
49
+ imagePath: '',
50
+ theme: undefined
51
+ };
52
+ ImageAssets.propTypes = {
53
+ /** className override */
54
+ className: PropTypes.string,
55
+ /** The path to the image we want to load */
56
+ imagePath: PropTypes.string,
57
+ /** Just a tooltip text */
58
+ tooltipText: PropTypes.string,
59
+ /** Theme object to use on this component, if none provided then the MUI5 theme provider theme is used*/
60
+ theme: PropTypes.object
61
+ };
@@ -0,0 +1,110 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { ThemeProvider } from '@mui/system';
4
+ import { createTheme, useTheme } from '@mui/material/styles';
5
+ import Button from '@mui/material/Button';
6
+ import AppsIcon from '@mui/icons-material/Apps';
7
+ import moment from 'moment';
8
+ import FancyDate from '../../Date/FancyDate';
9
+ export const HorizontalImageTile = ({
10
+ pictures,
11
+ event_date,
12
+ onImageClick,
13
+ view_all_images_str,
14
+ theme
15
+ }) => {
16
+ const compTheme = theme ? theme : useTheme();
17
+ const defaultTheme = createTheme(compTheme);
18
+ const getImageRounded = (numImages, index) => {
19
+ if (numImages === 4 && index === 2 || numImages === 3 && index === 1 || numImages === 2 && index === 0) {
20
+ return "rounded-tr-lg rounded-br-lg";
21
+ } else if (numImages === 5 && index === 1) {
22
+ return "rounded-tr-lg";
23
+ } else if (numImages === 5 && index === 3) {
24
+ return "rounded-br-lg";
25
+ }
26
+ };
27
+ const ImageTile = ({
28
+ pictures,
29
+ height
30
+ }) => {
31
+ //limit the number of pictures to 5
32
+ const numImages = pictures.slice(0, 5).length;
33
+
34
+ // console.log("numImages",numImages)
35
+ if (numImages === 1) {
36
+ return /*#__PURE__*/React.createElement("div", {
37
+ className: "flex ",
38
+ style: {
39
+ height: height,
40
+ maxHeight: height
41
+ }
42
+ }, /*#__PURE__*/React.createElement("img", {
43
+ src: pictures[0],
44
+ alt: "",
45
+ className: " w-full cursor-pointer duration-300 hover:brightness-75 h-auto object-cover rounded-lg shadow-md"
46
+ }));
47
+ }
48
+ let leftWidth = "w-1/2";
49
+ let rightWidth = "w-1/2";
50
+ if (numImages === 2) {
51
+ leftWidth = "w-1/2";
52
+ rightWidth = "w-1/2";
53
+ } else if (numImages === 3) {
54
+ leftWidth = "w-1/2";
55
+ rightWidth = "w-1/2 grid grid-cols-2 gap-6";
56
+ } else if (numImages === 4) {
57
+ leftWidth = "w-1/2";
58
+ rightWidth = "w-1/2 grid grid-cols-3 gap-6";
59
+ } else if (numImages >= 5) {
60
+ leftWidth = "w-1/2";
61
+ rightWidth = "w-1/2 grid grid-cols-2 grid-rows-2 gap-6";
62
+ }
63
+ return /*#__PURE__*/React.createElement("div", {
64
+ className: "relative flex justify-between ",
65
+ style: {
66
+ height: height,
67
+ maxHeight: height
68
+ },
69
+ onClick: onImageClick
70
+ }, /*#__PURE__*/React.createElement("div", {
71
+ className: `${leftWidth} mr-6`
72
+ }, /*#__PURE__*/React.createElement("img", {
73
+ src: pictures[0],
74
+ alt: "",
75
+ className: "w-full h-full cursor-pointer duration-300 hover:brightness-75 object-cover rounded-tl-lg rounded-bl-lg shadow-md"
76
+ })), /*#__PURE__*/React.createElement("div", {
77
+ className: rightWidth
78
+ }, pictures.slice(1, 5).map((image, index) => /*#__PURE__*/React.createElement("img", {
79
+ key: index,
80
+ src: image,
81
+ alt: "",
82
+ className: `w-full h-full cursor-pointer duration-300 hover:brightness-75 object-cover shadow-md ${getImageRounded(numImages, index)}`
83
+ }))), numImages >= 2 && /*#__PURE__*/React.createElement("div", {
84
+ className: "absolute bottom-0 right-0 m-6"
85
+ }, /*#__PURE__*/React.createElement(Button, {
86
+ variant: "outlined",
87
+ className: 'bg-white hover:bg-grey-300',
88
+ startIcon: /*#__PURE__*/React.createElement(AppsIcon, null)
89
+ }, view_all_images_str)));
90
+ };
91
+ return /*#__PURE__*/React.createElement(ThemeProvider, {
92
+ theme: defaultTheme
93
+ }, /*#__PURE__*/React.createElement("div", {
94
+ className: "w-full"
95
+ }, pictures?.length > 0 ? /*#__PURE__*/React.createElement(ImageTile, {
96
+ pictures: pictures,
97
+ height: 320
98
+ }) : /*#__PURE__*/React.createElement("div", {
99
+ className: " h-136 "
100
+ }, /*#__PURE__*/React.createElement(FancyDate, {
101
+ date: event_date
102
+ }))));
103
+ };
104
+ HorizontalImageTile.propTypes = {
105
+ pictures: PropTypes.arrayOf(PropTypes.string),
106
+ onImageClick: PropTypes.func,
107
+ theme: PropTypes.object,
108
+ view_all_images_str: PropTypes.string
109
+ };
110
+ export default HorizontalImageTile;
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { ThemeProvider } from '@mui/system';
4
+ import { createTheme, useTheme } from '@mui/material/styles';
5
+ export const VerticalImageTile = ({
6
+ pictures,
7
+ theme
8
+ }) => {
9
+ // limit the number of pictures to 5
10
+ const numImages = pictures.length;
11
+ if (numImages === 1) {
12
+ return /*#__PURE__*/React.createElement("div", {
13
+ className: "flex"
14
+ }, /*#__PURE__*/React.createElement("img", {
15
+ src: pictures[0],
16
+ alt: "",
17
+ className: "w-full h-full max-h-512 duration-300 object-cover "
18
+ }));
19
+ }
20
+ let bottomHeight = "flex flex-wrap ";
21
+ const compTheme = theme ? theme : useTheme();
22
+ const defaultTheme = createTheme(compTheme);
23
+ return /*#__PURE__*/React.createElement(ThemeProvider, {
24
+ theme: defaultTheme
25
+ }, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
26
+ className: "relative flex flex-col justify-between"
27
+ }, /*#__PURE__*/React.createElement("div", {
28
+ className: ``
29
+ }, /*#__PURE__*/React.createElement("img", {
30
+ src: pictures[0],
31
+ alt: "",
32
+ className: "w-full h-400 duration-300 object-cover rounded-t-md "
33
+ })), /*#__PURE__*/React.createElement("div", {
34
+ className: `${bottomHeight} w-full flex flex-row `
35
+ }, pictures.slice(1, pictures.length).map((image, index) => {
36
+ // let imageHeight = "w-full h-auto";
37
+ let imageHeight = index % 3 === 0 ? "w-full h-400" : "w-1/2 h-200";
38
+
39
+ // make it so that the last image is full width if there are an odd number of pictures
40
+ if (pictures.length % 2 === 0 && index === pictures.length - 2 && index % 3 === 0) {
41
+ imageHeight = "w-full h-400";
42
+ }
43
+ return /*#__PURE__*/React.createElement("img", {
44
+ key: index,
45
+ src: image,
46
+ alt: "",
47
+ className: ` ${imageHeight} duration-300 object-cover `
48
+ });
49
+ })))));
50
+ };
51
+ VerticalImageTile.propTypes = {
52
+ pictures: PropTypes.arrayOf(PropTypes.string),
53
+ theme: PropTypes.object
54
+ };
55
+ export default VerticalImageTile;
@@ -1,4 +1,4 @@
1
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
2
  import React, { useState, useCallback } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import AppBar from '@mui/material/AppBar';
@@ -22,14 +22,12 @@ const useStyles = makeStyles(() => ({
22
22
  // color: 'orange !important',
23
23
  // },
24
24
  },
25
-
26
25
  indicator: {
27
26
  height: 3,
28
27
  borderRadius: 25
29
28
  // backgroundColor: 'orange',
30
29
  }
31
30
  }));
32
-
33
31
  export const SimpleTab = props => {
34
32
  const {
35
33
  childrenTabs,
@@ -43,7 +43,7 @@ export const ReusablePopupMenu = props => {
43
43
  };
44
44
  const childrenWithProps = Children.map(children, child => {
45
45
  // Checking isValidElement is the safe way and avoids a typescript
46
- if ( /*#__PURE__*/isValidElement(child)) {
46
+ if (/*#__PURE__*/isValidElement(child)) {
47
47
  return /*#__PURE__*/React.createElement(Tooltip, {
48
48
  title: tooltipTitle.length > 0 ? tooltipTitle : ''
49
49
  }, /*#__PURE__*/cloneElement(child, {
@@ -1,4 +1,4 @@
1
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
2
  import React, { useState, useEffect } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { ThemeProvider } from '@mui/system';
package/dist/index.js CHANGED
@@ -21,7 +21,8 @@ import DropdownButton from './components/Buttons/DropdownButton';
21
21
  import translationResources from './locals/translationResources';
22
22
  import coreLocals from './locals/coreLocals';
23
23
  import currencySymbol from './locals/currencySymbol';
24
- import DateRangeCalendar from './components/Date/DateRangeCalendar';
24
+ import DateRangeCalendar from './components/Date/DatePickerReactStyled/DateRangeCalendar';
25
+ import DateCalendar from './components/Date/DatePickerReactStyled/DateCalendar';
25
26
  import SimpleLabel from './components/Labels/SimpleLabel';
26
27
  import CurrencyTextInput from './components/TextBoxes/CurrencyTextInput';
27
28
  import ImageStack from './components/Images/ImageStack';
@@ -29,4 +30,10 @@ import PlatformPaymentPlans from './components/Platform/PlatformPaymentPlans';
29
30
  import PlatformPlanTitles from './components/Platform/PlatformPlanTitles';
30
31
  import PlatformPlanPrices from './components/Platform/PlatformPlanPrices';
31
32
  import LoadingBackdrop from './components/Loaders/LoadingBackdrop';
32
- export { TestButton, CodeHighlight, CustomFab, HelpButton, GenericDialogWindow, PcSharedComponentThemeInheritor, ImageCanvasDraw, PCMScrollbar, TwoColumnDisplay, SimpleTab, HrefLink, GenericAppBar, ReusablePopupMenu, SearchBar, TillButton, ProductItemButton, DropdownButton, translationResources, coreLocals, currencySymbol, DateRangeCalendar, SimpleLabel, CurrencyTextInput, ImageStack, PlatformPaymentPlans, PlatformPlanTitles, PlatformPlanPrices, LoadingBackdrop, SimpleAccordion };
33
+ import PricingCalendar from './components/Date/PricingCalendar';
34
+ import FancyDate from './components/Date/FancyDate';
35
+ import HorizontalImageTile from './components/Images/HorizontalImageTile';
36
+ import VerticalImageTile from './components/Images/VerticalImageTile';
37
+ import EventCard from './components/Cards/EventCard';
38
+ import ImageAssets from './components/Icons/ImageAssets';
39
+ export { TestButton, CodeHighlight, CustomFab, HelpButton, GenericDialogWindow, PcSharedComponentThemeInheritor, ImageCanvasDraw, PCMScrollbar, TwoColumnDisplay, SimpleTab, HrefLink, GenericAppBar, ReusablePopupMenu, SearchBar, TillButton, ProductItemButton, DropdownButton, translationResources, coreLocals, currencySymbol, DateRangeCalendar, DateCalendar, SimpleLabel, CurrencyTextInput, ImageStack, PlatformPaymentPlans, PlatformPlanTitles, PlatformPlanPrices, LoadingBackdrop, SimpleAccordion, PricingCalendar, FancyDate, HorizontalImageTile, VerticalImageTile, EventCard, ImageAssets };