@inseefr/lunatic 3.0.1-rc.0 → 3.0.1
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/lib/components/shared/HOC/slottableComponent.d.ts +0 -2
- package/lib/components/shared/HOC/slottableComponent.js.map +1 -1
- package/lib/components/shared/MDLabel/MDLabel.d.ts +1 -1
- package/lib/components/shared/MDLabel/MDLabel.js +16 -13
- package/lib/components/shared/MDLabel/MDLabel.js.map +1 -1
- package/lib/components/shared/MDLabel/MDLabelLink.d.ts +8 -0
- package/lib/components/shared/MDLabel/MDLabelLink.js +35 -0
- package/lib/components/shared/MDLabel/MDLabelLink.js.map +1 -0
- package/package.json +1 -1
- package/lib/components/shared/MDLabel/MarkdownLink.d.ts +0 -8
- package/lib/components/shared/MDLabel/MarkdownLink.js +0 -20
- package/lib/components/shared/MDLabel/MarkdownLink.js.map +0 -1
|
@@ -37,7 +37,6 @@ import type { CustomCheckboxGroup } from '../../CheckboxGroup/CustomCheckboxGrou
|
|
|
37
37
|
import type { RouterLink } from '../MDLabel/RouterLink';
|
|
38
38
|
import type { SummaryResponses, SummaryTitle } from '../../Summary/Summary';
|
|
39
39
|
import type { LunaticComponentProps } from '../../type';
|
|
40
|
-
import type { MarkdownLink } from '../MDLabel/MarkdownLink';
|
|
41
40
|
/**
|
|
42
41
|
* Contains the type of every customizable component
|
|
43
42
|
*/
|
|
@@ -94,7 +93,6 @@ export type LunaticSlotComponents = {
|
|
|
94
93
|
ComponentWrapper: ComponentType<PropsWithChildren<LunaticComponentProps & {
|
|
95
94
|
index: number;
|
|
96
95
|
}>>;
|
|
97
|
-
MarkdownLink: typeof MarkdownLink;
|
|
98
96
|
};
|
|
99
97
|
export declare const SlotsProvider: ({ slots, children, }: PropsWithChildren<{
|
|
100
98
|
slots?: Partial<LunaticSlotComponents>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slottableComponent.js","sourceRoot":"","sources":["../../../../src/components/shared/HOC/slottableComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEN,aAAa,EAGb,UAAU,GACV,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"slottableComponent.js","sourceRoot":"","sources":["../../../../src/components/shared/HOC/slottableComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEN,aAAa,EAGb,UAAU,GACV,MAAM,OAAO,CAAC;AAqHf,MAAM,KAAK,GAAG,EAAgD,CAAC;AAE/D,MAAM,YAAY,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;AAE1C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC7B,KAAK,EACL,QAAQ,GACuD,EAAE,EAAE;IACnE,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,OAAO,4BAAG,QAAQ,GAAI,CAAC;IACxB,CAAC;IACD,OAAO,CACN,KAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAAI,KAAK,YAC1C,QAAQ,GACc,CACxB,CAAC;AACH,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CACjC,IAAiC,EACjC,iBAAuC;IAEvC,MAAM,kBAAkB,GAAG,CAAC,KAAQ,EAAE,EAAE;QACvC,MAAM,MAAM,GAAG,UAAU,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC;QAEjD,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;YAC9B,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAqB,CAAC;YACvD,OAAO,KAAC,aAAa,OAAK,KAAK,GAAI,CAAC;QACrC,CAAC;QAED,OAAO,KAAC,iBAAiB,OAAK,KAAK,GAAI,CAAC;IACzC,CAAC,CAAC;IACF,kBAAkB,CAAC,WAAW,GAAG,IAAI,CAAC;IACtC,OAAO,kBAAkB,CAAC;AAC3B,CAAC"}
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { MarkdownLink } from './MarkdownLink';
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import Markdown from 'react-markdown';
|
|
3
|
+
import { MDLabelLink } from './MDLabelLink';
|
|
5
4
|
import remarkBreaks from 'remark-breaks';
|
|
6
5
|
import emoji from 'remark-emoji';
|
|
7
|
-
export
|
|
8
|
-
|
|
6
|
+
export const MDLabel = ({ expression }) => {
|
|
7
|
+
return (_jsx(Markdown, { components: renderComponentsFor(expression), remarkPlugins: [[emoji, { accessible: true }], remarkBreaks], children: expression }));
|
|
8
|
+
};
|
|
9
|
+
const renderComponentsFor = (expression) => {
|
|
9
10
|
const components = {
|
|
10
|
-
p:
|
|
11
|
+
p: (props) => _jsx(_Fragment, { children: props.children }),
|
|
11
12
|
br: 'br',
|
|
12
|
-
a:
|
|
13
|
+
a: (props) => (_jsx(MDLabelLink, { ...{ ...props } })),
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
if (/\n\n/.test(expression)) {
|
|
16
|
+
return {
|
|
17
|
+
...components,
|
|
18
|
+
p: 'p',
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return components;
|
|
19
22
|
};
|
|
20
23
|
//# sourceMappingURL=MDLabel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MDLabel.js","sourceRoot":"","sources":["../../../../src/components/shared/MDLabel/MDLabel.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"MDLabel.js","sourceRoot":"","sources":["../../../../src/components/shared/MDLabel/MDLabel.tsx"],"names":[],"mappings":";AACA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,MAAM,cAAc,CAAC;AAIjC,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,EAAE,UAAU,EAAS,EAAE,EAAE;IAChD,OAAO,CACN,KAAC,QAAQ,IACR,UAAU,EAAE,mBAAmB,CAAC,UAAU,CAAC,EAC3C,aAAa,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,EAAE,YAAY,CAAC,YAE3D,UAAU,GACD,CACX,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAC3B,UAAkB,EAC8B,EAAE;IAClD,MAAM,UAAU,GAAG;QAClB,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,4BAAG,KAAK,CAAC,QAAQ,GAAI;QACnC,EAAE,EAAE,IAAI;QACR,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CACb,KAAC,WAAW,OAAM,EAAE,GAAG,KAAK,EAAyC,GAAI,CACzE;KACuD,CAAC;IAE1D,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7B,OAAO;YACN,GAAG,UAAU;YACb,CAAC,EAAE,GAAG;SACN,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACnB,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type PropsWithChildren } from 'react';
|
|
2
|
+
type Props = PropsWithChildren<{
|
|
3
|
+
href: string;
|
|
4
|
+
title: string;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const MDLabelLink: (props: Props) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function generateUniqueId(): string;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Tooltip } from 'react-tooltip';
|
|
4
|
+
import Markdown from 'react-markdown';
|
|
5
|
+
import { RouterLink } from './RouterLink';
|
|
6
|
+
export const MDLabelLink = (props) => {
|
|
7
|
+
const { href, children, title,
|
|
8
|
+
// logFunction
|
|
9
|
+
} = props;
|
|
10
|
+
// Must be replace by useId when queen move to React 18.
|
|
11
|
+
const [id] = useState(() => generateUniqueId());
|
|
12
|
+
const LinkComponent = (() => {
|
|
13
|
+
if (href.trim().startsWith('/')) {
|
|
14
|
+
return RouterLink;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return 'a';
|
|
18
|
+
}
|
|
19
|
+
})();
|
|
20
|
+
const linkProps = {
|
|
21
|
+
...(href.trim().startsWith('/')
|
|
22
|
+
? { to: href, id }
|
|
23
|
+
: { href, target: '_blank', rel: 'noopener noreferrer', id }),
|
|
24
|
+
...(title
|
|
25
|
+
? { 'data-tooltip-id': `tooltip-${id}`, className: 'link-md' }
|
|
26
|
+
: {}),
|
|
27
|
+
};
|
|
28
|
+
return (_jsxs(_Fragment, { children: [_jsx(LinkComponent, { ...linkProps, children: children }), title && (_jsx(Tooltip, { className: "tooltip-content", id: `tooltip-${id}`, children: _jsx(Markdown, { components: { p: (props) => _jsx(_Fragment, { children: props.children }) }, children: title }) }))] }));
|
|
29
|
+
};
|
|
30
|
+
export function generateUniqueId() {
|
|
31
|
+
const timestamp = Date.now().toString(36);
|
|
32
|
+
const randomPart = Math.random().toString(36).substring(2, 8);
|
|
33
|
+
return `${timestamp}-${randomPart}`;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=MDLabelLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MDLabelLink.js","sourceRoot":"","sources":["../../../../src/components/shared/MDLabel/MDLabelLink.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAA0B,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM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C,CACH,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,UAAU,gBAAgB;IAC/B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9D,OAAO,GAAG,SAAS,IAAI,UAAU,EAAE,CAAC;AACrC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type PropsWithChildren, type ReactNode } from 'react';
|
|
2
|
-
type Props = PropsWithChildren<{
|
|
3
|
-
href: string;
|
|
4
|
-
tooltip?: ReactNode;
|
|
5
|
-
}>;
|
|
6
|
-
export declare const MarkdownLink: import("react").ComponentType<Props>;
|
|
7
|
-
export declare function generateUniqueId(): string;
|
|
8
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import { Tooltip } from 'react-tooltip';
|
|
4
|
-
import { RouterLink } from './RouterLink';
|
|
5
|
-
import { slottableComponent } from '../HOC/slottableComponent';
|
|
6
|
-
export const MarkdownLink = slottableComponent('MarkdownLink', ({ href, children, tooltip }) => {
|
|
7
|
-
// Must be replace by useId when queen move to React 18.
|
|
8
|
-
const [id] = useState(() => generateUniqueId());
|
|
9
|
-
const extraProps = tooltip
|
|
10
|
-
? { 'data-tooltip-id': `tooltip-${id}`, className: 'link-md' }
|
|
11
|
-
: {};
|
|
12
|
-
const isAbsoluteLink = href.trim().startsWith('/');
|
|
13
|
-
return (_jsxs(_Fragment, { children: [isAbsoluteLink ? (_jsx(RouterLink, { to: href, id: id, ...extraProps, children: children })) : (_jsx("a", { href: href, target: "_blank", rel: "noopener noreferrer", id: id, ...extraProps, children: children })), tooltip && (_jsx(Tooltip, { className: "tooltip-content", id: `tooltip-${id}`, children: tooltip }))] }));
|
|
14
|
-
});
|
|
15
|
-
export function generateUniqueId() {
|
|
16
|
-
const timestamp = Date.now().toString(36);
|
|
17
|
-
const randomPart = Math.random().toString(36).substring(2, 8);
|
|
18
|
-
return `${timestamp}-${randomPart}`;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=MarkdownLink.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownLink.js","sourceRoot":"","sources":["../../../../src/components/shared/MDLabel/MarkdownLink.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAA0C,MAAM,OAAO,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAI/D,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,CAC7C,cAAc,EACd,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;IAC/B,wDAAwD;IACxD,MAAM,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAEhD,MAAM,UAAU,GAAG,OAAO;QACzB,CAAC,CAAC,EAAE,iBAAiB,EAAE,WAAW,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE;QAC9D,CAAC,CAAC,EAAE,CAAC;IACN,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAEnD,OAAO,CACN,8BACE,cAAc,CAAC,CAAC,CAAC,CACjB,KAAC,UAAU,IAAC,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,KAAM,UAAU,YAC1C,QAAQ,GACG,CACb,CAAC,CA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