@ndla/ui 53.0.1 → 54.0.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.
Files changed (72) hide show
  1. package/es/Embed/ConceptEmbed.js +14 -8
  2. package/es/Embed/RelatedContentEmbed.js +2 -1
  3. package/es/ErrorMessage/ErrorMessage.js +14 -17
  4. package/es/Figure/Figure.js +36 -20
  5. package/es/Layout/LayoutItem.js +20 -6
  6. package/es/Layout/index.js +0 -1
  7. package/es/List/OrderedList.js +12 -11
  8. package/es/TreeStructure/AddFolderButton.js +2 -2
  9. package/es/TreeStructure/ComboboxButton.js +2 -2
  10. package/es/TreeStructure/FolderItem.js +7 -7
  11. package/es/TreeStructure/FolderItems.js +2 -2
  12. package/es/TreeStructure/TreeStructure.js +5 -5
  13. package/es/all.css +1 -1
  14. package/es/index.js +1 -1
  15. package/lib/Embed/ConceptEmbed.d.ts +1 -0
  16. package/lib/Embed/ConceptEmbed.js +14 -8
  17. package/lib/Embed/RelatedContentEmbed.js +3 -1
  18. package/lib/ErrorMessage/ErrorMessage.js +14 -17
  19. package/lib/Figure/Figure.js +40 -20
  20. package/lib/Layout/LayoutItem.js +20 -8
  21. package/lib/Layout/index.d.ts +0 -1
  22. package/lib/Layout/index.js +0 -7
  23. package/lib/List/OrderedList.d.ts +0 -1
  24. package/lib/List/OrderedList.js +12 -12
  25. package/lib/TreeStructure/AddFolderButton.d.ts +1 -1
  26. package/lib/TreeStructure/AddFolderButton.js +2 -2
  27. package/lib/TreeStructure/ComboboxButton.d.ts +1 -1
  28. package/lib/TreeStructure/ComboboxButton.js +2 -2
  29. package/lib/TreeStructure/FolderItem.d.ts +1 -1
  30. package/lib/TreeStructure/FolderItem.js +7 -7
  31. package/lib/TreeStructure/FolderItems.d.ts +1 -1
  32. package/lib/TreeStructure/FolderItems.js +2 -2
  33. package/lib/TreeStructure/TreeStructure.d.ts +1 -1
  34. package/lib/TreeStructure/TreeStructure.js +5 -5
  35. package/lib/TreeStructure/arrowNavigation.d.ts +1 -1
  36. package/lib/TreeStructure/helperFunctions.d.ts +1 -1
  37. package/lib/TreeStructure/types.d.ts +1 -1
  38. package/lib/all.css +1 -1
  39. package/lib/index.d.ts +1 -1
  40. package/lib/index.js +0 -6
  41. package/package.json +16 -15
  42. package/src/Embed/AudioEmbed.stories.tsx +3 -3
  43. package/src/Embed/BrightcoveEmbed.stories.tsx +3 -3
  44. package/src/Embed/ConceptEmbed.stories.tsx +3 -3
  45. package/src/Embed/ConceptEmbed.tsx +20 -2
  46. package/src/Embed/ExternalEmbed.stories.tsx +3 -3
  47. package/src/Embed/H5pEmbed.stories.tsx +3 -3
  48. package/src/Embed/IframeEmbed.stories.tsx +3 -3
  49. package/src/Embed/ImageEmbed.stories.tsx +3 -3
  50. package/src/Embed/RelatedContentEmbed.stories.tsx +15 -3
  51. package/src/Embed/RelatedContentEmbed.tsx +4 -1
  52. package/src/Embed/UuDisclaimerEmbed.stories.tsx +3 -3
  53. package/src/ErrorMessage/ErrorMessage.tsx +8 -4
  54. package/src/Figure/Figure.tsx +102 -24
  55. package/src/Layout/LayoutItem.tsx +23 -6
  56. package/src/Layout/index.ts +0 -1
  57. package/src/List/OrderedList.stories.tsx +2 -2
  58. package/src/List/OrderedList.tsx +21 -18
  59. package/src/TreeStructure/AddFolderButton.tsx +1 -1
  60. package/src/TreeStructure/ComboboxButton.tsx +1 -1
  61. package/src/TreeStructure/FolderItem.tsx +1 -1
  62. package/src/TreeStructure/FolderItems.tsx +1 -1
  63. package/src/TreeStructure/TreeStructure.stories.tsx +1 -1
  64. package/src/TreeStructure/TreeStructure.tsx +1 -1
  65. package/src/TreeStructure/arrowNavigation.ts +1 -1
  66. package/src/TreeStructure/helperFunctions.ts +1 -1
  67. package/src/TreeStructure/types.ts +1 -1
  68. package/src/index.ts +1 -1
  69. package/es/Layout/Content.js +0 -19
  70. package/lib/Layout/Content.d.ts +0 -13
  71. package/lib/Layout/Content.js +0 -26
  72. package/src/Layout/Content.tsx +0 -17
@@ -6,22 +6,11 @@
6
6
  *
7
7
  */
8
8
 
9
- import { forwardRef, HTMLAttributes } from "react";
9
+ import { CSSProperties, forwardRef, HTMLAttributes, useMemo } from "react";
10
10
  import { css } from "@emotion/react";
11
11
  import styled from "@emotion/styled";
12
12
  import { fonts, spacing } from "@ndla/core";
13
13
 
14
- export const generateListResets = (counterName: string) => {
15
- let styles = "";
16
- for (let $i = 0; $i < 50; $i++) {
17
- styles += `
18
- &.ol-reset-${$i} { counter-reset: ${counterName} ${$i - 1}; }
19
- `;
20
- }
21
-
22
- return styles;
23
- };
24
-
25
14
  export const LetterCSS = css`
26
15
  padding-left: ${spacing.medium};
27
16
  > li {
@@ -73,7 +62,9 @@ export const NumberCSS = css`
73
62
  }
74
63
  > ol:not([data-type="letters"]) {
75
64
  counter-reset: level2;
76
- ${generateListResets("level2")};
65
+ &[data-count="true"] {
66
+ counter-reset: level2 var(--start, 0);
67
+ }
77
68
  > li {
78
69
  padding-left: ${spacing.nsmall};
79
70
  counter-increment: level2;
@@ -82,7 +73,9 @@ export const NumberCSS = css`
82
73
  }
83
74
  > ol:not([data-type="letters"]) {
84
75
  counter-reset: level3;
85
- ${generateListResets("level3")};
76
+ &[data-count="true"] {
77
+ counter-reset: level3 var(--start, 0);
78
+ }
86
79
  > li {
87
80
  padding-left: ${spacing.medium};
88
81
  counter-increment: level3;
@@ -91,7 +84,10 @@ export const NumberCSS = css`
91
84
  }
92
85
  > ol:not([data-type="letters"]) {
93
86
  counter-reset: level4;
94
- ${generateListResets("level4")};
87
+ &[data-count="true"] {
88
+ counter-reset: level4 var(--start, 0);
89
+ }
90
+
95
91
  > li {
96
92
  padding-left: ${spacing.large};
97
93
  counter-increment: level4;
@@ -110,12 +106,15 @@ export const NumberCSS = css`
110
106
 
111
107
  const StyledOl = styled.ol`
112
108
  ${fonts.sizes("18px", "29px")};
113
- ${generateListResets("level1")};
114
109
  padding: 0;
115
110
  list-style-type: none;
116
111
  counter-reset: level1;
117
112
  margin: ${spacing.normal} 0 ${spacing.normal} ${spacing.normal};
118
113
 
114
+ &[data-count="true"] {
115
+ counter-reset: level1 var(--start, 0);
116
+ }
117
+
119
118
  > li {
120
119
  margin-top: ${spacing.nsmall};
121
120
  padding-top: 0;
@@ -144,9 +143,13 @@ interface Props extends HTMLAttributes<HTMLOListElement> {
144
143
  start?: number;
145
144
  }
146
145
 
147
- const OrderedList = forwardRef<HTMLOListElement, Props>(({ type, children, ...rest }, ref) => {
146
+ const OrderedList = forwardRef<HTMLOListElement, Props>(({ type, children, start, ...rest }, ref) => {
147
+ const style = useMemo(() => {
148
+ return { "--start": start ? start - 1 : undefined } as CSSProperties;
149
+ }, [start]);
150
+
148
151
  return (
149
- <StyledOl data-type={type} ref={ref} {...rest}>
152
+ <StyledOl data-type={type} data-count={start != null} style={style} ref={ref} {...rest}>
150
153
  {children}
151
154
  </StyledOl>
152
155
  );
@@ -12,7 +12,7 @@ import styled from "@emotion/styled";
12
12
  import { ButtonV2 as Button } from "@ndla/button";
13
13
  import { Plus } from "@ndla/icons/action";
14
14
  import { Tooltip } from "@ndla/tooltip";
15
- import { IFolder } from "@ndla/types-backend/learningpath-api";
15
+ import { IFolder } from "@ndla/types-backend/myndla-api";
16
16
 
17
17
  interface AddFolderButtonProps {
18
18
  canAddFolder: boolean;
@@ -11,7 +11,7 @@ import styled from "@emotion/styled";
11
11
  import { ButtonV2 as Button, IconButtonV2 as IconButton } from "@ndla/button";
12
12
  import { breakpoints, colors, mq, spacing } from "@ndla/core";
13
13
  import { ChevronUp, ChevronDown } from "@ndla/icons/common";
14
- import { IFolder } from "@ndla/types-backend/learningpath-api";
14
+ import { IFolder } from "@ndla/types-backend/myndla-api";
15
15
  import { useForwardedRef } from "@ndla/util";
16
16
  import { arrowNavigation } from "./arrowNavigation";
17
17
  import { treestructureId } from "./helperFunctions";
@@ -15,7 +15,7 @@ import { ArrowDropDownRounded } from "@ndla/icons/common";
15
15
  import { FolderOutlined, FolderShared } from "@ndla/icons/contentType";
16
16
  import { Done } from "@ndla/icons/editor";
17
17
  import { SafeLink } from "@ndla/safelink";
18
- import { IFolder } from "@ndla/types-backend/learningpath-api";
18
+ import { IFolder } from "@ndla/types-backend/myndla-api";
19
19
  import { arrowNavigation } from "./arrowNavigation";
20
20
  import { treestructureId } from "./helperFunctions";
21
21
  import { CommonFolderItemsProps } from "./types";
@@ -9,7 +9,7 @@
9
9
  import { ReactNode } from "react";
10
10
  import styled from "@emotion/styled";
11
11
  import { animations } from "@ndla/core";
12
- import { IFolder } from "@ndla/types-backend/learningpath-api";
12
+ import { IFolder } from "@ndla/types-backend/myndla-api";
13
13
  import FolderItem from "./FolderItem";
14
14
  import { treestructureId } from "./helperFunctions";
15
15
  import { CommonFolderItemsProps, NewFolderInputFunc, OnCreatedFunc } from "./types";
@@ -17,7 +17,7 @@ import { FieldErrorMessage, FieldHelper, FormControl, InputContainer, InputV3, L
17
17
  import { Spinner } from "@ndla/icons";
18
18
  import { Cross } from "@ndla/icons/action";
19
19
  import { Done } from "@ndla/icons/editor";
20
- import { IFolder } from "@ndla/types-backend/learningpath-api";
20
+ import { IFolder } from "@ndla/types-backend/myndla-api";
21
21
  import { uuid } from "@ndla/util";
22
22
  import { flattenFolders } from "./helperFunctions";
23
23
  import TreeStructure, { TreeStructureProps } from "./TreeStructure";
@@ -9,7 +9,7 @@
9
9
  import { useEffect, useState, useMemo, useRef } from "react";
10
10
  import styled from "@emotion/styled";
11
11
  import { colors, fonts, misc, utils } from "@ndla/core";
12
- import { IFolder } from "@ndla/types-backend/learningpath-api";
12
+ import { IFolder } from "@ndla/types-backend/myndla-api";
13
13
  import AddFolderButton from "./AddFolderButton";
14
14
  import ComboboxButton from "./ComboboxButton";
15
15
  import FolderItems from "./FolderItems";
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import { KeyboardEvent } from "react";
10
- import { IFolder } from "@ndla/types-backend/learningpath-api";
10
+ import { IFolder } from "@ndla/types-backend/myndla-api";
11
11
 
12
12
  const navigateVertical = (
13
13
  visibleFolders: IFolder[],
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
 
9
- import { IFolder } from "@ndla/types-backend/learningpath-api";
9
+ import { IFolder } from "@ndla/types-backend/myndla-api";
10
10
  import { TreeStructureType } from "./types";
11
11
 
12
12
  export const flattenFolders = (folders: IFolder[], openFolders?: string[]): IFolder[] => {
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import { ReactNode } from "react";
10
- import { IFolder, IResource } from "@ndla/types-backend/learningpath-api";
10
+ import { IFolder, IResource } from "@ndla/types-backend/myndla-api";
11
11
 
12
12
  export type TreeStructureType = "navigation" | "picker";
13
13
 
package/src/index.ts CHANGED
@@ -117,7 +117,7 @@ export type { SimpleBreadcrumbItem, IndexedBreadcrumbItem } from "./Breadcrumb";
117
117
 
118
118
  export { i18nInstance, formatNestedMessages } from "./i18n";
119
119
 
120
- export { default as LayoutItem, OneColumn, PageContainer, Content } from "./Layout";
120
+ export { default as LayoutItem, OneColumn, PageContainer } from "./Layout";
121
121
 
122
122
  export {
123
123
  MediaList,
@@ -1,19 +0,0 @@
1
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
- /**
3
- * Copyright (c) 2016-present, NDLA.
4
- *
5
- * This source code is licensed under the GPLv3 license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- *
8
- */
9
-
10
- export const Content = _ref => {
11
- let {
12
- children
13
- } = _ref;
14
- return _jsx("div", {
15
- className: "o-content",
16
- children: children
17
- });
18
- };
19
- export default Content;
@@ -1,13 +0,0 @@
1
- /**
2
- * Copyright (c) 2016-present, NDLA.
3
- *
4
- * This source code is licensed under the GPLv3 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
- import { ReactNode } from "react";
9
- interface Props {
10
- children: ReactNode;
11
- }
12
- export declare const Content: ({ children }: Props) => import("@emotion/react/jsx-runtime").JSX.Element;
13
- export default Content;
@@ -1,26 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.Content = void 0;
7
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
8
- /**
9
- * Copyright (c) 2016-present, NDLA.
10
- *
11
- * This source code is licensed under the GPLv3 license found in the
12
- * LICENSE file in the root directory of this source tree.
13
- *
14
- */
15
-
16
- const Content = _ref => {
17
- let {
18
- children
19
- } = _ref;
20
- return (0, _jsxRuntime.jsx)("div", {
21
- className: "o-content",
22
- children: children
23
- });
24
- };
25
- exports.Content = Content;
26
- var _default = exports.default = Content;
@@ -1,17 +0,0 @@
1
- /**
2
- * Copyright (c) 2016-present, NDLA.
3
- *
4
- * This source code is licensed under the GPLv3 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
- import { ReactNode } from "react";
10
-
11
- interface Props {
12
- children: ReactNode;
13
- }
14
-
15
- export const Content = ({ children }: Props) => <div className="o-content">{children}</div>;
16
-
17
- export default Content;