@cratis/showrunner.marquee.react 2.10.0 → 2.11.0
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/Banner/MarqueeBanner.tsx +76 -19
- package/Dialog/MarqueeDialog.tsx +14 -3
- package/Icons.tsx +24 -0
- package/Labels/MarqueeLabels.ts +6 -0
- package/Labels/defaultMarqueeLabels.ts +2 -0
- package/Markdown/MarqueeInlineMarkdown.tsx +37 -0
- package/Markdown/MarqueeLink.tsx +14 -0
- package/Markdown/MarqueeMarkdown.tsx +3 -8
- package/Markdown/index.ts +2 -0
- package/Markdown/markdownText.ts +46 -0
- package/README.md +18 -4
- package/Selection/announcementSelection.ts +18 -3
- package/dist/cjs/Banner/MarqueeBanner.d.ts +1 -1
- package/dist/cjs/Banner/MarqueeBanner.d.ts.map +1 -1
- package/dist/cjs/Banner/MarqueeBanner.js +81 -24
- package/dist/cjs/Banner/MarqueeBanner.js.map +1 -1
- package/dist/cjs/Banner/MarqueeBanner.stories.d.ts +6 -0
- package/dist/cjs/Banner/MarqueeBanner.stories.d.ts.map +1 -1
- package/dist/cjs/Dialog/MarqueeDialog.d.ts.map +1 -1
- package/dist/cjs/Dialog/MarqueeDialog.js +16 -2
- package/dist/cjs/Dialog/MarqueeDialog.js.map +1 -1
- package/dist/cjs/Dialog/MarqueeDialog.stories.d.ts +2 -0
- package/dist/cjs/Dialog/MarqueeDialog.stories.d.ts.map +1 -1
- package/dist/cjs/Examples/LocalizedMarquee.d.ts.map +1 -1
- package/dist/cjs/Icons.d.ts +4 -0
- package/dist/cjs/Icons.d.ts.map +1 -1
- package/dist/cjs/Icons.js +16 -0
- package/dist/cjs/Icons.js.map +1 -1
- package/dist/cjs/Labels/MarqueeLabels.d.ts +2 -0
- package/dist/cjs/Labels/MarqueeLabels.d.ts.map +1 -1
- package/dist/cjs/Labels/defaultMarqueeLabels.d.ts.map +1 -1
- package/dist/cjs/Labels/defaultMarqueeLabels.js +2 -0
- package/dist/cjs/Labels/defaultMarqueeLabels.js.map +1 -1
- package/dist/cjs/Markdown/MarqueeInlineMarkdown.d.ts +6 -0
- package/dist/cjs/Markdown/MarqueeInlineMarkdown.d.ts.map +1 -0
- package/dist/cjs/Markdown/MarqueeInlineMarkdown.js +37 -0
- package/dist/cjs/Markdown/MarqueeInlineMarkdown.js.map +1 -0
- package/dist/cjs/Markdown/MarqueeLink.d.ts +5 -0
- package/dist/cjs/Markdown/MarqueeLink.d.ts.map +1 -0
- package/dist/cjs/Markdown/MarqueeLink.js +21 -0
- package/dist/cjs/Markdown/MarqueeLink.js.map +1 -0
- package/dist/cjs/Markdown/MarqueeMarkdown.d.ts.map +1 -1
- package/dist/cjs/Markdown/MarqueeMarkdown.js +2 -10
- package/dist/cjs/Markdown/MarqueeMarkdown.js.map +1 -1
- package/dist/cjs/Markdown/index.d.ts +2 -0
- package/dist/cjs/Markdown/index.d.ts.map +1 -1
- package/dist/cjs/Markdown/markdownText.d.ts +3 -0
- package/dist/cjs/Markdown/markdownText.d.ts.map +1 -0
- package/dist/cjs/Markdown/markdownText.js +35 -0
- package/dist/cjs/Markdown/markdownText.js.map +1 -0
- package/dist/cjs/Marquee.js +1 -0
- package/dist/cjs/Marquee.js.map +1 -1
- package/dist/cjs/Selection/announcementSelection.d.ts.map +1 -1
- package/dist/cjs/Selection/announcementSelection.js +15 -3
- package/dist/cjs/Selection/announcementSelection.js.map +1 -1
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/Banner/MarqueeBanner.d.ts +1 -1
- package/dist/esm/Banner/MarqueeBanner.d.ts.map +1 -1
- package/dist/esm/Banner/MarqueeBanner.js +82 -25
- package/dist/esm/Banner/MarqueeBanner.js.map +1 -1
- package/dist/esm/Banner/MarqueeBanner.stories.d.ts +6 -0
- package/dist/esm/Banner/MarqueeBanner.stories.d.ts.map +1 -1
- package/dist/esm/Banner/MarqueeBanner.stories.js +18 -1
- package/dist/esm/Banner/MarqueeBanner.stories.js.map +1 -1
- package/dist/esm/Dialog/MarqueeDialog.d.ts.map +1 -1
- package/dist/esm/Dialog/MarqueeDialog.js +16 -2
- package/dist/esm/Dialog/MarqueeDialog.js.map +1 -1
- package/dist/esm/Dialog/MarqueeDialog.stories.d.ts +2 -0
- package/dist/esm/Dialog/MarqueeDialog.stories.d.ts.map +1 -1
- package/dist/esm/Dialog/MarqueeDialog.stories.js +3 -0
- package/dist/esm/Dialog/MarqueeDialog.stories.js.map +1 -1
- package/dist/esm/Examples/CustomBanner.js +2 -2
- package/dist/esm/Examples/CustomBanner.js.map +1 -1
- package/dist/esm/Examples/CustomDialog.js +2 -2
- package/dist/esm/Examples/CustomDialog.js.map +1 -1
- package/dist/esm/Examples/LocalizedMarquee.d.ts.map +1 -1
- package/dist/esm/Examples/LocalizedMarquee.js +2 -0
- package/dist/esm/Examples/LocalizedMarquee.js.map +1 -1
- package/dist/esm/Examples/OwnSurface.js +2 -2
- package/dist/esm/Examples/OwnSurface.js.map +1 -1
- package/dist/esm/Icons.d.ts +4 -0
- package/dist/esm/Icons.d.ts.map +1 -1
- package/dist/esm/Icons.js +16 -1
- package/dist/esm/Icons.js.map +1 -1
- package/dist/esm/Labels/MarqueeLabels.d.ts +2 -0
- package/dist/esm/Labels/MarqueeLabels.d.ts.map +1 -1
- package/dist/esm/Labels/defaultMarqueeLabels.d.ts.map +1 -1
- package/dist/esm/Labels/defaultMarqueeLabels.js +2 -0
- package/dist/esm/Labels/defaultMarqueeLabels.js.map +1 -1
- package/dist/esm/Markdown/MarqueeInlineMarkdown.d.ts +6 -0
- package/dist/esm/Markdown/MarqueeInlineMarkdown.d.ts.map +1 -0
- package/dist/esm/Markdown/MarqueeInlineMarkdown.js +35 -0
- package/dist/esm/Markdown/MarqueeInlineMarkdown.js.map +1 -0
- package/dist/esm/Markdown/MarqueeLink.d.ts +5 -0
- package/dist/esm/Markdown/MarqueeLink.d.ts.map +1 -0
- package/dist/esm/Markdown/MarqueeLink.js +19 -0
- package/dist/esm/Markdown/MarqueeLink.js.map +1 -0
- package/dist/esm/Markdown/MarqueeMarkdown.d.ts.map +1 -1
- package/dist/esm/Markdown/MarqueeMarkdown.js +2 -10
- package/dist/esm/Markdown/MarqueeMarkdown.js.map +1 -1
- package/dist/esm/Markdown/index.d.ts +2 -0
- package/dist/esm/Markdown/index.d.ts.map +1 -1
- package/dist/esm/Markdown/index.js +2 -0
- package/dist/esm/Markdown/index.js.map +1 -1
- package/dist/esm/Markdown/markdownText.d.ts +3 -0
- package/dist/esm/Markdown/markdownText.d.ts.map +1 -0
- package/dist/esm/Markdown/markdownText.js +32 -0
- package/dist/esm/Markdown/markdownText.js.map +1 -0
- package/dist/esm/Marquee.js +1 -0
- package/dist/esm/Marquee.js.map +1 -1
- package/dist/esm/Selection/announcementSelection.d.ts.map +1 -1
- package/dist/esm/Selection/announcementSelection.js +15 -3
- package/dist/esm/Selection/announcementSelection.js.map +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
- package/styles.css +106 -7
|
@@ -8,4 +8,10 @@ export declare const Warning: Story;
|
|
|
8
8
|
export declare const Critical: Story;
|
|
9
9
|
export declare const Several: Story;
|
|
10
10
|
export declare const None: Story;
|
|
11
|
+
export declare const WithoutMessage: Story;
|
|
12
|
+
export declare const WithMessage: Story;
|
|
13
|
+
export declare const Expanded: Story;
|
|
14
|
+
export declare const Tooltip: Story;
|
|
15
|
+
export declare const MarkdownTitle: Story;
|
|
16
|
+
export declare const Permanent: Story;
|
|
11
17
|
//# sourceMappingURL=MarqueeBanner.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarqueeBanner.stories.d.ts","sourceRoot":"","sources":["../../../Banner/MarqueeBanner.stories.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"MarqueeBanner.stories.d.ts","sourceRoot":"","sources":["../../../Banner/MarqueeBanner.stories.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAI5D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,aAAa,CAIpC,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,aAAa,CAAC,CAAC;AAE5C,eAAO,MAAM,WAAW,EAAE,KAAkE,CAAC;AAC7F,eAAO,MAAM,OAAO,EAAE,KAAkE,CAAC;AACzF,eAAO,MAAM,QAAQ,EAAE,KAAkE,CAAC;AAC1F,eAAO,MAAM,OAAO,EAAE,KAA4E,CAAC;AACnG,eAAO,MAAM,IAAI,EAAE,KAAuC,CAAC;AAG3D,eAAO,MAAM,cAAc,EAAE,KAA2D,CAAC;AAGzF,eAAO,MAAM,WAAW,EAAE,KAAwD,CAAC;AAGnF,eAAO,MAAM,QAAQ,EAAE,KAKtB,CAAC;AAGF,eAAO,MAAM,OAAO,EAAE,KAKrB,CAAC;AAGF,eAAO,MAAM,aAAa,EAAE,KAA8D,CAAC;AAG3F,eAAO,MAAM,SAAS,EAAE,KAAsD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarqueeDialog.d.ts","sourceRoot":"","sources":["../../../Dialog/MarqueeDialog.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,
|
|
1
|
+
{"version":3,"file":"MarqueeDialog.d.ts","sourceRoot":"","sources":["../../../Dialog/MarqueeDialog.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAA4E,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAMtI,MAAM,WAAW,kBAAkB;IAE/B,YAAY,EAAE,iBAAiB,CAAC;IAGhC,OAAO,EAAE,OAAO,CAAC;IAGjB,OAAO,EAAE,MAAM,IAAI,CAAC;IAGpB,MAAM,EAAE,aAAa,CAAC;IAGtB,QAAQ,CAAC,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;CAClD;AAUD,eAAO,MAAM,aAAa,GAAI,gEAAkF,kBAAkB,gCA4BjI,CAAC"}
|
|
@@ -4,17 +4,25 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var dialogs = require('@cratis/arc.react/dialogs');
|
|
5
5
|
var Dialogs = require('@cratis/components/Dialogs');
|
|
6
6
|
var Icons = require('../Icons.js');
|
|
7
|
+
var MarqueeInlineMarkdown = require('../Markdown/MarqueeInlineMarkdown.js');
|
|
7
8
|
var MarqueeMarkdown = require('../Markdown/MarqueeMarkdown.js');
|
|
9
|
+
var markdownText = require('../Markdown/markdownText.js');
|
|
8
10
|
require('@cratis/showrunner.marquee');
|
|
9
11
|
var importancePresentation = require('../Selection/importancePresentation.js');
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* One announcement in a dialog. Focus moves into the dialog and is kept in it until it is closed, and lands on the
|
|
13
15
|
* title instead of the button, so the Enter or Space that was being pressed when it opened does not close it unread.
|
|
16
|
+
*
|
|
17
|
+
* The heading is the title as plain text, with the Markdown taken out, as a dialog heading is a string. A title that
|
|
18
|
+
* uses Markdown, such as a link, is shown again with its formatting at the top of the content. The message is optional
|
|
19
|
+
* and is left out when there is none.
|
|
14
20
|
*/ const MarqueeDialog = ({ announcement, hasMore, onClose, labels, markdown: Markdown = MarqueeMarkdown.MarqueeMarkdown })=>{
|
|
15
21
|
const presentation = importancePresentation.importancePresentation(announcement.importance, labels);
|
|
22
|
+
const plainTitle = markdownText.markdownToPlainText(announcement.title);
|
|
23
|
+
const titleHasMarkdown = announcement.title.trim() !== plainTitle;
|
|
16
24
|
return /*#__PURE__*/ jsxRuntime.jsx(Dialogs.Dialog, {
|
|
17
|
-
title:
|
|
25
|
+
title: plainTitle,
|
|
18
26
|
width: "34rem",
|
|
19
27
|
buttons: dialogs.DialogButtons.Ok,
|
|
20
28
|
okLabel: hasMore ? labels.next : labels.acknowledge,
|
|
@@ -31,7 +39,13 @@ var importancePresentation = require('../Selection/importancePresentation.js');
|
|
|
31
39
|
presentation: presentation
|
|
32
40
|
})
|
|
33
41
|
}),
|
|
34
|
-
/*#__PURE__*/ jsxRuntime.jsx(
|
|
42
|
+
titleHasMarkdown && /*#__PURE__*/ jsxRuntime.jsx("p", {
|
|
43
|
+
className: "marquee-dialog__title",
|
|
44
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(MarqueeInlineMarkdown.MarqueeInlineMarkdown, {
|
|
45
|
+
source: announcement.title
|
|
46
|
+
})
|
|
47
|
+
}),
|
|
48
|
+
markdownText.hasMarkdown(announcement.body) && /*#__PURE__*/ jsxRuntime.jsx(Markdown, {
|
|
35
49
|
source: announcement.body
|
|
36
50
|
})
|
|
37
51
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarqueeDialog.js","sources":["../../../Dialog/MarqueeDialog.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DialogButtons } from '@cratis/arc.react/dialogs';\nimport { Dialog, DialogInitialFocus } from '@cratis/components/Dialogs';\nimport { AnnouncementForMe } from '@cratis/showrunner.marquee';\nimport { ComponentType } from 'react';\nimport { ImportanceIcon } from '../Icons.js';\nimport { MarqueeLabels } from '../Labels/index.js';\nimport { MarqueeMarkdown, MarqueeMarkdownProps } from '../Markdown/index.js';\nimport { importancePresentation } from '../Selection/index.js';\n\n/**\n * Props for {@link MarqueeDialog}, and for the component given to the `dialog` slot of {@link Marquee}.\n */\nexport interface MarqueeDialogProps {\n /** The announcement to show. */\n announcement: AnnouncementForMe;\n\n /** Whether more dialogs follow this one; the button then moves on instead of finishing. */\n hasMore: boolean;\n\n /** Called when the person closes the dialog, with the button, Escape or the close button of the header. */\n onClose: () => void;\n\n /** The texts to show. */\n labels: MarqueeLabels;\n\n /** Renders the Markdown of a body; the `markdown` slot of {@link Marquee}. */\n markdown?: ComponentType<MarqueeMarkdownProps>;\n}\n\n/**\n * One announcement in a dialog. Focus moves into the dialog and is kept in it until it is closed, and lands on the\n * title instead of the button, so the Enter or Space that was being pressed when it opened does not close it unread.\n */\nexport const MarqueeDialog = ({ announcement, hasMore, onClose, labels, markdown: Markdown = MarqueeMarkdown }: MarqueeDialogProps) => {\n const presentation = importancePresentation(announcement.importance, labels);\n\n return (\n <Dialog\n title={
|
|
1
|
+
{"version":3,"file":"MarqueeDialog.js","sources":["../../../Dialog/MarqueeDialog.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DialogButtons } from '@cratis/arc.react/dialogs';\nimport { Dialog, DialogInitialFocus } from '@cratis/components/Dialogs';\nimport { AnnouncementForMe } from '@cratis/showrunner.marquee';\nimport { ComponentType } from 'react';\nimport { ImportanceIcon } from '../Icons.js';\nimport { MarqueeLabels } from '../Labels/index.js';\nimport { hasMarkdown, markdownToPlainText, MarqueeInlineMarkdown, MarqueeMarkdown, MarqueeMarkdownProps } from '../Markdown/index.js';\nimport { importancePresentation } from '../Selection/index.js';\n\n/**\n * Props for {@link MarqueeDialog}, and for the component given to the `dialog` slot of {@link Marquee}.\n */\nexport interface MarqueeDialogProps {\n /** The announcement to show. */\n announcement: AnnouncementForMe;\n\n /** Whether more dialogs follow this one; the button then moves on instead of finishing. */\n hasMore: boolean;\n\n /** Called when the person closes the dialog, with the button, Escape or the close button of the header. */\n onClose: () => void;\n\n /** The texts to show. */\n labels: MarqueeLabels;\n\n /** Renders the Markdown of a body; the `markdown` slot of {@link Marquee}. */\n markdown?: ComponentType<MarqueeMarkdownProps>;\n}\n\n/**\n * One announcement in a dialog. Focus moves into the dialog and is kept in it until it is closed, and lands on the\n * title instead of the button, so the Enter or Space that was being pressed when it opened does not close it unread.\n *\n * The heading is the title as plain text, with the Markdown taken out, as a dialog heading is a string. A title that\n * uses Markdown, such as a link, is shown again with its formatting at the top of the content. The message is optional\n * and is left out when there is none.\n */\nexport const MarqueeDialog = ({ announcement, hasMore, onClose, labels, markdown: Markdown = MarqueeMarkdown }: MarqueeDialogProps) => {\n const presentation = importancePresentation(announcement.importance, labels);\n const plainTitle = markdownToPlainText(announcement.title);\n const titleHasMarkdown = announcement.title.trim() !== plainTitle;\n\n return (\n <Dialog\n title={plainTitle}\n width='34rem'\n buttons={DialogButtons.Ok}\n okLabel={hasMore ? labels.next : labels.acknowledge}\n closeAriaLabel={labels.close}\n initialFocus={DialogInitialFocus.Content}\n onConfirm={onClose}\n onCancel={onClose}>\n <div className='marquee-dialog'>\n <div className={`marquee-dialog__importance marquee-dialog__importance--${presentation.modifier}`}>\n <ImportanceIcon presentation={presentation} />\n </div>\n {titleHasMarkdown && (\n <p className='marquee-dialog__title'>\n <MarqueeInlineMarkdown source={announcement.title} />\n </p>\n )}\n {hasMarkdown(announcement.body) && <Markdown source={announcement.body} />}\n </div>\n </Dialog>\n );\n};\n"],"names":["MarqueeDialog","announcement","hasMore","onClose","labels","markdown","Markdown","MarqueeMarkdown","presentation","importancePresentation","importance","plainTitle","markdownToPlainText","title","titleHasMarkdown","trim","_jsx","Dialog","width","buttons","DialogButtons","Ok","okLabel","next","acknowledge","closeAriaLabel","close","initialFocus","DialogInitialFocus","Content","onConfirm","onCancel","_jsxs","div","className","modifier","ImportanceIcon","p","MarqueeInlineMarkdown","source","hasMarkdown","body"],"mappings":";;;;;;;;;;;;AAgCA;;;;;;;AAOC,IACM,MAAMA,aAAAA,GAAgB,CAAC,EAAEC,YAAY,EAAEC,OAAO,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAAA,EAAUC,QAAAA,GAAWC,+BAAe,EAAsB,GAAA;AAC9H,IAAA,MAAMC,YAAAA,GAAeC,6CAAAA,CAAuBR,YAAAA,CAAaS,UAAU,EAAEN,MAAAA,CAAAA;IACrE,MAAMO,UAAAA,GAAaC,gCAAAA,CAAoBX,YAAAA,CAAaY,KAAK,CAAA;AACzD,IAAA,MAAMC,gBAAAA,GAAmBb,YAAAA,CAAaY,KAAK,CAACE,IAAI,EAAA,KAAOJ,UAAAA;AAEvD,IAAA,qBACIK,cAAA,CAACC,cAAAA,EAAAA;QACGJ,KAAAA,EAAOF,UAAAA;QACPO,KAAAA,EAAM,OAAA;AACNC,QAAAA,OAAAA,EAASC,sBAAcC,EAAE;AACzBC,QAAAA,OAAAA,EAASpB,OAAAA,GAAUE,MAAAA,CAAOmB,IAAI,GAAGnB,OAAOoB,WAAW;AACnDC,QAAAA,cAAAA,EAAgBrB,OAAOsB,KAAK;AAC5BC,QAAAA,YAAAA,EAAcC,2BAAmBC,OAAO;QACxCC,SAAAA,EAAW3B,OAAAA;QACX4B,QAAAA,EAAU5B,OAAAA;AACV,QAAA,QAAA,gBAAA6B,eAAA,CAACC,KAAAA,EAAAA;YAAIC,SAAAA,EAAU,gBAAA;;8BACXlB,cAAA,CAACiB,KAAAA,EAAAA;AAAIC,oBAAAA,SAAAA,EAAW,CAAC,uDAAuD,EAAE1B,YAAAA,CAAa2B,QAAQ,CAAA,CAAE;AAC7F,oBAAA,QAAA,gBAAAnB,cAAA,CAACoB,oBAAAA,EAAAA;wBAAe5B,YAAAA,EAAcA;;;AAEjCM,gBAAAA,gBAAAA,kBACGE,cAAA,CAACqB,GAAAA,EAAAA;oBAAEH,SAAAA,EAAU,uBAAA;AACT,oBAAA,QAAA,gBAAAlB,cAAA,CAACsB,2CAAAA,EAAAA;AAAsBC,wBAAAA,MAAAA,EAAQtC,aAAaY;;;gBAGnD2B,wBAAAA,CAAYvC,YAAAA,CAAawC,IAAI,CAAA,kBAAKzB,cAAA,CAACV,QAAAA,EAAAA;AAASiC,oBAAAA,MAAAA,EAAQtC,aAAawC;;;;;AAIlF;;"}
|
|
@@ -10,4 +10,6 @@ export declare const DialogEverySessionInformation: Story;
|
|
|
10
10
|
export declare const DialogEverySessionWarning: Story;
|
|
11
11
|
export declare const DialogEverySessionCritical: Story;
|
|
12
12
|
export declare const WithMoreToFollow: Story;
|
|
13
|
+
export declare const MarkdownTitle: Story;
|
|
14
|
+
export declare const WithoutMessage: Story;
|
|
13
15
|
//# sourceMappingURL=MarqueeDialog.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarqueeDialog.stories.d.ts","sourceRoot":"","sources":["../../../Dialog/MarqueeDialog.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"MarqueeDialog.stories.d.ts","sourceRoot":"","sources":["../../../Dialog/MarqueeDialog.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAI5D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,aAAa,CAIpC,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,aAAa,CAAC,CAAC;AAE5C,eAAO,MAAM,qBAAqB,EAAE,KAAuF,CAAC;AAC5H,eAAO,MAAM,iBAAiB,EAAE,KAAmF,CAAC;AACpH,eAAO,MAAM,kBAAkB,EAAE,KAAoF,CAAC;AACtH,eAAO,MAAM,6BAA6B,EAAE,KAA+F,CAAC;AAC5I,eAAO,MAAM,yBAAyB,EAAE,KAA2F,CAAC;AACpI,eAAO,MAAM,0BAA0B,EAAE,KAA4F,CAAC;AACtI,eAAO,MAAM,gBAAgB,EAAE,KAAkG,CAAC;AAGlI,eAAO,MAAM,aAAa,EAAE,KAAgK,CAAC;AAG7L,eAAO,MAAM,cAAc,EAAE,KAA2H,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalizedMarquee.d.ts","sourceRoot":"","sources":["../../../Examples/LocalizedMarquee.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"LocalizedMarquee.d.ts","sourceRoot":"","sources":["../../../Examples/LocalizedMarquee.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB,mCAc5B,CAAC"}
|
package/dist/cjs/Icons.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { ImportancePresentation } from './Selection/index.js';
|
|
2
|
+
export interface ChevronIconProps {
|
|
3
|
+
expanded: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare const ChevronIcon: ({ expanded }: ChevronIconProps) => import("react").JSX.Element;
|
|
2
6
|
export interface ImportanceIconProps {
|
|
3
7
|
presentation: ImportancePresentation;
|
|
4
8
|
}
|
package/dist/cjs/Icons.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icons.d.ts","sourceRoot":"","sources":["../../Icons.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAW9D,MAAM,WAAW,mBAAmB;IAEhC,YAAY,EAAE,sBAAsB,CAAC;CACxC;AAKD,eAAO,MAAM,cAAc,GAAI,kBAAkB,mBAAmB,gCAWnE,CAAC"}
|
|
1
|
+
{"version":3,"file":"Icons.d.ts","sourceRoot":"","sources":["../../Icons.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAW9D,MAAM,WAAW,gBAAgB;IAE7B,QAAQ,EAAE,OAAO,CAAC;CACrB;AAMD,eAAO,MAAM,WAAW,GAAI,cAAc,gBAAgB,gCAUzD,CAAC;AAKF,MAAM,WAAW,mBAAmB;IAEhC,YAAY,EAAE,sBAAsB,CAAC;CACxC;AAKD,eAAO,MAAM,cAAc,GAAI,kBAAkB,mBAAmB,gCAWnE,CAAC"}
|
package/dist/cjs/Icons.js
CHANGED
|
@@ -9,6 +9,21 @@ const paths = {
|
|
|
9
9
|
warning: 'M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z',
|
|
10
10
|
critical: 'M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* The chevron on the button of a banner that shows or hides its message. It is decorative: the button is named by its
|
|
14
|
+
* label and says whether it is expanded.
|
|
15
|
+
*/ const ChevronIcon = ({ expanded })=>/*#__PURE__*/ jsxRuntime.jsx("svg", {
|
|
16
|
+
className: expanded ? 'marquee-chevron marquee-chevron--expanded' : 'marquee-chevron',
|
|
17
|
+
viewBox: "0 0 24 24",
|
|
18
|
+
width: "1em",
|
|
19
|
+
height: "1em",
|
|
20
|
+
"aria-hidden": "true",
|
|
21
|
+
focusable: "false",
|
|
22
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
23
|
+
fill: "currentColor",
|
|
24
|
+
d: "M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"
|
|
25
|
+
})
|
|
26
|
+
});
|
|
12
27
|
/**
|
|
13
28
|
* The icon of an importance, named for screen readers so the level is read out with the announcement.
|
|
14
29
|
*/ const ImportanceIcon = ({ presentation })=>/*#__PURE__*/ jsxRuntime.jsx("svg", {
|
|
@@ -25,5 +40,6 @@ const paths = {
|
|
|
25
40
|
})
|
|
26
41
|
});
|
|
27
42
|
|
|
43
|
+
exports.ChevronIcon = ChevronIcon;
|
|
28
44
|
exports.ImportanceIcon = ImportanceIcon;
|
|
29
45
|
//# sourceMappingURL=Icons.js.map
|
package/dist/cjs/Icons.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icons.js","sources":["../../Icons.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ImportancePresentation } from './Selection/index.js';\n\nconst paths: Record<ImportancePresentation['modifier'], string> = {\n information: 'M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z',\n warning: 'M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z',\n critical: 'M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'\n};\n\n/**\n * Props for {@link ImportanceIcon}.\n */\nexport interface ImportanceIconProps {\n /** How the importance is presented. */\n presentation: ImportancePresentation;\n}\n\n/**\n * The icon of an importance, named for screen readers so the level is read out with the announcement.\n */\nexport const ImportanceIcon = ({ presentation }: ImportanceIconProps) => (\n <svg\n className={`marquee-icon marquee-icon--${presentation.modifier}`}\n viewBox='0 0 24 24'\n width='1em'\n height='1em'\n role='img'\n aria-label={presentation.label}\n focusable='false'>\n <path fill='currentColor' d={paths[presentation.modifier]} />\n </svg>\n);\n"],"names":["paths","information","warning","critical","
|
|
1
|
+
{"version":3,"file":"Icons.js","sources":["../../Icons.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ImportancePresentation } from './Selection/index.js';\n\nconst paths: Record<ImportancePresentation['modifier'], string> = {\n information: 'M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z',\n warning: 'M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z',\n critical: 'M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'\n};\n\n/**\n * Props for {@link ChevronIcon}.\n */\nexport interface ChevronIconProps {\n /** Whether the message it controls is shown; the chevron then points up instead of down. */\n expanded: boolean;\n}\n\n/**\n * The chevron on the button of a banner that shows or hides its message. It is decorative: the button is named by its\n * label and says whether it is expanded.\n */\nexport const ChevronIcon = ({ expanded }: ChevronIconProps) => (\n <svg\n className={expanded ? 'marquee-chevron marquee-chevron--expanded' : 'marquee-chevron'}\n viewBox='0 0 24 24'\n width='1em'\n height='1em'\n aria-hidden='true'\n focusable='false'>\n <path fill='currentColor' d='M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z' />\n </svg>\n);\n\n/**\n * Props for {@link ImportanceIcon}.\n */\nexport interface ImportanceIconProps {\n /** How the importance is presented. */\n presentation: ImportancePresentation;\n}\n\n/**\n * The icon of an importance, named for screen readers so the level is read out with the announcement.\n */\nexport const ImportanceIcon = ({ presentation }: ImportanceIconProps) => (\n <svg\n className={`marquee-icon marquee-icon--${presentation.modifier}`}\n viewBox='0 0 24 24'\n width='1em'\n height='1em'\n role='img'\n aria-label={presentation.label}\n focusable='false'>\n <path fill='currentColor' d={paths[presentation.modifier]} />\n </svg>\n);\n"],"names":["paths","information","warning","critical","ChevronIcon","expanded","_jsx","svg","className","viewBox","width","height","aria-hidden","focusable","path","fill","d","ImportanceIcon","presentation","modifier","role","aria-label","label"],"mappings":";;;;AAAA;AACA;AAIA,MAAMA,KAAAA,GAA4D;IAC9DC,WAAAA,EAAa,wEAAA;IACbC,OAAAA,EAAS,oDAAA;IACTC,QAAAA,EAAU;AACd,CAAA;AAUA;;;UAIaC,WAAAA,GAAc,CAAC,EAAEC,QAAQ,EAAoB,iBACtDC,cAAA,CAACC,KAAAA,EAAAA;AACGC,QAAAA,SAAAA,EAAWH,WAAW,2CAAA,GAA8C,iBAAA;QACpEI,OAAAA,EAAQ,WAAA;QACRC,KAAAA,EAAM,KAAA;QACNC,MAAAA,EAAO,KAAA;QACPC,aAAAA,EAAY,MAAA;QACZC,SAAAA,EAAU,OAAA;AACV,QAAA,QAAA,gBAAAP,cAAA,CAACQ,MAAAA,EAAAA;YAAKC,IAAAA,EAAK,cAAA;YAAeC,CAAAA,EAAE;;AAElC,KAAA;AAUF;;UAGaC,cAAAA,GAAiB,CAAC,EAAEC,YAAY,EAAuB,iBAChEZ,cAAA,CAACC,KAAAA,EAAAA;AACGC,QAAAA,SAAAA,EAAW,CAAC,2BAA2B,EAAEU,YAAAA,CAAaC,QAAQ,CAAA,CAAE;QAChEV,OAAAA,EAAQ,WAAA;QACRC,KAAAA,EAAM,KAAA;QACNC,MAAAA,EAAO,KAAA;QACPS,IAAAA,EAAK,KAAA;AACLC,QAAAA,YAAAA,EAAYH,aAAaI,KAAK;QAC9BT,SAAAA,EAAU,OAAA;AACV,QAAA,QAAA,gBAAAP,cAAA,CAACQ,MAAAA,EAAAA;YAAKC,IAAAA,EAAK,cAAA;AAAeC,YAAAA,CAAAA,EAAGhB,KAAK,CAACkB,YAAAA,CAAaC,QAAQ;;AAE9D,KAAA;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarqueeLabels.d.ts","sourceRoot":"","sources":["../../../Labels/MarqueeLabels.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,aAAa;IAE1B,OAAO,EAAE,MAAM,CAAC;IAGhB,WAAW,EAAE,MAAM,CAAC;IAGpB,IAAI,EAAE,MAAM,CAAC;IAGb,KAAK,EAAE,MAAM,CAAC;IAGd,WAAW,EAAE,MAAM,CAAC;IAGpB,OAAO,EAAE,MAAM,CAAC;IAGhB,QAAQ,EAAE,MAAM,CAAC;CACpB"}
|
|
1
|
+
{"version":3,"file":"MarqueeLabels.d.ts","sourceRoot":"","sources":["../../../Labels/MarqueeLabels.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,aAAa;IAE1B,OAAO,EAAE,MAAM,CAAC;IAGhB,WAAW,EAAE,MAAM,CAAC;IAGpB,IAAI,EAAE,MAAM,CAAC;IAGb,KAAK,EAAE,MAAM,CAAC;IAGd,MAAM,EAAE,MAAM,CAAC;IAGf,QAAQ,EAAE,MAAM,CAAC;IAGjB,WAAW,EAAE,MAAM,CAAC;IAGpB,OAAO,EAAE,MAAM,CAAC;IAGhB,QAAQ,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultMarqueeLabels.d.ts","sourceRoot":"","sources":["../../../Labels/defaultMarqueeLabels.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnD,eAAO,MAAM,oBAAoB,EAAE,
|
|
1
|
+
{"version":3,"file":"defaultMarqueeLabels.d.ts","sourceRoot":"","sources":["../../../Labels/defaultMarqueeLabels.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnD,eAAO,MAAM,oBAAoB,EAAE,aAUlC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultMarqueeLabels.js","sources":["../../../Labels/defaultMarqueeLabels.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { MarqueeLabels } from './MarqueeLabels.js';\n\n/**\n * The English texts Marquee shows without overrides.\n */\nexport const defaultMarqueeLabels: MarqueeLabels = {\n banners: 'Announcements',\n acknowledge: 'Got it',\n next: 'Next',\n close: 'Close',\n information: 'Information',\n warning: 'Warning',\n critical: 'Critical'\n};\n"],"names":["defaultMarqueeLabels","banners","acknowledge","next","close","information","warning","critical"],"mappings":";;AAAA;AACA;AAIA;;UAGaA,oBAAAA,GAAsC;IAC/CC,OAAAA,EAAS,eAAA;IACTC,WAAAA,EAAa,QAAA;IACbC,IAAAA,EAAM,MAAA;IACNC,KAAAA,EAAO,OAAA;IACPC,WAAAA,EAAa,aAAA;IACbC,OAAAA,EAAS,SAAA;IACTC,QAAAA,EAAU;AACd;;"}
|
|
1
|
+
{"version":3,"file":"defaultMarqueeLabels.js","sources":["../../../Labels/defaultMarqueeLabels.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { MarqueeLabels } from './MarqueeLabels.js';\n\n/**\n * The English texts Marquee shows without overrides.\n */\nexport const defaultMarqueeLabels: MarqueeLabels = {\n banners: 'Announcements',\n acknowledge: 'Got it',\n next: 'Next',\n close: 'Close',\n expand: 'Show the message',\n collapse: 'Hide the message',\n information: 'Information',\n warning: 'Warning',\n critical: 'Critical'\n};\n"],"names":["defaultMarqueeLabels","banners","acknowledge","next","close","expand","collapse","information","warning","critical"],"mappings":";;AAAA;AACA;AAIA;;UAGaA,oBAAAA,GAAsC;IAC/CC,OAAAA,EAAS,eAAA;IACTC,WAAAA,EAAa,QAAA;IACbC,IAAAA,EAAM,MAAA;IACNC,KAAAA,EAAO,OAAA;IACPC,MAAAA,EAAQ,kBAAA;IACRC,QAAAA,EAAU,kBAAA;IACVC,WAAAA,EAAa,aAAA;IACbC,OAAAA,EAAS,SAAA;IACTC,QAAAA,EAAU;AACd;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarqueeInlineMarkdown.d.ts","sourceRoot":"","sources":["../../../Markdown/MarqueeInlineMarkdown.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAQtC,MAAM,WAAW,0BAA0B;IAEvC,MAAM,EAAE,MAAM,CAAC;CAClB;AAWD,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC,0BAA0B,CAW3E,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var ReactMarkdown = require('react-markdown');
|
|
5
|
+
var MarqueeLink = require('./MarqueeLink.js');
|
|
6
|
+
var safeLink = require('./safeLink.js');
|
|
7
|
+
|
|
8
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
9
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
10
|
+
const inlineElements = [
|
|
11
|
+
'a',
|
|
12
|
+
'em',
|
|
13
|
+
'strong',
|
|
14
|
+
'code'
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* Renders the inline Markdown of an announcement title, `Maintenance tonight. [Read more here.](https://status.example.com)`,
|
|
18
|
+
* as React elements inside a `span`: links, emphasis and code only. Block elements, such as paragraphs, headings, lists
|
|
19
|
+
* and code blocks, are not rendered, and their text runs on in the line. It follows the same safety rules as
|
|
20
|
+
* {@link MarqueeMarkdown}: raw HTML is dropped, images are left out, a link opens in a new tab with `noopener noreferrer`,
|
|
21
|
+
* and only `https`, `mailto` and `tel` links are links at all.
|
|
22
|
+
*/ const MarqueeInlineMarkdown = ({ source })=>/*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
23
|
+
className: "marquee-inline-markdown",
|
|
24
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(ReactMarkdown, {
|
|
25
|
+
skipHtml: true,
|
|
26
|
+
allowedElements: inlineElements,
|
|
27
|
+
unwrapDisallowed: true,
|
|
28
|
+
urlTransform: safeLink.safeLinkOrEmpty,
|
|
29
|
+
components: {
|
|
30
|
+
a: MarqueeLink.MarqueeLink
|
|
31
|
+
},
|
|
32
|
+
children: source
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
exports.MarqueeInlineMarkdown = MarqueeInlineMarkdown;
|
|
37
|
+
//# sourceMappingURL=MarqueeInlineMarkdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarqueeInlineMarkdown.js","sources":["../../../Markdown/MarqueeInlineMarkdown.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ComponentType } from 'react';\nimport ReactMarkdown from 'react-markdown';\nimport { MarqueeLink } from './MarqueeLink.js';\nimport { safeLinkOrEmpty } from './safeLink.js';\n\n/**\n * Props for {@link MarqueeInlineMarkdown}.\n */\nexport interface MarqueeInlineMarkdownProps {\n /** The inline Markdown source, such as the title of an announcement. */\n source: string;\n}\n\nconst inlineElements = ['a', 'em', 'strong', 'code'];\n\n/**\n * Renders the inline Markdown of an announcement title, `Maintenance tonight. [Read more here.](https://status.example.com)`,\n * as React elements inside a `span`: links, emphasis and code only. Block elements, such as paragraphs, headings, lists\n * and code blocks, are not rendered, and their text runs on in the line. It follows the same safety rules as\n * {@link MarqueeMarkdown}: raw HTML is dropped, images are left out, a link opens in a new tab with `noopener noreferrer`,\n * and only `https`, `mailto` and `tel` links are links at all.\n */\nexport const MarqueeInlineMarkdown: ComponentType<MarqueeInlineMarkdownProps> = ({ source }: MarqueeInlineMarkdownProps) => (\n <span className='marquee-inline-markdown'>\n <ReactMarkdown\n skipHtml\n allowedElements={inlineElements}\n unwrapDisallowed\n urlTransform={safeLinkOrEmpty}\n components={{ a: MarqueeLink }}>\n {source}\n </ReactMarkdown>\n </span>\n);\n"],"names":["inlineElements","MarqueeInlineMarkdown","source","_jsx","span","className","ReactMarkdown","skipHtml","allowedElements","unwrapDisallowed","urlTransform","safeLinkOrEmpty","components","a","MarqueeLink"],"mappings":";;;;;;;AAAA;AACA;AAeA,MAAMA,cAAAA,GAAiB;AAAC,IAAA,GAAA;AAAK,IAAA,IAAA;AAAM,IAAA,QAAA;AAAU,IAAA;AAAO,CAAA;AAEpD;;;;;;UAOaC,qBAAAA,GAAmE,CAAC,EAAEC,MAAM,EAA8B,iBACnHC,cAAA,CAACC,MAAAA,EAAAA;QAAKC,SAAAA,EAAU,yBAAA;AACZ,QAAA,QAAA,gBAAAF,cAAA,CAACG,aAAAA,EAAAA;YACGC,QAAQ,EAAA,IAAA;YACRC,eAAAA,EAAiBR,cAAAA;YACjBS,gBAAgB,EAAA,IAAA;YAChBC,YAAAA,EAAcC,wBAAAA;YACdC,UAAAA,EAAY;gBAAEC,CAAAA,EAAGC;AAAY,aAAA;AAC5BZ,YAAAA,QAAAA,EAAAA;;AAGX,KAAA;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarqueeLink.d.ts","sourceRoot":"","sources":["../../../Markdown/MarqueeLink.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvC,KAAK,SAAS,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;AAMrC,eAAO,MAAM,WAAW,GAAI,2BAA2B,SAAS,gCAEnC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
|
|
5
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
6
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
7
|
+
/**
|
|
8
|
+
* A link in an announcement: it opens in a new tab with `noopener noreferrer`. A link that is not safe has no `href`
|
|
9
|
+
* left, because the URL transform emptied it, and is only its text.
|
|
10
|
+
*/ const MarqueeLink = ({ href, title, children })=>href ? /*#__PURE__*/ jsxRuntime.jsx("a", {
|
|
11
|
+
href: href,
|
|
12
|
+
title: title,
|
|
13
|
+
target: "_blank",
|
|
14
|
+
rel: "noopener noreferrer",
|
|
15
|
+
children: children
|
|
16
|
+
}) : /*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
17
|
+
children: children
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
exports.MarqueeLink = MarqueeLink;
|
|
21
|
+
//# sourceMappingURL=MarqueeLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarqueeLink.js","sources":["../../../Markdown/MarqueeLink.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ComponentProps } from 'react';\n\ntype LinkProps = ComponentProps<'a'>;\n\n/**\n * A link in an announcement: it opens in a new tab with `noopener noreferrer`. A link that is not safe has no `href`\n * left, because the URL transform emptied it, and is only its text.\n */\nexport const MarqueeLink = ({ href, title, children }: LinkProps) => href\n ? <a href={href} title={title} target='_blank' rel='noopener noreferrer'>{children}</a>\n : <span>{children}</span>;\n"],"names":["MarqueeLink","href","title","children","_jsx","a","target","rel","span"],"mappings":";;;;AAAA;AACA;AAMA;;;AAGC,IACM,MAAMA,WAAAA,GAAc,CAAC,EAAEC,IAAI,EAAEC,KAAK,EAAEC,QAAQ,EAAa,GAAKF,qBAC/DG,cAAA,CAACC,GAAAA,EAAAA;QAAEJ,IAAAA,EAAMA,IAAAA;QAAMC,KAAAA,EAAOA,KAAAA;QAAOI,MAAAA,EAAO,QAAA;QAASC,GAAAA,EAAI,qBAAA;AAAuBJ,QAAAA,QAAAA,EAAAA;uBACxEC,cAAA,CAACI,MAAAA,EAAAA;AAAML,QAAAA,QAAAA,EAAAA;AAAiB,KAAA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarqueeMarkdown.d.ts","sourceRoot":"","sources":["../../../Markdown/MarqueeMarkdown.tsx"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"MarqueeMarkdown.d.ts","sourceRoot":"","sources":["../../../Markdown/MarqueeMarkdown.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAStC,MAAM,WAAW,oBAAoB;IAEjC,MAAM,EAAE,MAAM,CAAC;IAGf,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAOD,eAAO,MAAM,eAAe,EAAE,aAAa,CAAC,oBAAoB,CAU/D,CAAC"}
|
|
@@ -2,19 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var ReactMarkdown = require('react-markdown');
|
|
5
|
+
var MarqueeLink = require('./MarqueeLink.js');
|
|
5
6
|
var safeLink = require('./safeLink.js');
|
|
6
7
|
|
|
7
8
|
// Copyright (c) Cratis. All rights reserved.
|
|
8
9
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
9
|
-
const Link = ({ href, title, children })=>href ? /*#__PURE__*/ jsxRuntime.jsx("a", {
|
|
10
|
-
href: href,
|
|
11
|
-
title: title,
|
|
12
|
-
target: "_blank",
|
|
13
|
-
rel: "noopener noreferrer",
|
|
14
|
-
children: children
|
|
15
|
-
}) : /*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
16
|
-
children: children
|
|
17
|
-
});
|
|
18
10
|
/**
|
|
19
11
|
* Renders the Markdown of an announcement as React elements, never as injected HTML: raw HTML in the source is
|
|
20
12
|
* dropped, images are left out, a link opens in a new tab with `noopener noreferrer`, and only `https`, `mailto`
|
|
@@ -28,7 +20,7 @@ const Link = ({ href, title, children })=>href ? /*#__PURE__*/ jsxRuntime.jsx("a
|
|
|
28
20
|
],
|
|
29
21
|
urlTransform: safeLink.safeLinkOrEmpty,
|
|
30
22
|
components: {
|
|
31
|
-
a:
|
|
23
|
+
a: MarqueeLink.MarqueeLink
|
|
32
24
|
},
|
|
33
25
|
children: source
|
|
34
26
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarqueeMarkdown.js","sources":["../../../Markdown/MarqueeMarkdown.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport {
|
|
1
|
+
{"version":3,"file":"MarqueeMarkdown.js","sources":["../../../Markdown/MarqueeMarkdown.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ComponentType } from 'react';\nimport ReactMarkdown from 'react-markdown';\nimport { MarqueeLink } from './MarqueeLink.js';\nimport { safeLinkOrEmpty } from './safeLink.js';\n\n/**\n * Props for the component that renders the Markdown body of an announcement. Give your own to the `markdown` slot of\n * {@link Marquee}.\n */\nexport interface MarqueeMarkdownProps {\n /** The Markdown source. */\n source: string;\n\n /** Whether to render inline, as the banner does: paragraphs run together and take no space between them. */\n compact?: boolean;\n}\n\n/**\n * Renders the Markdown of an announcement as React elements, never as injected HTML: raw HTML in the source is\n * dropped, images are left out, a link opens in a new tab with `noopener noreferrer`, and only `https`, `mailto`\n * and `tel` links are links at all.\n */\nexport const MarqueeMarkdown: ComponentType<MarqueeMarkdownProps> = ({ source, compact = false }: MarqueeMarkdownProps) => (\n <div className={compact ? 'marquee-markdown marquee-markdown--compact' : 'marquee-markdown'}>\n <ReactMarkdown\n skipHtml\n disallowedElements={['img']}\n urlTransform={safeLinkOrEmpty}\n components={{ a: MarqueeLink }}>\n {source}\n </ReactMarkdown>\n </div>\n);\n"],"names":["MarqueeMarkdown","source","compact","_jsx","div","className","ReactMarkdown","skipHtml","disallowedElements","urlTransform","safeLinkOrEmpty","components","a","MarqueeLink"],"mappings":";;;;;;;AAAA;AACA;AAmBA;;;;IAKO,MAAMA,eAAAA,GAAuD,CAAC,EAAEC,MAAM,EAAEC,OAAAA,GAAU,KAAK,EAAwB,iBAClHC,cAAA,CAACC,KAAAA,EAAAA;AAAIC,QAAAA,SAAAA,EAAWH,UAAU,4CAAA,GAA+C,kBAAA;AACrE,QAAA,QAAA,gBAAAC,cAAA,CAACG,aAAAA,EAAAA;YACGC,QAAQ,EAAA,IAAA;YACRC,kBAAAA,EAAoB;AAAC,gBAAA;AAAM,aAAA;YAC3BC,YAAAA,EAAcC,wBAAAA;YACdC,UAAAA,EAAY;gBAAEC,CAAAA,EAAGC;AAAY,aAAA;AAC5BZ,YAAAA,QAAAA,EAAAA;;AAGX,KAAA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Markdown/index.ts"],"names":[],"mappings":"AAGA,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Markdown/index.ts"],"names":[],"mappings":"AAGA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownText.d.ts","sourceRoot":"","sources":["../../../Markdown/markdownText.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,mBAAmB,GAAI,QAAQ,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,MAuBvE,CAAC;AAQF,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,MAAM,IAAI,MAA8C,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
4
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
|
+
const codeMarker = '\u0000';
|
|
6
|
+
const codeSpan = /(`+)([\s\S]*?[^`])\1(?!`)/g;
|
|
7
|
+
const urlInParentheses = String.raw`\((?:[^()]|\([^()]*\))*\)`;
|
|
8
|
+
/**
|
|
9
|
+
* Turns the inline Markdown of an announcement title into the plain text a screen reader, a document title or an
|
|
10
|
+
* `aria-label` should get: a link keeps its text and loses its address, emphasis and code lose their markers, an image
|
|
11
|
+
* keeps its alternative text, and raw HTML tags are dropped.
|
|
12
|
+
* @param source The title as written, possibly with inline Markdown.
|
|
13
|
+
* @returns The text without Markdown, with white space collapsed.
|
|
14
|
+
*/ const markdownToPlainText = (source)=>{
|
|
15
|
+
if (!source) {
|
|
16
|
+
return '';
|
|
17
|
+
}
|
|
18
|
+
const codes = [];
|
|
19
|
+
const withoutCode = source.replace(codeSpan, (_, __, code)=>{
|
|
20
|
+
codes.push(code.trim());
|
|
21
|
+
return `${codeMarker}${codes.length - 1}${codeMarker}`;
|
|
22
|
+
});
|
|
23
|
+
const plain = withoutCode.replace(new RegExp(String.raw`!\[([^\]]*)\]${urlInParentheses}`, 'g'), '$1').replace(new RegExp(String.raw`\[([^\]]*)\]${urlInParentheses}`, 'g'), '$1').replace(/<((?:https?:\/\/|mailto:|tel:)[^>\s]+)>/g, '$1').replace(/<\/?[a-zA-Z][^>]*>/g, '').replace(/(\*\*|__)(?=\S)([\s\S]*?\S)\1/g, '$2').replace(/(\*)(?=\S)([\s\S]*?\S)\1/g, '$2').replace(/(^|[^\p{L}\p{N}_])_(?=\S)([\s\S]*?\S)_(?![\p{L}\p{N}_])/gu, '$1$2').replace(/\\([\\`*_{}[\]()#+\-.!~<>|])/g, '$1').replace(new RegExp(`${codeMarker}(\\d+)${codeMarker}`, 'g'), (_, index)=>codes[Number(index)]);
|
|
24
|
+
return plain.replace(/\s+/g, ' ').trim();
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Whether there is anything to show in a Markdown text: the message of an announcement is optional, and a message of
|
|
28
|
+
* only white space is the same as none.
|
|
29
|
+
* @param source The Markdown as written, or nothing.
|
|
30
|
+
* @returns True when there is text.
|
|
31
|
+
*/ const hasMarkdown = (source)=>!!source && source.trim().length > 0;
|
|
32
|
+
|
|
33
|
+
exports.hasMarkdown = hasMarkdown;
|
|
34
|
+
exports.markdownToPlainText = markdownToPlainText;
|
|
35
|
+
//# sourceMappingURL=markdownText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownText.js","sources":["../../../Markdown/markdownText.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nconst codeMarker = '\\u0000';\nconst codeSpan = /(`+)([\\s\\S]*?[^`])\\1(?!`)/g;\nconst urlInParentheses = String.raw`\\((?:[^()]|\\([^()]*\\))*\\)`;\n\n/**\n * Turns the inline Markdown of an announcement title into the plain text a screen reader, a document title or an\n * `aria-label` should get: a link keeps its text and loses its address, emphasis and code lose their markers, an image\n * keeps its alternative text, and raw HTML tags are dropped.\n * @param source The title as written, possibly with inline Markdown.\n * @returns The text without Markdown, with white space collapsed.\n */\nexport const markdownToPlainText = (source: string | null | undefined): string => {\n if (!source) {\n return '';\n }\n\n const codes: string[] = [];\n const withoutCode = source.replace(codeSpan, (_, __, code: string) => {\n codes.push(code.trim());\n return `${codeMarker}${codes.length - 1}${codeMarker}`;\n });\n\n const plain = withoutCode\n .replace(new RegExp(String.raw`!\\[([^\\]]*)\\]${urlInParentheses}`, 'g'), '$1')\n .replace(new RegExp(String.raw`\\[([^\\]]*)\\]${urlInParentheses}`, 'g'), '$1')\n .replace(/<((?:https?:\\/\\/|mailto:|tel:)[^>\\s]+)>/g, '$1')\n .replace(/<\\/?[a-zA-Z][^>]*>/g, '')\n .replace(/(\\*\\*|__)(?=\\S)([\\s\\S]*?\\S)\\1/g, '$2')\n .replace(/(\\*)(?=\\S)([\\s\\S]*?\\S)\\1/g, '$2')\n .replace(/(^|[^\\p{L}\\p{N}_])_(?=\\S)([\\s\\S]*?\\S)_(?![\\p{L}\\p{N}_])/gu, '$1$2')\n .replace(/\\\\([\\\\`*_{}[\\]()#+\\-.!~<>|])/g, '$1')\n .replace(new RegExp(`${codeMarker}(\\\\d+)${codeMarker}`, 'g'), (_, index: string) => codes[Number(index)]);\n\n return plain.replace(/\\s+/g, ' ').trim();\n};\n\n/**\n * Whether there is anything to show in a Markdown text: the message of an announcement is optional, and a message of\n * only white space is the same as none.\n * @param source The Markdown as written, or nothing.\n * @returns True when there is text.\n */\nexport const hasMarkdown = (source: string | null | undefined): source is string => !!source && source.trim().length > 0;\n"],"names":["codeMarker","codeSpan","urlInParentheses","String","raw","markdownToPlainText","source","codes","withoutCode","replace","_","__","code","push","trim","length","plain","RegExp","index","Number","hasMarkdown"],"mappings":";;AAAA;AACA;AAEA,MAAMA,UAAAA,GAAa,QAAA;AACnB,MAAMC,QAAAA,GAAW,4BAAA;AACjB,MAAMC,gBAAAA,GAAmBC,MAAAA,CAAOC,GAAG,CAAC,yBAAyB,CAAC;AAE9D;;;;;;IAOO,MAAMC,mBAAAA,GAAsB,CAACC,MAAAA,GAAAA;AAChC,IAAA,IAAI,CAACA,MAAAA,EAAQ;QACT,OAAO,EAAA;AACX,IAAA;AAEA,IAAA,MAAMC,QAAkB,EAAE;AAC1B,IAAA,MAAMC,cAAcF,MAAAA,CAAOG,OAAO,CAACR,QAAAA,EAAU,CAACS,GAAGC,EAAAA,EAAIC,IAAAA,GAAAA;QACjDL,KAAAA,CAAMM,IAAI,CAACD,IAAAA,CAAKE,IAAI,EAAA,CAAA;AACpB,QAAA,OAAO,GAAGd,UAAAA,CAAAA,EAAaO,KAAAA,CAAMQ,MAAM,GAAG,IAAIf,UAAAA,CAAAA,CAAY;AAC1D,IAAA,CAAA,CAAA;AAEA,IAAA,MAAMgB,KAAAA,GAAQR,WAAAA,CACTC,OAAO,CAAC,IAAIQ,MAAAA,CAAOd,MAAAA,CAAOC,GAAG,CAAC,aAAa,EAAEF,gBAAAA,CAAiB,CAAC,EAAE,GAAA,CAAA,EAAM,IAAA,CAAA,CACvEO,OAAO,CAAC,IAAIQ,MAAAA,CAAOd,MAAAA,CAAOC,GAAG,CAAC,YAAY,EAAEF,gBAAAA,CAAiB,CAAC,EAAE,GAAA,CAAA,EAAM,IAAA,CAAA,CACtEO,OAAO,CAAC,4CAA4C,IAAA,CAAA,CACpDA,OAAO,CAAC,qBAAA,EAAuB,EAAA,CAAA,CAC/BA,OAAO,CAAC,gCAAA,EAAkC,MAC1CA,OAAO,CAAC,2BAAA,EAA6B,IAAA,CAAA,CACrCA,OAAO,CAAC,2DAAA,EAA6D,MAAA,CAAA,CACrEA,OAAO,CAAC,+BAAA,EAAiC,IAAA,CAAA,CACzCA,OAAO,CAAC,IAAIQ,MAAAA,CAAO,CAAA,EAAGjB,UAAAA,CAAW,MAAM,EAAEA,UAAAA,CAAAA,CAAY,EAAE,GAAA,CAAA,EAAM,CAACU,CAAAA,EAAGQ,KAAAA,GAAkBX,KAAK,CAACY,OAAOD,KAAAA,CAAAA,CAAO,CAAA;AAE5G,IAAA,OAAOF,KAAAA,CAAMP,OAAO,CAAC,MAAA,EAAQ,KAAKK,IAAI,EAAA;AAC1C;AAEA;;;;;AAKC,IACM,MAAMM,WAAAA,GAAc,CAACd,MAAAA,GAAwD,CAAC,CAACA,MAAAA,IAAUA,MAAAA,CAAOQ,IAAI,EAAA,CAAGC,MAAM,GAAG;;;"}
|
package/dist/cjs/Marquee.js
CHANGED
|
@@ -5,6 +5,7 @@ var react = require('react');
|
|
|
5
5
|
var MarqueeBanner = require('./Banner/MarqueeBanner.js');
|
|
6
6
|
var MarqueeDialog = require('./Dialog/MarqueeDialog.js');
|
|
7
7
|
var resolveLabels = require('./Labels/resolveLabels.js');
|
|
8
|
+
require('react-markdown');
|
|
8
9
|
var MarqueeMarkdown = require('./Markdown/MarqueeMarkdown.js');
|
|
9
10
|
var useAnnouncements = require('./useAnnouncements.js');
|
|
10
11
|
|
package/dist/cjs/Marquee.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Marquee.js","sources":["../../Marquee.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { AnnouncementForMe } from '@cratis/showrunner.marquee';\nimport { ComponentType, useMemo } from 'react';\nimport { MarqueeBanner, MarqueeBannerProps } from './Banner/index.js';\nimport { MarqueeDialog, MarqueeDialogProps } from './Dialog/index.js';\nimport { MarqueeLabels, resolveLabels } from './Labels/index.js';\nimport { MarqueeMarkdown, MarqueeMarkdownProps } from './Markdown/index.js';\nimport { useAnnouncements } from './useAnnouncements.js';\n\n/**\n * Props for {@link Marquee}.\n */\nexport interface MarqueeProps {\n /** Replaces the banners. Gets every banner to show, and draws them all. */\n banner?: ComponentType<MarqueeBannerProps>;\n\n /** Replaces the dialog. Gets one dialog at a time, the most important first. */\n dialog?: ComponentType<MarqueeDialogProps>;\n\n /** Replaces the Markdown renderer the default banner and dialog use, and that a custom one is given. */\n markdown?: ComponentType<MarqueeMarkdownProps>;\n\n /** The texts to replace; the rest stay English. */\n labels?: Partial<MarqueeLabels>;\n\n /** How often to apply the windows of the announcements against the clock, in milliseconds. Defaults to 60 seconds. */\n checkInterval?: number;\n}\n\n/**\n * Shows the announcements of a product the way its people expect: banners at the top, and dialogs one at a time. Mount\n * it once, first in the application shell and inside Arc's context; it brings its own queries and commands, so it needs\n * nothing but the backend package `Cratis.Showrunner.Marquee`.\n */\nexport const Marquee = ({ banner: Banner = MarqueeBanner, dialog: Dialog = MarqueeDialog, markdown = MarqueeMarkdown, labels, checkInterval }: MarqueeProps) => {\n const { banners, dialogs, close } = useAnnouncements({ checkInterval });\n const resolvedLabels = useMemo(() => resolveLabels(labels), [labels]);\n const [dialog, ...rest]: (AnnouncementForMe | undefined)[] = dialogs;\n\n return (\n <>\n <Banner announcements={banners} labels={resolvedLabels} markdown={markdown} />\n {dialog && (\n <Dialog\n key={dialog.id.toString()}\n announcement={dialog}\n hasMore={rest.length > 0}\n onClose={() => void close(dialog)}\n labels={resolvedLabels}\n markdown={markdown} />\n )}\n </>\n );\n};\n"],"names":["Marquee","banner","Banner","MarqueeBanner","dialog","Dialog","MarqueeDialog","markdown","MarqueeMarkdown","labels","checkInterval","banners","dialogs","close","useAnnouncements","resolvedLabels","useMemo","resolveLabels","rest","_jsxs","_Fragment","_jsx","announcements","announcement","hasMore","length","onClose","id","toString"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Marquee.js","sources":["../../Marquee.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { AnnouncementForMe } from '@cratis/showrunner.marquee';\nimport { ComponentType, useMemo } from 'react';\nimport { MarqueeBanner, MarqueeBannerProps } from './Banner/index.js';\nimport { MarqueeDialog, MarqueeDialogProps } from './Dialog/index.js';\nimport { MarqueeLabels, resolveLabels } from './Labels/index.js';\nimport { MarqueeMarkdown, MarqueeMarkdownProps } from './Markdown/index.js';\nimport { useAnnouncements } from './useAnnouncements.js';\n\n/**\n * Props for {@link Marquee}.\n */\nexport interface MarqueeProps {\n /** Replaces the banners. Gets every banner to show, and draws them all. */\n banner?: ComponentType<MarqueeBannerProps>;\n\n /** Replaces the dialog. Gets one dialog at a time, the most important first. */\n dialog?: ComponentType<MarqueeDialogProps>;\n\n /** Replaces the Markdown renderer the default banner and dialog use, and that a custom one is given. */\n markdown?: ComponentType<MarqueeMarkdownProps>;\n\n /** The texts to replace; the rest stay English. */\n labels?: Partial<MarqueeLabels>;\n\n /** How often to apply the windows of the announcements against the clock, in milliseconds. Defaults to 60 seconds. */\n checkInterval?: number;\n}\n\n/**\n * Shows the announcements of a product the way its people expect: banners at the top, and dialogs one at a time. Mount\n * it once, first in the application shell and inside Arc's context; it brings its own queries and commands, so it needs\n * nothing but the backend package `Cratis.Showrunner.Marquee`.\n */\nexport const Marquee = ({ banner: Banner = MarqueeBanner, dialog: Dialog = MarqueeDialog, markdown = MarqueeMarkdown, labels, checkInterval }: MarqueeProps) => {\n const { banners, dialogs, close } = useAnnouncements({ checkInterval });\n const resolvedLabels = useMemo(() => resolveLabels(labels), [labels]);\n const [dialog, ...rest]: (AnnouncementForMe | undefined)[] = dialogs;\n\n return (\n <>\n <Banner announcements={banners} labels={resolvedLabels} markdown={markdown} />\n {dialog && (\n <Dialog\n key={dialog.id.toString()}\n announcement={dialog}\n hasMore={rest.length > 0}\n onClose={() => void close(dialog)}\n labels={resolvedLabels}\n markdown={markdown} />\n )}\n </>\n );\n};\n"],"names":["Marquee","banner","Banner","MarqueeBanner","dialog","Dialog","MarqueeDialog","markdown","MarqueeMarkdown","labels","checkInterval","banners","dialogs","close","useAnnouncements","resolvedLabels","useMemo","resolveLabels","rest","_jsxs","_Fragment","_jsx","announcements","announcement","hasMore","length","onClose","id","toString"],"mappings":";;;;;;;;;;;AAAA;AACA;AA8BA;;;;AAIC,IACM,MAAMA,OAAAA,GAAU,CAAC,EAAEC,MAAAA,EAAQC,SAASC,2BAAa,EAAEC,QAAQC,MAAAA,GAASC,2BAAa,EAAEC,QAAAA,GAAWC,+BAAe,EAAEC,MAAM,EAAEC,aAAa,EAAgB,GAAA;IACvJ,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAEC,KAAK,EAAE,GAAGC,iCAAAA,CAAiB;AAAEJ,QAAAA;AAAc,KAAA,CAAA;AACrE,IAAA,MAAMK,cAAAA,GAAiBC,aAAAA,CAAQ,IAAMC,2BAAAA,CAAcR,MAAAA,CAAAA,EAAS;AAACA,QAAAA;AAAO,KAAA,CAAA;AACpE,IAAA,MAAM,CAACL,MAAAA,EAAQ,GAAGc,IAAAA,CAAK,GAAsCN,OAAAA;IAE7D,qBACIO,eAAA,CAAAC,mBAAA,EAAA;;0BACIC,cAAA,CAACnB,MAAAA,EAAAA;gBAAOoB,aAAAA,EAAeX,OAAAA;gBAASF,MAAAA,EAAQM,cAAAA;gBAAgBR,QAAAA,EAAUA;;AACjEH,YAAAA,MAAAA,kBACGiB,cAAA,CAAChB,MAAAA,EAAAA;gBAEGkB,YAAAA,EAAcnB,MAAAA;gBACdoB,OAAAA,EAASN,IAAAA,CAAKO,MAAM,GAAG,CAAA;gBACvBC,OAAAA,EAAS,IAAM,KAAKb,KAAAA,CAAMT,MAAAA,CAAAA;gBAC1BK,MAAAA,EAAQM,cAAAA;gBACRR,QAAAA,EAAUA;eALLH,MAAAA,CAAOuB,EAAE,CAACC,QAAQ,EAAA;;;AAS3C;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"announcementSelection.d.ts","sourceRoot":"","sources":["../../../Selection/announcementSelection.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAW,MAAM,4BAA4B,CAAC;AAKxE,MAAM,WAAW,qBAAqB;IAElC,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAG7B,OAAO,EAAE,iBAAiB,EAAE,CAAC;CAChC;
|
|
1
|
+
{"version":3,"file":"announcementSelection.d.ts","sourceRoot":"","sources":["../../../Selection/announcementSelection.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAW,MAAM,4BAA4B,CAAC;AAKxE,MAAM,WAAW,qBAAqB;IAElC,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAG7B,OAAO,EAAE,iBAAiB,EAAE,CAAC;CAChC;AAwBD,eAAO,MAAM,UAAU,GAAI,cAAc,iBAAiB,EAAE,KAAK,IAAI,KAAG,OACS,CAAC;AAiBlF,eAAO,MAAM,mBAAmB,GAAI,eAAe,iBAAiB,EAAE,EAAE,KAAK,IAAI,EAAE,WAAW,WAAW,CAAC,MAAM,CAAC,KAAG,qBASnH,CAAC"}
|
|
@@ -4,14 +4,26 @@ var showrunner_marquee = require('@cratis/showrunner.marquee');
|
|
|
4
4
|
|
|
5
5
|
// Copyright (c) Cratis. All rights reserved.
|
|
6
6
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
7
|
+
// Both ends of the window are optional. The backend sends the earliest date for an announcement that starts
|
|
8
|
+
// immediately and the latest for one that never ends; a date that is missing or not a date is read the same way.
|
|
9
|
+
const startOf = (announcement)=>{
|
|
10
|
+
const time = announcement.activeFrom?.getTime();
|
|
11
|
+
return time === undefined || Number.isNaN(time) ? Number.NEGATIVE_INFINITY : time;
|
|
12
|
+
};
|
|
13
|
+
const endOf = (announcement)=>{
|
|
14
|
+
const time = announcement.activeUntil?.getTime();
|
|
15
|
+
return time === undefined || Number.isNaN(time) ? Number.POSITIVE_INFINITY : time;
|
|
16
|
+
};
|
|
17
|
+
const compareTimes = (first, second)=>first === second ? 0 : first < second ? -1 : 1;
|
|
7
18
|
/**
|
|
8
19
|
* Whether an announcement is inside its window at a moment. The window starts at `activeFrom` and ends just before
|
|
9
|
-
* `activeUntil`, so an announcement that ends at 18:00 is gone at 18:00.
|
|
20
|
+
* `activeUntil`, so an announcement that ends at 18:00 is gone at 18:00. An announcement without a start is shown from
|
|
21
|
+
* the beginning, and one without an end is shown until it is withdrawn: it is permanent.
|
|
10
22
|
* @param announcement The announcement.
|
|
11
23
|
* @param now The moment.
|
|
12
24
|
* @returns True when it is to be shown.
|
|
13
|
-
*/ const isActiveAt = (announcement, now)=>announcement
|
|
14
|
-
const byImportanceThenWindow = (first, second)=>second.importance - first.importance || first
|
|
25
|
+
*/ const isActiveAt = (announcement, now)=>startOf(announcement) <= now.getTime() && now.getTime() < endOf(announcement);
|
|
26
|
+
const byImportanceThenWindow = (first, second)=>second.importance - first.importance || compareTimes(startOf(first), startOf(second)) || first.id.toString().localeCompare(second.id.toString());
|
|
15
27
|
/**
|
|
16
28
|
* Decides what is on screen from the announcements the backend returned, the clock and what the person closed.
|
|
17
29
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"announcementSelection.js","sources":["../../../Selection/announcementSelection.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { AnnouncementForMe, Display } from '@cratis/showrunner.marquee';\n\n/**\n * What of the announcements a person is to see is on screen right now.\n */\nexport interface AnnouncementSelection {\n /** The banners to show, the most important first. */\n banners: AnnouncementForMe[];\n\n /** The dialogs to show one at a time, the most important first. Only the first is open. */\n dialogs: AnnouncementForMe[];\n}\n\n/**\n * Whether an announcement is inside its window at a moment. The window starts at `activeFrom` and ends just before\n * `activeUntil`, so an announcement that ends at 18:00 is gone at 18:00.\n * @param announcement The announcement.\n * @param now The moment.\n * @returns True when it is to be shown.\n */\nexport const isActiveAt = (announcement: AnnouncementForMe, now: Date): boolean =>\n announcement
|
|
1
|
+
{"version":3,"file":"announcementSelection.js","sources":["../../../Selection/announcementSelection.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { AnnouncementForMe, Display } from '@cratis/showrunner.marquee';\n\n/**\n * What of the announcements a person is to see is on screen right now.\n */\nexport interface AnnouncementSelection {\n /** The banners to show, the most important first. */\n banners: AnnouncementForMe[];\n\n /** The dialogs to show one at a time, the most important first. Only the first is open. */\n dialogs: AnnouncementForMe[];\n}\n\n// Both ends of the window are optional. The backend sends the earliest date for an announcement that starts\n// immediately and the latest for one that never ends; a date that is missing or not a date is read the same way.\nconst startOf = (announcement: AnnouncementForMe): number => {\n const time = announcement.activeFrom?.getTime();\n return time === undefined || Number.isNaN(time) ? Number.NEGATIVE_INFINITY : time;\n};\n\nconst endOf = (announcement: AnnouncementForMe): number => {\n const time = announcement.activeUntil?.getTime();\n return time === undefined || Number.isNaN(time) ? Number.POSITIVE_INFINITY : time;\n};\n\nconst compareTimes = (first: number, second: number): number => first === second ? 0 : first < second ? -1 : 1;\n\n/**\n * Whether an announcement is inside its window at a moment. The window starts at `activeFrom` and ends just before\n * `activeUntil`, so an announcement that ends at 18:00 is gone at 18:00. An announcement without a start is shown from\n * the beginning, and one without an end is shown until it is withdrawn: it is permanent.\n * @param announcement The announcement.\n * @param now The moment.\n * @returns True when it is to be shown.\n */\nexport const isActiveAt = (announcement: AnnouncementForMe, now: Date): boolean =>\n startOf(announcement) <= now.getTime() && now.getTime() < endOf(announcement);\n\nconst byImportanceThenWindow = (first: AnnouncementForMe, second: AnnouncementForMe): number =>\n (second.importance - first.importance)\n || compareTimes(startOf(first), startOf(second))\n || first.id.toString().localeCompare(second.id.toString());\n\n/**\n * Decides what is on screen from the announcements the backend returned, the clock and what the person closed.\n *\n * A banner is shown for as long as its window lasts: it can not be closed. A dialog is shown until it is closed, the\n * most important first, and a dialog closed in this session is not offered again in it.\n * @param announcements The announcements the backend returned, with their windows, which the backend does not apply.\n * @param now The moment to apply the windows at.\n * @param closedIds The ids of the dialogs closed in this session.\n * @returns What to show.\n */\nexport const selectAnnouncements = (announcements: AnnouncementForMe[], now: Date, closedIds: ReadonlySet<string>): AnnouncementSelection => {\n const active = announcements.filter(announcement => isActiveAt(announcement, now));\n\n return {\n banners: active.filter(announcement => announcement.display === Display.banner).sort(byImportanceThenWindow),\n dialogs: active\n .filter(announcement => announcement.display !== Display.banner && !closedIds.has(announcement.id.toString()))\n .sort(byImportanceThenWindow)\n };\n};\n"],"names":["startOf","announcement","time","activeFrom","getTime","undefined","Number","isNaN","NEGATIVE_INFINITY","endOf","activeUntil","POSITIVE_INFINITY","compareTimes","first","second","isActiveAt","now","byImportanceThenWindow","importance","id","toString","localeCompare","selectAnnouncements","announcements","closedIds","active","filter","banners","display","Display","banner","sort","dialogs","has"],"mappings":";;;;AAAA;AACA;AAeA;AACA;AACA,MAAMA,UAAU,CAACC,YAAAA,GAAAA;IACb,MAAMC,IAAAA,GAAOD,YAAAA,CAAaE,UAAU,EAAEC,OAAAA,EAAAA;IACtC,OAAOF,IAAAA,KAASG,aAAaC,MAAAA,CAAOC,KAAK,CAACL,IAAAA,CAAAA,GAAQI,MAAAA,CAAOE,iBAAiB,GAAGN,IAAAA;AACjF,CAAA;AAEA,MAAMO,QAAQ,CAACR,YAAAA,GAAAA;IACX,MAAMC,IAAAA,GAAOD,YAAAA,CAAaS,WAAW,EAAEN,OAAAA,EAAAA;IACvC,OAAOF,IAAAA,KAASG,aAAaC,MAAAA,CAAOC,KAAK,CAACL,IAAAA,CAAAA,GAAQI,MAAAA,CAAOK,iBAAiB,GAAGT,IAAAA;AACjF,CAAA;AAEA,MAAMU,YAAAA,GAAe,CAACC,KAAAA,EAAeC,MAAAA,GAA2BD,KAAAA,KAAUC,SAAS,CAAA,GAAID,KAAAA,GAAQC,MAAAA,GAAS,EAAC,GAAI,CAAA;AAE7G;;;;;;;AAOC,IACM,MAAMC,UAAAA,GAAa,CAACd,cAAiCe,GAAAA,GACxDhB,OAAAA,CAAQC,YAAAA,CAAAA,IAAiBe,GAAAA,CAAIZ,OAAO,EAAA,IAAMY,GAAAA,CAAIZ,OAAO,EAAA,GAAKK,MAAMR,YAAAA;AAEpE,MAAMgB,sBAAAA,GAAyB,CAACJ,KAAAA,EAA0BC,MAAAA,GACrDA,MAAAA,CAAOI,UAAU,GAAGL,KAAAA,CAAMK,UAAU,IAClCN,YAAAA,CAAaZ,OAAAA,CAAQa,QAAQb,OAAAA,CAAQc,MAAAA,CAAAA,CAAAA,IACrCD,KAAAA,CAAMM,EAAE,CAACC,QAAQ,EAAA,CAAGC,aAAa,CAACP,MAAAA,CAAOK,EAAE,CAACC,QAAQ,EAAA,CAAA;AAE3D;;;;;;;;;AASC,IACM,MAAME,mBAAAA,GAAsB,CAACC,eAAoCP,GAAAA,EAAWQ,SAAAA,GAAAA;AAC/E,IAAA,MAAMC,SAASF,aAAAA,CAAcG,MAAM,CAACzB,CAAAA,YAAAA,GAAgBc,WAAWd,YAAAA,EAAce,GAAAA,CAAAA,CAAAA;IAE7E,OAAO;AACHW,QAAAA,OAAAA,EAASF,MAAAA,CAAOC,MAAM,CAACzB,CAAAA,YAAAA,GAAgBA,YAAAA,CAAa2B,OAAO,KAAKC,0BAAAA,CAAQC,MAAM,CAAA,CAAEC,IAAI,CAACd,sBAAAA,CAAAA;QACrFe,OAAAA,EAASP,MAAAA,CACJC,MAAM,CAACzB,CAAAA,eAAgBA,YAAAA,CAAa2B,OAAO,KAAKC,0BAAAA,CAAQC,MAAM,IAAI,CAACN,SAAAA,CAAUS,GAAG,CAAChC,YAAAA,CAAakB,EAAE,CAACC,QAAQ,EAAA,CAAA,CAAA,CACzGW,IAAI,CAACd,sBAAAA;AACd,KAAA;AACJ;;;"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -5,7 +5,9 @@ var MarqueeDialog = require('./Dialog/MarqueeDialog.js');
|
|
|
5
5
|
var Icons = require('./Icons.js');
|
|
6
6
|
var defaultMarqueeLabels = require('./Labels/defaultMarqueeLabels.js');
|
|
7
7
|
var resolveLabels = require('./Labels/resolveLabels.js');
|
|
8
|
+
var MarqueeInlineMarkdown = require('./Markdown/MarqueeInlineMarkdown.js');
|
|
8
9
|
var MarqueeMarkdown = require('./Markdown/MarqueeMarkdown.js');
|
|
10
|
+
var markdownText = require('./Markdown/markdownText.js');
|
|
9
11
|
var safeLink = require('./Markdown/safeLink.js');
|
|
10
12
|
var Marquee = require('./Marquee.js');
|
|
11
13
|
var announcementSelection = require('./Selection/announcementSelection.js');
|
|
@@ -16,10 +18,14 @@ var useAnnouncements = require('./useAnnouncements.js');
|
|
|
16
18
|
|
|
17
19
|
exports.MarqueeBanner = MarqueeBanner.MarqueeBanner;
|
|
18
20
|
exports.MarqueeDialog = MarqueeDialog.MarqueeDialog;
|
|
21
|
+
exports.ChevronIcon = Icons.ChevronIcon;
|
|
19
22
|
exports.ImportanceIcon = Icons.ImportanceIcon;
|
|
20
23
|
exports.defaultMarqueeLabels = defaultMarqueeLabels.defaultMarqueeLabels;
|
|
21
24
|
exports.resolveLabels = resolveLabels.resolveLabels;
|
|
25
|
+
exports.MarqueeInlineMarkdown = MarqueeInlineMarkdown.MarqueeInlineMarkdown;
|
|
22
26
|
exports.MarqueeMarkdown = MarqueeMarkdown.MarqueeMarkdown;
|
|
27
|
+
exports.hasMarkdown = markdownText.hasMarkdown;
|
|
28
|
+
exports.markdownToPlainText = markdownText.markdownToPlainText;
|
|
23
29
|
exports.isSafeLink = safeLink.isSafeLink;
|
|
24
30
|
exports.safeLinkOrEmpty = safeLink.safeLinkOrEmpty;
|
|
25
31
|
exports.Marquee = Marquee.Marquee;
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -7,5 +7,5 @@ export interface MarqueeBannerProps {
|
|
|
7
7
|
labels: MarqueeLabels;
|
|
8
8
|
markdown?: ComponentType<MarqueeMarkdownProps>;
|
|
9
9
|
}
|
|
10
|
-
export declare const MarqueeBanner: ({ announcements, labels, markdown
|
|
10
|
+
export declare const MarqueeBanner: ({ announcements, labels, markdown }: MarqueeBannerProps) => import("react").JSX.Element;
|
|
11
11
|
//# sourceMappingURL=MarqueeBanner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarqueeBanner.d.ts","sourceRoot":"","sources":["../../../Banner/MarqueeBanner.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"MarqueeBanner.d.ts","sourceRoot":"","sources":["../../../Banner/MarqueeBanner.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAkC,MAAM,OAAO,CAAC;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAuD,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAMjH,MAAM,WAAW,kBAAkB;IAE/B,aAAa,EAAE,iBAAiB,EAAE,CAAC;IAGnC,MAAM,EAAE,aAAa,CAAC;IAGtB,QAAQ,CAAC,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;CAClD;AA6ED,eAAO,MAAM,aAAa,GAAI,qCAAuD,kBAAkB,gCAMtG,CAAC"}
|