@mjhls/mjh-framework 1.0.620 → 1.0.621

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.
@@ -0,0 +1,191 @@
1
+ import React__default, { useState, useRef, useEffect } from 'react';
2
+ import { a as main_40 } from './main-7255814e.js';
3
+ import { _ as _slicedToArray } from './slicedToArray-a58d7edf.js';
4
+ import { I as IconContext } from './iconBase-602d52fe.js';
5
+ import Button from 'react-bootstrap/Button';
6
+ import { G as GoSearch } from './index.esm-73e847d2.js';
7
+ import SocialIcons from './SocialIcons.js';
8
+ import Form from 'react-bootstrap/Form';
9
+ import FormControl from 'react-bootstrap/FormControl';
10
+
11
+ var SocialSearchComponent = function SocialSearchComponent(_ref) {
12
+ var type = _ref.type,
13
+ socialIconVariant = _ref.socialIconVariant,
14
+ website = _ref.website,
15
+ navID = _ref.navID;
16
+
17
+ // Search Term
18
+ var _useState = useState(''),
19
+ _useState2 = _slicedToArray(_useState, 2),
20
+ searchKey = _useState2[0],
21
+ setSearchKey = _useState2[1];
22
+ // To calculate the position at which mobile searchbar should set.
23
+
24
+
25
+ var _useState3 = useState(0),
26
+ _useState4 = _slicedToArray(_useState3, 2),
27
+ topOffset = _useState4[0],
28
+ setTopOffset = _useState4[1];
29
+
30
+ var _useState5 = useState(0),
31
+ _useState6 = _slicedToArray(_useState5, 2),
32
+ rightOffset = _useState6[0],
33
+ setRightpOffset = _useState6[1];
34
+
35
+ var desktopComponent = useRef(null);
36
+ var mobileComponent = useRef(null);
37
+
38
+ useEffect(function () {
39
+ var navWrapper = document.getElementById(navID);
40
+ var mastNav = document.querySelector('.nav-brands');
41
+ var topOffset = 0;
42
+ if (window && window.innerWidth < 1200 && mastNav && mastNav.offsetHeight) topOffset = topOffset + mastNav.offsetHeight;
43
+ if (navWrapper && navWrapper.offsetHeight) topOffset = topOffset + navWrapper.offsetHeight;
44
+ setTopOffset(topOffset + 2);
45
+
46
+ if (desktopComponent && desktopComponent.current && desktopComponent.current.offsetWidth && desktopComponent.current.offsetLeft) {
47
+ setRightpOffset(window.innerWidth - desktopComponent.current.offsetLeft);
48
+ }
49
+ }, []);
50
+
51
+ // Search function
52
+ var submitSearch = function submitSearch(e) {
53
+ e.preventDefault();
54
+ window.location.href = '/search?searchTerm=' + searchKey;
55
+ };
56
+
57
+ // Toggling class of an element.Can't use toggle() as IE doesn't support toggle()
58
+ var toggleClass = function toggleClass(selector, type, addOn) {
59
+ if (type === 'id') {
60
+ var searchBar = document.getElementById(selector);
61
+ if (searchBar && searchBar.classList && searchBar.classList.contains(addOn)) {
62
+ searchBar.classList.remove(addOn);
63
+ } else if (searchBar && searchBar.classList) {
64
+ searchBar.classList.add(addOn);
65
+ }
66
+ } else if (type === 'class') {
67
+ var searchBtn = document.getElementsByClassName(selector)[0];
68
+ if (searchBtn && searchBtn.classList && searchBtn.classList.contains(addOn)) {
69
+ // Set overflow fix for iPhones safari browsers
70
+ if (main_40) {
71
+ var mainNav = document.querySelector('#navbar-ham');
72
+ if (mainNav && mainNav.style) mainNav.style.overflow = 'auto';
73
+ }
74
+ searchBtn.classList.remove(addOn);
75
+ } else if (searchBtn && searchBtn.classList) {
76
+ // Set overflow fix for iPhones safari browsers
77
+ if (main_40) {
78
+ var _mainNav = document.querySelector('#navbar-ham');
79
+ if (_mainNav && _mainNav.style) _mainNav.style.overflow = 'visible';
80
+ }
81
+ searchBtn.classList.add(addOn);
82
+ }
83
+ }
84
+ };
85
+
86
+ var socialSearchDesktop = function socialSearchDesktop() {
87
+ return React__default.createElement(
88
+ 'div',
89
+ { id: 'search-content-desktop', ref: desktopComponent, style: { display: 'flex' } },
90
+ React__default.createElement(
91
+ 'div',
92
+ { id: 'search-bar-desktop', style: { top: topOffset, right: rightOffset } },
93
+ React__default.createElement(
94
+ Form,
95
+ { style: { padding: '6px' }, inline: true, onSubmit: function onSubmit(e) {
96
+ return submitSearch(e);
97
+ } },
98
+ React__default.createElement(FormControl, { style: { width: '78%' }, placeholder: 'Search', type: 'text', value: searchKey, onChange: function onChange(e) {
99
+ return setSearchKey(e.target.value);
100
+ } }),
101
+ React__default.createElement(
102
+ Button,
103
+ { variant: 'primary', style: { backgroundColor: 'var(--secondary)', border: 'none', width: '20%', marginLeft: '2%' }, onClick: function onClick(e) {
104
+ return submitSearch(e);
105
+ } },
106
+ 'Search'
107
+ )
108
+ )
109
+ ),
110
+ React__default.createElement(
111
+ IconContext.Provider,
112
+ { value: { color: socialIconVariant === 'light' ? 'white' : 'black', className: 'search-btn-desktop', size: '35px' } },
113
+ React__default.createElement(GoSearch, {
114
+ onClick: function onClick() {
115
+ toggleClass('search-bar-desktop', 'id', 'show');
116
+ toggleClass('search-btn-desktop', 'class', 'active-search');
117
+ }
118
+ })
119
+ ),
120
+ website && website.socialLinks && website.socialLinks.length !== 0 && React__default.createElement(
121
+ 'div',
122
+ { id: 'social-tab-desktop', style: { display: 'flex', left: '0px', position: 'relative', paddingTop: '3px', maxHeight: '35px' } },
123
+ website.socialLinks && React__default.createElement(SocialIcons, { socialLinks: website.socialLinks, variant: socialIconVariant })
124
+ ),
125
+ React__default.createElement(
126
+ 'style',
127
+ { jsx: 'true' },
128
+ '\n #search-content-desktop .search-btn-desktop {\n padding: 5px;\n cursor: pointer;\n }\n #search-content-desktop #search-bar-desktop {\n display: none;\n background-color: var(--primary);\n position: absolute;\n width: 400px;\n border-radius: 5px;\n height: 48px;\n right: 15%;\n }\n #search-content-desktop .search-btn-desktop.active-search {\n border-radius: 5px;\n border: 1px solid var(--secondary) !important;\n }\n #search-content-desktop #search-bar-desktop.show {\n display: block !important;\n }\n '
129
+ )
130
+ );
131
+ };
132
+
133
+ var socialSearchMobile = function socialSearchMobile() {
134
+ return React__default.createElement(
135
+ 'div',
136
+ { id: 'search-content-mobile', ref: mobileComponent },
137
+ React__default.createElement(
138
+ 'div',
139
+ { id: 'search-bar-mobile', style: { top: topOffset } },
140
+ React__default.createElement(
141
+ Form,
142
+ { inline: true, style: { padding: '6px', width: '100%' }, onSubmit: function onSubmit(e) {
143
+ return submitSearch(e);
144
+ } },
145
+ React__default.createElement(FormControl, { style: { width: '78%' }, placeholder: 'Search', type: 'text', value: searchKey, onChange: function onChange(e) {
146
+ return setSearchKey(e.target.value);
147
+ } }),
148
+ React__default.createElement(
149
+ Button,
150
+ { variant: 'primary', style: { backgroundColor: 'var(--secondary)', border: 'none', width: '20%', marginLeft: '2%' }, onClick: function onClick(e) {
151
+ return submitSearch(e);
152
+ } },
153
+ 'Search'
154
+ )
155
+ )
156
+ ),
157
+ React__default.createElement(
158
+ IconContext.Provider,
159
+ { value: { color: socialIconVariant === 'light' ? 'white' : 'black', className: 'search-btn-mobile', size: '35px' } },
160
+ React__default.createElement(GoSearch, {
161
+ onClick: function onClick() {
162
+ var navToggle = document.getElementsByClassName('navbar-toggler')[0];
163
+ if (navToggle && navToggle.classList && !navToggle.classList.contains('collapsed')) {
164
+ var nav = document.querySelectorAll('.navbar-collapse');
165
+ for (var i = 0; i < nav.length; i++) {
166
+ if (nav[i] && nav[i].classList) nav[i].classList.remove('show');
167
+ }
168
+ if (navToggle && navToggle.classList) navToggle.classList.add('collapsed');
169
+ }
170
+
171
+ toggleClass('search-bar-mobile', 'id', 'show');
172
+ toggleClass('search-btn-mobile', 'class', 'active-search');
173
+ }
174
+ })
175
+ ),
176
+ React__default.createElement(
177
+ 'style',
178
+ { jsx: 'true' },
179
+ '\n #search-content-mobile {\n display: flex;\n z-index: 999;\n }\n @media screen and (min-width: 1200px) {\n #search-content-mobile {\n display: none;\n }\n }\n #search-content-mobile .search-btn-mobile {\n padding: 5px;\n right: 4%;\n height: 35px;\n width: 35px;\n margin-top: 4px;\n cursor: pointer;\n }\n #search-content-mobile #search-bar-mobile {\n position: fixed;\n display: none;\n left: 0px;\n width: 100%;\n border-radius: 5px;\n padding: 10px;\n background-color: var(--primary);\n }\n #search-content-mobile #search-bar-mobile .form-inline {\n margin-top: 0px;\n width: 100% !important;\n }\n #search-content-mobile #search-bar-mobile .form-inline .form-control {\n width: 78%;\n border-radius: 5px;\n height: 45px;\n }\n #search-content-mobile #search-bar-mobile .form-inline .btn {\n width: 20%;\n border-radius: 5px;\n background-color: #040c5a;\n height: 45px;\n margin-left: 5px;\n padding: 1px;\n }\n #search-content-mobile .search-btn-mobile.active-search {\n border-radius: 5px;\n border: 1px solid var(--secondary);\n }\n #search-content-mobile #search-bar-mobile.show {\n display: block !important;\n }\n '
180
+ )
181
+ );
182
+ };
183
+
184
+ if (type === 'mobile') {
185
+ return socialSearchMobile();
186
+ } else if (type === 'desktop') {
187
+ return socialSearchDesktop();
188
+ }
189
+ };
190
+
191
+ export { SocialSearchComponent as S };
@@ -50,6 +50,7 @@ import './index.esm-73e847d2.js';
50
50
  import './SocialIcons.js';
51
51
  import 'react-bootstrap/Form';
52
52
  import 'react-bootstrap/FormControl';
53
+ import './SocialSearchComponent-00385695.js';
53
54
  import MagazineNav from './NavMagazine.js';
54
55
  import { NavNative } from './NavNative.js';
55
56
  import './Search.js';
package/dist/esm/index.js CHANGED
@@ -105,6 +105,7 @@ import './index.esm-73e847d2.js';
105
105
  export { default as SocialIcons } from './SocialIcons.js';
106
106
  import 'react-bootstrap/Form';
107
107
  import 'react-bootstrap/FormControl';
108
+ import './SocialSearchComponent-00385695.js';
108
109
  export { default as NavMagazine } from './NavMagazine.js';
109
110
  export { NavNative } from './NavNative.js';
110
111
  export { default as Search } from './Search.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mjhls/mjh-framework",
3
- "version": "1.0.620",
3
+ "version": "1.0.621",
4
4
  "description": "Foundation Framework",
5
5
  "author": "mjh-framework",
6
6
  "license": "MIT",