@reykjavik/hanna-react 0.10.103 → 0.10.104

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 (136) hide show
  1. package/AccordionList.js +2 -2
  2. package/Alert.d.ts +2 -2
  3. package/Alert.js +1 -0
  4. package/AutosuggestSearch.d.ts +40 -0
  5. package/AutosuggestSearch.js +70 -0
  6. package/BasicTable.d.ts +24 -4
  7. package/BasicTable.js +20 -19
  8. package/BreadCrumbs.d.ts +2 -2
  9. package/CHANGELOG.md +34 -0
  10. package/ContactBubble.d.ts +4 -3
  11. package/ContactBubble.js +7 -4
  12. package/Datepicker.d.ts +8 -3
  13. package/Datepicker.js +36 -14
  14. package/FileInput.d.ts +2 -1
  15. package/FileInput.js +2 -2
  16. package/FormField.js +2 -2
  17. package/Gallery.d.ts +2 -1
  18. package/Gallery.js +5 -0
  19. package/Layout.d.ts +4 -3
  20. package/Layout.js +0 -3
  21. package/MainMenu/_PrimaryPanel.d.ts +3 -4
  22. package/MainMenu/_PrimaryPanel.js +1 -1
  23. package/MainMenu.d.ts +6 -4
  24. package/MainMenu.js +8 -16
  25. package/Multiselect.d.ts +2 -1
  26. package/Multiselect.js +4 -3
  27. package/NameCard.d.ts +2 -1
  28. package/NameCard.js +7 -0
  29. package/Pagination.d.ts +2 -2
  30. package/ReadSpeakerPlayer.js +13 -5
  31. package/SearchInput.d.ts +24 -2
  32. package/SearchInput.js +13 -3
  33. package/SearchResults.d.ts +2 -1
  34. package/SearchResults.js +10 -2
  35. package/ShareButtons.d.ts +3 -2
  36. package/SiteSearchAutocomplete.d.ts +11 -11
  37. package/SiteSearchAutocomplete.js +21 -7
  38. package/SiteSearchCurtain.js +2 -2
  39. package/SiteSearchInput.d.ts +19 -10
  40. package/SiteSearchInput.js +9 -6
  41. package/Tooltip.js +4 -3
  42. package/VerticalTabsTOC.js +2 -2
  43. package/_abstract/_ScrollWrapper.d.ts +10 -0
  44. package/_abstract/_ScrollWrapper.js +21 -0
  45. package/_abstract/_Table.d.ts +71 -0
  46. package/_abstract/_Table.js +55 -0
  47. package/_abstract/_TogglerGroup.js +2 -2
  48. package/_abstract/_TogglerInput.js +2 -2
  49. package/_mixed_export_resolution_/ReactDatepicker.d.ts +3 -0
  50. package/esm/AccordionList.js +1 -1
  51. package/esm/Alert.d.ts +2 -2
  52. package/esm/Alert.js +1 -0
  53. package/esm/AutosuggestSearch.d.ts +40 -0
  54. package/esm/AutosuggestSearch.js +66 -0
  55. package/esm/BasicTable.d.ts +24 -4
  56. package/esm/BasicTable.js +19 -18
  57. package/esm/BreadCrumbs.d.ts +2 -2
  58. package/esm/ContactBubble.d.ts +4 -3
  59. package/esm/ContactBubble.js +6 -3
  60. package/esm/Datepicker.d.ts +8 -3
  61. package/esm/Datepicker.js +35 -13
  62. package/esm/FileInput.d.ts +2 -1
  63. package/esm/FileInput.js +1 -1
  64. package/esm/FormField.js +1 -1
  65. package/esm/Gallery.d.ts +2 -1
  66. package/esm/Gallery.js +5 -0
  67. package/esm/Layout.d.ts +4 -3
  68. package/esm/Layout.js +0 -3
  69. package/esm/MainMenu/_PrimaryPanel.d.ts +3 -4
  70. package/esm/MainMenu/_PrimaryPanel.js +1 -1
  71. package/esm/MainMenu.d.ts +6 -4
  72. package/esm/MainMenu.js +8 -16
  73. package/esm/Multiselect.d.ts +2 -1
  74. package/esm/Multiselect.js +2 -1
  75. package/esm/NameCard.d.ts +2 -1
  76. package/esm/NameCard.js +7 -0
  77. package/esm/Pagination.d.ts +2 -2
  78. package/esm/ReadSpeakerPlayer.js +13 -5
  79. package/esm/SearchInput.d.ts +24 -2
  80. package/esm/SearchInput.js +13 -3
  81. package/esm/SearchResults.d.ts +2 -1
  82. package/esm/SearchResults.js +9 -1
  83. package/esm/ShareButtons.d.ts +3 -2
  84. package/esm/SiteSearchAutocomplete.d.ts +11 -11
  85. package/esm/SiteSearchAutocomplete.js +21 -7
  86. package/esm/SiteSearchCurtain.js +1 -1
  87. package/esm/SiteSearchInput.d.ts +19 -10
  88. package/esm/SiteSearchInput.js +8 -6
  89. package/esm/Tooltip.js +2 -1
  90. package/esm/VerticalTabsTOC.js +1 -1
  91. package/esm/_abstract/_ScrollWrapper.d.ts +10 -0
  92. package/esm/_abstract/_ScrollWrapper.js +16 -0
  93. package/esm/_abstract/_Table.d.ts +71 -0
  94. package/esm/_abstract/_Table.js +51 -0
  95. package/esm/_abstract/_TogglerGroup.js +1 -1
  96. package/esm/_abstract/_TogglerInput.js +1 -1
  97. package/esm/_mixed_export_resolution_/ReactDatepicker.d.ts +3 -0
  98. package/esm/index.d.ts +1 -0
  99. package/esm/utils/browserSide.d.ts +119 -1
  100. package/esm/utils/browserSide.js +152 -1
  101. package/esm/utils/config.d.ts +1 -14
  102. package/esm/utils/config.js +0 -2
  103. package/esm/utils/useCallbackOnEsc.d.ts +6 -0
  104. package/esm/utils/useCallbackOnEsc.js +25 -0
  105. package/esm/utils/useDomid.d.ts +8 -0
  106. package/esm/utils/useDomid.js +17 -0
  107. package/esm/utils/useLaggedState.d.ts +18 -0
  108. package/esm/utils/useLaggedState.js +84 -0
  109. package/esm/utils/useOnClickOutside.d.ts +9 -0
  110. package/esm/utils/useOnClickOutside.js +32 -0
  111. package/esm/utils/useScrollEdgeDetect.d.ts +15 -0
  112. package/esm/utils/useScrollEdgeDetect.js +45 -0
  113. package/esm/utils/useShortState.d.ts +2 -0
  114. package/esm/utils/useShortState.js +34 -0
  115. package/esm/utils.d.ts +1 -0
  116. package/esm/utils.js +1 -0
  117. package/index.d.ts +1 -0
  118. package/package.json +6 -2
  119. package/utils/browserSide.d.ts +119 -1
  120. package/utils/browserSide.js +156 -4
  121. package/utils/config.d.ts +1 -14
  122. package/utils/config.js +1 -4
  123. package/utils/useCallbackOnEsc.d.ts +6 -0
  124. package/utils/useCallbackOnEsc.js +29 -0
  125. package/utils/useDomid.d.ts +8 -0
  126. package/utils/useDomid.js +21 -0
  127. package/utils/useLaggedState.d.ts +18 -0
  128. package/utils/useLaggedState.js +88 -0
  129. package/utils/useOnClickOutside.d.ts +9 -0
  130. package/utils/useOnClickOutside.js +35 -0
  131. package/utils/useScrollEdgeDetect.d.ts +15 -0
  132. package/utils/useScrollEdgeDetect.js +50 -0
  133. package/utils/useShortState.d.ts +2 -0
  134. package/utils/useShortState.js +38 -0
  135. package/utils.d.ts +1 -0
  136. package/utils.js +1 -0
package/AccordionList.js CHANGED
@@ -4,12 +4,12 @@ exports.AccordionList = 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 hooks_1 = require("@hugsmidjan/react/hooks");
7
+ const useDomid_js_1 = require("./utils/useDomid.js");
8
8
  const utils_js_1 = require("./utils.js");
9
9
  const AccordionListItem = (props) => {
10
10
  const { title, content, id, disabled = false, ssr, open, onToggle } = props;
11
11
  const defaultOpen = (0, react_1.useRef)(props.defaultOpen);
12
- const domid = (0, hooks_1.useDomid)();
12
+ const domid = (0, useDomid_js_1.useDomid)();
13
13
  const isBrowser = (0, utils_js_1.useIsBrowserSide)(ssr);
14
14
  const itemDisabled = (isBrowser && disabled) || !content;
15
15
  return (react_1.default.createElement("div", { className: (0, classUtils_1.modifiedClass)('AccordionList__item', [itemDisabled && 'disabled']), id: id, "data-start-open": defaultOpen.current, "data-sprinkled": isBrowser },
package/Alert.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { MouseEvent, ReactNode } from 'react';
2
2
  import { EitherObj } from '@reykjavik/hanna-utils';
3
- import { DefaultTexts } from '@reykjavik/hanna-utils/i18n';
3
+ import { DefaultTexts, HannaLang } from '@reykjavik/hanna-utils/i18n';
4
4
  import { SSRSupportProps, WrapperElmProps } from './utils.js';
5
5
  export type AlertI18n = {
6
6
  closeLabel: string;
@@ -23,7 +23,7 @@ export type AlertProps = {
23
23
  /** server-side anchor href */
24
24
  closeUrl?: string;
25
25
  texts?: AlertI18n;
26
- lang?: string;
26
+ lang?: HannaLang;
27
27
  } & SSRSupportProps & EitherObj<{
28
28
  /** Seconds until the Alert auto-closes.
29
29
  *
package/Alert.js CHANGED
@@ -38,6 +38,7 @@ const useAutoClosing = (autoClose, props) => {
38
38
  exports.defaultAlertTexts = {
39
39
  en: { closeLabel: 'Hide' },
40
40
  is: { closeLabel: 'Fela' },
41
+ pl: { closeLabel: 'Ukryj' },
41
42
  };
42
43
  exports.alertTypes = {
43
44
  info: 1,
@@ -0,0 +1,40 @@
1
+ import { RenderInputComponentProps } from 'react-autosuggest';
2
+ import { DefaultTexts, HannaLang } from '@reykjavik/hanna-utils/i18n';
3
+ import { SearchInputProps } from './SearchInput.js';
4
+ import { SiteSearchInputProps } from './SiteSearchInput.js';
5
+ import { WrapperElmProps } from './utils.js';
6
+ export type AutosuggestSearchI18n = {
7
+ /** Label for the autocomplete's combobox container div */
8
+ label: string;
9
+ /** Label for the text input */
10
+ inputLabel: string;
11
+ /** Label for the search button */
12
+ buttonText: string;
13
+ /** Placeholder text for the text input */
14
+ placeholder?: string;
15
+ /** Label for the suggestions item list container */
16
+ suggestionsLabel: string;
17
+ /** @deprecated Not used (Will be removed in v0.11) */
18
+ lang?: string;
19
+ };
20
+ export declare const defaultAutosuggestSearchTexts: DefaultTexts<AutosuggestSearchI18n>;
21
+ export type AutosuggestSearchProps<T extends string | object> = {
22
+ options: Array<T>;
23
+ onInput: (value: string) => void;
24
+ onSelected: (payload: {
25
+ value: string;
26
+ option: T;
27
+ }) => void;
28
+ onClearOptions: () => void;
29
+ getOptionValue?: (option: T) => string;
30
+ renderSuggestion?: (option: T, context: {
31
+ query: string;
32
+ isHighlighted: boolean;
33
+ }) => JSX.Element | string;
34
+ itemActionIcon?: 'search' | 'go';
35
+ InputComponent?: (props: SiteSearchInputProps & SearchInputProps) => JSX.Element;
36
+ renderInputField?: (inputProps: RenderInputComponentProps, texts: AutosuggestSearchI18n) => JSX.Element;
37
+ texts?: AutosuggestSearchI18n;
38
+ lang?: HannaLang;
39
+ } & Pick<SearchInputProps, 'onSubmit' | 'onButtonClick' | 'button'> & WrapperElmProps;
40
+ export declare const AutosuggestSearch: <T extends string | object>(props: AutosuggestSearchProps<T>) => JSX.Element;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AutosuggestSearch = exports.defaultAutosuggestSearchTexts = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importStar(require("react"));
6
+ const react_autosuggest_1 = tslib_1.__importDefault(require("react-autosuggest"));
7
+ const classUtils_1 = require("@hugsmidjan/qj/classUtils");
8
+ const i18n_1 = require("@reykjavik/hanna-utils/i18n");
9
+ const SearchInput_js_1 = tslib_1.__importDefault(require("./SearchInput.js"));
10
+ exports.defaultAutosuggestSearchTexts = {
11
+ is: {
12
+ label: 'Leit á vefnum',
13
+ inputLabel: 'Leitarorð',
14
+ buttonText: 'Leita',
15
+ placeholder: 'Sláðu inn leitarorð',
16
+ suggestionsLabel: 'Tillögur',
17
+ },
18
+ en: {
19
+ label: 'Site search',
20
+ inputLabel: 'Search terms',
21
+ buttonText: 'Search',
22
+ placeholder: 'Enter search terms',
23
+ suggestionsLabel: 'Suggestions',
24
+ },
25
+ pl: {
26
+ label: 'Wyszukiwanie na stronie',
27
+ inputLabel: 'Wyszukaj frazę',
28
+ buttonText: 'Szukaj',
29
+ placeholder: 'Wpisz frazę',
30
+ suggestionsLabel: 'Sugestie',
31
+ },
32
+ };
33
+ const AutosuggestSearch = (props) => {
34
+ const { options, itemActionIcon, onInput, onSelected, onClearOptions, onSubmit, onButtonClick = onSubmit, button, getOptionValue = (opt) => typeof opt !== 'object' || !('value' in opt)
35
+ ? opt.toString()
36
+ : opt.value != null
37
+ ? opt.value.toString()
38
+ : '', renderSuggestion = (opt) => typeof opt === 'object' && 'label' in opt && opt.label != null
39
+ ? opt.label.toString()
40
+ : getOptionValue(opt), InputComponent = SearchInput_js_1.default, renderInputField, wrapperProps, } = props;
41
+ const [value, setValue] = (0, react_1.useState)('');
42
+ const inputRef = (0, react_1.createRef)();
43
+ const txt = (0, i18n_1.getTexts)(props, exports.defaultAutosuggestSearchTexts);
44
+ return (react_1.default.createElement(react_autosuggest_1.default, { theme: {
45
+ container: 'AutosuggestSearch',
46
+ containerOpen: 'AutosuggestSearch--open',
47
+ suggestionsContainer: 'AutosuggestSearch__container',
48
+ suggestionsContainerOpen: 'AutosuggestSearch__container--open',
49
+ suggestionsList: (0, classUtils_1.modifiedClass)('AutosuggestSearch__list', itemActionIcon && `action--${itemActionIcon}`),
50
+ suggestion: 'AutosuggestSearch__item',
51
+ suggestionHighlighted: 'AutosuggestSearch__item--highlighted',
52
+ }, focusInputOnSuggestionClick: true, suggestions: options, onSuggestionsClearRequested: onClearOptions, onSuggestionsFetchRequested: ({ value }) => onInput(value), getSuggestionValue: getOptionValue, onSuggestionSelected: (_event, data) => {
53
+ onSelected({ value: data.suggestionValue, option: data.suggestion });
54
+ },
55
+ // onSuggestionHighlighted={onSuggestionHighlighted}
56
+ renderSuggestion: renderSuggestion, containerProps: Object.assign(Object.assign({}, wrapperProps), { 'aria-label': txt.label }), renderSuggestionsContainer: ({ containerProps, children }) => (react_1.default.createElement("div", Object.assign({}, containerProps, { "aria-label": options.length ? txt.suggestionsLabel : undefined }), children)), inputProps: {
57
+ ref: inputRef,
58
+ value: value,
59
+ onChange: (_, { newValue }) => {
60
+ setValue(newValue);
61
+ },
62
+ }, renderInputComponent: renderInputField
63
+ ? (inputProps) => renderInputField(inputProps, txt)
64
+ : (inputProps) => {
65
+ /* prettier-ignore */
66
+ const { className, type, disabled, readOnly, required, children } = inputProps, siteSearchProps = tslib_1.__rest(inputProps, ["className", "type", "disabled", "readOnly", "required", "children"]);
67
+ return (react_1.default.createElement(InputComponent, Object.assign({ lang: props.lang }, siteSearchProps, { button: button, label: txt.inputLabel, placeholder: txt.placeholder, buttonText: txt.buttonText, onSubmit: onSubmit && (() => onSubmit(value)), onButtonClick: onButtonClick && (() => onButtonClick(value)) })));
68
+ } }));
69
+ };
70
+ exports.AutosuggestSearch = AutosuggestSearch;
package/BasicTable.d.ts CHANGED
@@ -1,15 +1,35 @@
1
- import { TableProps } from '@hugsmidjan/react/Table';
2
1
  import { EitherObj } from '@reykjavik/hanna-utils';
2
+ import { TableProps } from './_abstract/_Table.js';
3
3
  import { DeprecatedSeenProp } from './utils/seenEffect.js';
4
- import { MissingWrapperElmProps } from './utils.js';
4
+ import { HTMLProps, WrapperElmProps } from './utils.js';
5
+ type TableType = 'text' | 'number';
6
+ export type { TableBody, TableCell, TableCellData, TableCellMeta, TableCols, TableFoot, TableHead, TableRow, } from './_abstract/_Table.js';
5
7
  export type BasicTableProps = {
6
8
  compact?: boolean;
7
- type?: 'text' | 'number';
9
+ /**
10
+ * The main/default cell-data type of the table
11
+ *
12
+ * Defaults to 'text'
13
+ */
14
+ type?: TableType;
15
+ /**
16
+ * Custom HTML attributes for the component's `<table/>` element.
17
+ *
18
+ * Note, however, that some props may be intentionally
19
+ * excluded from the list.
20
+ *
21
+ * __WARNING:__
22
+ * In some cases props added this way can break the component, og hurt its
23
+ * accessibility. Also, some props may get ignored, or over-ridden by the
24
+ * component. User discretion is advised.
25
+ */
26
+ tableProps?: HTMLProps<'table'>;
27
+ /** @deprecated Use `wrapperProps={{ className }}` and `tableProps={{ className }}` instead (Will be removed in v0.11) */
8
28
  modifier?: string;
9
29
  } & EitherObj<{
10
30
  fullWidth?: boolean;
11
31
  }, {
12
32
  align?: 'right';
13
- }> & MissingWrapperElmProps & DeprecatedSeenProp & Omit<TableProps, 'className' | 'children'>;
33
+ }> & WrapperElmProps & DeprecatedSeenProp & TableProps;
14
34
  export declare const BasicTable: (props: BasicTableProps) => JSX.Element;
15
35
  export default BasicTable;
package/BasicTable.js CHANGED
@@ -4,29 +4,30 @@ exports.BasicTable = void 0;
4
4
  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
- const Table_1 = tslib_1.__importDefault(require("@hugsmidjan/react/Table"));
8
- const TableWrapper_1 = tslib_1.__importDefault(require("@hugsmidjan/react/TableWrapper"));
7
+ const _ScrollWrapper_js_1 = require("./_abstract/_ScrollWrapper.js");
8
+ const _Table_js_1 = require("./_abstract/_Table.js");
9
+ const tableTypes = {
10
+ text: '',
11
+ number: 'data--number',
12
+ };
9
13
  const BasicTable = (props) => {
10
- const { cols, caption, thead, tfoot, align, fullWidth } = props;
11
- const tbodyProps = props.tbodies
12
- ? { tbodies: props.tbodies }
13
- : { tbody: props.tbody || [] };
14
- const modifier = props.modifier;
15
- return (react_1.default.createElement(TableWrapper_1.default, { modifier: [
14
+ // eslint-disable-next-line deprecation/deprecation
15
+ const { align, fullWidth, type, tbody, tbodies, modifier } = props;
16
+ return (react_1.default.createElement(_ScrollWrapper_js_1.ScrollWrapper, { bem: "TableWrapper", modifier: [
16
17
  'BasicTable',
17
18
  modifier && 'BasicTable--' + modifier,
18
- fullWidth && 'BasicTable--fullwidth',
19
- align === 'right' && !fullWidth && 'BasicTable--align--' + align,
20
- ] },
21
- react_1.default.createElement(Table_1.default, Object.assign({ className: (0, classUtils_1.modifiedClass)('BasicTable', [
19
+ fullWidth
20
+ ? 'BasicTable--fullwidth'
21
+ : align === 'right'
22
+ ? 'BasicTable--align--' + align
23
+ : undefined,
24
+ ], wrapperProps: props.wrapperProps, innerWrap // TODO: Remove this once the CSS style-server has been updated
25
+ : true },
26
+ react_1.default.createElement(_Table_js_1.Table, Object.assign({ className: (0, classUtils_1.modifiedClass)('BasicTable', [
22
27
  props.compact && 'compact',
23
- modifier && modifier,
24
- ]) }, {
25
- cols,
26
- caption,
27
- thead,
28
- tfoot,
29
- }, tbodyProps))));
28
+ type && tableTypes[type],
29
+ modifier,
30
+ ]), cols: props.cols, caption: props.caption, thead: props.thead, tfoot: props.tfoot }, (tbody ? { tbody } : { tbodies }), { wrapperProps: props.tableProps }))));
30
31
  };
31
32
  exports.BasicTable = BasicTable;
32
33
  exports.default = exports.BasicTable;
package/BreadCrumbs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { DefaultTexts } from '@reykjavik/hanna-utils/i18n';
1
+ import { DefaultTexts, HannaLang } from '@reykjavik/hanna-utils/i18n';
2
2
  import { WrapperElmProps } from './utils.js';
3
3
  export type BreadCrumb = {
4
4
  href?: string;
@@ -10,7 +10,7 @@ export declare const defaultBreadCrumbsTexts: DefaultTexts<{
10
10
  }>;
11
11
  export type BreadCrumbsProps = {
12
12
  title?: string;
13
- lang?: string;
13
+ lang?: HannaLang;
14
14
  trail: BreadCrumbTrail;
15
15
  } & WrapperElmProps<null, 'aria-label'>;
16
16
  export declare const BreadCrumbs: (props: BreadCrumbsProps) => JSX.Element | null;
package/CHANGELOG.md CHANGED
@@ -4,6 +4,40 @@
4
4
 
5
5
  - ... <!-- Add new lines here. -->
6
6
 
7
+ ## 0.10.104
8
+
9
+ _2023-09-13_
10
+
11
+ - feat: Make all translated components respect `DEFAULT_LANG` from hanna-utils
12
+ - `BasicTable`:
13
+ - feat: Add props `wrapperProps`
14
+ - feat: Add prop `rowProps`
15
+ - feat: Export `Table*` types (`TableCell`, `TableRow`, etc.)
16
+ - feat: Allow `key` prop as part of `TableCellData`
17
+ - feat: Add component `AutosuggestSearch`
18
+ - `SiteSearchAutocomplete`:
19
+ - feat: Mark this component as deprecated, in favor of `AutosuggestSearch`
20
+ - fix: Add translation prop `buttonText` — (optional, but logs warning in
21
+ dev if missing.)
22
+ - fix: Spread `wrapperProps` on the wrapping `<div/>` element not the
23
+ contained `FormField`
24
+ - `SearchInput`:
25
+ - feat: Add prop `onSubmit` firing on `Enter` keypress
26
+ - feat: `onButtonClick` receives `value` as an argument
27
+ - feat: Use `onSubmit` as fallback for `onButtonClick`
28
+ - feat: Add prop `button` to toggle the button, ueses`onSubmit` as fallback
29
+ - fix: Minor prop and attribute assignment cleanup
30
+ - `SiteSearchInput`:
31
+ - feat: `onButtonClick` and `onSubmit` receive `value` as their argument
32
+ - feat: Add prop `button` to toggle the button, ueses`onSubmit` as fallback
33
+ - fix: Minor prop and attribute assignment cleanup
34
+ - `Datepicker`:
35
+ - feat: Add prop `lang`, deprecate `localeCode`
36
+ - feat: Add support for `hrefLang` values on `MainMenuItem` and
37
+ `MegaMenuItem`
38
+ - fix: Fix minor mistakes in aria-label translations
39
+ - feat: Add `useDomid` to `utils`
40
+
7
41
  ## 0.10.103
8
42
 
9
43
  _2023-09-13_
@@ -1,12 +1,13 @@
1
1
  import React from 'react';
2
- import { DefaultTexts } from '@reykjavik/hanna-utils/i18n';
2
+ import { DefaultTexts, HannaLang } from '@reykjavik/hanna-utils/i18n';
3
3
  import { SSRSupportProps, WrapperElmProps } from './utils.js';
4
4
  export type ContactBubbleI18n = {
5
- lang?: string;
6
5
  openBtn: string;
7
6
  openBtnLong?: string;
8
7
  closeBtn: string;
9
8
  closeBtnLong?: string;
9
+ /** @deprecated Not used (Will be removed in v0.11) */
10
+ lang?: string;
10
11
  };
11
12
  export declare const defaultTexts: DefaultTexts<ContactBubbleI18n>;
12
13
  declare const icons: {
@@ -46,7 +47,7 @@ export type ContactBubbleProps = {
46
47
  */
47
48
  alwaysShow?: boolean;
48
49
  texts?: ContactBubbleI18n;
49
- lang?: string;
50
+ lang?: HannaLang;
50
51
  } & SSRSupportProps & WrapperElmProps & ({
51
52
  open?: boolean;
52
53
  onToggle: (isOpen: boolean) => void;
package/ContactBubble.js CHANGED
@@ -5,24 +5,27 @@ 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
7
  const focusElm_1 = require("@hugsmidjan/qj/focusElm");
8
- const hooks_1 = require("@hugsmidjan/react/hooks");
9
8
  const i18n_1 = require("@reykjavik/hanna-utils/i18n");
10
9
  const _Link_js_1 = require("./_abstract/_Link.js");
11
10
  const breakOnNL_js_1 = require("./_abstract/breakOnNL.js");
11
+ const useDomid_js_1 = require("./utils/useDomid.js");
12
12
  const utils_js_1 = require("./utils.js");
13
13
  exports.defaultTexts = {
14
14
  is: {
15
- lang: 'is',
16
15
  openBtn: 'Hafa samband',
17
16
  closeBtn: 'Loka',
18
17
  closeBtnLong: 'Loka valmynd',
19
18
  },
20
19
  en: {
21
- lang: 'en',
22
20
  openBtn: 'Contact us',
23
21
  closeBtn: 'Close',
24
22
  closeBtnLong: 'Close bubble',
25
23
  },
24
+ pl: {
25
+ openBtn: 'Skontaktuj się z nami',
26
+ closeBtn: 'Zamknąć',
27
+ closeBtnLong: 'Zamknąć pęcherzyk',
28
+ },
26
29
  };
27
30
  // ---------------------------------------------------------------------------
28
31
  const icons = {
@@ -43,7 +46,7 @@ const ContactBubble = (props) => {
43
46
  const [localOpen, setLocalOpen] = (0, react_1.useState)(false);
44
47
  const open = useLocalState ? localOpen : props.open;
45
48
  const isBrowser = (0, utils_js_1.useIsBrowserSide)(props.ssr);
46
- const domid = (0, hooks_1.useDomid)();
49
+ const domid = (0, useDomid_js_1.useDomid)();
47
50
  const _wrapperRef = (0, react_1.useRef)(null);
48
51
  const wrapperRef = wrapperProps.ref || _wrapperRef;
49
52
  const { openBubble, closeBubble } = (0, react_1.useMemo)(() => ({
package/Datepicker.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { RefObject } from 'react';
2
+ import { HannaLang } from '@reykjavik/hanna-utils/i18n';
2
3
  import { FormFieldWrappingProps } from './FormField.js';
3
4
  export type DatepickerProps = {
4
5
  small?: boolean;
@@ -28,14 +29,17 @@ export type DatepickerProps = {
28
29
  * NOTE: This will be the default mode in v0.11.
29
30
  */
30
31
  isoMode?: boolean;
31
- localeCode?: 'is' | 'en' | 'pl';
32
+ texts?: DatepickerLocaleProps;
33
+ lang?: HannaLang;
32
34
  dateFormat?: string | Array<string>;
33
35
  isStartDate?: boolean;
34
36
  isEndDate?: boolean;
35
37
  inputRef?: RefObject<HTMLInputElement>;
36
38
  onChange?: (date?: Date) => void;
37
39
  datepickerExtraProps?: Record<string, unknown>;
38
- /** @deprecated Use `value` or `defaultValue` instead. (Will be removed in v0.11) */
40
+ /** @deprecated Use `lang` instead (Will be removed in v0.11) */
41
+ localeCode?: HannaLang;
42
+ /** @deprecated Use `value` or `defaultValue` instead. (Will be removed in v0.11) */
39
43
  initialDate?: Date;
40
44
  } & FormFieldWrappingProps;
41
45
  /**
@@ -44,6 +48,7 @@ export type DatepickerProps = {
44
48
  */
45
49
  export declare const getDateDiff: (refDate: Date, dayOffset: number) => Date;
46
50
  export type DatepickerLocaleProps = {
51
+ ariaLabelClose: string;
47
52
  nextMonthAriaLabel: string;
48
53
  nextMonthButtonLabel: string;
49
54
  nextYearAriaLabel: string;
@@ -54,8 +59,8 @@ export type DatepickerLocaleProps = {
54
59
  previousYearButtonLabel: string;
55
60
  timeInputLabel: string;
56
61
  weekAriaLabelPrefix: string;
62
+ monthAriaLabelPrefix: string;
57
63
  weekLabel: string;
58
- ariaLabelPrefix: string;
59
64
  chooseDayAriaLabelPrefix: string;
60
65
  disabledDayAriaLabelPrefix: string;
61
66
  };
package/Datepicker.js CHANGED
@@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Datepicker = exports.getDateDiff = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importDefault(require("react"));
6
- const hooks_1 = require("@hugsmidjan/react/hooks");
6
+ const i18n_1 = require("@reykjavik/hanna-utils/i18n");
7
7
  // For more info on localization see: https://stackoverflow.com/questions/54399084/change-locale-in-react-datepicker/58306958#58306958
8
8
  const index_js_1 = tslib_1.__importDefault(require("date-fns/locale/is/index.js"));
9
9
  const index_js_2 = tslib_1.__importDefault(require("date-fns/locale/pl/index.js"));
10
10
  const ReactDatepicker_js_1 = require("./_mixed_export_resolution_/ReactDatepicker.js"); // Docs: https://reactdatepicker.com/
11
+ const useDomid_js_1 = require("./utils/useDomid.js");
11
12
  const FormField_js_1 = require("./FormField.js");
12
13
  const utils_js_1 = require("./utils.js");
13
14
  (0, ReactDatepicker_js_1.registerLocale)('is', index_js_1.default);
@@ -22,8 +23,9 @@ const getDateDiff = (refDate, dayOffset) => {
22
23
  return newDate;
23
24
  };
24
25
  exports.getDateDiff = getDateDiff;
25
- const i18n = {
26
+ const defaultDatepickerTexts = {
26
27
  is: {
28
+ ariaLabelClose: 'Loka',
27
29
  nextMonthAriaLabel: 'Næsti mánuður',
28
30
  nextMonthButtonLabel: 'Næsti mánuður',
29
31
  nextYearAriaLabel: 'Næsta ár',
@@ -32,14 +34,34 @@ const i18n = {
32
34
  previousMonthButtonLabel: 'Fyrri mánuður',
33
35
  previousYearAriaLabel: 'Fyrra ár',
34
36
  previousYearButtonLabel: 'Fyrra ár',
35
- timeInputLabel: 'Tími: ',
36
- weekAriaLabelPrefix: 'Vika: ',
37
+ timeInputLabel: 'Tími:',
38
+ weekAriaLabelPrefix: 'Vika:',
37
39
  weekLabel: 'Vika',
38
- ariaLabelPrefix: 'Mánuður:',
40
+ monthAriaLabelPrefix: 'Mánuður:',
39
41
  chooseDayAriaLabelPrefix: 'Veldu:',
40
- disabledDayAriaLabelPrefix: 'Dagsetning ekki í boði',
42
+ disabledDayAriaLabelPrefix: 'Ekki í boði:',
43
+ },
44
+ // React-datepicker has its own (default) English translation built in.
45
+ // No need to repeat all of it here.
46
+ en: {
47
+ // ariaLabelClose: 'Close',
48
+ // nextMonthAriaLabel: 'Next month',
49
+ // nextMonthButtonLabel: 'Next month',
50
+ // nextYearAriaLabel: 'Next year',
51
+ // nextYearButtonLabel: 'Next year',
52
+ // previousMonthAriaLabel: 'Previous month',
53
+ // previousMonthButtonLabel: 'Previous month',
54
+ // previousYearAriaLabel: 'Previous year',
55
+ // previousYearButtonLabel: 'Previous year',
56
+ // timeInputLabel: 'Time:',
57
+ // weekAriaLabelPrefix: 'Week:',
58
+ // weekLabel: 'Week',
59
+ monthAriaLabelPrefix: 'Month:',
60
+ chooseDayAriaLabelPrefix: 'Choose:',
61
+ disabledDayAriaLabelPrefix: 'Not available:',
41
62
  },
42
63
  pl: {
64
+ ariaLabelClose: 'Zamknij',
43
65
  nextMonthAriaLabel: 'Następny miesiącu',
44
66
  nextMonthButtonLabel: 'Następny miesiącu',
45
67
  nextYearAriaLabel: 'Następny rok',
@@ -48,12 +70,12 @@ const i18n = {
48
70
  previousMonthButtonLabel: 'Poprzedni miesiac',
49
71
  previousYearAriaLabel: 'Poprzedni rok',
50
72
  previousYearButtonLabel: 'Poprzedni rok',
51
- timeInputLabel: 'Czas: ',
52
- weekAriaLabelPrefix: 'Tydzień: ',
73
+ timeInputLabel: 'Czas:',
74
+ weekAriaLabelPrefix: 'Tydzień:',
53
75
  weekLabel: 'Tydzień',
54
- ariaLabelPrefix: 'Miesiąc:',
76
+ monthAriaLabelPrefix: 'Miesiąc:',
55
77
  chooseDayAriaLabelPrefix: 'Wybierać:',
56
- disabledDayAriaLabelPrefix: 'Data niedostępna',
78
+ disabledDayAriaLabelPrefix: 'Niedostępna:',
57
79
  },
58
80
  };
59
81
  /**
@@ -62,7 +84,7 @@ const i18n = {
62
84
  * Internally, this component uses the [`react-datepicker`](https://reactdatepicker.com/) component.
63
85
  */
64
86
  const Datepicker = (props) => {
65
- const { placeholder, localeCode = 'is', dateFormat = 'd.M.yyyy', name, startDate, endDate, minDate, maxDate, isStartDate = false, isEndDate = false, onChange, datepickerExtraProps, inputRef, isoMode, fieldWrapperProps, } = (0, FormField_js_1.groupFormFieldWrapperProps)(props);
87
+ const { placeholder, dateFormat = 'd.M.yyyy', name, startDate, endDate, minDate, maxDate, isStartDate = false, isEndDate = false, onChange, datepickerExtraProps, inputRef, isoMode, texts, lang = props.localeCode, fieldWrapperProps, } = (0, FormField_js_1.groupFormFieldWrapperProps)(props);
66
88
  const [value, setValue] = utils_js_1.useMixedControlState.raw(props.value || props.initialDate, // eslint-disable-line deprecation/deprecation
67
89
  props.defaultValue, 'value');
68
90
  /*
@@ -70,8 +92,8 @@ const Datepicker = (props) => {
70
92
  and `props.initialDate` is removed:
71
93
  */
72
94
  // const [value, setValue] = useMixedControlState(props, 'value');
73
- const domid = (0, hooks_1.useDomid)(props.id);
74
- const txts = i18n[localeCode] || {};
95
+ const domid = (0, useDomid_js_1.useDomid)(props.id);
96
+ const txts = (0, i18n_1.getTexts)({ texts, lang }, defaultDatepickerTexts);
75
97
  const filled = !!value;
76
98
  const empty = !filled && !placeholder;
77
99
  return (react_1.default.createElement(FormField_js_1.FormField, Object.assign({ extraClassName: "Datepicker", filled: filled, empty: empty }, fieldWrapperProps, { renderInput: (className, inputProps, addFocusProps) => {
@@ -82,7 +104,7 @@ const Datepicker = (props) => {
82
104
  return elm;
83
105
  }) }, addFocusProps()),
84
106
  isoMode && (react_1.default.createElement("input", { type: "hidden", name: name, value: value === null || value === void 0 ? void 0 : value.toISOString().slice(0, 10) })),
85
- react_1.default.createElement(ReactDatepicker_js_1.ReactDatePicker, Object.assign({ id: domid, required: inputProps.required, disabled: inputProps.disabled, readOnly: inputProps.readOnly, selected: value, name: isoMode ? undefined : name, locale: localeCode, dateFormat:
107
+ react_1.default.createElement(ReactDatepicker_js_1.ReactDatePicker, Object.assign({ id: domid, required: inputProps.required, disabled: inputProps.disabled, readOnly: inputProps.readOnly, selected: value, name: isoMode ? undefined : name, locale: lang, dateFormat:
86
108
  // NOTE: Force all dateFormat values into Array<string> to temporarily work around
87
109
  // a bug in the current version of react-datepicker where invalid `string` values
88
110
  // are re-parsed with `new Date()`, causing surprising (weird) false positives
package/FileInput.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { HannaLang } from '@reykjavik/hanna-utils/i18n';
1
2
  import { FileListProps } from './FileInput/_FileInputFileList.js';
2
3
  import { FormFieldWrappingProps } from './FormField.js';
3
4
  export type FileInputProps = FormFieldWrappingProps & {
@@ -15,7 +16,7 @@ export type FileInputProps = FormFieldWrappingProps & {
15
16
  accept?: string | Array<string>;
16
17
  dropzoneText: string | JSX.Element;
17
18
  removeFileText?: string;
18
- lang?: string;
19
+ lang?: HannaLang;
19
20
  showFileSize?: boolean;
20
21
  showImagePreviews?: boolean;
21
22
  FileList?: false | ((props: FileListProps) => JSX.Element | null);
package/FileInput.js CHANGED
@@ -4,11 +4,11 @@ exports.FileInput = 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 hooks_1 = require("@hugsmidjan/react/hooks");
8
7
  const i18n_1 = require("@reykjavik/hanna-utils/i18n");
9
8
  const ReactDropzone_js_1 = require("./_mixed_export_resolution_/ReactDropzone.js");
10
9
  const _FileInput_utils_js_1 = require("./FileInput/_FileInput.utils.js");
11
10
  const _FileInputFileList_js_1 = require("./FileInput/_FileInputFileList.js");
11
+ const useDomid_js_1 = require("./utils/useDomid.js");
12
12
  const FormField_js_1 = tslib_1.__importStar(require("./FormField.js"));
13
13
  const defaultRemoveFileText = {
14
14
  is: 'Fjarlægja',
@@ -37,7 +37,7 @@ const FileInput = (props) => {
37
37
  multiple = (_b = (_a = props.dropzoneProps) === null || _a === void 0 ? void 0 : _a.multiple) !== null && _b !== void 0 ? _b : true, // eslint-disable-line deprecation/deprecation
38
38
  accept = (_c = props.dropzoneProps) === null || _c === void 0 ? void 0 : _c.accept, // eslint-disable-line deprecation/deprecation
39
39
  dropzoneText, removeFileText = defaultRemoveFileText[lang] || defaultRemoveFileText[i18n_1.DEFAULT_LANG], FileList = _FileInputFileList_js_1.DefaultFileList, onFilesUpdated = () => undefined, onFilesRejected, showFileSize, showImagePreviews, value = [], fieldWrapperProps } = _d, inputElementProps = tslib_1.__rest(_d, ["dropzoneProps", "multiple", "accept", "dropzoneText", "removeFileText", "FileList", "onFilesUpdated", "onFilesRejected", "showFileSize", "showImagePreviews", "value", "fieldWrapperProps"]);
40
- const domid = (0, hooks_1.useDomid)(props.id);
40
+ const domid = (0, useDomid_js_1.useDomid)(props.id);
41
41
  const fileInputWrapper = (0, react_1.useRef)(null);
42
42
  const fileInput = (0, react_1.useRef)(null);
43
43
  const files = value;
package/FormField.js CHANGED
@@ -4,8 +4,8 @@ exports.groupFormFieldWrapperProps = exports.getFormFieldWrapperProps = exports.
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 hooks_1 = require("@hugsmidjan/react/hooks");
8
7
  const env_js_1 = require("./utils/env.js");
8
+ const useDomid_js_1 = require("./utils/useDomid.js");
9
9
  const utils_js_1 = require("./utils.js");
10
10
  const inputClassNames = {
11
11
  bem: 'FormField',
@@ -20,7 +20,7 @@ const FormField = (props) => {
20
20
  renderInput, id, ssr, wrapperProps, } = props;
21
21
  const isBrowser = (0, utils_js_1.useIsBrowserSide)(ssr);
22
22
  const isInvalid = invalid || !!errorMessage || undefined;
23
- const domid = (0, hooks_1.useDomid)(id);
23
+ const domid = (0, useDomid_js_1.useDomid)(id);
24
24
  const [focused, setFocused] = (0, react_1.useState)(false);
25
25
  // @ts-expect-error (Duck knows why this errors?!)
26
26
  const addFocusProps = (0, react_1.useCallback)((ownProps) => {
package/Gallery.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { HannaLang } from '@reykjavik/hanna-utils/i18n';
1
2
  import { GalleryItemProps } from './Gallery/_GalleryItem.js';
2
3
  import { DeprecatedSeenProp } from './utils/seenEffect.js';
3
4
  import { SSRSupportProps, WrapperElmProps } from './utils.js';
@@ -10,7 +11,7 @@ export type GalleryI18n = {
10
11
  export type GalleryProps = {
11
12
  items: Array<GalleryItemProps>;
12
13
  texts?: GalleryI18n;
13
- lang?: string;
14
+ lang?: HannaLang;
14
15
  } & SSRSupportProps & WrapperElmProps & DeprecatedSeenProp;
15
16
  export declare const Gallery: (props: GalleryProps) => JSX.Element;
16
17
  export default Gallery;
package/Gallery.js CHANGED
@@ -19,6 +19,11 @@ const defaultTexts = {
19
19
  modalPrevLabel: 'Fyrri mynd',
20
20
  modalCloseLabel: 'Til baka í grein',
21
21
  },
22
+ pl: {
23
+ modalNextLabel: 'Następne zdjęcie',
24
+ modalPrevLabel: 'Poprzednie zdjęcie',
25
+ modalCloseLabel: 'Powrót do artykułu',
26
+ },
22
27
  };
23
28
  const Gallery = (props) => {
24
29
  const { items, ssr } = props;
package/Layout.d.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  import { ReactNode } from 'react';
2
2
  import type { HannaColorTheme } from '@reykjavik/hanna-css';
3
3
  import { EitherObj } from '@reykjavik/hanna-utils';
4
- import { DefaultTexts } from '@reykjavik/hanna-utils/i18n';
4
+ import { DefaultTexts, HannaLang } from '@reykjavik/hanna-utils/i18n';
5
5
  import { BemModifierProps } from './utils/types.js';
6
6
  import { SSRSupportProps, WrapperElmProps } from './utils.js';
7
7
  export type LayoutI18n = {
8
- lang?: string;
9
8
  skipLinkLabel: string;
10
9
  closeMenuLabel: string;
11
10
  closeMenuLabelLong?: string;
11
+ /** @deprecated Not used (Will be removed in v0.11) */
12
+ lang?: string;
12
13
  };
13
14
  export declare const defaultLayoutTexts: DefaultTexts<LayoutI18n>;
14
15
  type LayoutProps = {
@@ -19,7 +20,7 @@ type LayoutProps = {
19
20
  logoLink?: string;
20
21
  siteName?: string;
21
22
  texts?: LayoutI18n;
22
- lang?: string;
23
+ lang?: HannaLang;
23
24
  } & SSRSupportProps & WrapperElmProps & BemModifierProps & EitherObj<{
24
25
  mainChildren: ReactNode;
25
26
  }, {