@reykjavik/hanna-react 0.10.153 → 0.10.155

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/CHANGELOG.md CHANGED
@@ -4,6 +4,20 @@
4
4
 
5
5
  - ... <!-- Add new lines here. -->
6
6
 
7
+ ## 0.10.155
8
+
9
+ _2025-06-23_
10
+
11
+ - feat: Allow `MainMenu2` items to be `undefined` for easier conditional item
12
+ array population
13
+
14
+ ## 0.10.154
15
+
16
+ _2025-06-20_
17
+
18
+ - feat: Add optional `inline` prop to `LayoutProps.customLogo`
19
+ - fix: `ImageProps.inline` should not fail to replace with an empty result
20
+
7
21
  ## 0.10.153
8
22
 
9
23
  _2025-06-19_
package/MainMenu2.d.ts CHANGED
@@ -64,11 +64,11 @@ export type MainMenu2SubMenuItem = MainMenu2Item & {
64
64
  export type MainMenu2SubMenu = {
65
65
  title: string;
66
66
  current?: boolean;
67
- subItems: Array<MainMenu2SubMenuItem | MainMenu2CustomItem>;
67
+ subItems: Array<MainMenu2SubMenuItem | MainMenu2CustomItem | undefined>;
68
68
  };
69
- export type MainMenu2ItemList = Array<MainMenu2Item | MainMenu2CustomItem>;
70
- export type MainMenu2ButtonItemList = Array<MainMenu2ButtonItem | MainMenu2CustomItem>;
71
- export type MainMenu2SubMenuItemList = Array<MainMenu2SubMenuItem | MainMenu2CustomItem>;
69
+ export type MainMenu2ItemList = Array<MainMenu2Item | MainMenu2CustomItem | undefined>;
70
+ export type MainMenu2ButtonItemList = Array<MainMenu2ButtonItem | MainMenu2CustomItem | undefined>;
71
+ export type MainMenu2SubMenuItemList = Array<MainMenu2SubMenuItem | MainMenu2CustomItem | undefined>;
72
72
  export type MainMenu2Props = {
73
73
  /**
74
74
  * URL for the mandatory (usually screen-reader-only) homepage Link.
package/MainMenu2.js CHANGED
@@ -64,6 +64,9 @@ const iconMap = {
64
64
  const getRenderers = (props) => {
65
65
  const { onItemClick, closeMenu, openMenu, isBrowser } = props;
66
66
  const renderItem = (classPrefix, item, opts = {}) => {
67
+ if (!item) {
68
+ return;
69
+ }
67
70
  const { key, Tag = 'li', button } = opts;
68
71
  if (typeof item === 'function') {
69
72
  const Item = item;
@@ -109,7 +112,8 @@ const getRenderers = (props) => {
109
112
  if (!items || !items.length) {
110
113
  return null;
111
114
  }
112
- return (react_1.default.createElement("ul", Object.assign({ className: `${classSuffix}items` }, opts.listProps), items.map((listItem, i) => renderItem(classSuffix, listItem, { key: i, button: opts.buttons }))));
115
+ return (react_1.default.createElement("ul", Object.assign({ className: `${classSuffix}items` }, opts.listProps), items.map((listItem, i) => listItem &&
116
+ renderItem(classSuffix, listItem, { key: i, button: opts.buttons }))));
113
117
  };
114
118
  return { renderList, renderItem };
115
119
  };
@@ -163,7 +167,7 @@ const MainMenu2 = (props) => {
163
167
  if (!('title' in item) || 'current' in item) {
164
168
  return item;
165
169
  }
166
- const current = (_a = item.subItems.find((subItem) => 'current' in subItem && !!subItem.current)) === null || _a === void 0 ? void 0 : _a.current;
170
+ const current = (_a = item.subItems.find((subItem) => !!(subItem && 'current' in subItem && !!subItem.current))) === null || _a === void 0 ? void 0 : _a.current;
167
171
  return Object.assign(Object.assign({}, item), { current });
168
172
  });
169
173
  let defaultActive = mainItems.findIndex((item) => 'current' in item && item.current);
@@ -1,6 +1,7 @@
1
1
  export declare const renderLayoutHomeLink: (bem: string, logoLink: string, siteName?: string, customLogo?: {
2
2
  src: string;
3
3
  altText: string;
4
+ inline?: boolean;
4
5
  }) => JSX.Element;
5
6
  export declare const issueSiteNameWarningInDev: (props: {
6
7
  siteName?: string;
@@ -15,7 +15,7 @@ const renderLayoutHomeLink = (bem, logoLink, siteName, customLogo) => {
15
15
  return (react_1.default.createElement(_Link_js_1.Link, { className: `${bem}__header__homelink`, href: logoLink },
16
16
  ' ',
17
17
  react_1.default.createElement(_Image_js_1.Image, { bem: undefined, className: (0, hanna_utils_1.modifiedClass)(`${bem}__header__logo`, customLogo && 'custom'), src: (customLogo === null || customLogo === void 0 ? void 0 : customLogo.src) ||
18
- (0, assets_1.getRvkLogoUrl)(siteName ? 'reykjavik-logo-notext.svg' : 'reykjavik-logo.svg'), altText: (customLogo === null || customLogo === void 0 ? void 0 : customLogo.altText) || 'Reykjavík', inline: true }),
18
+ (0, assets_1.getRvkLogoUrl)(siteName ? 'reykjavik-logo-notext.svg' : 'reykjavik-logo.svg'), altText: (customLogo === null || customLogo === void 0 ? void 0 : customLogo.altText) || 'Reykjavík', inline: customLogo ? customLogo.inline : true }),
19
19
  ' ',
20
20
  siteName && react_1.default.createElement("span", { className: `${bem}__header__sitename` }, siteName),
21
21
  ' '));
@@ -64,11 +64,11 @@ export type MainMenu2SubMenuItem = MainMenu2Item & {
64
64
  export type MainMenu2SubMenu = {
65
65
  title: string;
66
66
  current?: boolean;
67
- subItems: Array<MainMenu2SubMenuItem | MainMenu2CustomItem>;
67
+ subItems: Array<MainMenu2SubMenuItem | MainMenu2CustomItem | undefined>;
68
68
  };
69
- export type MainMenu2ItemList = Array<MainMenu2Item | MainMenu2CustomItem>;
70
- export type MainMenu2ButtonItemList = Array<MainMenu2ButtonItem | MainMenu2CustomItem>;
71
- export type MainMenu2SubMenuItemList = Array<MainMenu2SubMenuItem | MainMenu2CustomItem>;
69
+ export type MainMenu2ItemList = Array<MainMenu2Item | MainMenu2CustomItem | undefined>;
70
+ export type MainMenu2ButtonItemList = Array<MainMenu2ButtonItem | MainMenu2CustomItem | undefined>;
71
+ export type MainMenu2SubMenuItemList = Array<MainMenu2SubMenuItem | MainMenu2CustomItem | undefined>;
72
72
  export type MainMenu2Props = {
73
73
  /**
74
74
  * URL for the mandatory (usually screen-reader-only) homepage Link.
package/esm/MainMenu2.js CHANGED
@@ -60,6 +60,9 @@ const iconMap = {
60
60
  const getRenderers = (props) => {
61
61
  const { onItemClick, closeMenu, openMenu, isBrowser } = props;
62
62
  const renderItem = (classPrefix, item, opts = {}) => {
63
+ if (!item) {
64
+ return;
65
+ }
63
66
  const { key, Tag = 'li', button } = opts;
64
67
  if (typeof item === 'function') {
65
68
  const Item = item;
@@ -105,7 +108,8 @@ const getRenderers = (props) => {
105
108
  if (!items || !items.length) {
106
109
  return null;
107
110
  }
108
- return (React.createElement("ul", Object.assign({ className: `${classSuffix}items` }, opts.listProps), items.map((listItem, i) => renderItem(classSuffix, listItem, { key: i, button: opts.buttons }))));
111
+ return (React.createElement("ul", Object.assign({ className: `${classSuffix}items` }, opts.listProps), items.map((listItem, i) => listItem &&
112
+ renderItem(classSuffix, listItem, { key: i, button: opts.buttons }))));
109
113
  };
110
114
  return { renderList, renderItem };
111
115
  };
@@ -159,7 +163,7 @@ export const MainMenu2 = (props) => {
159
163
  if (!('title' in item) || 'current' in item) {
160
164
  return item;
161
165
  }
162
- const current = (_a = item.subItems.find((subItem) => 'current' in subItem && !!subItem.current)) === null || _a === void 0 ? void 0 : _a.current;
166
+ const current = (_a = item.subItems.find((subItem) => !!(subItem && 'current' in subItem && !!subItem.current))) === null || _a === void 0 ? void 0 : _a.current;
163
167
  return Object.assign(Object.assign({}, item), { current });
164
168
  });
165
169
  let defaultActive = mainItems.findIndex((item) => 'current' in item && item.current);
@@ -1,6 +1,7 @@
1
1
  export declare const renderLayoutHomeLink: (bem: string, logoLink: string, siteName?: string, customLogo?: {
2
2
  src: string;
3
3
  altText: string;
4
+ inline?: boolean;
4
5
  }) => JSX.Element;
5
6
  export declare const issueSiteNameWarningInDev: (props: {
6
7
  siteName?: string;
@@ -11,7 +11,7 @@ export const renderLayoutHomeLink = (bem, logoLink, siteName, customLogo) => {
11
11
  return (React.createElement(Link, { className: `${bem}__header__homelink`, href: logoLink },
12
12
  ' ',
13
13
  React.createElement(Image, { bem: undefined, className: modifiedClass(`${bem}__header__logo`, customLogo && 'custom'), src: (customLogo === null || customLogo === void 0 ? void 0 : customLogo.src) ||
14
- getRvkLogoUrl(siteName ? 'reykjavik-logo-notext.svg' : 'reykjavik-logo.svg'), altText: (customLogo === null || customLogo === void 0 ? void 0 : customLogo.altText) || 'Reykjavík', inline: true }),
14
+ getRvkLogoUrl(siteName ? 'reykjavik-logo-notext.svg' : 'reykjavik-logo.svg'), altText: (customLogo === null || customLogo === void 0 ? void 0 : customLogo.altText) || 'Reykjavík', inline: customLogo ? customLogo.inline : true }),
15
15
  ' ',
16
16
  siteName && React.createElement("span", { className: `${bem}__header__sitename` }, siteName),
17
17
  ' '));
@@ -10,6 +10,9 @@ export const useGetSVGtext = (imageSrc, altText) => {
10
10
  useEffect(() => {
11
11
  if (imageSrc) {
12
12
  getSVGtext(imageSrc, altText).then((code) => {
13
+ if (!code) {
14
+ return;
15
+ }
13
16
  if (imageSrc === srcRef.current) {
14
17
  setInlineSvg({ imageSrc, code });
15
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reykjavik/hanna-react",
3
- "version": "0.10.153",
3
+ "version": "0.10.155",
4
4
  "author": "Reykjavík (http://www.reykjavik.is)",
5
5
  "contributors": [
6
6
  "Hugsmiðjan ehf (http://www.hugsmidjan.is)",
@@ -17,7 +17,7 @@
17
17
  "@floating-ui/react": "^0.19.2",
18
18
  "@hugsmidjan/qj": "^4.22.1",
19
19
  "@hugsmidjan/react": "^0.4.32",
20
- "@reykjavik/hanna-css": "^0.4.18",
20
+ "@reykjavik/hanna-css": "^0.4.19",
21
21
  "@reykjavik/hanna-utils": "^0.2.21",
22
22
  "@types/react-autosuggest": "^10.1.0",
23
23
  "@types/react-datepicker": "^4.8.0",
@@ -13,6 +13,9 @@ const useGetSVGtext = (imageSrc, altText) => {
13
13
  (0, react_1.useEffect)(() => {
14
14
  if (imageSrc) {
15
15
  (0, hanna_utils_1.getSVGtext)(imageSrc, altText).then((code) => {
16
+ if (!code) {
17
+ return;
18
+ }
16
19
  if (imageSrc === srcRef.current) {
17
20
  setInlineSvg({ imageSrc, code });
18
21
  }