@onesy/ui-react 1.0.33 → 1.0.34

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/Medias/Medias.js CHANGED
@@ -203,32 +203,52 @@ const Medias = react_1.default.forwardRef((props_, ref) => {
203
203
  }, [values]);
204
204
  const getLink = react_1.default.useCallback((item, index) => {
205
205
  var _a;
206
- if (!(item === null || item === void 0 ? void 0 : item.urlEmbed))
206
+ const urlEmbed = item === null || item === void 0 ? void 0 : item.urlEmbed;
207
+ if (!urlEmbed)
207
208
  return null;
208
- let url;
209
- try {
210
- url = new URL(item.urlEmbed);
211
- }
212
- catch (error) {
213
- console.log('Invalid embed URL', item);
214
- return null;
215
- }
216
- const id = (_a = url.pathname) === null || _a === void 0 ? void 0 : _a.split('/').filter(Boolean).slice(-1)[0];
217
- if (!(url === null || url === void 0 ? void 0 : url.hostname) || !id)
218
- return null;
219
- if (item.urlEmbed.includes('youtu.be')) {
220
- return ((0, jsx_runtime_1.jsx)("iframe", { title: item.name || '', src: `https://www.youtube.com/embed/${id}`, allow: 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share', allowFullScreen: true, className: classes.aspectRatioYoutube }, index));
221
- }
222
- if (item.urlEmbed.includes('instagram.com')) {
223
- return ((0, jsx_runtime_1.jsx)("iframe", { title: item.name || '', src: `https://www.instagram.com/reel/${id}/embed`, allowFullScreen: true, className: classes.aspectRatioInstagram }, index));
224
- }
225
- if (item.urlEmbed.includes('tiktok.com')) {
226
- return ((0, jsx_runtime_1.jsx)("iframe", { title: item.name || '', src: `https://www.tiktok.com/embed/v2/${id}`, allowFullScreen: true, className: classes.aspectRatioTiktok }, index));
227
- }
228
- if (item.urlEmbed.includes('vimeo.com')) {
229
- return ((0, jsx_runtime_1.jsx)("iframe", { title: item.name || '', src: `https://player.vimeo.com/video/${id}`, allowFullScreen: true, className: classes.aspectRatioVimeo }, index));
209
+ const otherProps = {
210
+ key: index
211
+ };
212
+ const urlEmbedStart = urlEmbed.replace('http://', '').replace('https://', '');
213
+ const isPlatform = (urlEmbedStart.startsWith('youtu') ||
214
+ urlEmbedStart.startsWith('www.youtu') ||
215
+ urlEmbedStart.startsWith('instagram') ||
216
+ urlEmbedStart.startsWith('www.instagram') ||
217
+ urlEmbedStart.startsWith('tiktok') ||
218
+ urlEmbedStart.startsWith('www.tiktok') ||
219
+ urlEmbedStart.startsWith('vimeo') ||
220
+ urlEmbedStart.startsWith('www.vimeo'));
221
+ // predefined
222
+ if (isPlatform) {
223
+ let url;
224
+ try {
225
+ url = new URL(item.urlEmbed);
226
+ }
227
+ catch (error) {
228
+ console.log('Invalid embed URL', item);
229
+ return null;
230
+ }
231
+ const id = (_a = url.pathname) === null || _a === void 0 ? void 0 : _a.split('/').filter(Boolean).slice(-1)[0];
232
+ if (!(url === null || url === void 0 ? void 0 : url.hostname) || !id)
233
+ return null;
234
+ if (item.urlEmbed.includes('youtu.be')) {
235
+ return ((0, jsx_runtime_1.jsx)("iframe", Object.assign({}, otherProps, { title: item.name || '', src: `https://www.youtube.com/embed/${id}`, allow: 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share', allowFullScreen: true, className: classes.aspectRatioYoutube })));
236
+ }
237
+ if (item.urlEmbed.includes('instagram.com')) {
238
+ return ((0, jsx_runtime_1.jsx)("iframe", Object.assign({}, otherProps, { title: item.name || '', src: `https://www.instagram.com/reel/${id}/embed`, allowFullScreen: true, className: classes.aspectRatioInstagram })));
239
+ }
240
+ if (item.urlEmbed.includes('tiktok.com')) {
241
+ return ((0, jsx_runtime_1.jsx)("iframe", Object.assign({}, otherProps, { title: item.name || '', src: `https://www.tiktok.com/embed/v2/${id}`, allowFullScreen: true, className: classes.aspectRatioTiktok })));
242
+ }
243
+ if (item.urlEmbed.includes('vimeo.com')) {
244
+ return ((0, jsx_runtime_1.jsx)("iframe", Object.assign({}, otherProps, { title: item.name || '', src: `https://player.vimeo.com/video/${id}`, allowFullScreen: true, className: classes.aspectRatioVimeo })));
245
+ }
246
+ return ((0, jsx_runtime_1.jsx)(Link, Object.assign({}, otherProps, { href: item === null || item === void 0 ? void 0 : item.urlEmbed, target: 'blank' }, { children: item.name || item.urlEmbed })));
230
247
  }
231
- return ((0, jsx_runtime_1.jsx)(Link, Object.assign({ href: item === null || item === void 0 ? void 0 : item.urlEmbed, target: 'blank' }, { children: item.name || item.urlEmbed }), index));
248
+ // custom embed code
249
+ return ((0, jsx_runtime_1.jsx)(Line, Object.assign({}, otherProps, { fullWidth: true, dangerouslySetInnerHTML: {
250
+ __html: urlEmbed
251
+ } })));
232
252
  }, []);
233
253
  const getItem = (version, item, index) => {
234
254
  var _a, _b, _c, _d, _e, _f;
package/Page/Page.js CHANGED
@@ -42,7 +42,7 @@ const useStyle = (0, style_react_1.style)(theme => ({
42
42
  name: {
43
43
  maxWidth: '440px'
44
44
  }
45
- }), { name: 'onesy-Page' });
45
+ }), { name: 'onesy' });
46
46
  const Page = react_1.default.forwardRef((props_, ref) => {
47
47
  const theme = (0, style_react_1.useOnesyTheme)();
48
48
  const props = react_1.default.useMemo(() => { var _a, _b, _c, _d, _e, _f, _g, _h; return (Object.assign(Object.assign(Object.assign({}, (_d = (_c = (_b = (_a = theme === null || theme === void 0 ? void 0 : theme.ui) === null || _a === void 0 ? void 0 : _a.elements) === null || _b === void 0 ? void 0 : _b.all) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.default), (_h = (_g = (_f = (_e = theme === null || theme === void 0 ? void 0 : theme.ui) === null || _e === void 0 ? void 0 : _e.elements) === null || _f === void 0 ? void 0 : _f.onesyPage) === null || _g === void 0 ? void 0 : _g.props) === null || _h === void 0 ? void 0 : _h.default), props_)); }, [props_]);
@@ -45,7 +45,7 @@ const useStyle = (0, style_react_1.style)(theme => ({
45
45
  out: {
46
46
  animation: '$fadeOut 0.24s forwards'
47
47
  }
48
- }), { name: 'onesy-PageTransition' });
48
+ }), { name: 'onesyTransition' });
49
49
  const PageTransition = react_1.default.forwardRef((props_, ref) => {
50
50
  const theme = (0, style_react_1.useOnesyTheme)();
51
51
  const props = react_1.default.useMemo(() => { var _a, _b, _c, _d, _e, _f, _g, _h; return (Object.assign(Object.assign(Object.assign({}, (_d = (_c = (_b = (_a = theme === null || theme === void 0 ? void 0 : theme.ui) === null || _a === void 0 ? void 0 : _a.elements) === null || _b === void 0 ? void 0 : _b.all) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.default), (_h = (_g = (_f = (_e = theme === null || theme === void 0 ? void 0 : theme.ui) === null || _e === void 0 ? void 0 : _e.elements) === null || _f === void 0 ? void 0 : _f.onesyPageTransition) === null || _g === void 0 ? void 0 : _g.props) === null || _h === void 0 ? void 0 : _h.default), props_)); }, [props_]);
@@ -209,58 +209,71 @@ const Medias = /*#__PURE__*/React.forwardRef((props_, ref) => {
209
209
  return items_;
210
210
  }, [values]);
211
211
  const getLink = React.useCallback((item, index) => {
212
- if (!item?.urlEmbed) return null;
213
- let url;
214
- try {
215
- url = new URL(item.urlEmbed);
216
- } catch (error) {
217
- console.log('Invalid embed URL', item);
218
- return null;
219
- }
220
- const id = url.pathname?.split('/').filter(Boolean).slice(-1)[0];
221
- if (!url?.hostname || !id) return null;
222
- if (item.urlEmbed.includes('youtu.be')) {
223
- return /*#__PURE__*/React.createElement("iframe", {
224
- key: index,
225
- title: item.name || '',
226
- src: `https://www.youtube.com/embed/${id}`,
227
- allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",
228
- allowFullScreen: true,
229
- className: classes.aspectRatioYoutube
230
- });
231
- }
232
- if (item.urlEmbed.includes('instagram.com')) {
233
- return /*#__PURE__*/React.createElement("iframe", {
234
- key: index,
235
- title: item.name || '',
236
- src: `https://www.instagram.com/reel/${id}/embed`,
237
- allowFullScreen: true,
238
- className: classes.aspectRatioInstagram
239
- });
240
- }
241
- if (item.urlEmbed.includes('tiktok.com')) {
242
- return /*#__PURE__*/React.createElement("iframe", {
243
- key: index,
244
- title: item.name || '',
245
- src: `https://www.tiktok.com/embed/v2/${id}`,
246
- allowFullScreen: true,
247
- className: classes.aspectRatioTiktok
248
- });
249
- }
250
- if (item.urlEmbed.includes('vimeo.com')) {
251
- return /*#__PURE__*/React.createElement("iframe", {
252
- key: index,
253
- title: item.name || '',
254
- src: `https://player.vimeo.com/video/${id}`,
255
- allowFullScreen: true,
256
- className: classes.aspectRatioVimeo
257
- });
212
+ const urlEmbed = item?.urlEmbed;
213
+ if (!urlEmbed) return null;
214
+ const otherProps = {
215
+ key: index
216
+ };
217
+ const urlEmbedStart = urlEmbed.replace('http://', '').replace('https://', '');
218
+ const isPlatform = urlEmbedStart.startsWith('youtu') || urlEmbedStart.startsWith('www.youtu') || urlEmbedStart.startsWith('instagram') || urlEmbedStart.startsWith('www.instagram') || urlEmbedStart.startsWith('tiktok') || urlEmbedStart.startsWith('www.tiktok') || urlEmbedStart.startsWith('vimeo') || urlEmbedStart.startsWith('www.vimeo');
219
+
220
+ // predefined
221
+ if (isPlatform) {
222
+ let url;
223
+ try {
224
+ url = new URL(item.urlEmbed);
225
+ } catch (error) {
226
+ console.log('Invalid embed URL', item);
227
+ return null;
228
+ }
229
+ const id = url.pathname?.split('/').filter(Boolean).slice(-1)[0];
230
+ if (!url?.hostname || !id) return null;
231
+ if (item.urlEmbed.includes('youtu.be')) {
232
+ return /*#__PURE__*/React.createElement("iframe", _extends({}, otherProps, {
233
+ title: item.name || '',
234
+ src: `https://www.youtube.com/embed/${id}`,
235
+ allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",
236
+ allowFullScreen: true,
237
+ className: classes.aspectRatioYoutube
238
+ }));
239
+ }
240
+ if (item.urlEmbed.includes('instagram.com')) {
241
+ return /*#__PURE__*/React.createElement("iframe", _extends({}, otherProps, {
242
+ title: item.name || '',
243
+ src: `https://www.instagram.com/reel/${id}/embed`,
244
+ allowFullScreen: true,
245
+ className: classes.aspectRatioInstagram
246
+ }));
247
+ }
248
+ if (item.urlEmbed.includes('tiktok.com')) {
249
+ return /*#__PURE__*/React.createElement("iframe", _extends({}, otherProps, {
250
+ title: item.name || '',
251
+ src: `https://www.tiktok.com/embed/v2/${id}`,
252
+ allowFullScreen: true,
253
+ className: classes.aspectRatioTiktok
254
+ }));
255
+ }
256
+ if (item.urlEmbed.includes('vimeo.com')) {
257
+ return /*#__PURE__*/React.createElement("iframe", _extends({}, otherProps, {
258
+ title: item.name || '',
259
+ src: `https://player.vimeo.com/video/${id}`,
260
+ allowFullScreen: true,
261
+ className: classes.aspectRatioVimeo
262
+ }));
263
+ }
264
+ return /*#__PURE__*/React.createElement(Link, _extends({}, otherProps, {
265
+ href: item?.urlEmbed,
266
+ target: "blank"
267
+ }), item.name || item.urlEmbed);
258
268
  }
259
- return /*#__PURE__*/React.createElement(Link, {
260
- key: index,
261
- href: item?.urlEmbed,
262
- target: "blank"
263
- }, item.name || item.urlEmbed);
269
+
270
+ // custom embed code
271
+ return /*#__PURE__*/React.createElement(Line, _extends({}, otherProps, {
272
+ fullWidth: true,
273
+ dangerouslySetInnerHTML: {
274
+ __html: urlEmbed
275
+ }
276
+ }));
264
277
  }, []);
265
278
  const getItem = (version, item, index) => {
266
279
  const media = item.value;
package/esm/Page/Page.js CHANGED
@@ -32,7 +32,7 @@ const useStyle = styleMethod(theme => ({
32
32
  maxWidth: '440px'
33
33
  }
34
34
  }), {
35
- name: 'onesy-Page'
35
+ name: 'onesy'
36
36
  });
37
37
  const Page = /*#__PURE__*/React.forwardRef((props_, ref) => {
38
38
  const theme = useOnesyTheme();
@@ -35,7 +35,7 @@ const useStyle = styleMethod(theme => ({
35
35
  animation: '$fadeOut 0.24s forwards'
36
36
  }
37
37
  }), {
38
- name: 'onesy-PageTransition'
38
+ name: 'onesyTransition'
39
39
  });
40
40
  const PageTransition = /*#__PURE__*/React.forwardRef((props_, ref) => {
41
41
  const theme = useOnesyTheme();
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license UiReact v1.0.33
1
+ /** @license UiReact v1.0.34
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onesy/ui-react",
3
- "version": "1.0.33",
3
+ "version": "1.0.34",
4
4
  "description": "UI for React",
5
5
  "repository": "https://github.com/onesy-me/onesy.git",
6
6
  "author": "Lazar <lazareric2@gmail.com>",