@reykjavik/hanna-react 0.10.102 → 0.10.103

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,15 @@
4
4
 
5
5
  - ... <!-- Add new lines here. -->
6
6
 
7
+ ## 0.10.103
8
+
9
+ _2023-09-13_
10
+
11
+ - feat: Allow `BlingComboProps` values as `blingType` for `NewsHero` and
12
+ `InfoHero`
13
+ - fix: Correctly pass `ssr` prop down to sub-`Tabs`
14
+ - fix: Respect `ssr` passed to `VerticalTabsTOC`
15
+
7
16
  ## 0.10.102
8
17
 
9
18
  _2023-09-04_
package/InfoHero.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { BlingComboProps } from './_abstract/_Blings.js';
1
2
  import { ButtonProps } from './_abstract/_Button.js';
2
3
  import { ImageProps } from './_abstract/_Image.js';
3
4
  import { Alignment } from './constants.js';
@@ -13,7 +14,7 @@ export type InfoHeroProps = {
13
14
  footer?: string | JSX.Element;
14
15
  align?: Alignment;
15
16
  image?: ImageProps;
16
- blingType?: BlingOptions;
17
+ blingType?: BlingOptions | BlingComboProps;
17
18
  } & WrapperElmProps;
18
19
  export declare const InfoHero: (props: InfoHeroProps) => JSX.Element;
19
20
  export default InfoHero;
package/InfoHero.js CHANGED
@@ -71,8 +71,9 @@ const InfoHero = (props) => {
71
71
  const { title, titleBlurb, subTitle, blurb, image, buttons = [], footer, align, blingType, wrapperProps, } = props;
72
72
  const showButtons = Boolean(buttons.length);
73
73
  const alignment = align && constants_js_1.aligns[align] ? align : 'right';
74
- const blings = (blingType && blingOptions[blingType]) ||
75
- blingOptions.waves; // default to `waves`
74
+ const blings = typeof blingType === 'object'
75
+ ? blingType
76
+ : (blingType && blingOptions[blingType]) || blingOptions.waves; // default to `waves`
76
77
  return (react_1.default.createElement("div", Object.assign({}, wrapperProps, { className: (0, classUtils_1.modifiedClass)('InfoHero', 'align--' + alignment, (wrapperProps || {}).className) }),
77
78
  react_1.default.createElement("div", { className: "InfoHero__content" },
78
79
  react_1.default.createElement("h1", { className: "InfoHero__title" }, title),
package/NewsHero.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { BlingComboProps } from './_abstract/_Blings.js';
1
2
  import { ImageProps } from './_abstract/_Image.js';
2
3
  import { DeprecatedSeenProp } from './utils/seenEffect.js';
3
4
  import { WrapperElmProps } from './utils.js';
@@ -9,7 +10,7 @@ export type NewsHeroProps = {
9
10
  /** For custom sharing component */
10
11
  sharing?: boolean | (() => JSX.Element);
11
12
  image?: ImageProps;
12
- blingType?: BlingOptions;
13
+ blingType?: BlingOptions | BlingComboProps;
13
14
  } & WrapperElmProps & DeprecatedSeenProp;
14
15
  export declare const NewsHero: (props: NewsHeroProps) => JSX.Element;
15
16
  export default NewsHero;
package/NewsHero.js CHANGED
@@ -76,7 +76,10 @@ const blingOptions = {
76
76
  };
77
77
  const NewsHero = (props) => {
78
78
  const { title, sharing = true, meta, summary, image, blingType, wrapperProps } = props;
79
- const blings = (blingType && blingOptions[blingType]) || (0, hanna_utils_1.getStableRandomItem)(blingOptions, title);
79
+ const blings = typeof blingType === 'object'
80
+ ? blingType
81
+ : (blingType && blingOptions[blingType]) ||
82
+ (0, hanna_utils_1.getStableRandomItem)(blingOptions, title);
80
83
  return (react_1.default.createElement("div", Object.assign({}, wrapperProps, { className: (0, classUtils_1.modifiedClass)('NewsHero', [!image && 'align--right'], (wrapperProps || {}).className) }),
81
84
  react_1.default.createElement("div", { className: "NewsHero__content" },
82
85
  react_1.default.createElement("h1", { className: "NewsHero__title" }, title),
package/Tabs.d.ts CHANGED
@@ -26,7 +26,7 @@ type BaseTabsProps<T extends TabItemProps = TabItemProps> = {
26
26
  export type TabsProps<T extends TabItemProps = TabItemProps> = BaseTabsProps<T> & {
27
27
  vertical?: boolean;
28
28
  /** Optional <Tabs/> block connected to the currently active tab */
29
- subTabs?: BaseTabsProps;
29
+ subTabs?: Omit<BaseTabsProps, 'ssr'>;
30
30
  } & WrapperElmProps<null, 'role' | 'aria-label' | 'aria-labelledby'> & DeprecatedSeenProp;
31
31
  /** @deprecated Use `TabsProps` instead (Will be removed in v0.11) */
32
32
  export type TablistProps<T extends TabItemProps = TabItemProps> = TabsProps<T>;
package/Tabs.js CHANGED
@@ -47,7 +47,7 @@ const renderTab = (tabProps, index, listProps) => {
47
47
  // NOTE: This isBrowser tablist behavior is based on
48
48
  // https://www.w3.org/TR/wai-aria-practices-1.1/examples/tabs/tabs-2/tabs.html
49
49
  const Tabs = (props) => {
50
- var _a, _b;
50
+ var _a;
51
51
  const { tabs, role, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-controls': listAriaControls, wrapperProps = {}, id = wrapperProps.id, activeIdx, onSetActive, activateOnFocus, ssr, vertical, subTabs, } = props;
52
52
  const isBrowser = (0, utils_js_1.useIsBrowserSide)(ssr);
53
53
  const [focusedIdx, setFocusedIdx] = (0, react_1.useState)(activeIdx || 0);
@@ -89,7 +89,7 @@ const Tabs = (props) => {
89
89
  };
90
90
  return (react_1.default.createElement("div", Object.assign({}, props.wrapperProps, { className: (0, classUtils_1.modifiedClass)('Tabs', vertical && 'vertical', wrapperProps.className), role: tabRole && role, id: id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, onKeyDown: handleKeydown, "data-sprinkled": isBrowser }),
91
91
  tabs.map((tabProps, index) => renderTab(tabProps, index, listProps)),
92
- subTabs && (react_1.default.createElement(exports.Tabs, Object.assign({}, subTabs, { role: 'role' in subTabs ? subTabs.role : role, activateOnFocus: (_a = subTabs.activateOnFocus) !== null && _a !== void 0 ? _a : activateOnFocus, ssr: (_b = subTabs.ssr) !== null && _b !== void 0 ? _b : ssr,
92
+ subTabs && (react_1.default.createElement(exports.Tabs, Object.assign({}, subTabs, { role: 'role' in subTabs ? subTabs.role : role, activateOnFocus: (_a = subTabs.activateOnFocus) !== null && _a !== void 0 ? _a : activateOnFocus, ssr: ssr,
93
93
  // just to be sure
94
94
  vertical: undefined, subTabs: undefined })))));
95
95
  };
@@ -67,7 +67,7 @@ const VerticalTabsTOC = (props) => {
67
67
  const itemId = getItemId(item);
68
68
  const newId = itemId || getItemId((_a = itemsById[itemId].subTabs) === null || _a === void 0 ? void 0 : _a.tabs[0]);
69
69
  (0, frag_1.setFrag)(newId);
70
- }, tabs: updatedItems, role: "tablist", activateOnFocus: props.activateOnFocus, activeIdx: state.activeIdx, subTabs: state.subTabs }));
70
+ }, tabs: updatedItems, role: "tablist", activateOnFocus: props.activateOnFocus, activeIdx: state.activeIdx, subTabs: state.subTabs, ssr: props.ssr }));
71
71
  };
72
72
  exports.VerticalTabsTOC = VerticalTabsTOC;
73
73
  exports.default = exports.VerticalTabsTOC;
@@ -1,8 +1,9 @@
1
1
  import { BlingType } from '@reykjavik/hanna-utils/assets';
2
2
  import { BlingProps } from '../Bling.js';
3
- export type BlingComboProps = Array<Omit<BlingProps, 'type' | 'blingUrl'> & {
3
+ type ConstrainedBlingProps = {
4
4
  type: BlingType;
5
- }>;
5
+ } & Omit<BlingProps, 'type' | 'blingUrl'>;
6
+ export type BlingComboProps = [ConstrainedBlingProps, ...Array<ConstrainedBlingProps>];
6
7
  type BlingsProps = {
7
8
  blings: BlingComboProps;
8
9
  mirror?: boolean;
package/esm/InfoHero.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { BlingComboProps } from './_abstract/_Blings.js';
1
2
  import { ButtonProps } from './_abstract/_Button.js';
2
3
  import { ImageProps } from './_abstract/_Image.js';
3
4
  import { Alignment } from './constants.js';
@@ -13,7 +14,7 @@ export type InfoHeroProps = {
13
14
  footer?: string | JSX.Element;
14
15
  align?: Alignment;
15
16
  image?: ImageProps;
16
- blingType?: BlingOptions;
17
+ blingType?: BlingOptions | BlingComboProps;
17
18
  } & WrapperElmProps;
18
19
  export declare const InfoHero: (props: InfoHeroProps) => JSX.Element;
19
20
  export default InfoHero;
package/esm/InfoHero.js CHANGED
@@ -67,8 +67,9 @@ export const InfoHero = (props) => {
67
67
  const { title, titleBlurb, subTitle, blurb, image, buttons = [], footer, align, blingType, wrapperProps, } = props;
68
68
  const showButtons = Boolean(buttons.length);
69
69
  const alignment = align && aligns[align] ? align : 'right';
70
- const blings = (blingType && blingOptions[blingType]) ||
71
- blingOptions.waves; // default to `waves`
70
+ const blings = typeof blingType === 'object'
71
+ ? blingType
72
+ : (blingType && blingOptions[blingType]) || blingOptions.waves; // default to `waves`
72
73
  return (React.createElement("div", Object.assign({}, wrapperProps, { className: modifiedClass('InfoHero', 'align--' + alignment, (wrapperProps || {}).className) }),
73
74
  React.createElement("div", { className: "InfoHero__content" },
74
75
  React.createElement("h1", { className: "InfoHero__title" }, title),
package/esm/NewsHero.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { BlingComboProps } from './_abstract/_Blings.js';
1
2
  import { ImageProps } from './_abstract/_Image.js';
2
3
  import { DeprecatedSeenProp } from './utils/seenEffect.js';
3
4
  import { WrapperElmProps } from './utils.js';
@@ -9,7 +10,7 @@ export type NewsHeroProps = {
9
10
  /** For custom sharing component */
10
11
  sharing?: boolean | (() => JSX.Element);
11
12
  image?: ImageProps;
12
- blingType?: BlingOptions;
13
+ blingType?: BlingOptions | BlingComboProps;
13
14
  } & WrapperElmProps & DeprecatedSeenProp;
14
15
  export declare const NewsHero: (props: NewsHeroProps) => JSX.Element;
15
16
  export default NewsHero;
package/esm/NewsHero.js CHANGED
@@ -72,7 +72,10 @@ const blingOptions = {
72
72
  };
73
73
  export const NewsHero = (props) => {
74
74
  const { title, sharing = true, meta, summary, image, blingType, wrapperProps } = props;
75
- const blings = (blingType && blingOptions[blingType]) || getStableRandomItem(blingOptions, title);
75
+ const blings = typeof blingType === 'object'
76
+ ? blingType
77
+ : (blingType && blingOptions[blingType]) ||
78
+ getStableRandomItem(blingOptions, title);
76
79
  return (React.createElement("div", Object.assign({}, wrapperProps, { className: modifiedClass('NewsHero', [!image && 'align--right'], (wrapperProps || {}).className) }),
77
80
  React.createElement("div", { className: "NewsHero__content" },
78
81
  React.createElement("h1", { className: "NewsHero__title" }, title),
package/esm/Tabs.d.ts CHANGED
@@ -26,7 +26,7 @@ type BaseTabsProps<T extends TabItemProps = TabItemProps> = {
26
26
  export type TabsProps<T extends TabItemProps = TabItemProps> = BaseTabsProps<T> & {
27
27
  vertical?: boolean;
28
28
  /** Optional <Tabs/> block connected to the currently active tab */
29
- subTabs?: BaseTabsProps;
29
+ subTabs?: Omit<BaseTabsProps, 'ssr'>;
30
30
  } & WrapperElmProps<null, 'role' | 'aria-label' | 'aria-labelledby'> & DeprecatedSeenProp;
31
31
  /** @deprecated Use `TabsProps` instead (Will be removed in v0.11) */
32
32
  export type TablistProps<T extends TabItemProps = TabItemProps> = TabsProps<T>;
package/esm/Tabs.js CHANGED
@@ -43,7 +43,7 @@ const renderTab = (tabProps, index, listProps) => {
43
43
  // NOTE: This isBrowser tablist behavior is based on
44
44
  // https://www.w3.org/TR/wai-aria-practices-1.1/examples/tabs/tabs-2/tabs.html
45
45
  export const Tabs = (props) => {
46
- var _a, _b;
46
+ var _a;
47
47
  const { tabs, role, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-controls': listAriaControls, wrapperProps = {}, id = wrapperProps.id, activeIdx, onSetActive, activateOnFocus, ssr, vertical, subTabs, } = props;
48
48
  const isBrowser = useIsBrowserSide(ssr);
49
49
  const [focusedIdx, setFocusedIdx] = useState(activeIdx || 0);
@@ -85,7 +85,7 @@ export const Tabs = (props) => {
85
85
  };
86
86
  return (React.createElement("div", Object.assign({}, props.wrapperProps, { className: modifiedClass('Tabs', vertical && 'vertical', wrapperProps.className), role: tabRole && role, id: id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, onKeyDown: handleKeydown, "data-sprinkled": isBrowser }),
87
87
  tabs.map((tabProps, index) => renderTab(tabProps, index, listProps)),
88
- subTabs && (React.createElement(Tabs, Object.assign({}, subTabs, { role: 'role' in subTabs ? subTabs.role : role, activateOnFocus: (_a = subTabs.activateOnFocus) !== null && _a !== void 0 ? _a : activateOnFocus, ssr: (_b = subTabs.ssr) !== null && _b !== void 0 ? _b : ssr,
88
+ subTabs && (React.createElement(Tabs, Object.assign({}, subTabs, { role: 'role' in subTabs ? subTabs.role : role, activateOnFocus: (_a = subTabs.activateOnFocus) !== null && _a !== void 0 ? _a : activateOnFocus, ssr: ssr,
89
89
  // just to be sure
90
90
  vertical: undefined, subTabs: undefined })))));
91
91
  };
@@ -63,6 +63,6 @@ export const VerticalTabsTOC = (props) => {
63
63
  const itemId = getItemId(item);
64
64
  const newId = itemId || getItemId((_a = itemsById[itemId].subTabs) === null || _a === void 0 ? void 0 : _a.tabs[0]);
65
65
  setFrag(newId);
66
- }, tabs: updatedItems, role: "tablist", activateOnFocus: props.activateOnFocus, activeIdx: state.activeIdx, subTabs: state.subTabs }));
66
+ }, tabs: updatedItems, role: "tablist", activateOnFocus: props.activateOnFocus, activeIdx: state.activeIdx, subTabs: state.subTabs, ssr: props.ssr }));
67
67
  };
68
68
  export default VerticalTabsTOC;
@@ -1,8 +1,9 @@
1
1
  import { BlingType } from '@reykjavik/hanna-utils/assets';
2
2
  import { BlingProps } from '../Bling.js';
3
- export type BlingComboProps = Array<Omit<BlingProps, 'type' | 'blingUrl'> & {
3
+ type ConstrainedBlingProps = {
4
4
  type: BlingType;
5
- }>;
5
+ } & Omit<BlingProps, 'type' | 'blingUrl'>;
6
+ export type BlingComboProps = [ConstrainedBlingProps, ...Array<ConstrainedBlingProps>];
6
7
  type BlingsProps = {
7
8
  blings: BlingComboProps;
8
9
  mirror?: boolean;
@@ -1,8 +1,8 @@
1
1
  import { RefObject } from 'react';
2
- export declare const DATA_ATTR_NAME = "is-seen";
2
+ export declare const DATA_ATTR_NAME: "is-seen";
3
3
  export declare const getObserver: {
4
4
  (target: Element, callback?: ((target: Element) => void) | undefined): (() => void) | undefined;
5
- DATA_ATTR_NAME: string;
5
+ DATA_ATTR_NAME: "is-seen";
6
6
  };
7
7
  declare const effects: {
8
8
  /** The default effect type */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reykjavik/hanna-react",
3
- "version": "0.10.102",
3
+ "version": "0.10.103",
4
4
  "author": "Reykjavík (http://www.reykjavik.is)",
5
5
  "contributors": [
6
6
  "Hugsmiðjan ehf (http://www.hugsmidjan.is)",
@@ -1,8 +1,8 @@
1
1
  import { RefObject } from 'react';
2
- export declare const DATA_ATTR_NAME = "is-seen";
2
+ export declare const DATA_ATTR_NAME: "is-seen";
3
3
  export declare const getObserver: {
4
4
  (target: Element, callback?: ((target: Element) => void) | undefined): (() => void) | undefined;
5
- DATA_ATTR_NAME: string;
5
+ DATA_ATTR_NAME: "is-seen";
6
6
  };
7
7
  declare const effects: {
8
8
  /** The default effect type */