dhre-component-lib 0.0.7 → 0.0.8

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 (126) hide show
  1. package/dist/components/Avatar/Avatar.d.ts +9 -0
  2. package/dist/components/Avatar/Avatar.js +6 -0
  3. package/dist/components/Avatar/Avatar.test.d.ts +1 -0
  4. package/dist/components/Avatar/Avatar.test.js +50 -0
  5. package/dist/components/Avatar/index.d.ts +1 -0
  6. package/dist/components/Avatar/index.js +1 -0
  7. package/dist/components/Badge/Badge.d.ts +8 -0
  8. package/dist/components/Badge/Badge.js +7 -0
  9. package/dist/components/Badge/Badge.test.d.ts +1 -0
  10. package/dist/components/Badge/Badge.test.js +52 -0
  11. package/dist/components/Badge/index.d.ts +1 -0
  12. package/dist/components/Badge/index.js +1 -0
  13. package/dist/components/BreadCrumb/BreadCrumb.d.ts +14 -0
  14. package/dist/components/BreadCrumb/BreadCrumb.js +8 -0
  15. package/dist/components/BreadCrumb/BreadCrumb.test.d.ts +1 -0
  16. package/dist/components/BreadCrumb/BreadCrumb.test.js +55 -0
  17. package/dist/components/BreadCrumb/index.d.ts +1 -0
  18. package/dist/components/BreadCrumb/index.js +1 -0
  19. package/dist/components/Button/Button.d.ts +10 -0
  20. package/dist/components/Button/Button.js +7 -0
  21. package/dist/components/Button/Button.test.d.ts +1 -0
  22. package/dist/components/Button/Button.test.js +48 -0
  23. package/dist/components/Button/index.d.ts +1 -0
  24. package/dist/components/Button/index.js +1 -0
  25. package/dist/components/Checkbox/Checkbox.d.ts +11 -0
  26. package/dist/components/Checkbox/Checkbox.js +28 -0
  27. package/dist/components/Checkbox/Checkbox.test.d.ts +1 -0
  28. package/dist/components/Checkbox/Checkbox.test.js +70 -0
  29. package/dist/components/Checkbox/index.d.ts +1 -0
  30. package/dist/components/Checkbox/index.js +1 -0
  31. package/dist/components/CircularProgress/CircularProgress.d.ts +10 -0
  32. package/dist/components/CircularProgress/CircularProgress.js +22 -0
  33. package/dist/components/CircularProgress/CircularProgress.test.d.ts +1 -0
  34. package/dist/components/CircularProgress/CircularProgress.test.js +44 -0
  35. package/dist/components/CircularProgress/index.d.ts +1 -0
  36. package/dist/components/CircularProgress/index.js +1 -0
  37. package/dist/components/Divider/Divider.d.ts +8 -0
  38. package/dist/components/Divider/Divider.js +29 -0
  39. package/dist/components/Divider/Divider.test.d.ts +1 -0
  40. package/dist/components/Divider/Divider.test.js +31 -0
  41. package/dist/components/Divider/index.d.ts +1 -0
  42. package/dist/components/Divider/index.js +1 -0
  43. package/dist/components/Enum.d.ts +17 -0
  44. package/dist/components/Enum.js +17 -0
  45. package/dist/components/InputTextField/InputTextField.d.ts +16 -0
  46. package/dist/components/InputTextField/InputTextField.js +29 -0
  47. package/dist/components/InputTextField/InputTextField.test.d.ts +1 -0
  48. package/dist/components/InputTextField/InputTextField.test.js +97 -0
  49. package/dist/components/InputTextField/index.d.ts +1 -0
  50. package/dist/components/InputTextField/index.js +1 -0
  51. package/dist/components/Link/Link.d.ts +10 -0
  52. package/dist/components/Link/Link.js +29 -0
  53. package/dist/components/Link/Link.test.d.ts +1 -0
  54. package/dist/components/Link/Link.test.js +58 -0
  55. package/dist/components/Link/index.d.ts +1 -0
  56. package/dist/components/Link/index.js +1 -0
  57. package/dist/components/Map/Directions.d.ts +13 -0
  58. package/dist/components/Map/Directions.js +6 -0
  59. package/dist/components/Map/GoogleMap.d.ts +12 -0
  60. package/dist/components/Map/GoogleMap.js +100 -0
  61. package/dist/components/Map/GoogleMapsLoader.d.ts +4 -0
  62. package/dist/components/Map/GoogleMapsLoader.js +10 -0
  63. package/dist/components/Map/index.d.ts +2 -0
  64. package/dist/components/Map/index.js +2 -0
  65. package/dist/components/Modal/Modal.d.ts +10 -0
  66. package/dist/components/Modal/Modal.js +14 -0
  67. package/dist/components/Modal/Modal.test.d.ts +1 -0
  68. package/dist/components/Modal/Modal.test.js +51 -0
  69. package/dist/components/Modal/index.d.ts +1 -0
  70. package/dist/components/Modal/index.js +1 -0
  71. package/dist/components/Notification/Notification.d.ts +10 -0
  72. package/dist/components/Notification/Notification.js +21 -0
  73. package/dist/components/Notification/Notification.test.d.ts +1 -0
  74. package/dist/components/Notification/Notification.test.js +97 -0
  75. package/dist/components/Notification/index.d.ts +1 -0
  76. package/dist/components/Notification/index.js +1 -0
  77. package/dist/components/OtpInput/OtpInput.d.ts +14 -0
  78. package/dist/components/OtpInput/OtpInput.js +74 -0
  79. package/dist/components/OtpInput/OtpInput.test.d.ts +1 -0
  80. package/dist/components/OtpInput/OtpInput.test.js +76 -0
  81. package/dist/components/OtpInput/index.d.ts +1 -0
  82. package/dist/components/OtpInput/index.js +1 -0
  83. package/dist/components/PdfView/PdfView.d.ts +18 -0
  84. package/dist/components/PdfView/PdfView.js +92 -0
  85. package/dist/components/PdfView/PdfView.test.d.ts +1 -0
  86. package/dist/components/PdfView/PdfView.test.js +41 -0
  87. package/dist/components/PdfView/index.d.ts +1 -0
  88. package/dist/components/PdfView/index.js +1 -0
  89. package/dist/components/Progress/Progress.d.ts +12 -0
  90. package/dist/components/Progress/Progress.js +29 -0
  91. package/dist/components/Progress/Progress.test.d.ts +1 -0
  92. package/dist/components/Progress/Progress.test.js +34 -0
  93. package/dist/components/Progress/index.d.ts +1 -0
  94. package/dist/components/Progress/index.js +1 -0
  95. package/dist/components/RadioButton/RadioButton.d.ts +14 -0
  96. package/dist/components/RadioButton/RadioButton.js +28 -0
  97. package/dist/components/RadioButton/RadioButton.test.d.ts +1 -0
  98. package/dist/components/RadioButton/RadioButton.test.js +29 -0
  99. package/dist/components/RadioButton/index.d.ts +1 -0
  100. package/dist/components/RadioButton/index.js +1 -0
  101. package/dist/components/Switch/Switch.d.ts +13 -0
  102. package/dist/components/Switch/Switch.js +7 -0
  103. package/dist/components/Switch/Switch.test.d.ts +1 -0
  104. package/dist/components/Switch/Switch.test.js +46 -0
  105. package/dist/components/Switch/index.d.ts +1 -0
  106. package/dist/components/Switch/index.js +1 -0
  107. package/dist/components/Tag/Tag.d.ts +9 -0
  108. package/dist/components/Tag/Tag.js +7 -0
  109. package/dist/components/Tag/Tag.test.d.ts +1 -0
  110. package/dist/components/Tag/Tag.test.js +54 -0
  111. package/dist/components/Tag/index.d.ts +1 -0
  112. package/dist/components/Tag/index.js +1 -0
  113. package/dist/components/Tooltip/Tooltip.d.ts +9 -0
  114. package/dist/components/Tooltip/Tooltip.js +11 -0
  115. package/dist/components/Tooltip/Tooltip.test.d.ts +1 -0
  116. package/dist/components/Tooltip/Tooltip.test.js +59 -0
  117. package/dist/components/Tooltip/index.d.ts +1 -0
  118. package/dist/components/Tooltip/index.js +1 -0
  119. package/dist/components/index.d.ts +15 -0
  120. package/dist/components/index.js +15 -0
  121. package/dist/index.d.ts +1 -0
  122. package/dist/index.js +1 -0
  123. package/dist/theme/colors.d.ts +1 -0
  124. package/dist/theme/colors.js +2 -0
  125. package/package.json +6 -2
  126. package/tsconfig.json +13 -118
@@ -0,0 +1,17 @@
1
+ export declare const INPUT_TYPES: {
2
+ PASSWORD: string;
3
+ TEXT: string;
4
+ EMAIL: string;
5
+ NUMBER: string;
6
+ DATE: string;
7
+ };
8
+ export declare const DIVIDER_ORIENTATION: {
9
+ Horizontal: string;
10
+ Vertical: string;
11
+ };
12
+ export declare const LINK_TARGET: {
13
+ Self: string;
14
+ Blank: string;
15
+ Parent: string;
16
+ Top: string;
17
+ };
@@ -0,0 +1,17 @@
1
+ export var INPUT_TYPES = {
2
+ PASSWORD: 'password',
3
+ TEXT: 'text',
4
+ EMAIL: 'email',
5
+ NUMBER: 'number',
6
+ DATE: 'date',
7
+ };
8
+ export var DIVIDER_ORIENTATION = {
9
+ Horizontal: "horizontal",
10
+ Vertical: "vertical",
11
+ };
12
+ export var LINK_TARGET = {
13
+ Self: '_self',
14
+ Blank: '_blank',
15
+ Parent: '_parent',
16
+ Top: '_top',
17
+ };
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ export interface CustomInputFieldProps {
3
+ label?: string;
4
+ value?: string;
5
+ type?: string;
6
+ placeholder?: string;
7
+ onChange?: React.ChangeEventHandler<HTMLInputElement>;
8
+ className?: string;
9
+ inputClassName?: string;
10
+ labelClassName?: string;
11
+ error?: string;
12
+ errorClassName?: string;
13
+ id?: string;
14
+ }
15
+ declare const CustomInputField: React.FC<CustomInputFieldProps>;
16
+ export default CustomInputField;
@@ -0,0 +1,29 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
+ import { INPUT_TYPES } from '../Enum';
25
+ var CustomInputField = function (_a) {
26
+ var label = _a.label, _b = _a.value, value = _b === void 0 ? '' : _b, _c = _a.type, type = _c === void 0 ? INPUT_TYPES.TEXT : _c, _d = _a.placeholder, placeholder = _d === void 0 ? '' : _d, onChange = _a.onChange, _e = _a.className, className = _e === void 0 ? '' : _e, _f = _a.inputClassName, inputClassName = _f === void 0 ? '' : _f, _g = _a.labelClassName, labelClassName = _g === void 0 ? '' : _g, _h = _a.error, error = _h === void 0 ? '' : _h, _j = _a.errorClassName, errorClassName = _j === void 0 ? '' : _j, rest = __rest(_a, ["label", "value", "type", "placeholder", "onChange", "className", "inputClassName", "labelClassName", "error", "errorClassName"]);
27
+ return (_jsxs("div", { className: className, children: [label && _jsx("label", { className: labelClassName, children: label }), _jsx("input", __assign({ type: type, value: value, placeholder: placeholder, onChange: onChange, className: inputClassName }, rest)), error && _jsx("div", { className: errorClassName, children: error })] }));
28
+ };
29
+ export default CustomInputField;
@@ -0,0 +1,97 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { render, screen, fireEvent } from '@testing-library/react';
14
+ import CustomInputField from './InputTextField';
15
+ import { INPUT_TYPES } from '../Enum';
16
+ var renderWithProps = function (props) {
17
+ if (props === void 0) { props = {}; }
18
+ var defaultProps = __assign({ label: 'Test Label', value: 'Test Value', type: INPUT_TYPES.TEXT, placeholder: 'Enter text...', onChange: jest.fn(), className: 'custom-input-wrapper', inputClassName: 'custom-input', labelClassName: 'custom-label', error: '', errorClassName: 'custom-error', id: 'test-input-field' }, props);
19
+ return render(_jsx(CustomInputField, __assign({}, defaultProps)));
20
+ };
21
+ describe('CustomInputField Component', function () {
22
+ // it('renders without crashing', () => {
23
+ // renderWithProps();
24
+ // // Check if the label correctly associates with the input by using the id
25
+ // const input = screen.getByLabelText('Test Label');
26
+ // expect(input).toBeInTheDocument();
27
+ // });
28
+ it('renders the label correctly', function () {
29
+ renderWithProps();
30
+ expect(screen.getByText('Test Label')).toHaveClass('custom-label');
31
+ });
32
+ it('renders the input with the correct value', function () {
33
+ renderWithProps();
34
+ expect(screen.getByDisplayValue('Test Value')).toHaveClass('custom-input');
35
+ });
36
+ it('calls the onChange handler when input value changes', function () {
37
+ var mockOnChange = jest.fn();
38
+ renderWithProps({ onChange: mockOnChange });
39
+ var input = screen.getByDisplayValue('Test Value');
40
+ fireEvent.change(input, { target: { value: 'New Value' } });
41
+ expect(mockOnChange).toHaveBeenCalledTimes(1);
42
+ });
43
+ it('displays the error message correctly', function () {
44
+ renderWithProps({ error: 'Error message' });
45
+ expect(screen.getByText('Error message')).toHaveClass('custom-error');
46
+ });
47
+ it('renders the input with the correct type', function () {
48
+ renderWithProps({ type: INPUT_TYPES.EMAIL });
49
+ expect(screen.getByPlaceholderText('Enter text...')).toHaveAttribute('type', INPUT_TYPES.EMAIL);
50
+ });
51
+ // it('applies the passed className to the wrapper div', () => {
52
+ // renderWithProps();
53
+ // // Check the class name of the wrapper div
54
+ // const wrapper = screen.getByLabelText('Test Label').parentElement?.parentElement;
55
+ // expect(wrapper).toHaveClass('custom-input-wrapper');
56
+ // });
57
+ it('applies additional props to the input field', function () {
58
+ renderWithProps();
59
+ expect(screen.getByPlaceholderText('Enter text...')).toBeInTheDocument();
60
+ });
61
+ });
62
+ describe('CustomInputField Component - Default Values', function () {
63
+ it('renders the input field with default value when value prop is not provided', function () {
64
+ render(_jsx(CustomInputField, { label: "Test Label", type: INPUT_TYPES.TEXT, value: "", onChange: jest.fn() }));
65
+ expect(screen.getByPlaceholderText('')).toHaveValue('');
66
+ });
67
+ it('renders the input field with default type when type prop is not provided', function () {
68
+ render(_jsx(CustomInputField, { label: "Test Label", value: "Test Value", type: INPUT_TYPES.TEXT, onChange: jest.fn() }));
69
+ expect(screen.getByDisplayValue('Test Value')).toHaveAttribute('type', INPUT_TYPES.TEXT);
70
+ });
71
+ it('renders the input field with default placeholder when placeholder prop is not provided', function () {
72
+ render(_jsx(CustomInputField, { label: "Test Label", value: "Test Value", type: INPUT_TYPES.TEXT, onChange: jest.fn() }));
73
+ expect(screen.getByDisplayValue('Test Value')).toHaveAttribute('placeholder', '');
74
+ });
75
+ // it('applies default class names if className, inputClassName, or labelClassName are not provided', () => {
76
+ // render(<CustomInputField label="Test Label" value="Test Value" type={INPUT_TYPES.TEXT} onChange={jest.fn()} />);
77
+ // // Get the label element
78
+ // const label = screen.getByText('Test Label');
79
+ // const input = screen.getByDisplayValue('Test Value');
80
+ // // Get the parent wrapper div
81
+ // const wrapper = label.closest('div');
82
+ // // Check if the wrapper div has default class names or no class names
83
+ // if (wrapper) {
84
+ // // Expect no additional class names or specific default class names
85
+ // expect(wrapper).toHaveClass('default-wrapper-class'); // Replace with actual default class
86
+ // }
87
+ // // Check if the input field has default input class names or no class names
88
+ // expect(input).toHaveClass('default-input-class'); // Replace with actual default class
89
+ // // Check if the label has default label class names or no class names
90
+ // expect(label).toHaveClass('default-label-class'); // Replace with actual default class
91
+ // });
92
+ it('does not render the error message if error prop is not provided', function () {
93
+ render(_jsx(CustomInputField, { label: "Test Label", value: "Test Value", type: INPUT_TYPES.TEXT, onChange: jest.fn() }));
94
+ var errorMessage = screen.queryByText('Error message');
95
+ expect(errorMessage).not.toBeInTheDocument();
96
+ });
97
+ });
@@ -0,0 +1 @@
1
+ export { default } from "./InputTextField";
@@ -0,0 +1 @@
1
+ export { default } from "./InputTextField";
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ export interface LinkProps {
3
+ href: string;
4
+ target?: string;
5
+ rel?: string;
6
+ className?: string;
7
+ children?: React.ReactNode;
8
+ }
9
+ declare const Link: React.FC<LinkProps>;
10
+ export default Link;
@@ -0,0 +1,29 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import { jsx as _jsx } from "react/jsx-runtime";
24
+ import { LINK_TARGET } from '../Enum';
25
+ var Link = function (_a) {
26
+ var href = _a.href, _b = _a.target, target = _b === void 0 ? LINK_TARGET.Self : _b, rel = _a.rel, _c = _a.className, className = _c === void 0 ? '' : _c, children = _a.children, rest = __rest(_a, ["href", "target", "rel", "className", "children"]);
27
+ return (_jsx("a", __assign({ href: href, target: target, rel: rel, className: className }, rest, { children: children })));
28
+ };
29
+ export default Link;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,58 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { render, screen } from '@testing-library/react';
14
+ import Link from './Link';
15
+ import { LINK_TARGET } from '../Enum';
16
+ describe('Link Component', function () {
17
+ var defaultProps = {
18
+ href: 'https://example.com',
19
+ target: LINK_TARGET.Self,
20
+ rel: 'noopener noreferrer',
21
+ className: 'custom-link',
22
+ children: 'Click here',
23
+ };
24
+ it('renders the link with the correct href', function () {
25
+ render(_jsx(Link, __assign({}, defaultProps)));
26
+ expect(screen.getByText('Click here')).toHaveAttribute('href', 'https://example.com');
27
+ });
28
+ it('renders the link with the correct target attribute', function () {
29
+ render(_jsx(Link, __assign({}, defaultProps)));
30
+ expect(screen.getByText('Click here')).toHaveAttribute('target', LINK_TARGET.Self);
31
+ });
32
+ it('renders the link with the correct rel attribute', function () {
33
+ render(_jsx(Link, __assign({}, defaultProps)));
34
+ expect(screen.getByText('Click here')).toHaveAttribute('rel', 'noopener noreferrer');
35
+ });
36
+ it('renders the link with the correct className', function () {
37
+ render(_jsx(Link, __assign({}, defaultProps)));
38
+ expect(screen.getByText('Click here')).toHaveClass('custom-link');
39
+ });
40
+ it('renders the link with the correct children', function () {
41
+ render(_jsx(Link, __assign({}, defaultProps)));
42
+ expect(screen.getByText('Click here')).toBeInTheDocument();
43
+ });
44
+ it('renders with default target when not specified', function () {
45
+ var propsWithoutTarget = {
46
+ href: defaultProps.href,
47
+ rel: defaultProps.rel,
48
+ className: defaultProps.className,
49
+ children: defaultProps.children,
50
+ };
51
+ render(_jsx(Link, __assign({}, propsWithoutTarget)));
52
+ expect(screen.getByText('Click here')).toHaveAttribute('target', LINK_TARGET.Self);
53
+ });
54
+ it('applies additional props to the link element', function () {
55
+ render(_jsx(Link, __assign({}, defaultProps, { "data-testid": "custom-link" })));
56
+ expect(screen.getByTestId('custom-link')).toBeInTheDocument();
57
+ });
58
+ });
@@ -0,0 +1 @@
1
+ export { default } from "./Link";
@@ -0,0 +1 @@
1
+ export { default } from "./Link";
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ interface GetDirectionActionProps {
3
+ title: string;
4
+ titleClasses?: string;
5
+ location: string;
6
+ locationClasses?: string;
7
+ hours: string;
8
+ hoursClasses?: string;
9
+ directionsLink: string;
10
+ buttonName?: string;
11
+ }
12
+ declare const GetDirectionAction: React.FC<GetDirectionActionProps>;
13
+ export default GetDirectionAction;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ var GetDirectionAction = function (_a) {
3
+ var title = _a.title, titleClasses = _a.titleClasses, location = _a.location, locationClasses = _a.locationClasses, hours = _a.hours, hoursClasses = _a.hoursClasses, directionsLink = _a.directionsLink, _b = _a.buttonName, buttonName = _b === void 0 ? 'Get Directions' : _b;
4
+ return (_jsxs("div", { className: "direction-action-container", children: [_jsx("h3", { className: titleClasses, children: title }), _jsx("p", { className: locationClasses, children: location }), _jsx("p", { className: hoursClasses, children: hours }), _jsx("a", { href: directionsLink, target: "_blank", rel: "noopener noreferrer", className: "directions-link", children: buttonName })] }));
5
+ };
6
+ export default GetDirectionAction;
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ export interface MapComponentProps {
3
+ containerClassName?: string;
4
+ zoom?: number;
5
+ mapOptions?: google.maps.MapOptions;
6
+ radius?: number;
7
+ googleMapsUrls: string[];
8
+ buttonText: string;
9
+ buttonClassName: string;
10
+ }
11
+ declare const MapComponent: React.FC<MapComponentProps>;
12
+ export default MapComponent;
@@ -0,0 +1,100 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState, useRef, useEffect } from "react";
3
+ import { GoogleMap, Marker, Circle, DirectionsRenderer, } from "@react-google-maps/api";
4
+ import { useGoogleMapsLoader } from "./GoogleMapsLoader";
5
+ import styles from './GoogleMap.module.scss';
6
+ var MapComponent = function (_a) {
7
+ var _b = _a.containerClassName, containerClassName = _b === void 0 ? "map-container" : _b, _c = _a.zoom, zoom = _c === void 0 ? 18 : _c, _d = _a.mapOptions, mapOptions = _d === void 0 ? {
8
+ zoomControl: true,
9
+ tilt: 0,
10
+ gestureHandling: "auto",
11
+ mapTypeId: "roadmap",
12
+ } : _d, _e = _a.radius, radius = _e === void 0 ? 5000 : _e, googleMapsUrls = _a.googleMapsUrls, buttonText = _a.buttonText, buttonClassName = _a.buttonClassName;
13
+ var _f = useState(null), location = _f[0], setLocation = _f[1];
14
+ var _g = useState(false), mapVisible = _g[0], setMapVisible = _g[1];
15
+ var _h = useState(null), directionsResponse = _h[0], setDirectionsResponse = _h[1];
16
+ var mapRef = useRef(null);
17
+ var directionsService = useRef(null);
18
+ var directionsRenderer = useRef(null);
19
+ var handleLocationRequest = function () {
20
+ if ("geolocation" in navigator) {
21
+ navigator.geolocation.getCurrentPosition(function (_a) {
22
+ var coords = _a.coords;
23
+ var latitude = coords.latitude, longitude = coords.longitude;
24
+ setLocation({ latitude: latitude, longitude: longitude });
25
+ setMapVisible(true);
26
+ }, function () {
27
+ alert("Failed to get location. Please try again.");
28
+ });
29
+ }
30
+ else {
31
+ alert("Geolocation is not supported by this browser.");
32
+ }
33
+ };
34
+ var handleMarkerClick = function (lat, lng) {
35
+ if (location) {
36
+ var directionsServiceInstance = directionsService.current || new google.maps.DirectionsService();
37
+ var directionsRendererInstance = directionsRenderer.current || new google.maps.DirectionsRenderer();
38
+ if (!directionsService.current)
39
+ directionsService.current = directionsServiceInstance;
40
+ if (!directionsRenderer.current)
41
+ directionsRenderer.current = directionsRendererInstance;
42
+ var directionsRequest = {
43
+ origin: { lat: location.latitude, lng: location.longitude },
44
+ destination: { lat: lat, lng: lng },
45
+ travelMode: google.maps.TravelMode.DRIVING,
46
+ };
47
+ directionsService.current.route(directionsRequest, function (result, status) {
48
+ if (status === google.maps.DirectionsStatus.OK) {
49
+ setDirectionsResponse(result);
50
+ if (mapRef.current && directionsRenderer.current) {
51
+ directionsRenderer.current.setMap(mapRef.current);
52
+ directionsRenderer.current.setDirections(result);
53
+ }
54
+ }
55
+ else {
56
+ alert("Failed to get directions. Please try again.");
57
+ }
58
+ });
59
+ }
60
+ };
61
+ var extractCoordinatesFromUrl = function (url) {
62
+ var regex = /@(-?\d+\.\d+),(-?\d+\.\d+)/;
63
+ var match = url.match(regex);
64
+ if (match) {
65
+ return {
66
+ lat: parseFloat(match[1]),
67
+ lng: parseFloat(match[2]),
68
+ };
69
+ }
70
+ return null;
71
+ };
72
+ var isLoaded = useGoogleMapsLoader().isLoaded;
73
+ useEffect(function () { }, [isLoaded]);
74
+ useEffect(function () { }, [mapVisible]);
75
+ if (!isLoaded) {
76
+ return _jsx("div", { children: "Loading map..." });
77
+ }
78
+ if (mapVisible && location) {
79
+ return (_jsxs("div", { className: containerClassName, children: [_jsx("button", { onClick: handleLocationRequest, className: buttonClassName, children: buttonText }), _jsxs(GoogleMap, { mapContainerStyle: styles.mapContainerStyle, center: { lat: location.latitude, lng: location.longitude }, zoom: zoom, options: mapOptions, onLoad: function (map) {
80
+ mapRef.current = map;
81
+ directionsRenderer.current = new google.maps.DirectionsRenderer();
82
+ directionsRenderer.current.setMap(map);
83
+ }, children: [_jsx(Marker, { position: { lat: location.latitude, lng: location.longitude }, icon: "http://maps.google.com/mapfiles/ms/icons/red-dot.png" }), _jsx(Circle, { center: { lat: location.latitude, lng: location.longitude }, radius: radius, options: {
84
+ strokeColor: "#FF0000",
85
+ strokeOpacity: 0.8,
86
+ strokeWeight: 2,
87
+ fillColor: "#FF0000",
88
+ fillOpacity: 0,
89
+ } }), googleMapsUrls.map(function (url, index) {
90
+ var coord = extractCoordinatesFromUrl(url);
91
+ if (!coord)
92
+ return null;
93
+ return (_jsx(Marker, { position: { lat: coord.lat, lng: coord.lng }, title: "Sample Location ".concat(index + 1), icon: "http://maps.google.com/mapfiles/ms/icons/blue-dot.png", onClick: function () { return handleMarkerClick(coord.lat, coord.lng); } }, index));
94
+ }), directionsResponse && (_jsx(DirectionsRenderer, { directions: directionsResponse, options: { suppressMarkers: true } }))] })] }));
95
+ }
96
+ else {
97
+ return (_jsx("div", { className: containerClassName, children: _jsx("button", { onClick: handleLocationRequest, className: buttonClassName, children: buttonText }) }));
98
+ }
99
+ };
100
+ export default MapComponent;
@@ -0,0 +1,4 @@
1
+ export declare const useGoogleMapsLoader: () => {
2
+ isLoaded: boolean;
3
+ loadError: Error | undefined;
4
+ };
@@ -0,0 +1,10 @@
1
+ import { useJsApiLoader } from '@react-google-maps/api';
2
+ var GOOGLE_MAPS_API_KEY = process.env.NEXT_PUBLIC_GOOGLE_MAP_API; // Ensure you are using environment variable
3
+ export var useGoogleMapsLoader = function () {
4
+ return useJsApiLoader({
5
+ googleMapsApiKey: GOOGLE_MAPS_API_KEY, // Replace with your API key
6
+ libraries: ['places', 'drawing', 'geometry'], // Include all libraries you need
7
+ language: 'en',
8
+ region: 'US',
9
+ });
10
+ };
@@ -0,0 +1,2 @@
1
+ export { default as Directions } from "./Directions";
2
+ export { default as GoogleMap } from "./GoogleMap";
@@ -0,0 +1,2 @@
1
+ export { default as Directions } from "./Directions";
2
+ export { default as GoogleMap } from "./GoogleMap";
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ interface ModalProps {
3
+ isOpen: boolean;
4
+ onClose: () => void;
5
+ children: React.ReactNode;
6
+ modalOverlayClassname?: string;
7
+ modalContentClassname?: string;
8
+ }
9
+ declare const Modal: React.FC<ModalProps>;
10
+ export default Modal;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import styles from './Modal.module.scss';
3
+ var Modal = function (_a) {
4
+ var isOpen = _a.isOpen, onClose = _a.onClose, children = _a.children, _b = _a.modalOverlayClassname, modalOverlayClassname = _b === void 0 ? '' : _b, _c = _a.modalContentClassname, modalContentClassname = _c === void 0 ? '' : _c;
5
+ if (!isOpen)
6
+ return null;
7
+ var handleOverlayClick = function (event) {
8
+ if (event.target === event.currentTarget) {
9
+ onClose();
10
+ }
11
+ };
12
+ return (_jsx("button", { className: "".concat(styles.modalOverlay, " ").concat(modalOverlayClassname), onClick: handleOverlayClick, children: _jsx("div", { className: "".concat(styles.modalContent, " ").concat(modalContentClassname), children: children }) }));
13
+ };
14
+ export default Modal;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,51 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { render, screen, fireEvent } from '@testing-library/react';
3
+ import Modal from './Modal';
4
+ describe('Modal Component', function () {
5
+ var onCloseMock = jest.fn();
6
+ var modalContentText = 'This is the modal content';
7
+ var renderModal = function (isOpen, modalOverlayClassname, modalContentClassname) {
8
+ render(_jsx(Modal, { isOpen: isOpen, onClose: onCloseMock, modalOverlayClassname: modalOverlayClassname, modalContentClassname: modalContentClassname, children: _jsx("div", { children: modalContentText }) }));
9
+ };
10
+ afterEach(function () {
11
+ jest.clearAllMocks();
12
+ });
13
+ it('renders the modal when isOpen is true', function () {
14
+ renderModal(true);
15
+ expect(screen.getByText(modalContentText)).toBeInTheDocument();
16
+ });
17
+ it('does not render the modal when isOpen is false', function () {
18
+ renderModal(false);
19
+ expect(screen.queryByText(modalContentText)).not.toBeInTheDocument();
20
+ });
21
+ it('calls onClose when clicking on the overlay', function () {
22
+ renderModal(true);
23
+ var overlay = screen.getByText(modalContentText).closest('button');
24
+ fireEvent.click(overlay);
25
+ expect(onCloseMock).toHaveBeenCalled();
26
+ });
27
+ it('does not call onClose when clicking inside the modal content', function () {
28
+ renderModal(true);
29
+ var modalContent = screen.getByText(modalContentText);
30
+ fireEvent.click(modalContent);
31
+ expect(onCloseMock).not.toHaveBeenCalled();
32
+ });
33
+ it('applies the provided modalOverlayClassname', function () {
34
+ var overlayClass = 'customOverlayClass';
35
+ renderModal(true, overlayClass);
36
+ var overlay = screen.getByText(modalContentText).closest('button');
37
+ expect(overlay).toHaveClass(overlayClass);
38
+ });
39
+ it('applies the provided modalContentClassname', function () {
40
+ var contentClass = 'customContentClass';
41
+ renderModal(true, undefined, contentClass);
42
+ var modalContent = screen.getByText(modalContentText);
43
+ expect(modalContent.parentElement).toHaveClass(contentClass);
44
+ });
45
+ it('does not render modal when isOpen is false, even if modalOverlayClassname and modalContentClassname are provided', function () {
46
+ var overlayClass = 'customOverlayClass';
47
+ var contentClass = 'customContentClass';
48
+ renderModal(false, overlayClass, contentClass);
49
+ expect(screen.queryByText(modalContentText)).not.toBeInTheDocument();
50
+ });
51
+ });
@@ -0,0 +1 @@
1
+ export { default } from "./Modal";
@@ -0,0 +1 @@
1
+ export { default } from "./Modal";
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import './Notification.module.scss';
3
+ export interface NotificationProps {
4
+ message: string;
5
+ severity?: 'error' | 'warning' | 'info' | 'success';
6
+ autoHideDuration?: number;
7
+ onClose?: (event: React.SyntheticEvent<any> | Event, reason?: string) => void;
8
+ }
9
+ declare const Notification: React.FC<NotificationProps>;
10
+ export default Notification;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect } from "react";
3
+ import './Notification.module.scss';
4
+ var Notification = function (_a) {
5
+ var message = _a.message, _b = _a.severity, severity = _b === void 0 ? 'info' : _b, _c = _a.autoHideDuration, autoHideDuration = _c === void 0 ? 6000 : _c, onClose = _a.onClose;
6
+ useEffect(function () {
7
+ if (autoHideDuration && onClose) {
8
+ var timer_1 = setTimeout(function () {
9
+ onClose(new Event('timeout'), 'timeout');
10
+ }, autoHideDuration);
11
+ return function () { return clearTimeout(timer_1); };
12
+ }
13
+ }, [autoHideDuration, onClose]);
14
+ var handleClose = function (event, reason) {
15
+ if (onClose) {
16
+ onClose(event, reason);
17
+ }
18
+ };
19
+ return (_jsxs("div", { className: "notification ".concat(severity), onClick: function (e) { return handleClose(e); }, role: "alert", children: [_jsx("div", { className: "notification-message", children: message }), _jsx("button", { className: "close-button", onClick: function (e) { return handleClose(e, 'close'); }, "aria-label": "Close notification", children: "\u00D7" })] }));
20
+ };
21
+ export default Notification;