@openedx/frontend-base 1.0.0-alpha.14 → 1.0.0-alpha.15

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.
Files changed (60) hide show
  1. package/dist/runtime/config/index.js +5 -1
  2. package/dist/runtime/config/index.js.map +1 -1
  3. package/dist/runtime/index.d.ts +1 -1
  4. package/dist/runtime/index.js +1 -1
  5. package/dist/runtime/index.js.map +1 -1
  6. package/dist/runtime/react/AuthenticatedPageRoute.d.ts +2 -0
  7. package/dist/runtime/react/AuthenticatedPageRoute.js +2 -0
  8. package/dist/runtime/react/AuthenticatedPageRoute.js.map +1 -1
  9. package/dist/runtime/react/NotFoundPage.d.ts +2 -0
  10. package/dist/runtime/react/NotFoundPage.js +14 -0
  11. package/dist/runtime/react/NotFoundPage.js.map +1 -0
  12. package/dist/runtime/react/index.d.ts +1 -0
  13. package/dist/runtime/react/index.js +1 -0
  14. package/dist/runtime/react/index.js.map +1 -1
  15. package/dist/runtime/routing/authenticatedLoader.d.ts +2 -0
  16. package/dist/runtime/routing/authenticatedLoader.js +27 -0
  17. package/dist/runtime/routing/authenticatedLoader.js.map +1 -0
  18. package/dist/runtime/routing/index.d.ts +1 -0
  19. package/dist/runtime/routing/index.js +1 -0
  20. package/dist/runtime/routing/index.js.map +1 -1
  21. package/dist/runtime/routing/utils.js +20 -5
  22. package/dist/runtime/routing/utils.js.map +1 -1
  23. package/dist/runtime/slots/widget/hooks.d.ts +3 -3
  24. package/dist/runtime/slots/widget/hooks.js.map +1 -1
  25. package/dist/runtime/slots/widget/types.d.ts +8 -0
  26. package/dist/runtime/slots/widget/types.js.map +1 -1
  27. package/dist/runtime/slots/widget/utils.d.ts +2 -2
  28. package/dist/runtime/slots/widget/utils.js +20 -2
  29. package/dist/runtime/slots/widget/utils.js.map +1 -1
  30. package/dist/shell/dev/devHome/HomePage.js +3 -3
  31. package/dist/shell/dev/devHome/HomePage.js.map +1 -1
  32. package/dist/shell/dev/slotShowcase/HorizontalSlotLayout.js +2 -1
  33. package/dist/shell/dev/slotShowcase/HorizontalSlotLayout.js.map +1 -1
  34. package/dist/shell/dev/slotShowcase/LayoutWithOptions.js +2 -2
  35. package/dist/shell/dev/slotShowcase/LayoutWithOptions.js.map +1 -1
  36. package/dist/shell/dev/slotShowcase/SlotShowcasePage.d.ts +1 -0
  37. package/dist/shell/dev/slotShowcase/SlotShowcasePage.js +10 -1
  38. package/dist/shell/dev/slotShowcase/SlotShowcasePage.js.map +1 -1
  39. package/dist/shell/dev/slotShowcase/ToggleByRoleLayout.d.ts +1 -0
  40. package/dist/shell/dev/slotShowcase/ToggleByRoleLayout.js +11 -0
  41. package/dist/shell/dev/slotShowcase/ToggleByRoleLayout.js.map +1 -0
  42. package/dist/shell/dev/slotShowcase/WidgetWithOptions.js +1 -1
  43. package/dist/shell/dev/slotShowcase/WidgetWithOptions.js.map +1 -1
  44. package/dist/shell/dev/slotShowcase/app.js +76 -40
  45. package/dist/shell/dev/slotShowcase/app.js.map +1 -1
  46. package/dist/shell/header/AuthenticatedMenu.js +0 -2
  47. package/dist/shell/header/AuthenticatedMenu.js.map +1 -1
  48. package/dist/shell/router/createRouter.js +12 -1
  49. package/dist/shell/router/createRouter.js.map +1 -1
  50. package/dist/tools/babel.config.d.ts +2 -0
  51. package/dist/tools/babel.config.js +3 -0
  52. package/dist/tools/cli/openedx.js +1 -1
  53. package/dist/tools/cli/utils/formatter.js +1 -8
  54. package/dist/tools/eslint/base.eslint.config.js +4 -3
  55. package/dist/tools/webpack/common-config/dev/getDevServer.js +1 -3
  56. package/dist/tools/webpack/plugins/html-webpack-new-relic-plugin/HtmlWebpackNewRelicPlugin.d.ts +1 -3
  57. package/dist/tools/webpack/utils/getPublicPath.js +1 -1
  58. package/dist/types.d.ts +1 -0
  59. package/dist/types.js.map +1 -1
  60. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"HomePage.js","sourceRoot":"","sources":["../../../../shell/dev/devHome/HomePage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,MAAM,CAAC,OAAO,UAAU,QAAQ;IAC9B,MAAM,aAAa,GAAG,iBAAiB,CAAC,YAAY,CAAC,CAAC;IACtD,MAAM,YAAY,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;IAC3D,MAAM,eAAe,GAAG,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAC1D,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IAEvB,OAAO,CACL,eAAK,SAAS,EAAC,KAAK,aAClB,sBAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAK,EACjD,yBACG,aAAa,KAAK,IAAI,IAAI,CACzB,uBAAI,KAAC,IAAI,IAAC,EAAE,EAAE,aAAa,sCAA8B,GAAK,CAC/D,EACA,YAAY,KAAK,IAAI,IAAI,CACxB,uBAAI,KAAC,IAAI,IAAC,EAAE,EAAE,YAAY,qCAA6B,GAAK,CAC7D,EACA,eAAe,KAAK,IAAI,IAAI,CAC3B,uBAAI,KAAC,IAAI,IAAC,EAAE,EAAE,eAAe,yCAAiC,GAAK,CACpE,IACE,IACD,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { Link } from 'react-router-dom';\nimport { useIntl } from '../../../runtime';\nimport { getUrlByRouteRole } from '../../../runtime/routing';\nimport messages from './messages';\n\nexport default function HomePage() {\n const coursewareUrl = getUrlByRouteRole('courseware');\n const dashboardUrl = getUrlByRouteRole('learnerDashboard');\n const slotShowcaseUrl = getUrlByRouteRole('slotShowcase');\n const intl = useIntl();\n\n return (\n <div className=\"p-3\">\n <p>{intl.formatMessage(messages.homeContent)}</p>\n <ul>\n {coursewareUrl !== null && (\n <li><Link to={coursewareUrl}>Go to courseware page</Link></li>\n )}\n {dashboardUrl !== null && (\n <li><Link to={dashboardUrl}>Go to dashboard page</Link></li>\n )}\n {slotShowcaseUrl !== null && (\n <li><Link to={slotShowcaseUrl}>Go to slot showcase page</Link></li>\n )}\n </ul>\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"HomePage.js","sourceRoot":"","sources":["../../../../shell/dev/devHome/HomePage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,MAAM,CAAC,OAAO,UAAU,QAAQ;IAC9B,MAAM,aAAa,GAAG,iBAAiB,CAAC,sCAAsC,CAAC,CAAC;IAChF,MAAM,YAAY,GAAG,iBAAiB,CAAC,qCAAqC,CAAC,CAAC;IAC9E,MAAM,eAAe,GAAG,iBAAiB,CAAC,wCAAwC,CAAC,CAAC;IACpF,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IAEvB,OAAO,CACL,eAAK,SAAS,EAAC,KAAK,aAClB,sBAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAK,EACjD,yBACG,aAAa,KAAK,IAAI,IAAI,CACzB,uBAAI,KAAC,IAAI,IAAC,EAAE,EAAE,aAAa,sCAA8B,GAAK,CAC/D,EACA,YAAY,KAAK,IAAI,IAAI,CACxB,uBAAI,KAAC,IAAI,IAAC,EAAE,EAAE,YAAY,qCAA6B,GAAK,CAC7D,EACA,eAAe,KAAK,IAAI,IAAI,CAC3B,uBAAI,KAAC,IAAI,IAAC,EAAE,EAAE,eAAe,yCAAiC,GAAK,CACpE,IACE,IACD,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { Link } from 'react-router-dom';\nimport { useIntl } from '../../../runtime';\nimport { getUrlByRouteRole } from '../../../runtime/routing';\nimport messages from './messages';\n\nexport default function HomePage() {\n const coursewareUrl = getUrlByRouteRole('org.openedx.frontend.role.courseware');\n const dashboardUrl = getUrlByRouteRole('org.openedx.frontend.role.dashboard');\n const slotShowcaseUrl = getUrlByRouteRole('org.openedx.frontend.role.slotShowcase');\n const intl = useIntl();\n\n return (\n <div className=\"p-3\">\n <p>{intl.formatMessage(messages.homeContent)}</p>\n <ul>\n {coursewareUrl !== null && (\n <li><Link to={coursewareUrl}>Go to courseware page</Link></li>\n )}\n {dashboardUrl !== null && (\n <li><Link to={dashboardUrl}>Go to dashboard page</Link></li>\n )}\n {slotShowcaseUrl !== null && (\n <li><Link to={slotShowcaseUrl}>Go to slot showcase page</Link></li>\n )}\n </ul>\n </div>\n );\n}\n"]}
@@ -1,7 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Stack } from '@openedx/paragon';
2
3
  import { useWidgets } from '../../../runtime';
3
4
  export default function HorizontalSlotLayout() {
4
5
  const widgets = useWidgets();
5
- return (_jsx("div", { className: "d-flex gap-3", children: widgets }));
6
+ return (_jsx(Stack, { direction: "horizontal", gap: 3, children: widgets }));
6
7
  }
7
8
  //# sourceMappingURL=HorizontalSlotLayout.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"HorizontalSlotLayout.js","sourceRoot":"","sources":["../../../../shell/dev/slotShowcase/HorizontalSlotLayout.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,CAAC,OAAO,UAAU,oBAAoB;IAC1C,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAE7B,OAAO,CACL,cAAK,SAAS,EAAC,cAAc,YAC1B,OAAO,GACJ,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useWidgets } from '../../../runtime';\n\nexport default function HorizontalSlotLayout() {\n const widgets = useWidgets();\n\n return (\n <div className=\"d-flex gap-3\">\n {widgets}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"HorizontalSlotLayout.js","sourceRoot":"","sources":["../../../../shell/dev/slotShowcase/HorizontalSlotLayout.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,CAAC,OAAO,UAAU,oBAAoB;IAC1C,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAE7B,OAAO,CACL,KAAC,KAAK,IAAC,SAAS,EAAC,YAAY,EAAC,GAAG,EAAE,CAAC,YACjC,OAAO,GACF,CACT,CAAC;AACJ,CAAC","sourcesContent":["import { Stack } from '@openedx/paragon';\nimport { useWidgets } from '../../../runtime';\n\nexport default function HorizontalSlotLayout() {\n const widgets = useWidgets();\n\n return (\n <Stack direction=\"horizontal\" gap={3}>\n {widgets}\n </Stack>\n );\n}\n"]}
@@ -1,9 +1,9 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useLayoutOptions, useWidgets } from '../../../runtime';
3
3
  export default function LayoutWithOptions() {
4
4
  const widgets = useWidgets();
5
5
  const options = useLayoutOptions();
6
6
  const title = typeof options.title === 'string' ? options.title : 'Foo';
7
- return (_jsxs(_Fragment, { children: [_jsxs("div", { children: ["Layout Title: ", _jsx("strong", { children: title })] }), _jsx("div", { children: widgets })] }));
7
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "showcase-layout-title", children: ["Layout Title: ", title] }), _jsx("div", { children: widgets })] }));
8
8
  }
9
9
  //# sourceMappingURL=LayoutWithOptions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LayoutWithOptions.js","sourceRoot":"","sources":["../../../../shell/dev/slotShowcase/LayoutWithOptions.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEhE,MAAM,CAAC,OAAO,UAAU,iBAAiB;IACvC,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;IAEnC,MAAM,KAAK,GAAG,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IAExE,OAAO,CACL,8BACE,4CAAmB,2BAAS,KAAK,GAAU,IAAM,EACjD,wBACG,OAAO,GACJ,IACL,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import { useLayoutOptions, useWidgets } from '../../../runtime';\n\nexport default function LayoutWithOptions() {\n const widgets = useWidgets();\n const options = useLayoutOptions();\n\n const title = typeof options.title === 'string' ? options.title : 'Foo';\n\n return (\n <>\n <div>Layout Title: <strong>{title}</strong></div>\n <div>\n {widgets}\n </div>\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"LayoutWithOptions.js","sourceRoot":"","sources":["../../../../shell/dev/slotShowcase/LayoutWithOptions.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEhE,MAAM,CAAC,OAAO,UAAU,iBAAiB;IACvC,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;IAEnC,MAAM,KAAK,GAAG,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IAExE,OAAO,CACL,8BACE,eAAK,SAAS,EAAC,uBAAuB,+BAAgB,KAAK,IAAO,EAClE,wBACG,OAAO,GACJ,IACL,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import { useLayoutOptions, useWidgets } from '../../../runtime';\n\nexport default function LayoutWithOptions() {\n const widgets = useWidgets();\n const options = useLayoutOptions();\n\n const title = typeof options.title === 'string' ? options.title : 'Foo';\n\n return (\n <>\n <div className=\"showcase-layout-title\">Layout Title: {title}</div>\n <div>\n {widgets}\n </div>\n </>\n );\n}\n"]}
@@ -1 +1,2 @@
1
+ import './SlotShowcase.scss';
1
2
  export default function SlotShowcasePage(): import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Card, Container } from '@openedx/paragon';
2
3
  import { Slot } from '../../../runtime';
3
4
  import HorizontalSlotLayout from './HorizontalSlotLayout';
4
5
  import LayoutWithOptions from './LayoutWithOptions';
6
+ import ToggleByRoleLayout from './ToggleByRoleLayout';
7
+ import './SlotShowcase.scss';
8
+ function SlotContainer({ children }) {
9
+ return (_jsx(Card, { className: "showcase-slot", children: _jsx(Card.Body, { children: children }) }));
10
+ }
11
+ function Section({ title, children }) {
12
+ return (_jsxs("div", { children: [_jsx("h3", { className: "text-primary-500", children: title }), children] }));
13
+ }
5
14
  export default function SlotShowcasePage() {
6
- return (_jsxs("div", { className: "p-3", children: [_jsx("h1", { children: "Slot Showcase" }), _jsxs("p", { children: ["As a best practice, widgets should pass additional props (", _jsx("code", { children: "...props" }), ") to their rendered HTMLElement. This accomplishes two things:"] }), _jsxs("ul", { children: [_jsxs("li", { children: ["It allows custom layouts to add ", _jsx("code", { children: "className" }), " and ", _jsx("code", { children: "style" }), " props as necessary for the layout."] }), _jsx("li", { children: "It allows widgets to be effectively \"wrapped\" by a parent component to alter their behavior." })] }), _jsx("h3", { children: "Simple slot with default layout" }), _jsx("p", { children: "This slot has no opinionated layout, it just renders its children." }), _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseSimple" }), _jsx("h3", { children: "Simple slot with default content and props" }), _jsx("p", { children: "This slot has default content, and it exposes a slot prop to widgets." }), _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseSimpleWithDefaultContent", aSlotProp: "hello!", children: _jsx("div", { children: "Look, I'm default content!" }) }), _jsx("h2", { children: "UI Layout Operations" }), _jsx("h3", { children: "Slot with custom layout" }), _jsx("p", { children: "This slot uses a horizontal flexbox layout from a component." }), _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseCustom", layout: HorizontalSlotLayout }), _jsx("p", { children: "This slot uses a horizontal flexbox layout from a JSX element." }), _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseCustom", layout: _jsx(HorizontalSlotLayout, {}) }), _jsx("h3", { children: "Slot with override custom layout" }), _jsx("p", { children: "This slot uses a horizontal flexbox layout, but it was added by a layout replace operation." }), _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseCustomConfig" }), _jsx("h3", { children: "Slot with layout options" }), _jsx("p", { children: "These slots use a custom layout that takes options. The first shows the default title, the second shows it set to \"Bar\"" }), _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseLayoutWithOptionsDefault", layout: LayoutWithOptions }), _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseLayoutWithOptions", layout: LayoutWithOptions }), _jsx("h2", { children: "UI Widget Operations" }), _jsx("h3", { children: "Slot with prepended element" }), _jsx("p", { children: "This slot has a prepended element (and two appended elements)." }), _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcasePrepending" }), _jsx("h3", { children: "Slot with inserted elements" }), _jsxs("p", { children: ["This slot has elements inserted before and after the second element. Also note that the insert operations are declared ", _jsx("em", { children: "before" }), " the related element is declared, but can still insert themselves relative to it."] }), _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseInserting" }), _jsx("h3", { children: "Slot with replaced element" }), _jsx("p", { children: "This slot has an element replacing element two." }), _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseReplacing" }), _jsx("h3", { children: "Slot with removed element" }), _jsxs("p", { children: ["This slot has removed element two (", _jsx("code", { children: "WidgetOperationTypes.REMOVE" }), ")."] }), _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseRemoving" }), _jsx("h3", { children: "Slot with widget with options." }), _jsx("p", { children: "Both widgets accept options. The first shows the default title, the second shows it set to \"Bar\"" }), _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseWidgetOptions" })] }));
15
+ return (_jsxs(Container, { size: "xl", className: "showcase-page py-4", children: [_jsxs("div", { className: "showcase-full-width", children: [_jsx("h1", { children: "Slot Showcase" }), _jsxs("p", { children: ["As a best practice, widgets should pass additional props (", _jsx("code", { children: "...props" }), ") to their rendered HTMLElement. This allows custom layouts to add ", _jsx("code", { children: "className" }), " and ", _jsx("code", { children: "style" }), " props as necessary for the layout."] })] }), _jsxs(Section, { title: "Simple slot with default layout", children: [_jsx("p", { children: "This slot has no opinionated layout, it just renders its children." }), _jsx(SlotContainer, { children: _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseSimple" }) })] }), _jsxs(Section, { title: "Simple slot with default content and props", children: [_jsx("p", { children: "This slot has default content, and it exposes a slot prop to widgets." }), _jsx(SlotContainer, { children: _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseSimpleWithDefaultContent", aSlotProp: "hello!", children: _jsx("div", { className: "showcase-widget", children: "Look, I'm default content!" }) }) })] }), _jsx("h2", { className: "showcase-divider", children: "UI Layout Operations" }), _jsxs(Section, { title: "Slot with custom layout (component)", children: [_jsx("p", { children: "This slot uses a horizontal flexbox layout from a component." }), _jsx(SlotContainer, { children: _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseCustom", layout: HorizontalSlotLayout }) })] }), _jsxs(Section, { title: "Slot with custom layout (element)", children: [_jsx("p", { children: "This slot uses a horizontal flexbox layout from a JSX element." }), _jsx(SlotContainer, { children: _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseCustom", layout: _jsx(HorizontalSlotLayout, {}) }) })] }), _jsxs(Section, { title: "Slot with override custom layout", children: [_jsx("p", { children: "This slot uses a horizontal flexbox layout, but it was added by a layout replace operation." }), _jsx(SlotContainer, { children: _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseCustomConfig" }) })] }), _jsxs(Section, { title: "Slot with layout options (default)", children: [_jsx("p", { children: "This slot uses a custom layout that takes options. It shows the default title." }), _jsx(SlotContainer, { children: _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseLayoutWithOptionsDefault", layout: LayoutWithOptions }) })] }), _jsxs(Section, { title: "Slot with layout options (configured)", children: [_jsx("p", { children: "Same layout, but the title option is set to \"Bar\"." }), _jsx(SlotContainer, { children: _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseLayoutWithOptions", layout: LayoutWithOptions }) })] }), _jsxs(Section, { title: "Slot with widget filtering by role", children: [_jsxs("p", { children: ["This slot has four widgets, two with a \"highlighted\" role. The layout uses ", _jsx("code", { children: "widgets.byRole()" }), " to toggle between all and highlighted."] }), _jsx(SlotContainer, { children: _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseFilterByRole", layout: ToggleByRoleLayout }) })] }), _jsx("h2", { className: "showcase-divider", children: "UI Widget Operations" }), _jsxs(Section, { title: "Slot with prepended element", children: [_jsx("p", { children: "This slot has a prepended element (and two appended elements)." }), _jsx(SlotContainer, { children: _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcasePrepending" }) })] }), _jsxs(Section, { title: "Slot with inserted elements", children: [_jsxs("p", { children: ["This slot has elements inserted before and after the second element. The insert operations are declared ", _jsx("em", { children: "before" }), " the related element, but can still insert themselves relative to it."] }), _jsx(SlotContainer, { children: _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseInserting" }) })] }), _jsxs(Section, { title: "Slot with replaced element", children: [_jsx("p", { children: "This slot has an element replacing element two." }), _jsx(SlotContainer, { children: _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseReplacing" }) })] }), _jsxs(Section, { title: "Slot with removed element", children: [_jsxs("p", { children: ["This slot has removed element two (", _jsx("code", { children: "WidgetOperationTypes.REMOVE" }), ")."] }), _jsx(SlotContainer, { children: _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseRemoving" }) })] }), _jsxs(Section, { title: "Slot with widget options (default)", children: [_jsx("p", { children: "This widget accepts options. It shows the default title." }), _jsx(SlotContainer, { children: _jsx(Slot, { id: "org.openedx.frontend.slot.dev.slotShowcaseWidgetOptions" }) })] })] }));
7
16
  }
8
17
  //# sourceMappingURL=SlotShowcasePage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SlotShowcasePage.js","sourceRoot":"","sources":["../../../../shell/dev/slotShowcase/SlotShowcasePage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAEpD,MAAM,CAAC,OAAO,UAAU,gBAAgB;IACtC,OAAO,CACL,eAAK,SAAS,EAAC,KAAK,aAClB,yCAAsB,EAEtB,sFAA6D,sCAAqB,sEAAkE,EACpJ,yBACE,6DAAoC,uCAAsB,WAAK,mCAAkB,2CAAwC,EACzH,0HAA+G,IAC5G,EAEL,2DAAwC,EACxC,6FAAyE,EACzE,KAAC,IAAI,IAAC,EAAE,EAAC,kDAAkD,GAAG,EAE9D,sEAAmD,EACnD,gGAA4E,EAC5E,KAAC,IAAI,IAAC,EAAE,EAAC,oEAAoE,EAAC,SAAS,EAAC,QAAQ,YAC9F,uDAA0C,GACrC,EAEP,gDAA6B,EAE7B,mDAAgC,EAChC,uFAAmE,EACnE,KAAC,IAAI,IAAC,EAAE,EAAC,kDAAkD,EAAC,MAAM,EAAE,oBAAoB,GAAI,EAC5F,yFAAqE,EACrE,KAAC,IAAI,IAAC,EAAE,EAAC,kDAAkD,EAAC,MAAM,EAAE,KAAC,oBAAoB,KAAG,GAAI,EAEhG,4DAAyC,EACzC,sHAAkG,EAClG,KAAC,IAAI,IAAC,EAAE,EAAC,wDAAwD,GAAG,EAEpE,oDAAiC,EACjC,qJAAyI,EACzI,KAAC,IAAI,IAAC,EAAE,EAAC,oEAAoE,EAAC,MAAM,EAAE,iBAAiB,GAAI,EAC3G,KAAC,IAAI,IAAC,EAAE,EAAC,6DAA6D,EAAC,MAAM,EAAE,iBAAiB,GAAI,EAEpG,gDAA6B,EAE7B,uDAAoC,EACpC,yFAAqE,EACrE,KAAC,IAAI,IAAC,EAAE,EAAC,sDAAsD,GAAG,EAElE,uDAAoC,EACpC,mJAA0H,kCAAe,yFAAqF,EAC9N,KAAC,IAAI,IAAC,EAAE,EAAC,qDAAqD,GAAG,EAEjE,sDAAmC,EACnC,0EAAsD,EACtD,KAAC,IAAI,IAAC,EAAE,EAAC,qDAAqD,GAAG,EAEjE,qDAAkC,EAClC,+DAAsC,yDAAwC,UAAM,EACpF,KAAC,IAAI,IAAC,EAAE,EAAC,oDAAoD,GAAG,EAEhE,0DAAuC,EACvC,8HAAkH,EAClH,KAAC,IAAI,IAAC,EAAE,EAAC,yDAAyD,GAAG,IACjE,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { Slot } from '../../../runtime';\nimport HorizontalSlotLayout from './HorizontalSlotLayout';\nimport LayoutWithOptions from './LayoutWithOptions';\n\nexport default function SlotShowcasePage() {\n return (\n <div className=\"p-3\">\n <h1>Slot Showcase</h1>\n\n <p>As a best practice, widgets should pass additional props (<code>...props</code>) to their rendered HTMLElement. This accomplishes two things:</p>\n <ul>\n <li>It allows custom layouts to add <code>className</code> and <code>style</code> props as necessary for the layout.</li>\n <li>It allows widgets to be effectively &quot;wrapped&quot; by a parent component to alter their behavior.</li>\n </ul>\n\n <h3>Simple slot with default layout</h3>\n <p>This slot has no opinionated layout, it just renders its children.</p>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseSimple\" />\n\n <h3>Simple slot with default content and props</h3>\n <p>This slot has default content, and it exposes a slot prop to widgets.</p>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseSimpleWithDefaultContent\" aSlotProp=\"hello!\">\n <div>Look, I&apos;m default content!</div>\n </Slot>\n\n <h2>UI Layout Operations</h2>\n\n <h3>Slot with custom layout</h3>\n <p>This slot uses a horizontal flexbox layout from a component.</p>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseCustom\" layout={HorizontalSlotLayout} />\n <p>This slot uses a horizontal flexbox layout from a JSX element.</p>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseCustom\" layout={<HorizontalSlotLayout />} />\n\n <h3>Slot with override custom layout</h3>\n <p>This slot uses a horizontal flexbox layout, but it was added by a layout replace operation.</p>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseCustomConfig\" />\n\n <h3>Slot with layout options</h3>\n <p>These slots use a custom layout that takes options. The first shows the default title, the second shows it set to &quot;Bar&quot;</p>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseLayoutWithOptionsDefault\" layout={LayoutWithOptions} />\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseLayoutWithOptions\" layout={LayoutWithOptions} />\n\n <h2>UI Widget Operations</h2>\n\n <h3>Slot with prepended element</h3>\n <p>This slot has a prepended element (and two appended elements).</p>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcasePrepending\" />\n\n <h3>Slot with inserted elements</h3>\n <p>This slot has elements inserted before and after the second element. Also note that the insert operations are declared <em>before</em> the related element is declared, but can still insert themselves relative to it.</p>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseInserting\" />\n\n <h3>Slot with replaced element</h3>\n <p>This slot has an element replacing element two.</p>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseReplacing\" />\n\n <h3>Slot with removed element</h3>\n <p>This slot has removed element two (<code>WidgetOperationTypes.REMOVE</code>).</p>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseRemoving\" />\n\n <h3>Slot with widget with options.</h3>\n <p>Both widgets accept options. The first shows the default title, the second shows it set to &quot;Bar&quot;</p>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseWidgetOptions\" />\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"SlotShowcasePage.js","sourceRoot":"","sources":["../../../../shell/dev/slotShowcase/SlotShowcasePage.tsx"],"names":[],"mappings":"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","sourcesContent":["import { ReactNode } from 'react';\nimport { Card, Container } from '@openedx/paragon';\nimport { Slot } from '../../../runtime';\nimport HorizontalSlotLayout from './HorizontalSlotLayout';\nimport LayoutWithOptions from './LayoutWithOptions';\nimport ToggleByRoleLayout from './ToggleByRoleLayout';\nimport './SlotShowcase.scss';\n\nfunction SlotContainer({ children }: { children: ReactNode }) {\n return (\n <Card className=\"showcase-slot\">\n <Card.Body>\n {children}\n </Card.Body>\n </Card>\n );\n}\n\nfunction Section({ title, children }: { title: string, children: ReactNode }) {\n return (\n <div>\n <h3 className=\"text-primary-500\">{title}</h3>\n {children}\n </div>\n );\n}\n\nexport default function SlotShowcasePage() {\n return (\n <Container size=\"xl\" className=\"showcase-page py-4\">\n <div className=\"showcase-full-width\">\n <h1>Slot Showcase</h1>\n <p>As a best practice, widgets should pass additional props (<code>...props</code>) to their rendered HTMLElement. This allows custom layouts to add <code>className</code> and <code>style</code> props as necessary for the layout.</p>\n </div>\n\n <Section title=\"Simple slot with default layout\">\n <p>This slot has no opinionated layout, it just renders its children.</p>\n <SlotContainer>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseSimple\" />\n </SlotContainer>\n </Section>\n\n <Section title=\"Simple slot with default content and props\">\n <p>This slot has default content, and it exposes a slot prop to widgets.</p>\n <SlotContainer>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseSimpleWithDefaultContent\" aSlotProp=\"hello!\">\n <div className=\"showcase-widget\">Look, I&apos;m default content!</div>\n </Slot>\n </SlotContainer>\n </Section>\n\n <h2 className=\"showcase-divider\">UI Layout Operations</h2>\n\n <Section title=\"Slot with custom layout (component)\">\n <p>This slot uses a horizontal flexbox layout from a component.</p>\n <SlotContainer>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseCustom\" layout={HorizontalSlotLayout} />\n </SlotContainer>\n </Section>\n\n <Section title=\"Slot with custom layout (element)\">\n <p>This slot uses a horizontal flexbox layout from a JSX element.</p>\n <SlotContainer>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseCustom\" layout={<HorizontalSlotLayout />} />\n </SlotContainer>\n </Section>\n\n <Section title=\"Slot with override custom layout\">\n <p>This slot uses a horizontal flexbox layout, but it was added by a layout replace operation.</p>\n <SlotContainer>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseCustomConfig\" />\n </SlotContainer>\n </Section>\n\n <Section title=\"Slot with layout options (default)\">\n <p>This slot uses a custom layout that takes options. It shows the default title.</p>\n <SlotContainer>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseLayoutWithOptionsDefault\" layout={LayoutWithOptions} />\n </SlotContainer>\n </Section>\n\n <Section title=\"Slot with layout options (configured)\">\n <p>Same layout, but the title option is set to &quot;Bar&quot;.</p>\n <SlotContainer>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseLayoutWithOptions\" layout={LayoutWithOptions} />\n </SlotContainer>\n </Section>\n\n <Section title=\"Slot with widget filtering by role\">\n <p>This slot has four widgets, two with a &quot;highlighted&quot; role. The layout uses <code>widgets.byRole()</code> to toggle between all and highlighted.</p>\n <SlotContainer>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseFilterByRole\" layout={ToggleByRoleLayout} />\n </SlotContainer>\n </Section>\n\n <h2 className=\"showcase-divider\">UI Widget Operations</h2>\n\n <Section title=\"Slot with prepended element\">\n <p>This slot has a prepended element (and two appended elements).</p>\n <SlotContainer>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcasePrepending\" />\n </SlotContainer>\n </Section>\n\n <Section title=\"Slot with inserted elements\">\n <p>This slot has elements inserted before and after the second element. The insert operations are declared <em>before</em> the related element, but can still insert themselves relative to it.</p>\n <SlotContainer>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseInserting\" />\n </SlotContainer>\n </Section>\n\n <Section title=\"Slot with replaced element\">\n <p>This slot has an element replacing element two.</p>\n <SlotContainer>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseReplacing\" />\n </SlotContainer>\n </Section>\n\n <Section title=\"Slot with removed element\">\n <p>This slot has removed element two (<code>WidgetOperationTypes.REMOVE</code>).</p>\n <SlotContainer>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseRemoving\" />\n </SlotContainer>\n </Section>\n\n <Section title=\"Slot with widget options (default)\">\n <p>This widget accepts options. It shows the default title.</p>\n <SlotContainer>\n <Slot id=\"org.openedx.frontend.slot.dev.slotShowcaseWidgetOptions\" />\n </SlotContainer>\n </Section>\n\n </Container>\n );\n}\n"]}
@@ -0,0 +1 @@
1
+ export default function ToggleByRoleLayout(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { Button } from '@openedx/paragon';
4
+ import { useWidgets } from '../../../runtime';
5
+ const highlitedRole = 'org.openedx.frontend.role.slotShowcase.highlighted';
6
+ export default function ToggleByRoleLayout() {
7
+ const widgets = useWidgets();
8
+ const [showHighlighted, setShowHighlighted] = useState(false);
9
+ return (_jsxs("div", { children: [_jsx(Button, { size: "sm", variant: "outline-primary", className: "mb-2", onClick: () => setShowHighlighted(!showHighlighted), children: showHighlighted ? 'Show all widgets' : 'Show only highlighted widgets' }), _jsx("div", { children: showHighlighted ? widgets.byRole(highlitedRole) : widgets })] }));
10
+ }
11
+ //# sourceMappingURL=ToggleByRoleLayout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToggleByRoleLayout.js","sourceRoot":"","sources":["../../../../shell/dev/slotShowcase/ToggleByRoleLayout.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,aAAa,GAAG,oDAAoD,CAAC;AAE3E,MAAM,CAAC,OAAO,UAAU,kBAAkB;IACxC,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE9D,OAAO,CACL,0BACE,KAAC,MAAM,IAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAC,iBAAiB,EAAC,SAAS,EAAC,MAAM,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,CAAC,eAAe,CAAC,YAC7G,eAAe,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,+BAA+B,GAChE,EACT,wBACG,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,OAAO,GACtD,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useState } from 'react';\nimport { Button } from '@openedx/paragon';\nimport { useWidgets } from '../../../runtime';\n\nconst highlitedRole = 'org.openedx.frontend.role.slotShowcase.highlighted';\n\nexport default function ToggleByRoleLayout() {\n const widgets = useWidgets();\n const [showHighlighted, setShowHighlighted] = useState(false);\n\n return (\n <div>\n <Button size=\"sm\" variant=\"outline-primary\" className=\"mb-2\" onClick={() => setShowHighlighted(!showHighlighted)}>\n {showHighlighted ? 'Show all widgets' : 'Show only highlighted widgets'}\n </Button>\n <div>\n {showHighlighted ? widgets.byRole(highlitedRole) : widgets}\n </div>\n </div>\n );\n}\n"]}
@@ -3,6 +3,6 @@ import { useWidgetOptions } from '../../../runtime';
3
3
  export default function WidgetWithOptions() {
4
4
  const options = useWidgetOptions();
5
5
  const title = typeof options.title === 'string' ? options.title : 'Foo';
6
- return (_jsx("div", { children: title }));
6
+ return (_jsx("div", { className: "showcase-widget", children: title }));
7
7
  }
8
8
  //# sourceMappingURL=WidgetWithOptions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WidgetWithOptions.js","sourceRoot":"","sources":["../../../../shell/dev/slotShowcase/WidgetWithOptions.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,CAAC,OAAO,UAAU,iBAAiB;IACvC,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;IAEnC,MAAM,KAAK,GAAG,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IAExE,OAAO,CACL,wBAAM,KAAK,GAAO,CACnB,CAAC;AACJ,CAAC","sourcesContent":["import { useWidgetOptions } from '../../../runtime';\n\nexport default function WidgetWithOptions() {\n const options = useWidgetOptions();\n\n const title = typeof options.title === 'string' ? options.title : 'Foo';\n\n return (\n <div>{title}</div>\n );\n}\n"]}
1
+ {"version":3,"file":"WidgetWithOptions.js","sourceRoot":"","sources":["../../../../shell/dev/slotShowcase/WidgetWithOptions.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,CAAC,OAAO,UAAU,iBAAiB;IACvC,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;IAEnC,MAAM,KAAK,GAAG,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IAExE,OAAO,CACL,cAAK,SAAS,EAAC,iBAAiB,YAAE,KAAK,GAAO,CAC/C,CAAC;AACJ,CAAC","sourcesContent":["import { useWidgetOptions } from '../../../runtime';\n\nexport default function WidgetWithOptions() {\n const options = useWidgetOptions();\n\n const title = typeof options.title === 'string' ? options.title : 'Foo';\n\n return (\n <div className=\"showcase-widget\">{title}</div>\n );\n}\n"]}
@@ -1,23 +1,32 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
13
  import { NavDropdownMenuSlot } from '../..';
3
14
  import LinkMenuItem from '../../menus/LinkMenuItem';
4
15
  import { LayoutOperationTypes, WidgetOperationTypes, useSlotContext } from '../../../runtime';
5
16
  import HorizontalSlotLayout from './HorizontalSlotLayout';
6
17
  import SlotShowcasePage from './SlotShowcasePage';
7
18
  import WidgetWithOptions from './WidgetWithOptions';
8
- function Title({ title, op }) {
9
- return (_jsxs("span", { children: [title, op && (_jsxs(_Fragment, { children: [' ', "(", _jsx("code", { children: op }), ")"] }))] }));
10
- }
11
- function Child({ title, op }) {
12
- return (_jsxs("div", { children: [title, op && (_jsxs("span", { children: [' ', "(", _jsx("code", { children: op }), ")"] }))] }));
19
+ function Widget(_a) {
20
+ var { title, op, className } = _a, props = __rest(_a, ["title", "op", "className"]);
21
+ return (_jsxs("div", Object.assign({ className: `showcase-widget ${className !== null && className !== void 0 ? className : ''}` }, props, { children: [title, op && (_jsxs("span", { children: [' ', "(", _jsx("code", { children: op }), ")"] }))] })));
13
22
  }
14
23
  function TakesProps({ aSlotProp }) {
15
- return (_jsxs("div", { children: ["And this is a slot prop that was passed down via props: ", _jsx("code", { children: aSlotProp })] }));
24
+ return (_jsxs("div", { className: "showcase-widget", children: ["And this is a slot prop that was passed down via props: ", _jsx("code", { children: aSlotProp })] }));
16
25
  }
17
26
  function TakesPropsViaContext() {
18
27
  const slotContext = useSlotContext();
19
28
  const aSlotProp = typeof slotContext.aSlotProp === 'string' ? slotContext.aSlotProp : 'foo';
20
- return (_jsxs("div", { children: ["And this is the same prop, but accessed via slot context: ", _jsx("code", { children: aSlotProp })] }));
29
+ return (_jsxs("div", { className: "showcase-widget", children: ["And this is the same prop, but accessed via slot context: ", _jsx("code", { children: aSlotProp })] }));
21
30
  }
22
31
  const app = {
23
32
  appId: 'org.openedx.frontend.app.slotShowcase',
@@ -35,19 +44,19 @@ const app = {
35
44
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseSimple',
36
45
  id: 'org.openedx.frontend.widget.slotShowcase.simpleChild1',
37
46
  op: WidgetOperationTypes.APPEND,
38
- element: (_jsx(Child, { title: "Child One" }))
47
+ element: (_jsx(Widget, { title: "Widget One" }))
39
48
  },
40
49
  {
41
50
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseSimple',
42
51
  id: 'org.openedx.frontend.widget.slotShowcase.simpleChild2',
43
52
  op: WidgetOperationTypes.APPEND,
44
- element: (_jsx(Child, { title: "Child Two" }))
53
+ element: (_jsx(Widget, { title: "Widget Two" }))
45
54
  },
46
55
  {
47
56
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseSimple',
48
57
  id: 'org.openedx.frontend.widget.slotShowcase.simpleChild3',
49
58
  op: WidgetOperationTypes.APPEND,
50
- element: (_jsx(Child, { title: "Child Three" }))
59
+ element: (_jsx(Widget, { title: "Widget Three" }))
51
60
  },
52
61
  {
53
62
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseSimpleWithDefaultContent',
@@ -66,38 +75,38 @@ const app = {
66
75
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseCustom',
67
76
  id: 'org.openedx.frontend.widget.slotShowcase.customChild1',
68
77
  op: WidgetOperationTypes.APPEND,
69
- element: (_jsx(Child, { title: "Child One" }))
78
+ element: (_jsx(Widget, { title: "Widget One" }))
70
79
  },
71
80
  {
72
81
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseCustom',
73
82
  id: 'org.openedx.frontend.widget.slotShowcase.customChild2',
74
83
  op: WidgetOperationTypes.APPEND,
75
- element: (_jsx(Child, { title: "Child Two" }))
84
+ element: (_jsx(Widget, { title: "Widget Two" }))
76
85
  },
77
86
  {
78
87
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseCustom',
79
88
  id: 'org.openedx.frontend.widget.slotShowcase.customChild3',
80
89
  op: WidgetOperationTypes.APPEND,
81
- element: (_jsx(Child, { title: "Child Three" }))
90
+ element: (_jsx(Widget, { title: "Widget Three" }))
82
91
  },
83
92
  // Override custom layout
84
93
  {
85
94
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseCustomConfig',
86
95
  id: 'org.openedx.frontend.widget.slotShowcase.customConfigChild1',
87
96
  op: WidgetOperationTypes.APPEND,
88
- element: (_jsx(Child, { title: "Child One" }))
97
+ element: (_jsx(Widget, { title: "Widget One" }))
89
98
  },
90
99
  {
91
100
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseCustomConfig',
92
101
  id: 'org.openedx.frontend.widget.slotShowcase.customConfigChild2',
93
102
  op: WidgetOperationTypes.APPEND,
94
- element: (_jsx(Child, { title: "Child Two" }))
103
+ element: (_jsx(Widget, { title: "Widget Two" }))
95
104
  },
96
105
  {
97
106
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseCustomConfig',
98
107
  id: 'org.openedx.frontend.widget.slotShowcase.customConfigChild3',
99
108
  op: WidgetOperationTypes.APPEND,
100
- element: (_jsx(Child, { title: "Child Three" }))
109
+ element: (_jsx(Widget, { title: "Widget Three" }))
101
110
  },
102
111
  {
103
112
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseCustomConfig',
@@ -109,44 +118,44 @@ const app = {
109
118
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseLayoutWithOptions',
110
119
  op: LayoutOperationTypes.OPTIONS,
111
120
  options: {
112
- title: (_jsx(Title, { title: "Bar", op: "LayoutOperationTypes.OPTIONS" })),
121
+ title: 'Bar',
113
122
  }
114
123
  },
115
124
  {
116
125
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseLayoutWithOptions',
117
126
  id: 'org.openedx.frontend.widget.slotShowcase.layoutWithOptionsChild1',
118
127
  op: WidgetOperationTypes.APPEND,
119
- element: (_jsx(Child, { title: "Child One" }))
128
+ element: (_jsx(Widget, { title: "Widget One" }))
120
129
  },
121
130
  {
122
131
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseLayoutWithOptions',
123
132
  id: 'org.openedx.frontend.widget.slotShowcase.layoutWithOptionsChild2',
124
133
  op: WidgetOperationTypes.APPEND,
125
- element: (_jsx(Child, { title: "Child Two" }))
134
+ element: (_jsx(Widget, { title: "Widget Two" }))
126
135
  },
127
136
  {
128
137
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseLayoutWithOptions',
129
138
  id: 'org.openedx.frontend.widget.slotShowcase.layoutWithOptionsChild3',
130
139
  op: WidgetOperationTypes.APPEND,
131
- element: (_jsx(Child, { title: "Child Three" }))
140
+ element: (_jsx(Widget, { title: "Widget Three" }))
132
141
  },
133
142
  {
134
143
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseLayoutWithOptionsDefault',
135
144
  id: 'org.openedx.frontend.widget.slotShowcase.layoutWithOptionsDefaultChild1',
136
145
  op: WidgetOperationTypes.APPEND,
137
- element: (_jsx(Child, { title: "Child One" }))
146
+ element: (_jsx(Widget, { title: "Widget One" }))
138
147
  },
139
148
  {
140
149
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseLayoutWithOptionsDefault',
141
150
  id: 'org.openedx.frontend.widget.slotShowcase.layoutWithOptionsDefaultChild2',
142
151
  op: WidgetOperationTypes.APPEND,
143
- element: (_jsx(Child, { title: "Child Two" }))
152
+ element: (_jsx(Widget, { title: "Widget Two" }))
144
153
  },
145
154
  {
146
155
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseLayoutWithOptionsDefault',
147
156
  id: 'org.openedx.frontend.widget.slotShowcase.layoutWithOptionsDefaultChild3',
148
157
  op: WidgetOperationTypes.APPEND,
149
- element: (_jsx(Child, { title: "Child Three" }))
158
+ element: (_jsx(Widget, { title: "Widget Three" }))
150
159
  },
151
160
  // TODO: Override Layout
152
161
  // Prepending
@@ -154,19 +163,19 @@ const app = {
154
163
  slotId: 'org.openedx.frontend.slot.dev.slotShowcasePrepending',
155
164
  id: 'org.openedx.frontend.widget.slotShowcase.prependingChild1',
156
165
  op: WidgetOperationTypes.APPEND,
157
- element: (_jsx(Child, { title: "Child One", op: "WidgetOperationTypes.APPEND" }))
166
+ element: (_jsx(Widget, { title: "Widget One", op: "WidgetOperationTypes.APPEND" }))
158
167
  },
159
168
  {
160
169
  slotId: 'org.openedx.frontend.slot.dev.slotShowcasePrepending',
161
170
  id: 'org.openedx.frontend.widget.slotShowcase.prependingChild2',
162
171
  op: WidgetOperationTypes.APPEND,
163
- element: (_jsx(Child, { title: "Child Two", op: "WidgetOperationTypes.APPEND" }))
172
+ element: (_jsx(Widget, { title: "Widget Two", op: "WidgetOperationTypes.APPEND" }))
164
173
  },
165
174
  {
166
175
  slotId: 'org.openedx.frontend.slot.dev.slotShowcasePrepending',
167
176
  id: 'org.openedx.frontend.widget.slotShowcase.prependingChild3',
168
177
  op: WidgetOperationTypes.PREPEND,
169
- element: (_jsx(Child, { title: "Child Three", op: "WidgetOperationTypes.PREPEND" }))
178
+ element: (_jsx(Widget, { title: "Widget Three", op: "WidgetOperationTypes.PREPEND" }))
170
179
  },
171
180
  // Inserting
172
181
  {
@@ -174,77 +183,77 @@ const app = {
174
183
  id: 'slot-showcase.inserting.child4',
175
184
  op: WidgetOperationTypes.INSERT_AFTER,
176
185
  relatedId: 'org.openedx.frontend.widget.slotShowcase.insertingChild2',
177
- element: (_jsx(Child, { title: "Child Four", op: "WidgetOperationTypes.INSERT_AFTER" }))
186
+ element: (_jsx(Widget, { title: "Widget Four", op: "WidgetOperationTypes.INSERT_AFTER" }))
178
187
  },
179
188
  {
180
189
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseInserting',
181
190
  id: 'slot-showcase.inserting.child5',
182
191
  op: WidgetOperationTypes.INSERT_BEFORE,
183
192
  relatedId: 'org.openedx.frontend.widget.slotShowcase.insertingChild2',
184
- element: (_jsx(Child, { title: "Child Five", op: "WidgetOperationTypes.INSERT_BEFORE" }))
193
+ element: (_jsx(Widget, { title: "Widget Five", op: "WidgetOperationTypes.INSERT_BEFORE" }))
185
194
  },
186
195
  {
187
196
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseInserting',
188
197
  id: 'org.openedx.frontend.widget.slotShowcase.insertingChild1',
189
198
  op: WidgetOperationTypes.APPEND,
190
- element: (_jsx(Child, { title: "Child One" }))
199
+ element: (_jsx(Widget, { title: "Widget One" }))
191
200
  },
192
201
  {
193
202
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseInserting',
194
203
  id: 'org.openedx.frontend.widget.slotShowcase.insertingChild2',
195
204
  op: WidgetOperationTypes.APPEND,
196
- element: (_jsx(Child, { title: "Child Two" }))
205
+ element: (_jsx(Widget, { title: "Widget Two" }))
197
206
  },
198
207
  {
199
208
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseInserting',
200
209
  id: 'org.openedx.frontend.widget.slotShowcase.insertingChild3',
201
210
  op: WidgetOperationTypes.APPEND,
202
- element: (_jsx(Child, { title: "Child Three" }))
211
+ element: (_jsx(Widget, { title: "Widget Three" }))
203
212
  },
204
213
  // Replacing
205
214
  {
206
215
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseReplacing',
207
216
  id: 'org.openedx.frontend.widget.slotShowcase.replacingChild1',
208
217
  op: WidgetOperationTypes.APPEND,
209
- element: (_jsx(Child, { title: "Child One" }))
218
+ element: (_jsx(Widget, { title: "Widget One" }))
210
219
  },
211
220
  {
212
221
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseReplacing',
213
222
  id: 'org.openedx.frontend.widget.slotShowcase.replacingChild2',
214
223
  op: WidgetOperationTypes.APPEND,
215
- element: (_jsx(Child, { title: "Child Two" }))
224
+ element: (_jsx(Widget, { title: "Widget Two" }))
216
225
  },
217
226
  {
218
227
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseReplacing',
219
228
  id: 'org.openedx.frontend.widget.slotShowcase.replacingChild3',
220
229
  op: WidgetOperationTypes.APPEND,
221
- element: (_jsx(Child, { title: "Child Three" }))
230
+ element: (_jsx(Widget, { title: "Widget Three" }))
222
231
  },
223
232
  {
224
233
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseReplacing',
225
234
  id: 'org.openedx.frontend.widget.slotShowcase.replacingChild4',
226
235
  op: WidgetOperationTypes.REPLACE,
227
236
  relatedId: 'org.openedx.frontend.widget.slotShowcase.replacingChild2',
228
- element: (_jsx(Child, { title: "Child Four", op: "WidgetOperationTypes.REPLACE" }))
237
+ element: (_jsx(Widget, { title: "Widget Four", op: "WidgetOperationTypes.REPLACE" }))
229
238
  },
230
239
  // Hiding
231
240
  {
232
241
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseRemoving',
233
242
  id: 'org.openedx.frontend.widget.slotShowcase.removingChild1',
234
243
  op: WidgetOperationTypes.APPEND,
235
- element: (_jsx(Child, { title: "Child One" }))
244
+ element: (_jsx(Widget, { title: "Widget One" }))
236
245
  },
237
246
  {
238
247
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseRemoving',
239
248
  id: 'org.openedx.frontend.widget.slotShowcase.removingChild2',
240
249
  op: WidgetOperationTypes.APPEND,
241
- element: (_jsx(Child, { title: "Child Two" }))
250
+ element: (_jsx(Widget, { title: "Widget Two" }))
242
251
  },
243
252
  {
244
253
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseRemoving',
245
254
  id: 'org.openedx.frontend.widget.slotShowcase.removingChild3',
246
255
  op: WidgetOperationTypes.APPEND,
247
- element: (_jsx(Child, { title: "Child Three" }))
256
+ element: (_jsx(Widget, { title: "Widget Three" }))
248
257
  },
249
258
  {
250
259
  slotId: 'org.openedx.frontend.slot.dev.slotShowcaseRemoving',
@@ -269,9 +278,36 @@ const app = {
269
278
  relatedId: 'org.openedx.frontend.widget.slotShowcase.widgetOptionsChild2',
270
279
  op: WidgetOperationTypes.OPTIONS,
271
280
  options: {
272
- title: (_jsx(Title, { title: "Bar", op: "WidgetOperationTypes.OPTIONS" })),
281
+ title: 'Bar',
273
282
  }
274
283
  },
284
+ // Widget filtering by role
285
+ {
286
+ slotId: 'org.openedx.frontend.slot.dev.slotShowcaseFilterByRole',
287
+ id: 'org.openedx.frontend.widget.slotShowcase.filterChild1',
288
+ op: WidgetOperationTypes.APPEND,
289
+ element: (_jsx(Widget, { title: "Widget One" }))
290
+ },
291
+ {
292
+ slotId: 'org.openedx.frontend.slot.dev.slotShowcaseFilterByRole',
293
+ id: 'org.openedx.frontend.widget.slotShowcase.filterChild2',
294
+ role: 'org.openedx.frontend.role.slotShowcase.highlighted',
295
+ op: WidgetOperationTypes.APPEND,
296
+ element: (_jsx(Widget, { title: "Widget Two (highlighted)", className: "showcase-widget-highlighted" }))
297
+ },
298
+ {
299
+ slotId: 'org.openedx.frontend.slot.dev.slotShowcaseFilterByRole',
300
+ id: 'org.openedx.frontend.widget.slotShowcase.filterChild3',
301
+ op: WidgetOperationTypes.APPEND,
302
+ element: (_jsx(Widget, { title: "Widget Three" }))
303
+ },
304
+ {
305
+ slotId: 'org.openedx.frontend.slot.dev.slotShowcaseFilterByRole',
306
+ id: 'org.openedx.frontend.widget.slotShowcase.filterChild4',
307
+ role: 'org.openedx.frontend.role.slotShowcase.highlighted',
308
+ op: WidgetOperationTypes.APPEND,
309
+ element: (_jsx(Widget, { title: "Widget Four (highlighted)", className: "showcase-widget-highlighted" }))
310
+ },
275
311
  // Header
276
312
  {
277
313
  slotId: 'org.openedx.frontend.slot.header.primaryLinks.v1',