@reykjavik/hanna-react 0.10.99 → 0.10.101

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 (344) hide show
  1. package/AccordionList.d.ts +2 -2
  2. package/AccordionList.js +2 -2
  3. package/ActionCards.d.ts +2 -1
  4. package/ActionCards.js +1 -1
  5. package/Alert.d.ts +2 -2
  6. package/Alert.js +20 -12
  7. package/ArticleCards.d.ts +4 -1
  8. package/ArticleCards.js +1 -1
  9. package/ArticleCarousel/_ArticleCarouselCard.js +1 -2
  10. package/ArticleCarousel.d.ts +2 -2
  11. package/ArticleCarousel.js +1 -1
  12. package/ArticleMeta.d.ts +2 -1
  13. package/ArticleMeta.js +2 -2
  14. package/Attention.d.ts +2 -1
  15. package/Attention.js +4 -1
  16. package/BasicTable.d.ts +2 -1
  17. package/BgBox.d.ts +2 -1
  18. package/BgBox.js +4 -2
  19. package/Bling.d.ts +2 -1
  20. package/Bling.js +5 -3
  21. package/BlockBreak.js +1 -0
  22. package/BreadCrumbs.d.ts +2 -1
  23. package/BreadCrumbs.js +3 -2
  24. package/ButtonBack.js +2 -0
  25. package/ButtonBar.d.ts +4 -3
  26. package/ButtonBar.js +3 -3
  27. package/ButtonPrimary.js +2 -0
  28. package/ButtonSecondary.js +2 -0
  29. package/ButtonTertiary.js +2 -0
  30. package/CHANGELOG.md +14 -1
  31. package/CarouselStepper.d.ts +2 -1
  32. package/CenterColumn.d.ts +2 -1
  33. package/CenterColumn.js +4 -2
  34. package/CheckboxButton.d.ts +4 -2
  35. package/CheckboxButtonsGroup.js +2 -2
  36. package/CityBlock.d.ts +2 -1
  37. package/CityBlock.js +1 -1
  38. package/ContactBubble.d.ts +2 -2
  39. package/ContactBubble.js +5 -4
  40. package/ContentArticle.d.ts +2 -1
  41. package/ContentArticle.js +3 -2
  42. package/ContentImage.d.ts +2 -1
  43. package/ContentImage.js +4 -3
  44. package/Datepicker.js +6 -6
  45. package/ExtraLinks.d.ts +2 -1
  46. package/ExtraLinks.js +4 -2
  47. package/FeatureList.d.ts +2 -1
  48. package/FeatureList.js +3 -2
  49. package/FieldGroup.d.ts +2 -1
  50. package/FieldGroup.js +4 -2
  51. package/FileInput.d.ts +2 -2
  52. package/FileInput.js +10 -5
  53. package/Foonote.js +3 -4
  54. package/Footnote.d.ts +2 -1
  55. package/Footnote.js +2 -1
  56. package/Form.js +4 -5
  57. package/FormField.d.ts +25 -5
  58. package/FormField.js +32 -7
  59. package/Gallery/_GalleryItem.js +2 -2
  60. package/Gallery/_GalleryModalItem.js +1 -1
  61. package/Gallery.d.ts +2 -2
  62. package/Gallery.js +5 -4
  63. package/GridBlocks.d.ts +2 -5
  64. package/GridBlocks.js +3 -3
  65. package/Heading.d.ts +2 -1
  66. package/Heading.js +3 -3
  67. package/HeroBlock.d.ts +2 -1
  68. package/HeroBlock.js +4 -3
  69. package/IframeBlock.d.ts +9 -4
  70. package/IframeBlock.js +13 -12
  71. package/Illustration.d.ts +2 -1
  72. package/Illustration.js +1 -1
  73. package/ImageCards.d.ts +2 -1
  74. package/ImageCards.js +2 -2
  75. package/InfoBlock.d.ts +2 -1
  76. package/InfoBlock.js +3 -2
  77. package/InfoHero.d.ts +2 -1
  78. package/InfoHero.js +3 -3
  79. package/IslandBlock.d.ts +2 -1
  80. package/IslandBlock.js +2 -2
  81. package/IslandPageBlock.d.ts +2 -1
  82. package/IslandPageBlock.js +2 -2
  83. package/LabeledTextBlock.d.ts +2 -1
  84. package/LabeledTextBlock.js +2 -2
  85. package/Layout.d.ts +2 -2
  86. package/Layout.js +3 -3
  87. package/MainMenu.d.ts +2 -2
  88. package/MainMenu.js +4 -3
  89. package/MiniMetrics.d.ts +2 -1
  90. package/MiniMetrics.js +3 -2
  91. package/Modal.d.ts +2 -1
  92. package/Multiselect.d.ts +11 -6
  93. package/Multiselect.js +15 -11
  94. package/NameCard.d.ts +2 -1
  95. package/NameCard.js +10 -6
  96. package/NameCards.d.ts +3 -2
  97. package/NameCards.js +3 -2
  98. package/NewsHero.d.ts +2 -1
  99. package/NewsHero.js +3 -3
  100. package/PageFilter.d.ts +2 -1
  101. package/PageFilter.js +2 -2
  102. package/PageHeading.d.ts +2 -1
  103. package/PageHeading.js +2 -5
  104. package/Picture.d.ts +2 -1
  105. package/Picture.js +1 -5
  106. package/ProcessOverview.d.ts +2 -1
  107. package/ProcessOverview.js +2 -5
  108. package/RadioButtonsGroup.js +2 -2
  109. package/RadioGroup.js +1 -1
  110. package/ReadSpeakerPlayer.d.ts +1 -1
  111. package/ReadSpeakerPlayer.js +2 -2
  112. package/RelatedLinks.d.ts +2 -1
  113. package/RelatedLinks.js +3 -2
  114. package/RowBlock.d.ts +2 -1
  115. package/RowBlock.js +2 -2
  116. package/RowBlockColumn.d.ts +2 -1
  117. package/RowBlockColumn.js +3 -3
  118. package/SearchInput.d.ts +3 -9
  119. package/SearchInput.js +4 -5
  120. package/SearchResults/_SearchResultsItem.js +1 -1
  121. package/SearchResults.d.ts +2 -1
  122. package/SearchResults.js +2 -2
  123. package/SeenEffect.js +2 -0
  124. package/Selectbox.js +3 -4
  125. package/ShareButtons.d.ts +2 -2
  126. package/ShareButtons.js +5 -3
  127. package/Sharpie.d.ts +2 -1
  128. package/Sharpie.js +2 -2
  129. package/SiteSearchAutocomplete.d.ts +2 -1
  130. package/SiteSearchAutocomplete.js +4 -4
  131. package/SiteSearchCurtain.js +2 -0
  132. package/SiteSearchInput.d.ts +3 -6
  133. package/SiteSearchInput.js +4 -4
  134. package/Skeleton.d.ts +4 -1
  135. package/Skeleton.js +15 -18
  136. package/SubHeading.d.ts +2 -1
  137. package/SubHeading.js +3 -3
  138. package/Tabs.d.ts +2 -2
  139. package/Tabs.js +5 -5
  140. package/TagPill.js +2 -0
  141. package/TextBlock.d.ts +2 -1
  142. package/TextBlock.js +3 -3
  143. package/TextButton.js +2 -0
  144. package/TextInput.d.ts +2 -2
  145. package/TextInput.js +3 -4
  146. package/Tooltip.d.ts +2 -1
  147. package/Tooltip.js +28 -15
  148. package/VSpacer.d.ts +2 -1
  149. package/VSpacer.js +3 -7
  150. package/VerticalTabsTOC.d.ts +1 -1
  151. package/VerticalTabsTOC.js +1 -1
  152. package/WizardLayout.d.ts +2 -2
  153. package/WizardLayout.js +4 -3
  154. package/WizardLayoutClose.js +2 -0
  155. package/WizardStepper.d.ts +2 -1
  156. package/WizardStepper.js +2 -2
  157. package/_abstract/_AbstractCarousel.d.ts +2 -2
  158. package/_abstract/_AbstractCarousel.js +6 -3
  159. package/_abstract/_Block.d.ts +2 -1
  160. package/_abstract/_Block.js +3 -3
  161. package/_abstract/_Button.js +4 -1
  162. package/_abstract/_CardList.d.ts +3 -1
  163. package/_abstract/_CardList.js +6 -3
  164. package/_abstract/_Image.d.ts +6 -3
  165. package/_abstract/_Image.js +11 -4
  166. package/_abstract/_Quote.d.ts +2 -1
  167. package/_abstract/_Quote.js +3 -2
  168. package/_abstract/_TogglerGroup.js +1 -1
  169. package/_abstract/_TogglerGroupField.js +5 -5
  170. package/_abstract/_TogglerInput.d.ts +2 -2
  171. package/_abstract/_TogglerInput.js +4 -2
  172. package/esm/AccordionList.d.ts +2 -2
  173. package/esm/AccordionList.js +3 -3
  174. package/esm/ActionCards.d.ts +2 -1
  175. package/esm/ActionCards.js +1 -1
  176. package/esm/Alert.d.ts +2 -2
  177. package/esm/Alert.js +21 -13
  178. package/esm/ArticleCards.d.ts +4 -1
  179. package/esm/ArticleCards.js +1 -1
  180. package/esm/ArticleCarousel/_ArticleCarouselCard.js +1 -2
  181. package/esm/ArticleCarousel.d.ts +2 -2
  182. package/esm/ArticleCarousel.js +1 -1
  183. package/esm/ArticleMeta.d.ts +2 -1
  184. package/esm/ArticleMeta.js +2 -2
  185. package/esm/Attention.d.ts +2 -1
  186. package/esm/Attention.js +4 -1
  187. package/esm/BasicTable.d.ts +2 -1
  188. package/esm/BgBox.d.ts +2 -1
  189. package/esm/BgBox.js +4 -2
  190. package/esm/Bling.d.ts +2 -1
  191. package/esm/Bling.js +5 -3
  192. package/esm/BlockBreak.js +1 -0
  193. package/esm/BreadCrumbs.d.ts +2 -1
  194. package/esm/BreadCrumbs.js +3 -2
  195. package/esm/ButtonBack.js +2 -0
  196. package/esm/ButtonBar.d.ts +4 -3
  197. package/esm/ButtonBar.js +3 -3
  198. package/esm/ButtonPrimary.js +2 -0
  199. package/esm/ButtonSecondary.js +2 -0
  200. package/esm/ButtonTertiary.js +2 -0
  201. package/esm/CarouselStepper.d.ts +2 -1
  202. package/esm/CenterColumn.d.ts +2 -1
  203. package/esm/CenterColumn.js +4 -2
  204. package/esm/CheckboxButton.d.ts +4 -2
  205. package/esm/CheckboxButtonsGroup.js +2 -2
  206. package/esm/CityBlock.d.ts +2 -1
  207. package/esm/CityBlock.js +1 -1
  208. package/esm/ContactBubble.d.ts +2 -2
  209. package/esm/ContactBubble.js +5 -4
  210. package/esm/ContentArticle.d.ts +2 -1
  211. package/esm/ContentArticle.js +3 -2
  212. package/esm/ContentImage.d.ts +2 -1
  213. package/esm/ContentImage.js +4 -3
  214. package/esm/Datepicker.js +7 -7
  215. package/esm/ExtraLinks.d.ts +2 -1
  216. package/esm/ExtraLinks.js +4 -2
  217. package/esm/FeatureList.d.ts +2 -1
  218. package/esm/FeatureList.js +3 -2
  219. package/esm/FieldGroup.d.ts +2 -1
  220. package/esm/FieldGroup.js +4 -2
  221. package/esm/FileInput.d.ts +2 -2
  222. package/esm/FileInput.js +10 -5
  223. package/esm/Foonote.js +2 -2
  224. package/esm/Footnote.d.ts +2 -1
  225. package/esm/Footnote.js +2 -1
  226. package/esm/Form.js +5 -5
  227. package/esm/FormField.d.ts +25 -5
  228. package/esm/FormField.js +30 -6
  229. package/esm/Gallery/_GalleryItem.js +2 -2
  230. package/esm/Gallery/_GalleryModalItem.js +1 -1
  231. package/esm/Gallery.d.ts +2 -2
  232. package/esm/Gallery.js +6 -5
  233. package/esm/GridBlocks.d.ts +2 -5
  234. package/esm/GridBlocks.js +3 -3
  235. package/esm/Heading.d.ts +2 -1
  236. package/esm/Heading.js +3 -3
  237. package/esm/HeroBlock.d.ts +2 -1
  238. package/esm/HeroBlock.js +4 -3
  239. package/esm/IframeBlock.d.ts +9 -4
  240. package/esm/IframeBlock.js +13 -12
  241. package/esm/Illustration.d.ts +2 -1
  242. package/esm/Illustration.js +1 -1
  243. package/esm/ImageCards.d.ts +2 -1
  244. package/esm/ImageCards.js +2 -2
  245. package/esm/InfoBlock.d.ts +2 -1
  246. package/esm/InfoBlock.js +3 -2
  247. package/esm/InfoHero.d.ts +2 -1
  248. package/esm/InfoHero.js +3 -3
  249. package/esm/IslandBlock.d.ts +2 -1
  250. package/esm/IslandBlock.js +2 -2
  251. package/esm/IslandPageBlock.d.ts +2 -1
  252. package/esm/IslandPageBlock.js +2 -2
  253. package/esm/LabeledTextBlock.d.ts +2 -1
  254. package/esm/LabeledTextBlock.js +2 -2
  255. package/esm/Layout.d.ts +2 -2
  256. package/esm/Layout.js +3 -3
  257. package/esm/MainMenu.d.ts +2 -2
  258. package/esm/MainMenu.js +4 -3
  259. package/esm/MiniMetrics.d.ts +2 -1
  260. package/esm/MiniMetrics.js +3 -2
  261. package/esm/Modal.d.ts +2 -1
  262. package/esm/Multiselect.d.ts +11 -6
  263. package/esm/Multiselect.js +15 -11
  264. package/esm/NameCard.d.ts +2 -1
  265. package/esm/NameCard.js +10 -6
  266. package/esm/NameCards.d.ts +3 -2
  267. package/esm/NameCards.js +3 -2
  268. package/esm/NewsHero.d.ts +2 -1
  269. package/esm/NewsHero.js +3 -3
  270. package/esm/PageFilter.d.ts +2 -1
  271. package/esm/PageFilter.js +2 -2
  272. package/esm/PageHeading.d.ts +2 -1
  273. package/esm/PageHeading.js +2 -5
  274. package/esm/Picture.d.ts +2 -1
  275. package/esm/Picture.js +1 -5
  276. package/esm/ProcessOverview.d.ts +2 -1
  277. package/esm/ProcessOverview.js +2 -5
  278. package/esm/RadioButtonsGroup.js +2 -2
  279. package/esm/RadioGroup.js +1 -1
  280. package/esm/ReadSpeakerPlayer.d.ts +1 -1
  281. package/esm/ReadSpeakerPlayer.js +2 -2
  282. package/esm/RelatedLinks.d.ts +2 -1
  283. package/esm/RelatedLinks.js +3 -2
  284. package/esm/RowBlock.d.ts +2 -1
  285. package/esm/RowBlock.js +2 -2
  286. package/esm/RowBlockColumn.d.ts +2 -1
  287. package/esm/RowBlockColumn.js +3 -3
  288. package/esm/SearchInput.d.ts +3 -9
  289. package/esm/SearchInput.js +4 -5
  290. package/esm/SearchResults/_SearchResultsItem.js +1 -1
  291. package/esm/SearchResults.d.ts +2 -1
  292. package/esm/SearchResults.js +2 -2
  293. package/esm/SeenEffect.js +2 -0
  294. package/esm/Selectbox.js +3 -4
  295. package/esm/ShareButtons.d.ts +2 -2
  296. package/esm/ShareButtons.js +5 -3
  297. package/esm/Sharpie.d.ts +2 -1
  298. package/esm/Sharpie.js +2 -2
  299. package/esm/SiteSearchAutocomplete.d.ts +2 -1
  300. package/esm/SiteSearchAutocomplete.js +4 -4
  301. package/esm/SiteSearchCurtain.js +2 -0
  302. package/esm/SiteSearchInput.d.ts +3 -6
  303. package/esm/SiteSearchInput.js +4 -4
  304. package/esm/Skeleton.d.ts +4 -1
  305. package/esm/Skeleton.js +15 -18
  306. package/esm/SubHeading.d.ts +2 -1
  307. package/esm/SubHeading.js +3 -3
  308. package/esm/Tabs.d.ts +2 -2
  309. package/esm/Tabs.js +5 -5
  310. package/esm/TagPill.js +2 -0
  311. package/esm/TextBlock.d.ts +2 -1
  312. package/esm/TextBlock.js +3 -3
  313. package/esm/TextButton.js +2 -0
  314. package/esm/TextInput.d.ts +2 -2
  315. package/esm/TextInput.js +3 -4
  316. package/esm/Tooltip.d.ts +2 -1
  317. package/esm/Tooltip.js +28 -15
  318. package/esm/VSpacer.d.ts +2 -1
  319. package/esm/VSpacer.js +3 -7
  320. package/esm/VerticalTabsTOC.d.ts +1 -1
  321. package/esm/VerticalTabsTOC.js +1 -1
  322. package/esm/WizardLayout.d.ts +2 -2
  323. package/esm/WizardLayout.js +4 -3
  324. package/esm/WizardLayoutClose.js +2 -0
  325. package/esm/WizardStepper.d.ts +2 -1
  326. package/esm/WizardStepper.js +2 -2
  327. package/esm/_abstract/_AbstractCarousel.d.ts +2 -2
  328. package/esm/_abstract/_AbstractCarousel.js +6 -3
  329. package/esm/_abstract/_Block.d.ts +2 -1
  330. package/esm/_abstract/_Block.js +3 -3
  331. package/esm/_abstract/_Button.js +4 -1
  332. package/esm/_abstract/_CardList.d.ts +3 -1
  333. package/esm/_abstract/_CardList.js +6 -3
  334. package/esm/_abstract/_Image.d.ts +6 -3
  335. package/esm/_abstract/_Image.js +12 -5
  336. package/esm/_abstract/_Quote.d.ts +2 -1
  337. package/esm/_abstract/_Quote.js +3 -2
  338. package/esm/_abstract/_TogglerGroup.js +1 -1
  339. package/esm/_abstract/_TogglerGroupField.js +5 -5
  340. package/esm/_abstract/_TogglerInput.d.ts +2 -2
  341. package/esm/_abstract/_TogglerInput.js +4 -2
  342. package/esm/utils.d.ts +25 -2
  343. package/package.json +1 -1
  344. package/utils.d.ts +25 -2
@@ -4,6 +4,8 @@ exports.WizardLayoutClose = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importDefault(require("react"));
6
6
  const _Button_js_1 = require("./_abstract/_Button.js");
7
+ // NOTE: As a `_abstract/_Button.tsx`-derived component, all `<button/>` and
8
+ // `<a/>` props are allowed directly, so adding `wrapperProps` makes no sense.
7
9
  const WizardLayoutClose = (props) => (react_1.default.createElement(_Button_js_1.Button, Object.assign({ bem: "WizardLayoutClose" }, props)));
8
10
  exports.WizardLayoutClose = WizardLayoutClose;
9
11
  exports.default = exports.WizardLayoutClose;
@@ -1,3 +1,4 @@
1
+ import { WrapperElmProps } from './utils.js';
1
2
  export type WizardStepperStep = {
2
3
  label: string;
3
4
  /**
@@ -31,6 +32,6 @@ export type WizardStepperProps = {
31
32
  /** By default, clickable steps after the active step are not immediately clickable */
32
33
  allowForwardSkip?: boolean;
33
34
  onClick: (clickedIndex: number) => void;
34
- };
35
+ } & WrapperElmProps;
35
36
  export declare const WizardStepper: (props: WizardStepperProps) => JSX.Element;
36
37
  export default WizardStepper;
package/WizardStepper.js CHANGED
@@ -5,8 +5,8 @@ const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importDefault(require("react"));
6
6
  const classUtils_1 = require("@hugsmidjan/qj/classUtils");
7
7
  const WizardStepper = (props) => {
8
- const { steps, activeStep = -1, allowForwardSkip, disableBacktrack, onClick } = props;
9
- return (react_1.default.createElement("div", { className: (0, classUtils_1.modifiedClass)('WizardStepper', activeStep === -1 && 'preview') }, steps.map((step, i) => {
8
+ const { steps, activeStep = -1, allowForwardSkip, disableBacktrack, onClick, wrapperProps, } = props;
9
+ return (react_1.default.createElement("div", Object.assign({}, wrapperProps, { className: (0, classUtils_1.modifiedClass)('WizardStepper', activeStep === -1 && 'preview', (wrapperProps || {}).className) }), steps.map((step, i) => {
10
10
  const { clickable, done, neutral } = step;
11
11
  const label = step.label || '…';
12
12
  const stepClass = (0, classUtils_1.modifiedClass)('WizardStepper__step', [
@@ -1,6 +1,6 @@
1
1
  import { ReactElement, ReactNode } from 'react';
2
2
  import { EitherObj } from '@reykjavik/hanna-utils';
3
- import { SSRSupportProps } from '../utils.js';
3
+ import { SSRSupportProps, WrapperElmProps } from '../utils.js';
4
4
  import { SeenProp } from '../utils/seenEffect.js';
5
5
  import { BemProps } from '../utils/types.js';
6
6
  export type CarouselProps<I extends Record<string, unknown> = {}, P extends Record<string, unknown> | undefined = {}> = {
@@ -20,7 +20,7 @@ export type CarouselProps<I extends Record<string, unknown> = {}, P extends Reco
20
20
  * `<Fragment />` or some such.
21
21
  */
22
22
  itemCount?: number;
23
- }> & SeenProp;
23
+ }> & WrapperElmProps & SeenProp;
24
24
  type AbstractCarouselProps<I extends Record<string, unknown> = Record<string, unknown>, P extends Record<string, unknown> | undefined = Record<string, unknown>> = CarouselProps<I, P> & BemProps & {
25
25
  title?: string;
26
26
  };
@@ -23,15 +23,16 @@ const scrollXBy = (elm, deltaX) => {
23
23
  // NOTE 2: Both Chrome and Safari tend to snap hard to the nearest list item
24
24
  // while Firefox is more smooth. Haven't found a way around that.
25
25
  };
26
+ // eslint-disable-next-line complexity
26
27
  const AbstractCarousel = (props) => {
27
- const { title, items = [], Component, ComponentProps, bem = 'Carousel', modifier, ssr, startSeen, } = props;
28
+ const { title, items = [], Component, ComponentProps, bem = 'Carousel', modifier, ssr, startSeen, className, wrapperProps, } = props;
28
29
  const children = !props.children
29
30
  ? undefined
30
31
  : Array.isArray(props.children)
31
32
  ? props.children.filter(hanna_utils_1.notNully)
32
33
  : [props.children];
33
34
  const [leftOffset, setLeftOffset] = (0, react_1.useState)();
34
- const itemCount = props.itemCount || (children || items).length;
35
+ const itemCount = props.itemCount != null ? props.itemCount : (children || items).length;
35
36
  const listRef = (0, react_1.useRef)(null);
36
37
  const [activeItem, setActiveItem] = (0, react_1.useState)(0);
37
38
  const isBrowser = (0, utils_js_1.useIsBrowserSide)(ssr);
@@ -96,7 +97,9 @@ const AbstractCarousel = (props) => {
96
97
  items.map((item, i) => (
97
98
  // @ts-expect-error (Can't be arsed...)
98
99
  react_1.default.createElement(Component, Object.assign({ key: i }, ComponentProps, item))))));
99
- return (react_1.default.createElement("div", { className: (0, classUtils_1.modifiedClass)(bem, modifier, props.className), ref: outerRef, "data-sprinkled": isBrowser },
100
+ return (react_1.default.createElement("div", Object.assign({}, wrapperProps, { className: (0, classUtils_1.modifiedClass)(bem, modifier,
101
+ // Prefer `className` over `wrapperProps.className`
102
+ className || (wrapperProps || {}).className), ref: outerRef, "data-sprinkled": isBrowser }),
100
103
  title && react_1.default.createElement("h2", { className: bem + '__title' }, title),
101
104
  isBrowser ? (react_1.default.createElement("div", { className: bem + '__itemlist-wrapper' },
102
105
  itemList,
@@ -1,3 +1,4 @@
1
+ import { WrapperElmProps } from '../utils.js';
1
2
  import { SeenProp } from '../utils/seenEffect.js';
2
3
  import { BemModifierProps } from '../utils/types.js';
3
4
  import { ButtonProps } from './_Button.js';
@@ -15,7 +16,7 @@ export type ContentBlock = {
15
16
  content: Array<BlockItem>;
16
17
  image?: undefined;
17
18
  } & SeenProp;
18
- export type BlockProps = BemModifierProps & (ContentBlock | ContentImageBlock);
19
+ export type BlockProps = (ContentBlock | ContentImageBlock) & BemModifierProps & WrapperElmProps;
19
20
  export declare const Block: (props: BlockProps & {
20
21
  bem: string;
21
22
  }) => JSX.Element;
@@ -8,10 +8,10 @@ const seenEffect_js_1 = require("../utils/seenEffect.js");
8
8
  const _Button_js_1 = require("./_Button.js");
9
9
  const _Image_js_1 = require("./_Image.js");
10
10
  const Block = (props) => {
11
- const { image, modifier, bem, content, startSeen } = props;
11
+ const { image, modifier, bem, content, startSeen, wrapperProps } = props;
12
12
  const [ref] = (0, seenEffect_js_1.useSeenEffect)(startSeen);
13
13
  const contentItems = Array.isArray(content) ? content : [content];
14
- return (react_1.default.createElement("div", { className: (0, classUtils_1.modifiedClass)(bem, modifier), ref: ref },
14
+ return (react_1.default.createElement("div", Object.assign({}, wrapperProps, { className: (0, classUtils_1.modifiedClass)(bem, modifier, (wrapperProps || {}).className), ref: ref }),
15
15
  contentItems.map(({ title, summary, buttons = [] }, i) => {
16
16
  const hasSummary = summary && (typeof summary !== 'string' || !!summary.trim());
17
17
  return (react_1.default.createElement("div", { key: i, className: `${bem}__content` },
@@ -23,6 +23,6 @@ const Block = (props) => {
23
23
  react_1.default.createElement(_Button_js_1.Button, Object.assign({ bem: `${bem}__button`, key: i }, buttonProps)),
24
24
  ' ')))))));
25
25
  }),
26
- image && react_1.default.createElement(_Image_js_1.Image, Object.assign({ className: `${bem}__image` }, image))));
26
+ image && react_1.default.createElement(_Image_js_1.Image, Object.assign({ bem: `${bem}__image` }, image))));
27
27
  };
28
28
  exports.Block = Block;
@@ -25,8 +25,11 @@ const icons = {
25
25
  // TODO: insert icons
26
26
  edit: 'edit',
27
27
  };
28
+ // NOTE: As this component already accepts all `<button/>` and `<a/>` props
29
+ // directly, it makes little sense to add support for `wrapperProps` on top.
28
30
  const Button = (props) => {
29
- const { bem, small, size = 'normal', modifier, children, variant = 'normal', icon = 'none', label = children } = props, buttonProps = tslib_1.__rest(props, ["bem", "small", "size", "modifier", "children", "variant", "icon", "label"]);
31
+ const { bem, small, // eslint-disable-line deprecation/deprecation
32
+ size = small ? 'small' : 'normal', modifier, children, variant = 'normal', icon = 'none', label = children } = props, buttonProps = tslib_1.__rest(props, ["bem", "small", "size", "modifier", "children", "variant", "icon", "label"]);
30
33
  const className = bem &&
31
34
  (0, classUtils_1.modifiedClass)(bem, [modifier, variants[variant], sizes[size], navigationFlags[icon]]);
32
35
  const iconProp = icons[icon] && { 'data-icon': icons[icon] };
@@ -1,5 +1,7 @@
1
1
  import React, { ReactElement, ReactNode } from 'react';
2
2
  import { EitherObj } from '@reykjavik/hanna-utils';
3
+ import { WrapperElmProps } from '../utils.js';
4
+ import { BemModifierProps } from '../utils/types.js';
3
5
  import { ImageProps } from './_Image.js';
4
6
  export type TextCardProps = {
5
7
  title: string;
@@ -28,6 +30,6 @@ type _CardListProps = EitherObj<ImageCardListProps, TextCardListProps> & CardLis
28
30
  bemPrefix: string;
29
31
  children?: ReactNode;
30
32
  standalone?: boolean;
31
- };
33
+ } & WrapperElmProps<'ul'> & BemModifierProps;
32
34
  export declare const CardList: (props: _CardListProps) => JSX.Element;
33
35
  export {};
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CardList = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importDefault(require("react"));
6
+ const classUtils_1 = require("@hugsmidjan/qj/classUtils");
6
7
  const _Button_js_1 = require("./_Button.js");
7
8
  const _Image_js_1 = require("./_Image.js");
8
9
  const Card = (props) => {
@@ -11,7 +12,7 @@ const Card = (props) => {
11
12
  return (react_1.default.createElement(react_1.default.Fragment, null,
12
13
  react_1.default.createElement(_Button_js_1.Button, { bem: cardClass, href: href, target: target },
13
14
  ' ',
14
- !!(image || imgPlaceholder) && (react_1.default.createElement(_Image_js_1.Image, Object.assign({ className: `${bem}__image` }, image, { placeholder: imgPlaceholder }))),
15
+ !!(image || imgPlaceholder) && (react_1.default.createElement(_Image_js_1.Image, Object.assign({ bem: `${bem}__image` }, image, { placeholder: imgPlaceholder }))),
15
16
  react_1.default.createElement("span", { className: `${cardClass}__title` }, title),
16
17
  ' ',
17
18
  meta && react_1.default.createElement("span", { className: `${cardClass}__meta` }, meta),
@@ -21,7 +22,7 @@ const Card = (props) => {
21
22
  ' '));
22
23
  };
23
24
  const CardList = (props) => {
24
- const { bemPrefix, title, summaryElement, cards, titleTag = 'h2', children, imgPlaceholder, } = props;
25
+ const { bemPrefix, modifier, title, summaryElement, cards, titleTag = 'h2', children, imgPlaceholder, wrapperProps, } = props;
25
26
  const TitleTag = titleTag;
26
27
  const fallbackImageUrl = (imgPlaceholder !== true && imgPlaceholder) || undefined;
27
28
  const fallbackImageStyle = fallbackImageUrl
@@ -33,7 +34,9 @@ const CardList = (props) => {
33
34
  summaryElement ? (react_1.default.createElement("div", { className: bemPrefix + '__summary' },
34
35
  title && react_1.default.createElement(TitleTag, { className: bemPrefix + '__title' }, title),
35
36
  summaryElement)) : (title && react_1.default.createElement(TitleTag, { className: bemPrefix + '__title' }, title)),
36
- react_1.default.createElement("ul", { className: bemPrefix + (props.standalone ? '' : '__list'), style: fallbackImageStyle }, cards.map((card, i) => (react_1.default.createElement("li", { key: i, className: bemPrefix + '__item' },
37
+ react_1.default.createElement("ul", Object.assign({}, wrapperProps, { className: props.standalone
38
+ ? (0, classUtils_1.modifiedClass)(bemPrefix, modifier, (wrapperProps || {}).className)
39
+ : bemPrefix + '__list', style: fallbackImageStyle }), cards.map((card, i) => (react_1.default.createElement("li", { key: i, className: bemPrefix + '__item' },
37
40
  react_1.default.createElement(Card
38
41
  /* Assert as `ImageCardProps` to silence the imgPlaceholder false-positive */
39
42
  , Object.assign({}, card, { bem: bemPrefix, imgPlaceholder: !!imgPlaceholder })))))),
@@ -1,3 +1,5 @@
1
+ import { WrapperElmProps } from '../utils.js';
2
+ import { BemProps } from '../utils/types.js';
1
3
  export type Source = {
2
4
  srcset: string;
3
5
  media: string;
@@ -23,14 +25,15 @@ export type ImagePropsInlinedSvg = {
23
25
  };
24
26
  export type ImageProps = ImagePropsLinked | ImagePropsInlinedSvg;
25
27
  type _ImageProps = {
26
- /** container className */
27
- className: string | undefined;
28
28
  /** Controls if the container is rendered when image is missing/undefined.
29
29
  * (With a `--missing` className modifier added.)
30
30
  *
31
31
  * Accepts a function that defines a default content for the container.
32
32
  */
33
33
  placeholder?: boolean | (() => JSX.Element);
34
- };
34
+ /** Extra, custom className in addition to the `bem` base */
35
+ className?: string | undefined;
36
+ bem: string | undefined;
37
+ } & BemProps & WrapperElmProps;
35
38
  export declare const Image: (props: ImageProps & _ImageProps) => JSX.Element | null;
36
39
  export {};
@@ -7,19 +7,26 @@ const classUtils_1 = require("@hugsmidjan/qj/classUtils");
7
7
  const useGetSVGtext_js_1 = require("../utils/useGetSVGtext.js");
8
8
  // eslint-disable-next-line complexity
9
9
  const Image = (props) => {
10
- const { src, altText = '', sources = [], preloadSrc, className, inline, placeholder, focalPoint, } = props;
10
+ const { src, altText = '', sources = [], preloadSrc, modifier, bem, inline, placeholder, focalPoint, className, wrapperProps = {}, } = props;
11
11
  const _src = (sources.length && preloadSrc) || src;
12
12
  const imageSrc = _src || (sources[0] != null ? sources[0].srcset.split(' ')[0] : undefined);
13
13
  const imgLoading = preloadSrc ? 'eager' : 'lazy';
14
14
  const inlineSvg = (0, useGetSVGtext_js_1.useGetSVGtext)(inline ? imageSrc : undefined, altText);
15
+ const extraClasses = (0, classUtils_1.classes)(className, wrapperProps.className) || undefined;
16
+ const classNames = bem
17
+ ? (0, classUtils_1.modifiedClass)(bem, [modifier, !imageSrc && 'missing'], extraClasses)
18
+ : extraClasses;
15
19
  if (!imageSrc) {
16
- return placeholder ? (react_1.default.createElement("span", { className: className && (0, classUtils_1.modifiedClass)(className, 'missing') }, placeholder !== true && placeholder())) : null;
20
+ return placeholder ? (react_1.default.createElement("span", Object.assign({}, props.wrapperProps, { className: classNames }), placeholder !== true && placeholder())) : null;
17
21
  }
18
22
  if (inline && inlineSvg) {
19
23
  const __html = inlineSvg.imageSrc === imageSrc ? inlineSvg.code : '';
20
- return react_1.default.createElement("span", { className: className, dangerouslySetInnerHTML: { __html } });
24
+ return (react_1.default.createElement("span", Object.assign({}, props.wrapperProps, { className: classNames, dangerouslySetInnerHTML: { __html } })));
21
25
  }
22
- return (react_1.default.createElement("picture", { className: className, style: focalPoint ? { '--focalPoint': focalPoint } : undefined },
26
+ const wrapperStyles = wrapperProps.style;
27
+ return (react_1.default.createElement("picture", Object.assign({}, props.wrapperProps, { className: classNames, style: focalPoint
28
+ ? Object.assign(Object.assign({}, wrapperStyles), { '--focalPoint': focalPoint })
29
+ : wrapperStyles }),
23
30
  ' ',
24
31
  sources.map((source, i) => (react_1.default.createElement(react_1.default.Fragment, null,
25
32
  react_1.default.createElement("source", { key: i, srcSet: source.srcset, media: source.media }),
@@ -1,8 +1,9 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { EitherObj } from '@reykjavik/hanna-utils';
3
+ import { WrapperElmProps } from '../utils.js';
3
4
  export type QuoteProps = {
4
5
  children: ReactNode;
5
- } & EitherObj<object, {
6
+ } & WrapperElmProps & EitherObj<object, {
6
7
  by: string | JSX.Element;
7
8
  byHref?: string;
8
9
  }>;
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports._Quote = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importDefault(require("react"));
6
+ const classUtils_1 = require("@hugsmidjan/qj/classUtils");
6
7
  const _Link_js_1 = require("./_Link.js");
7
8
  const _Quote = (props) => {
8
- const { bem, children, by, byHref } = props;
9
- return (react_1.default.createElement("figure", { className: bem },
9
+ const { bem, children, by, byHref, wrapperProps } = props;
10
+ return (react_1.default.createElement("figure", Object.assign({}, wrapperProps, { className: (0, classUtils_1.modifiedClass)(bem, null, (wrapperProps || {}).className) }),
10
11
  react_1.default.createElement("blockquote", { className: bem + '__quote' }, children),
11
12
  by && (react_1.default.createElement("figcaption", { className: bem + '__by' }, byHref ? (react_1.default.createElement(_Link_js_1.Link, { href: byHref }, by)) : typeof by === 'string' ? (react_1.default.createElement("span", null, by)) : (by)))));
12
13
  };
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TogglerGroup = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importStar(require("react"));
6
- const hooks_1 = require("@hugsmidjan/react/hooks");
7
6
  const classUtils_1 = require("@hugsmidjan/qj/classUtils");
7
+ const hooks_1 = require("@hugsmidjan/react/hooks");
8
8
  const utils_js_1 = require("../utils.js");
9
9
  const TogglerGroup = (props) => {
10
10
  const {
@@ -4,18 +4,18 @@ exports.TogglerGroupField = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importStar(require("react"));
6
6
  const classUtils_1 = require("@hugsmidjan/qj/classUtils");
7
- const FormField_js_1 = tslib_1.__importDefault(require("../FormField.js"));
7
+ const FormField_js_1 = tslib_1.__importStar(require("../FormField.js"));
8
8
  const _TogglerGroup_js_1 = require("./_TogglerGroup.js");
9
9
  const TogglerGroupField = (props) => {
10
- const { bem, Toggler, className, modifier, label, LabelTag, assistText, hideLabel, disabled, readOnly, invalid, errorMessage, required, reqText, id, value, defaultValue } = props, togglerGroupProps = tslib_1.__rest(props, ["bem", "Toggler", "className", "modifier", "label", "LabelTag", "assistText", "hideLabel", "disabled", "readOnly", "invalid", "errorMessage", "required", "reqText", "id", "value", "defaultValue"]);
10
+ const _a = (0, FormField_js_1.groupFormFieldWrapperProps)(props), { bem, Toggler, modifier, value, defaultValue, fieldWrapperProps } = _a, togglerGroupProps = tslib_1.__rest(_a, ["bem", "Toggler", "modifier", "value", "defaultValue", "fieldWrapperProps"]);
11
11
  const _value = (0, react_1.useMemo)(() => (value == null ? undefined : typeof value === 'string' ? [value] : value), [value]);
12
12
  const _defaultValue = (0, react_1.useMemo)(() => defaultValue == null
13
13
  ? undefined
14
14
  : typeof defaultValue === 'string'
15
15
  ? [defaultValue]
16
16
  : defaultValue, [defaultValue]);
17
- return (react_1.default.createElement(FormField_js_1.default, { className: (0, classUtils_1.modifiedClass)(bem, modifier, className), group: true, label: label, LabelTag: LabelTag, assistText: assistText, hideLabel: hideLabel, disabled: !!disabled, readOnly: readOnly, invalid: invalid, errorMessage: errorMessage, required: required, reqText: reqText, id: id, renderInput: (className, inputProps) => {
18
- return (react_1.default.createElement(_TogglerGroup_js_1.TogglerGroup, Object.assign({ bem: className.options }, inputProps, togglerGroupProps, { disabled: disabled, value: _value, defaultValue: _defaultValue, Toggler: Toggler })));
19
- } }));
17
+ return (react_1.default.createElement(FormField_js_1.default, Object.assign({ extraClassName: (0, classUtils_1.modifiedClass)(bem, modifier), group: true }, fieldWrapperProps, { renderInput: (className, inputProps) => {
18
+ return (react_1.default.createElement(_TogglerGroup_js_1.TogglerGroup, Object.assign({ bem: className.options }, inputProps, togglerGroupProps, { disabled: props.disabled, value: _value, defaultValue: _defaultValue, Toggler: Toggler })));
19
+ } })));
20
20
  };
21
21
  exports.TogglerGroupField = TogglerGroupField;
@@ -1,3 +1,4 @@
1
+ import { WrapperElmProps } from '../utils.js';
1
2
  import { BemModifierProps } from '../utils/types.js';
2
3
  export type TogglerInputProps = {
3
4
  label: string | JSX.Element;
@@ -13,9 +14,8 @@ export type TogglerInputProps = {
13
14
  reqText?: string | false;
14
15
  errorMessage?: string | JSX.Element;
15
16
  Wrapper?: 'div' | 'li';
16
- wrapperProps?: JSX.IntrinsicElements['div'];
17
17
  inputProps?: JSX.IntrinsicElements['input'];
18
- } & BemModifierProps & Omit<JSX.IntrinsicElements['input'], 'type'>;
18
+ } & BemModifierProps & WrapperElmProps & Omit<JSX.IntrinsicElements['input'], 'type'>;
19
19
  type _TogglerInputProps = {
20
20
  bem: string;
21
21
  type: 'radio' | 'checkbox';
@@ -10,7 +10,7 @@ const TogglerInput = (props) => {
10
10
  const domid = (0, hooks_1.useDomid)(id);
11
11
  const errorId = errorMessage && 'error' + domid;
12
12
  const reqStar = required && reqText !== false && (react_1.default.createElement("abbr", { className: bem + '__label__reqstar',
13
- // TODO: add mo-better i18n thinking
13
+ // FIXME: add mo-better i18n thinking
14
14
  title: (reqText || 'Þarf að haka í') + ': ' }, "*"));
15
15
  const readOnly = restInputProps.readOnly || (inputProps || {}).readOnly;
16
16
  const labelContent = (react_1.default.createElement(react_1.default.Fragment, null,
@@ -19,7 +19,9 @@ const TogglerInput = (props) => {
19
19
  " ",
20
20
  label,
21
21
  ' '));
22
- return (react_1.default.createElement(Wrapper, Object.assign({}, wrapperProps, { className: (0, classUtils_1.modifiedClass)(bem, modifier, className) }),
22
+ return (react_1.default.createElement(Wrapper, Object.assign({}, wrapperProps, { className: (0, classUtils_1.modifiedClass)(bem, modifier,
23
+ // Prefer `className` over `wrapperProps.className`
24
+ className || (wrapperProps || {}).className) }),
23
25
  react_1.default.createElement("input", Object.assign({ className: bem + '__input', type: type, id: domid, "aria-invalid": invalid || !!errorMessage || undefined, "aria-describedby": errorId }, restInputProps, inputProps, (readOnly && { disabled: true }))),
24
26
  ' ',
25
27
  react_1.default.createElement("label", { className: bem + '__label', htmlFor: domid },
@@ -1,5 +1,5 @@
1
1
  import { SeenProp } from './utils/seenEffect.js';
2
- import { SSRSupportProps } from './utils.js';
2
+ import { SSRSupportProps, WrapperElmProps } from './utils.js';
3
3
  export type AccordionListItemProps = {
4
4
  title: string | JSX.Element;
5
5
  content: string | JSX.Element | undefined;
@@ -19,6 +19,6 @@ export type AccordionListProps = {
19
19
  /** Index of those items that should start open (uncontrolled use) */
20
20
  defaultOpen?: Array<number>;
21
21
  wide?: boolean;
22
- } & SSRSupportProps & SeenProp;
22
+ } & WrapperElmProps & SSRSupportProps & SeenProp;
23
23
  export declare const AccordionList: (props: AccordionListProps) => JSX.Element;
24
24
  export default AccordionList;
@@ -2,7 +2,7 @@ import React, { useRef } from 'react';
2
2
  import { modifiedClass } from '@hugsmidjan/qj/classUtils';
3
3
  import { useDomid } from '@hugsmidjan/react/hooks';
4
4
  import { useSeenEffect } from './utils/seenEffect.js';
5
- import { useIsBrowserSide, useMixedControlState } from './utils.js';
5
+ import { useIsBrowserSide, useMixedControlState, } from './utils.js';
6
6
  const AccordionListItem = (props) => {
7
7
  const { title, content, id, disabled = false, ssr, open, onToggle } = props;
8
8
  const defaultOpen = useRef(props.defaultOpen);
@@ -14,7 +14,7 @@ const AccordionListItem = (props) => {
14
14
  React.createElement("div", { id: isBrowser && domid, className: "AccordionList__content", hidden: isBrowser && (!open || itemDisabled) }, content)));
15
15
  };
16
16
  export const AccordionList = (props) => {
17
- const { items, ssr, wide, startSeen, defaultOpen } = props;
17
+ const { items, ssr, wide, startSeen, defaultOpen, wrapperProps } = props;
18
18
  const [ref] = useSeenEffect(startSeen);
19
19
  const [open, setOpenArray, mode] = useMixedControlState(props, 'open', []);
20
20
  const onToggle = (index) => {
@@ -27,6 +27,6 @@ export const AccordionList = (props) => {
27
27
  return newOpen;
28
28
  });
29
29
  };
30
- return (React.createElement("div", { className: modifiedClass('AccordionList', [wide && 'wide']), ref: ref }, items.map((item, i) => (React.createElement(AccordionListItem, Object.assign({ key: i }, item, { ssr: ssr, open: open.includes(i), onToggle: () => onToggle(i), defaultOpen: defaultOpen && defaultOpen.includes(i) }))))));
30
+ return (React.createElement("div", Object.assign({}, wrapperProps, { className: modifiedClass('AccordionList', [wide && 'wide'], (wrapperProps || {}).className), ref: ref }), items.map((item, i) => (React.createElement(AccordionListItem, Object.assign({ key: i }, item, { ssr: ssr, open: open.includes(i), onToggle: () => onToggle(i), defaultOpen: defaultOpen && defaultOpen.includes(i) }))))));
31
31
  };
32
32
  export default AccordionList;
@@ -1,6 +1,7 @@
1
1
  import { CardListSummaryProps, TextCardListProps, TextCardProps } from './_abstract/_CardList.js';
2
2
  import { SeenProp } from './utils/seenEffect.js';
3
- export type ActionCardsProps = TextCardListProps & CardListSummaryProps & SeenProp;
3
+ import { WrapperElmProps } from './utils.js';
4
+ export type ActionCardsProps = TextCardListProps & CardListSummaryProps & WrapperElmProps & SeenProp;
4
5
  export type ActionCardsItemProps = TextCardProps;
5
6
  export declare const ActionCards: (props: ActionCardsProps) => JSX.Element;
6
7
  export default ActionCards;
@@ -4,6 +4,6 @@ import { useSeenEffect } from './utils/seenEffect.js';
4
4
  export const ActionCards = (props) => {
5
5
  const [ref] = useSeenEffect(props.startSeen);
6
6
  return (React.createElement("div", { className: "ActionCards", ref: ref },
7
- React.createElement(CardList, Object.assign({}, props, { bemPrefix: "ActionCards" }))));
7
+ React.createElement(CardList, Object.assign({ bemPrefix: "ActionCards" }, props, { wrapperProps: undefined }))));
8
8
  };
9
9
  export default ActionCards;
package/esm/Alert.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { MouseEvent, ReactNode } from 'react';
2
2
  import { EitherObj } from '@reykjavik/hanna-utils';
3
3
  import { DefaultTexts } from '@reykjavik/hanna-utils/i18n';
4
- import { SSRSupportProps } from './utils.js';
4
+ import { SSRSupportProps, WrapperElmProps } from './utils.js';
5
5
  export type AlertI18n = {
6
6
  closeLabel: string;
7
7
  closeLabelLong?: string;
@@ -42,6 +42,6 @@ export type AlertProps = {
42
42
  onClose?(event: MouseEvent): void | boolean;
43
43
  /** Callback that fires after the alert has closed/transitoned out */
44
44
  onClosed?(): void;
45
- }>;
45
+ }> & WrapperElmProps<null, 'role' | 'hidden'>;
46
46
  export declare const Alert: (props: AlertProps) => JSX.Element;
47
47
  export default Alert;
package/esm/Alert.js CHANGED
@@ -3,21 +3,31 @@ import { modifiedClass } from '@hugsmidjan/qj/classUtils';
3
3
  import { getTexts } from '@reykjavik/hanna-utils/i18n';
4
4
  import { Button } from './_abstract/_Button.js';
5
5
  import { isPreact } from './utils/env.js';
6
- import { useIsBrowserSide } from './utils.js';
6
+ import { useIsBrowserSide, } from './utils.js';
7
7
  // FIXME: Eventually import from @reykjavik/hanna-css
8
8
  const AlertCloseTransitionDuration = 400;
9
- const useAutoClosing = (autoClose) => {
9
+ const useAutoClosing = (autoClose, props) => {
10
10
  const [temp, setTemp] = useState(0);
11
11
  if (!autoClose) {
12
12
  return { autoClosing: false };
13
13
  }
14
- const thaw = () => setTemp((temp) => temp + 1);
15
- const freeze = () => setTemp((temp) => temp - 1);
14
+ const thaw = (e) => {
15
+ setTemp((temp) => temp + 1);
16
+ const handler = props[e.type.startsWith('blur') ? 'onBlur' : 'onMouseLeave'];
17
+ // @ts-expect-error (Proper fix ends up as too much code for this extreme edge case)
18
+ handler && handler(e);
19
+ };
20
+ const freeze = (e) => {
21
+ setTemp((temp) => temp - 1);
22
+ const handler = props[e.type.startsWith('focus') ? 'onFocus' : 'onMouseEnter'];
23
+ // @ts-expect-error (Resolving ends up as too much code for this extreme edge case)
24
+ handler && handler(e);
25
+ };
16
26
  return {
17
27
  autoClosing: temp === 0,
18
28
  autoClosingProps: Object.assign({ onMouseEnter: freeze, onMouseLeave: thaw, onFocus: freeze, onBlur: thaw }, (isPreact && {
19
- onfocusin: (e) => e.currentTarget !== e.target && freeze(),
20
- onfocusout: (e) => e.currentTarget !== e.target && thaw(),
29
+ onfocusin: (e) => e.currentTarget !== e.target && freeze(e),
30
+ onfocusout: (e) => e.currentTarget !== e.target && thaw(e),
21
31
  })),
22
32
  };
23
33
  };
@@ -33,7 +43,8 @@ export const alertTypes = {
33
43
  critical: 1,
34
44
  };
35
45
  export const Alert = (props) => {
36
- const { type, childrenHTML, children, onClose, closeUrl, closable = !!(onClose || closeUrl != null), ssr, onClosed, } = props;
46
+ const { type, childrenHTML, children, onClose, // eslint-disable-line deprecation/deprecation
47
+ closeUrl, closable = !!(onClose || closeUrl != null), ssr, onClosed, wrapperProps, } = props;
37
48
  const autoClose = Math.max(props.autoClose || 0, 0);
38
49
  const closing = useRef();
39
50
  const [open, setOpen] = useState(!!ssr);
@@ -46,7 +57,7 @@ export const Alert = (props) => {
46
57
  const closeAlert = useCallback((event) => {
47
58
  const ret = onClose &&
48
59
  // @ts-expect-error (@deprecated `event` parameter will be removed in v0.11)
49
- onClose(event);
60
+ onClose(event); // eslint-disable-line deprecation/deprecation
50
61
  if (ret !== false) {
51
62
  setOpen(false);
52
63
  if (closing.current) {
@@ -58,7 +69,7 @@ export const Alert = (props) => {
58
69
  }, AlertCloseTransitionDuration);
59
70
  }
60
71
  }, [onClose, onClosed]);
61
- const { autoClosing, autoClosingProps } = useAutoClosing(autoClose);
72
+ const { autoClosing, autoClosingProps } = useAutoClosing(autoClose, props);
62
73
  useEffect(() => {
63
74
  if (autoClosing) {
64
75
  let autoCloseTimeout;
@@ -77,10 +88,7 @@ export const Alert = (props) => {
77
88
  };
78
89
  }
79
90
  }, [closeAlert, autoClosing, autoClose]);
80
- return (React.createElement("div", Object.assign({ className: modifiedClass('Alert', [
81
- !!alertTypes[type] && type,
82
- closable && 'closable',
83
- ]), role: "alert", hidden: !open || undefined }, autoClosingProps),
91
+ return (React.createElement("div", Object.assign({}, wrapperProps, { className: modifiedClass('Alert', [!!alertTypes[type] && type, closable && 'closable'], (wrapperProps || {}).className), role: "alert", hidden: !open || undefined }, autoClosingProps),
84
92
  childrenHTML ? (React.createElement("div", { dangerouslySetInnerHTML: { __html: childrenHTML } })) : (children),
85
93
  ' ',
86
94
  showCloseButton && (React.createElement(Button, Object.assign({ bem: "Alert__close" }, (closeUrl != null ? { href: closeUrl } : { type: 'button' }), { onClick: (e) => {
@@ -1,7 +1,10 @@
1
1
  import { ImageCardListProps, ImageCardProps } from './_abstract/_CardList.js';
2
+ import { WrapperElmProps } from './utils.js';
2
3
  export type ArticleCardsItemProps = ImageCardProps;
3
4
  /** @deprecated Use `ArticleCardsItemProps` instead (Remove in v0.11) */
4
5
  export type ArticleCardProps = ArticleCardsItemProps;
5
- export type ArticleCardsProps = Pick<ImageCardListProps, 'cards' | 'imgPlaceholder'>;
6
+ export type ArticleCardsProps = Pick<ImageCardListProps, 'cards' | 'imgPlaceholder'> & {
7
+ size?: 'large' | 'normal';
8
+ } & WrapperElmProps<'ul'>;
6
9
  export declare const ArticleCards: (props: ArticleCardsProps) => JSX.Element;
7
10
  export default ArticleCards;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { CardList } from './_abstract/_CardList.js';
3
- export const ArticleCards = (props) => (React.createElement(CardList, { bemPrefix: "ArticleCards", standalone: true, cards: props.cards, imgPlaceholder: props.imgPlaceholder || true }));
3
+ export const ArticleCards = (props) => (React.createElement(CardList, { bemPrefix: "ArticleCards", modifier: props.size === 'large' ? 'large' : undefined, standalone: true, cards: props.cards, imgPlaceholder: props.imgPlaceholder || true, wrapperProps: props.wrapperProps }));
4
4
  export default ArticleCards;
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import { modifiedClass } from '@hugsmidjan/qj/classUtils';
3
2
  import { getIllustrationUrl } from '@reykjavik/hanna-utils/assets';
4
3
  import { Image } from '../_abstract/_Image.js';
5
4
  import { Link } from '../_abstract/_Link.js';
@@ -11,7 +10,7 @@ export const ArticleCarouselCard = (props) => {
11
10
  return (React.createElement("div", { className: "ArticleCarouselCard", "data-color": color && colorFamilies[color], "data-color-theme": !color ? theme && themeOptions[theme] : undefined },
12
11
  React.createElement(Link, { className: "ArticleCarouselCard__link", href: href, target: target },
13
12
  ' ',
14
- React.createElement(Image, Object.assign({ placeholder: true, className: modifiedClass('ArticleCarouselCard__illustration', photo && 'photo') }, imageProps)),
13
+ React.createElement(Image, Object.assign({ bem: "ArticleCarouselCard__illustration", modifier: photo && 'photo', placeholder: true }, imageProps)),
15
14
  React.createElement("h3", { className: "ArticleCarouselCard__title" }, title),
16
15
  ' '),
17
16
  ' ',
@@ -1,11 +1,11 @@
1
1
  import { ArticleCarouselCardProps, ArticleCarouselImageProps } from './ArticleCarousel/_ArticleCarouselCard.js';
2
2
  import { SeenProp } from './utils/seenEffect.js';
3
- import { SSRSupportProps } from './utils.js';
3
+ import { SSRSupportProps, WrapperElmProps } from './utils.js';
4
4
  export type ArticleCarouselProps = {
5
5
  items: Array<ArticleCarouselCardProps>;
6
6
  title?: string;
7
7
  moreLabel?: string;
8
- } & SSRSupportProps & SeenProp;
8
+ } & WrapperElmProps & SSRSupportProps & SeenProp;
9
9
  export type { ArticleCarouselCardProps, ArticleCarouselImageProps };
10
10
  export declare const ArticleCarousel: (props: ArticleCarouselProps) => JSX.Element;
11
11
  export default ArticleCarousel;
@@ -3,6 +3,6 @@ import { AbstractCarousel } from './_abstract/_AbstractCarousel.js';
3
3
  import { ArticleCarouselCard, } from './ArticleCarousel/_ArticleCarouselCard.js';
4
4
  export const ArticleCarousel = (props) => {
5
5
  const { title, items, moreLabel, ssr, startSeen } = props;
6
- return (React.createElement(AbstractCarousel, { bem: "ArticleCarousel", title: title, items: items, Component: ArticleCarouselCard, ComponentProps: { moreLabel }, ssr: ssr, startSeen: startSeen }));
6
+ return (React.createElement(AbstractCarousel, { bem: "ArticleCarousel", title: title, items: items, Component: ArticleCarouselCard, ComponentProps: { moreLabel }, ssr: ssr, startSeen: startSeen, wrapperProps: props.wrapperProps }));
7
7
  };
8
8
  export default ArticleCarousel;
@@ -1,3 +1,4 @@
1
+ import { WrapperElmProps } from './utils.js';
1
2
  export type ArticleMetaItem = {
2
3
  label: string;
3
4
  href?: string;
@@ -5,6 +6,6 @@ export type ArticleMetaItem = {
5
6
  export type ArticleMetaProps = {
6
7
  items: Array<ArticleMetaItem>;
7
8
  small?: boolean;
8
- };
9
+ } & WrapperElmProps;
9
10
  export declare const ArticleMeta: (props: ArticleMetaProps) => JSX.Element | null;
10
11
  export default ArticleMeta;
@@ -2,11 +2,11 @@ import React, { Fragment } from 'react';
2
2
  import { modifiedClass } from '@hugsmidjan/qj/classUtils';
3
3
  import { Link } from './_abstract/_Link.js';
4
4
  export const ArticleMeta = (props) => {
5
- const { items, small } = props;
5
+ const { items, small, wrapperProps } = props;
6
6
  if (items.length === 0) {
7
7
  return null;
8
8
  }
9
- return (React.createElement("div", { className: modifiedClass('ArticleMeta', small && 'small') }, items.map(({ label, href }, i) => (React.createElement(Fragment, { key: i },
9
+ return (React.createElement("div", Object.assign({}, wrapperProps, { className: modifiedClass('ArticleMeta', small && 'small', (wrapperProps || {}).className) }), items.map(({ label, href }, i) => (React.createElement(Fragment, { key: i },
10
10
  href == null ? (React.createElement("span", { className: "ArticleMeta__item" },
11
11
  " ",
12
12
  label,
@@ -1,7 +1,8 @@
1
1
  import { ReactNode } from 'react';
2
+ import { WrapperElmProps } from './utils.js';
2
3
  export type AttentionProps = {
3
4
  small?: boolean;
4
5
  children: ReactNode;
5
- };
6
+ } & WrapperElmProps;
6
7
  export declare const Attention: (props: AttentionProps) => JSX.Element;
7
8
  export default Attention;