@onesy/ui-react 1.0.33 → 1.0.35

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
@@ -143,6 +143,9 @@ const useStyle = (0, style_react_1.style)(theme => ({
143
143
  aspectRatioTiktok: {
144
144
  aspectRatio: '3 / 6.84',
145
145
  width: '324px'
146
+ },
147
+ customEmbed: {
148
+ maxWidth: '750px'
146
149
  }
147
150
  }), { name: 'onesy-Medias' });
148
151
  const Medias = react_1.default.forwardRef((props_, ref) => {
@@ -203,32 +206,52 @@ const Medias = react_1.default.forwardRef((props_, ref) => {
203
206
  }, [values]);
204
207
  const getLink = react_1.default.useCallback((item, index) => {
205
208
  var _a;
206
- if (!(item === null || item === void 0 ? void 0 : item.urlEmbed))
207
- return null;
208
- let url;
209
- try {
210
- url = new URL(item.urlEmbed);
211
- }
212
- catch (error) {
213
- console.log('Invalid embed URL', item);
209
+ const urlEmbed = item === null || item === void 0 ? void 0 : item.urlEmbed;
210
+ if (!urlEmbed)
214
211
  return null;
212
+ const otherProps = {
213
+ key: index
214
+ };
215
+ const urlEmbedStart = urlEmbed.replace('http://', '').replace('https://', '');
216
+ const isPlatform = (urlEmbedStart.startsWith('youtu') ||
217
+ urlEmbedStart.startsWith('www.youtu') ||
218
+ urlEmbedStart.startsWith('instagram') ||
219
+ urlEmbedStart.startsWith('www.instagram') ||
220
+ urlEmbedStart.startsWith('tiktok') ||
221
+ urlEmbedStart.startsWith('www.tiktok') ||
222
+ urlEmbedStart.startsWith('vimeo') ||
223
+ urlEmbedStart.startsWith('www.vimeo'));
224
+ // predefined
225
+ if (isPlatform) {
226
+ let url;
227
+ try {
228
+ url = new URL(item.urlEmbed);
229
+ }
230
+ catch (error) {
231
+ console.log('Invalid embed URL', item);
232
+ return null;
233
+ }
234
+ const id = (_a = url.pathname) === null || _a === void 0 ? void 0 : _a.split('/').filter(Boolean).slice(-1)[0];
235
+ if (!(url === null || url === void 0 ? void 0 : url.hostname) || !id)
236
+ return null;
237
+ if (item.urlEmbed.includes('youtu.be')) {
238
+ 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 })));
239
+ }
240
+ if (item.urlEmbed.includes('instagram.com')) {
241
+ 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 })));
242
+ }
243
+ if (item.urlEmbed.includes('tiktok.com')) {
244
+ 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 })));
245
+ }
246
+ if (item.urlEmbed.includes('vimeo.com')) {
247
+ 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 })));
248
+ }
249
+ 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 })));
215
250
  }
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));
230
- }
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));
251
+ // custom embed code
252
+ return ((0, jsx_runtime_1.jsx)(Line, Object.assign({}, otherProps, { className: classes.customEmbed, fullWidth: true, dangerouslySetInnerHTML: {
253
+ __html: urlEmbed
254
+ } })));
232
255
  }, []);
233
256
  const getItem = (version, item, index) => {
234
257
  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_]);
@@ -132,6 +132,9 @@ const useStyle = styleMethod(theme => ({
132
132
  aspectRatioTiktok: {
133
133
  aspectRatio: '3 / 6.84',
134
134
  width: '324px'
135
+ },
136
+ customEmbed: {
137
+ maxWidth: '750px'
135
138
  }
136
139
  }), {
137
140
  name: 'onesy-Medias'
@@ -209,58 +212,72 @@ const Medias = /*#__PURE__*/React.forwardRef((props_, ref) => {
209
212
  return items_;
210
213
  }, [values]);
211
214
  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
- });
215
+ const urlEmbed = item?.urlEmbed;
216
+ if (!urlEmbed) return null;
217
+ const otherProps = {
218
+ key: index
219
+ };
220
+ const urlEmbedStart = urlEmbed.replace('http://', '').replace('https://', '');
221
+ 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');
222
+
223
+ // predefined
224
+ if (isPlatform) {
225
+ let url;
226
+ try {
227
+ url = new URL(item.urlEmbed);
228
+ } catch (error) {
229
+ console.log('Invalid embed URL', item);
230
+ return null;
231
+ }
232
+ const id = url.pathname?.split('/').filter(Boolean).slice(-1)[0];
233
+ if (!url?.hostname || !id) return null;
234
+ if (item.urlEmbed.includes('youtu.be')) {
235
+ return /*#__PURE__*/React.createElement("iframe", _extends({}, otherProps, {
236
+ title: item.name || '',
237
+ src: `https://www.youtube.com/embed/${id}`,
238
+ allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",
239
+ allowFullScreen: true,
240
+ className: classes.aspectRatioYoutube
241
+ }));
242
+ }
243
+ if (item.urlEmbed.includes('instagram.com')) {
244
+ return /*#__PURE__*/React.createElement("iframe", _extends({}, otherProps, {
245
+ title: item.name || '',
246
+ src: `https://www.instagram.com/reel/${id}/embed`,
247
+ allowFullScreen: true,
248
+ className: classes.aspectRatioInstagram
249
+ }));
250
+ }
251
+ if (item.urlEmbed.includes('tiktok.com')) {
252
+ return /*#__PURE__*/React.createElement("iframe", _extends({}, otherProps, {
253
+ title: item.name || '',
254
+ src: `https://www.tiktok.com/embed/v2/${id}`,
255
+ allowFullScreen: true,
256
+ className: classes.aspectRatioTiktok
257
+ }));
258
+ }
259
+ if (item.urlEmbed.includes('vimeo.com')) {
260
+ return /*#__PURE__*/React.createElement("iframe", _extends({}, otherProps, {
261
+ title: item.name || '',
262
+ src: `https://player.vimeo.com/video/${id}`,
263
+ allowFullScreen: true,
264
+ className: classes.aspectRatioVimeo
265
+ }));
266
+ }
267
+ return /*#__PURE__*/React.createElement(Link, _extends({}, otherProps, {
268
+ href: item?.urlEmbed,
269
+ target: "blank"
270
+ }), item.name || item.urlEmbed);
258
271
  }
259
- return /*#__PURE__*/React.createElement(Link, {
260
- key: index,
261
- href: item?.urlEmbed,
262
- target: "blank"
263
- }, item.name || item.urlEmbed);
272
+
273
+ // custom embed code
274
+ return /*#__PURE__*/React.createElement(Line, _extends({}, otherProps, {
275
+ className: classes.customEmbed,
276
+ fullWidth: true,
277
+ dangerouslySetInnerHTML: {
278
+ __html: urlEmbed
279
+ }
280
+ }));
264
281
  }, []);
265
282
  const getItem = (version, item, index) => {
266
283
  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.35
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.35",
4
4
  "description": "UI for React",
5
5
  "repository": "https://github.com/onesy-me/onesy.git",
6
6
  "author": "Lazar <lazareric2@gmail.com>",