jamespot-react-components 1.3.90 → 1.3.91
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/dist/jamespot-react-components.cjs +1023 -921
- package/dist/jamespot-react-components.js +7919 -7630
- package/dist/src/components/Editors/components/EditorInput.d.ts +5 -1
- package/dist/src/components/JRCIframeVideo/JRCIframeVideo.d.ts +62 -0
- package/dist/src/components/JRCIframeVideo/JRCIframeVideo.stories.d.ts +10 -0
- package/dist/src/components/Widgets/JRCWidgetYoutube/JRCWidgetYoutubeEditor.d.ts +12 -0
- package/dist/src/components/index.d.ts +2 -0
- package/dist/src/translation/lang.json.d.ts +8 -1
- package/dist/src/utils/index.d.ts +2 -0
- package/dist/src/utils/utils.iframeVideo.d.ts +48 -0
- package/package.json +3 -3
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import { RegisterOptions } from 'react-hook-form';
|
|
1
2
|
import { FormControls } from '../../Form/Input/Common/useFormControls';
|
|
2
|
-
export declare const EditorInput: ({ label, placeholder, initialValue, width, rules, description, isMultiline, onChange, }: {
|
|
3
|
+
export declare const EditorInput: ({ label, placeholder, initialValue, width, rules, rulesValidate, description, isMultiline, onChange, }: {
|
|
3
4
|
label: string;
|
|
4
5
|
placeholder?: string;
|
|
5
6
|
initialValue: string | undefined;
|
|
6
7
|
autoFocus?: boolean;
|
|
7
8
|
width?: string;
|
|
8
9
|
rules?: FormControls;
|
|
10
|
+
rulesValidate?: RegisterOptions<{
|
|
11
|
+
text: string;
|
|
12
|
+
}>["validate"];
|
|
9
13
|
description?: string;
|
|
10
14
|
isMultiline?: boolean;
|
|
11
15
|
onChange: (text: string) => void;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { DataCy } from '../../types/dataAttributes';
|
|
2
|
+
/**
|
|
3
|
+
* Provider detection / URL transformation contract.
|
|
4
|
+
*
|
|
5
|
+
* The component is agnostic of which providers exist — the consumer wires the
|
|
6
|
+
* helpers it needs. This keeps `JRCIframeVideo` in `jamespot-react-components`
|
|
7
|
+
* free of any backend convention (e.g. Studio's widgetType vocabulary).
|
|
8
|
+
*/
|
|
9
|
+
export interface JRCIframeVideoHelpers {
|
|
10
|
+
parse: (url: string) => {
|
|
11
|
+
provider: string;
|
|
12
|
+
videoId: string;
|
|
13
|
+
} | null;
|
|
14
|
+
toEmbedUrl: (parsed: {
|
|
15
|
+
provider: string;
|
|
16
|
+
videoId: string;
|
|
17
|
+
}) => string;
|
|
18
|
+
getThumbnailUrl: (parsed: {
|
|
19
|
+
provider: string;
|
|
20
|
+
videoId: string;
|
|
21
|
+
}, publicUrl: string, options?: {
|
|
22
|
+
signal?: AbortSignal;
|
|
23
|
+
}) => Promise<string | null>;
|
|
24
|
+
}
|
|
25
|
+
export interface JRCIframeVideoProps extends DataCy {
|
|
26
|
+
/** Public video URL provided by the user. */
|
|
27
|
+
url: string;
|
|
28
|
+
/**
|
|
29
|
+
* - 'view' : thumbnail + click-to-load iframe inline (detail view)
|
|
30
|
+
* - 'compact' : thumbnail + click opens the source URL in a new tab
|
|
31
|
+
*/
|
|
32
|
+
mode: 'view' | 'compact';
|
|
33
|
+
/** Aria label / iframe title — should describe the video content. */
|
|
34
|
+
title?: string;
|
|
35
|
+
/** Provider helpers injected by the consumer. */
|
|
36
|
+
helpers: JRCIframeVideoHelpers;
|
|
37
|
+
/** Corner radius in px. Defaults: 8 in view mode, 6 in compact. Pass 0 for square corners. */
|
|
38
|
+
borderRadius?: number;
|
|
39
|
+
/**
|
|
40
|
+
* View mode only — load the iframe immediately instead of waiting for a user click
|
|
41
|
+
* on the thumbnail. Disables the RGPD-friendly two-step gate. No effect in compact mode.
|
|
42
|
+
*/
|
|
43
|
+
autoload?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Background color of the view container, visible while the iframe is loading. Defaults to the
|
|
46
|
+
* theme's `grey1`. Pass `'transparent'` to let the parent's background show through (useful
|
|
47
|
+
* when the parent already paints a black backdrop, matching the provider's player chrome).
|
|
48
|
+
*/
|
|
49
|
+
loadingBackground?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Renders an embedded video with a click-to-load thumbnail (RGPD-friendly: the
|
|
53
|
+
* iframe is mounted only when the user clicks, never automatically).
|
|
54
|
+
*
|
|
55
|
+
* - `mode='view'` : the iframe replaces the thumbnail in place
|
|
56
|
+
* - `mode='compact'` : the click opens the source URL in a new tab
|
|
57
|
+
*
|
|
58
|
+
* If the URL is unsafe (`javascript:` etc.) the component renders an error
|
|
59
|
+
* banner. If the URL is safe but no provider matches, it renders a degraded
|
|
60
|
+
* `<a target="_blank">` fallback.
|
|
61
|
+
*/
|
|
62
|
+
export declare const JRCIframeVideo: import('react').NamedExoticComponent<JRCIframeVideoProps>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { JRCIframeVideo } from './JRCIframeVideo';
|
|
3
|
+
declare const meta: Meta<typeof JRCIframeVideo>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof JRCIframeVideo>;
|
|
6
|
+
export declare const View: Story;
|
|
7
|
+
export declare const Compact: Story;
|
|
8
|
+
export declare const UnsupportedProvider: Story;
|
|
9
|
+
export declare const EmptyUrl: Story;
|
|
10
|
+
export declare const UnsafeUrl: Story;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { WidgetYoutubeContent } from 'jamespot-user-api';
|
|
2
|
+
export interface JRCWidgetYoutubeEditorProps {
|
|
3
|
+
uniqid: string;
|
|
4
|
+
content: WidgetYoutubeContent;
|
|
5
|
+
onChangeContent: (uniqid: string, content: WidgetYoutubeContent) => void;
|
|
6
|
+
/**
|
|
7
|
+
* Optional URL validator. Returning false marks the field as invalid (empty values are not validated).
|
|
8
|
+
* Injected by the consumer so this component stays agnostic of provider detection logic.
|
|
9
|
+
*/
|
|
10
|
+
validateUrl?: (url: string) => boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const JRCWidgetYoutubeEditor: ({ uniqid, content, onChangeContent, validateUrl, }: JRCWidgetYoutubeEditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -98,6 +98,7 @@ export { JRCGrid } from './JRCGrid/JRCGrid';
|
|
|
98
98
|
export { JRCHtml } from './JRCHtml/JRCHtml';
|
|
99
99
|
export { JRCIcon } from './JRCIcon/JRCIcon';
|
|
100
100
|
export { JRCIconButton } from './JRCIconButton/JRCIconButton';
|
|
101
|
+
export { JRCIframeVideo } from './JRCIframeVideo/JRCIframeVideo';
|
|
101
102
|
export { JRCImg } from './JRCImg/JRCImg';
|
|
102
103
|
export { JRCList } from './JRCList/JRCList';
|
|
103
104
|
export { JRCLoader } from './JRCLoader/JRCLoader';
|
|
@@ -198,4 +199,5 @@ export { JRCWidgetUserProfile } from './Widgets/JRCWidgetUserProfile/JRCWidgetUs
|
|
|
198
199
|
export { JRCWidgetUserProfileEditor } from './Widgets/JRCWidgetUserProfile/JRCWidgetUserProfileEditor';
|
|
199
200
|
export { JRCWidgetWelcome } from './Widgets/JRCWidgetWelcome/JRCWidgetWelcome';
|
|
200
201
|
export { JRCWidgetWelcomeEditor } from './Widgets/JRCWidgetWelcome/JRCWidgetWelcomeEditor';
|
|
202
|
+
export { JRCWidgetYoutubeEditor } from './Widgets/JRCWidgetYoutube/JRCWidgetYoutubeEditor';
|
|
201
203
|
export { WidgetCalendarEditor } from './Widgets/WidgetCalendar/WidgetCalendarEditor';
|
|
@@ -213,6 +213,9 @@ declare const _default: {
|
|
|
213
213
|
"GLOBAL_Form_SendAlert": "Send the alert email to those who have requested it",
|
|
214
214
|
"GLOBAL_Go_To_Content": "Go to content",
|
|
215
215
|
"GLOBAL_Groups": "Groups",
|
|
216
|
+
"GLOBAL_IframeVideo_InvalidUrl": "Invalid or unsafe URL",
|
|
217
|
+
"GLOBAL_IframeVideo_OpenInNewTab": "Open video in a new tab",
|
|
218
|
+
"GLOBAL_IframeVideo_Play": "Play video",
|
|
216
219
|
"GLOBAL_Image": "Image",
|
|
217
220
|
"GLOBAL_Import": "Import",
|
|
218
221
|
"GLOBAL_Insert": "Insert",
|
|
@@ -460,7 +463,11 @@ declare const _default: {
|
|
|
460
463
|
"WIDGET_User_Profil": "Profil utilisateur",
|
|
461
464
|
"WIDGET_Welcome_Default_Message": "Bienvenue",
|
|
462
465
|
"WIDGET_Welcome_Linebreak_Label": "Saut de ligne (après le message)",
|
|
463
|
-
"WIDGET_Welcome": "Message d'accueil"
|
|
466
|
+
"WIDGET_Welcome": "Message d'accueil",
|
|
467
|
+
"WIDGET_Youtube_Url": "Video URL",
|
|
468
|
+
"WIDGET_Youtube": "Video",
|
|
469
|
+
"WIDGET_Youtube_Text": "Embed a YouTube video",
|
|
470
|
+
"WIDGET_Youtube_InvalidUrl_FieldError": "Enter a valid YouTube URL"
|
|
464
471
|
}
|
|
465
472
|
}
|
|
466
473
|
;
|
|
@@ -4,6 +4,7 @@ import * as document from './utils.document';
|
|
|
4
4
|
import * as file from './utils.files';
|
|
5
5
|
import * as form from './utils.form';
|
|
6
6
|
import * as icons from './utils.icons';
|
|
7
|
+
import * as iframeVideo from './utils.iframeVideo';
|
|
7
8
|
import * as image from './utils.image';
|
|
8
9
|
import * as misc from './utils.misc';
|
|
9
10
|
import * as object from './utils.object';
|
|
@@ -17,6 +18,7 @@ export declare const Utils: {
|
|
|
17
18
|
file: typeof file;
|
|
18
19
|
form: typeof form;
|
|
19
20
|
icons: typeof icons;
|
|
21
|
+
iframeVideo: typeof iframeVideo;
|
|
20
22
|
image: typeof image;
|
|
21
23
|
misc: typeof misc;
|
|
22
24
|
object: typeof object;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* iframeVideo — provider detection and URL transformation utilities.
|
|
3
|
+
*
|
|
4
|
+
* Centralises the regex / embed URL / thumbnail logic for the supported video
|
|
5
|
+
* providers. Pure functions, no React, no side effects beyond the thumbnail
|
|
6
|
+
* fetch (which calls public oEmbed endpoints from the providers themselves —
|
|
7
|
+
* no Jamespot backend involvement).
|
|
8
|
+
*
|
|
9
|
+
* Currently consumed: YouTube only (widget-youtube). The Vimeo / Dailymotion /
|
|
10
|
+
* Loom branches are intentional infra for upcoming widgets — do not remove
|
|
11
|
+
* without checking the corresponding ticket in the tracker.
|
|
12
|
+
*/
|
|
13
|
+
export type Provider = 'youtube' | 'vimeo' | 'dailymotion' | 'loom';
|
|
14
|
+
export interface ParsedProvider {
|
|
15
|
+
provider: Provider;
|
|
16
|
+
videoId: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Type guard used by consumers to narrow a string-typed provider (e.g. coming
|
|
20
|
+
* from `JRCIframeVideoHelpers.toEmbedUrl` whose param is intentionally wide)
|
|
21
|
+
* back to the narrow `Provider` union before calling `toEmbedUrl` / `getThumbnailUrl`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isKnownProvider(value: string): value is Provider;
|
|
24
|
+
/**
|
|
25
|
+
* Validate that the given string is an http/https URL with no dangerous scheme.
|
|
26
|
+
* Used as a defense-in-depth check before rendering anything iframe-related.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isSafeUrl(input: unknown): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Detect the video provider for an URL and extract the video id.
|
|
31
|
+
* Returns null if no supported provider matches.
|
|
32
|
+
*/
|
|
33
|
+
export declare function parseProvider(url: string): ParsedProvider | null;
|
|
34
|
+
/**
|
|
35
|
+
* Build the embed iframe URL for a given provider + videoId.
|
|
36
|
+
* Always returns an https URL.
|
|
37
|
+
*/
|
|
38
|
+
export declare function toEmbedUrl(parsed: ParsedProvider): string;
|
|
39
|
+
/**
|
|
40
|
+
* Resolve a thumbnail URL for a given provider + videoId.
|
|
41
|
+
*
|
|
42
|
+
* - YouTube: predictable static URL (no fetch needed).
|
|
43
|
+
* - Vimeo / Dailymotion: public oEmbed endpoint (no auth, cacheable by browser).
|
|
44
|
+
* - Loom: no public thumbnail API known — returns null, caller falls back.
|
|
45
|
+
*/
|
|
46
|
+
export declare function getThumbnailUrl(parsed: ParsedProvider, publicUrl: string, options?: {
|
|
47
|
+
signal?: AbortSignal;
|
|
48
|
+
}): Promise<string | null>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jamespot-react-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.91",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/jamespot-react-components.cjs",
|
|
6
6
|
"module": "dist/jamespot-react-components.js",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"eslint-plugin-storybook": "10.3.6",
|
|
60
60
|
"globals": "^16.5.0",
|
|
61
61
|
"html2canvas": "^1.4.1",
|
|
62
|
-
"jamespot-front-business": "^1.3.
|
|
63
|
-
"jamespot-user-api": "^1.3.
|
|
62
|
+
"jamespot-front-business": "^1.3.91",
|
|
63
|
+
"jamespot-user-api": "^1.3.91",
|
|
64
64
|
"jsdom": "^26.1.0",
|
|
65
65
|
"knip": "^5.88.1",
|
|
66
66
|
"lint-staged": "^16.4.0",
|