@ndla/ui 3.3.11 → 3.3.12

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.
@@ -73,7 +73,7 @@ const StyledLetterSpacing = styled.span`
73
73
  type subjectProps = {
74
74
  name: string;
75
75
  url?: string;
76
- path: string;
76
+ path?: string;
77
77
  id?: string;
78
78
  };
79
79
  type categoryProps = {
@@ -160,7 +160,7 @@ const renderList = (
160
160
  onNavigate();
161
161
  }
162
162
  }}
163
- to={subject.url || subject.path}>
163
+ to={subject.url || subject.path || ''}>
164
164
  {subject.name}
165
165
  </SafeLink>
166
166
  <StyledSpacingElement />
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
 
9
- import React, { useEffect, useRef, useState } from 'react';
9
+ import React, { FormEvent, useEffect, useRef, useState } from 'react';
10
10
  import styled from '@emotion/styled';
11
11
  import { colors, breakpoints, mq } from '@ndla/core';
12
12
  // @ts-ignore
@@ -76,8 +76,8 @@ const SearchInput = styled.input`
76
76
  `;
77
77
 
78
78
  type Props = {
79
- onSubmit: (event: {}) => void;
80
- value: string;
79
+ onSubmit: (event: FormEvent<HTMLFormElement>) => void;
80
+ value?: string;
81
81
  onChange: (value: string) => void;
82
82
  filters?: PopupFilterProps;
83
83
  activeFilters?: {
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
 
9
- import React from 'react';
9
+ import React, { FormEvent } from 'react';
10
10
  import styled from '@emotion/styled';
11
11
  import { breakpoints, fonts, mq, spacing } from '@ndla/core';
12
12
 
@@ -75,7 +75,7 @@ type Props = {
75
75
  searchPhrase?: string;
76
76
  searchPhraseSuggestion?: string;
77
77
  searchPhraseSuggestionOnClick?: () => void;
78
- searchValue: string;
78
+ searchValue?: string;
79
79
  filters?: PopupFilterProps;
80
80
  activeFilters?: {
81
81
  filters: FilterProps[];
@@ -83,7 +83,7 @@ type Props = {
83
83
  };
84
84
  competenceGoals?: CompetenceGoalsItemType[];
85
85
  onSearchValueChange: (value: string) => void;
86
- onSubmit: () => void;
86
+ onSubmit: (event: FormEvent<HTMLFormElement>) => void;
87
87
  noResults?: boolean;
88
88
  };
89
89
 
@@ -203,12 +203,11 @@ type context = {
203
203
  };
204
204
 
205
205
  export type SearchItemType = {
206
- id: string;
206
+ id: string | number;
207
207
  title: string;
208
208
  url: string;
209
209
  ingress: string;
210
- contexts: context[];
211
- image: React.ReactNode | null;
210
+ contexts?: context[];
212
211
  img?: { url: string; alt: string };
213
212
  labels?: string[];
214
213
  children?: React.ReactNode;
@@ -220,7 +219,7 @@ type Props = {
220
219
  const SearchItem = ({ item, type }: Props) => {
221
220
  const { t } = useTranslation();
222
221
  const { title, url, ingress, contexts, img = null, labels = [] } = item;
223
- const mainContext = contexts[0];
222
+ const mainContext = contexts?.[0];
224
223
 
225
224
  const Breadcrumb = ({ breadcrumb, children }: { breadcrumb: string[]; children?: React.ReactNode }) => (
226
225
  <BreadcrumbPath>
@@ -268,7 +267,7 @@ const SearchItem = ({ item, type }: Props) => {
268
267
  {item.children}
269
268
  <ItemText>{parse(ingress)}</ItemText>
270
269
  {mainContext && <Breadcrumb breadcrumb={mainContext.breadcrumb} />}
271
- {contexts.length > 1 && (
270
+ {contexts && contexts.length > 1 && (
272
271
  <ContextsWrapper>
273
272
  <Modal
274
273
  activateButton={
@@ -120,7 +120,7 @@ const AuthorsWrapper = styled.div`
120
120
  `;
121
121
 
122
122
  export type SearchNotionItemProps = {
123
- id: string;
123
+ id: string | number;
124
124
  title: string;
125
125
  text: React.ReactNode;
126
126
  image?: { url: string; alt: string };
@@ -12,4 +12,6 @@ import SearchFieldHeader from './SearchFieldHeader';
12
12
  import SearchNotionsResult from './SearchNotionsResult';
13
13
  import SearchSubjectResult from './SearchSubjectResult';
14
14
 
15
+ export type { ContentType } from './SearchTypeResult';
16
+
15
17
  export { SearchTypeResult, SearchHeader, SearchFieldHeader, SearchNotionsResult, SearchSubjectResult };