@reykjavik/hanna-react 0.10.123 → 0.10.124

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,13 @@
4
4
 
5
5
  - ... <!-- Add new lines here. -->
6
6
 
7
+ ## 0.10.124
8
+
9
+ _2024-04-05_
10
+
11
+ - feat: Add prop `openBtnLabel` to `ContactBubble`
12
+ - feat: Make `FileInput`'s `dropzoneText` prop optional
13
+
7
14
  ## 0.10.123
8
15
 
9
16
  _2024-03-21_
@@ -46,6 +46,8 @@ export type ContactBubbleProps = {
46
46
  * magic and always show the bubble toggler
47
47
  */
48
48
  alwaysShow?: boolean;
49
+ /** Shorthand override for texts.openBtn, for quick customization */
50
+ openBtnLabel?: string;
49
51
  texts?: ContactBubbleI18n;
50
52
  lang?: HannaLang;
51
53
  } & SSRSupportProps & WrapperElmProps & ({
package/ContactBubble.js CHANGED
@@ -42,6 +42,8 @@ exports.ensureIcon = ensureIcon;
42
42
  const ContactBubble = (props) => {
43
43
  const { title, links, onToggle, alwaysShow, wrapperProps = {} } = props;
44
44
  const txt = (0, i18n_1.getTexts)(props, exports.defaultTexts);
45
+ const openLabel = props.openBtnLabel || txt.openBtn;
46
+ const openLabelLong = !props.openBtnLabel ? txt.openBtnLong : undefined;
45
47
  const useLocalState = props.open == null;
46
48
  const [localOpen, setLocalOpen] = (0, react_1.useState)(false);
47
49
  const open = useLocalState ? localOpen : props.open;
@@ -132,8 +134,8 @@ const ContactBubble = (props) => {
132
134
  if (links.length === 0) {
133
135
  return null;
134
136
  }
135
- const menu = (react_1.default.createElement("div", Object.assign({}, props.wrapperProps, { className: (0, classUtils_1.modifiedClass)('ContactBubble', null, wrapperProps.className), id: isBrowser && domid, hidden: isBrowser && !open, "data-always-show": alwaysShow || undefined, "data-sprinkled": isBrowser }),
136
- react_1.default.createElement("h2", { className: "ContactBubble__title" }, title || txt.openBtn),
137
+ const menu = (react_1.default.createElement("div", Object.assign({}, props.wrapperProps, { className: (0, classUtils_1.modifiedClass)('ContactBubble', null, wrapperProps.className), id: isBrowser && domid, hidden: isBrowser && !open, "data-label-openbtn": props.openBtnLabel, "data-always-show": alwaysShow || undefined, "data-sprinkled": isBrowser }),
138
+ react_1.default.createElement("h2", { className: "ContactBubble__title" }, title || openLabel),
137
139
  react_1.default.createElement("ul", { className: "ContactBubble__list" }, links.map((linkInfo, i) => {
138
140
  const { href, label, extraLabel, target, onClick } = linkInfo;
139
141
  const icon = (0, exports.ensureIcon)(linkInfo.icon);
@@ -159,7 +161,7 @@ const ContactBubble = (props) => {
159
161
  '\n\n',
160
162
  isBrowser && (react_1.default.createElement("button", { className: "ContactBubble__closebtn", "aria-controls": domid, "aria-label": txt.closeBtnLong, onClick: () => closeBubble(), type: "button" }, txt.closeBtn))));
161
163
  return isBrowser ? (react_1.default.createElement("div", { className: "ContactBubble__wrapper", ref: wrapperRef },
162
- react_1.default.createElement("button", { className: "ContactBubble__openbtn", "aria-controls": domid, "aria-expanded": open, "aria-label": txt.openBtnLong, onClick: open ? () => closeBubble() : openBubble, type: "button" }, txt.openBtn),
164
+ react_1.default.createElement("button", { className: "ContactBubble__openbtn", "aria-controls": domid, "aria-expanded": open, "aria-label": openLabelLong, onClick: open ? () => closeBubble() : openBubble, type: "button" }, openLabel),
163
165
  '\n\n',
164
166
  menu)) : (menu);
165
167
  };
package/FileInput.d.ts CHANGED
@@ -14,7 +14,7 @@ export type FileInputProps = FormFieldWrappingProps & {
14
14
  * Default: no restrictions.
15
15
  */
16
16
  accept?: string | Array<string>;
17
- dropzoneText: string | JSX.Element;
17
+ dropzoneText?: string | JSX.Element;
18
18
  removeFileText?: string;
19
19
  lang?: HannaLang;
20
20
  showFileSize?: boolean;
package/FileInput.js CHANGED
@@ -15,6 +15,20 @@ const defaultRemoveFileText = {
15
15
  en: 'Remove',
16
16
  pl: 'Usuń',
17
17
  };
18
+ const defaultDropzoneText = {
19
+ is: () => (react_1.default.createElement(react_1.default.Fragment, null,
20
+ "Drag\u00F0u skr\u00E1 hinga\u00F0, e\u00F0a ",
21
+ react_1.default.createElement("strong", null, "smelltu"),
22
+ " til a\u00F0 velja.")),
23
+ en: () => (react_1.default.createElement(react_1.default.Fragment, null,
24
+ "Drag files here, or ",
25
+ react_1.default.createElement("strong", null, "click"),
26
+ " to select.")),
27
+ pl: () => (react_1.default.createElement(react_1.default.Fragment, null,
28
+ "Przeci\u0105gnij plik tutaj, lub ",
29
+ react_1.default.createElement("strong", null, "kliknij"),
30
+ " by wybra\u0107.")),
31
+ };
18
32
  const defaultOnFilesRejected = (rejectedFiles) => {
19
33
  window.alert(`Error:\n${rejectedFiles
20
34
  .map((elm) => {
@@ -31,11 +45,11 @@ const arrayToFileList = (arr) => {
31
45
  };
32
46
  const FileInput = (props) => {
33
47
  var _a, _b, _c;
34
- const lang = props.lang || i18n_1.DEFAULT_LANG;
48
+ const lang = (0, i18n_1.ensureHannaLang)(props.lang) || i18n_1.DEFAULT_LANG;
35
49
  const _d = (0, FormField_js_1.groupFormFieldWrapperProps)(props), { dropzoneProps, // eslint-disable-line deprecation/deprecation
36
50
  multiple = (_b = (_a = props.dropzoneProps) === null || _a === void 0 ? void 0 : _a.multiple) !== null && _b !== void 0 ? _b : true, // eslint-disable-line deprecation/deprecation
37
51
  accept = (_c = props.dropzoneProps) === null || _c === void 0 ? void 0 : _c.accept, // eslint-disable-line deprecation/deprecation
38
- 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"]);
52
+ dropzoneText = defaultDropzoneText[lang](), removeFileText = defaultRemoveFileText[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"]);
39
53
  const domid = (0, useDomid_js_1.useDomid)(props.id);
40
54
  const fileInputWrapper = (0, react_1.useRef)(null);
41
55
  const fileInput = (0, react_1.useRef)(null);
@@ -46,6 +46,8 @@ export type ContactBubbleProps = {
46
46
  * magic and always show the bubble toggler
47
47
  */
48
48
  alwaysShow?: boolean;
49
+ /** Shorthand override for texts.openBtn, for quick customization */
50
+ openBtnLabel?: string;
49
51
  texts?: ContactBubbleI18n;
50
52
  lang?: HannaLang;
51
53
  } & SSRSupportProps & WrapperElmProps & ({
@@ -37,6 +37,8 @@ export const ensureIcon = (maybeIcon) => maybeIcon && icons[maybeIcon]
37
37
  export const ContactBubble = (props) => {
38
38
  const { title, links, onToggle, alwaysShow, wrapperProps = {} } = props;
39
39
  const txt = getTexts(props, defaultTexts);
40
+ const openLabel = props.openBtnLabel || txt.openBtn;
41
+ const openLabelLong = !props.openBtnLabel ? txt.openBtnLong : undefined;
40
42
  const useLocalState = props.open == null;
41
43
  const [localOpen, setLocalOpen] = useState(false);
42
44
  const open = useLocalState ? localOpen : props.open;
@@ -127,8 +129,8 @@ export const ContactBubble = (props) => {
127
129
  if (links.length === 0) {
128
130
  return null;
129
131
  }
130
- const menu = (React.createElement("div", Object.assign({}, props.wrapperProps, { className: modifiedClass('ContactBubble', null, wrapperProps.className), id: isBrowser && domid, hidden: isBrowser && !open, "data-always-show": alwaysShow || undefined, "data-sprinkled": isBrowser }),
131
- React.createElement("h2", { className: "ContactBubble__title" }, title || txt.openBtn),
132
+ const menu = (React.createElement("div", Object.assign({}, props.wrapperProps, { className: modifiedClass('ContactBubble', null, wrapperProps.className), id: isBrowser && domid, hidden: isBrowser && !open, "data-label-openbtn": props.openBtnLabel, "data-always-show": alwaysShow || undefined, "data-sprinkled": isBrowser }),
133
+ React.createElement("h2", { className: "ContactBubble__title" }, title || openLabel),
132
134
  React.createElement("ul", { className: "ContactBubble__list" }, links.map((linkInfo, i) => {
133
135
  const { href, label, extraLabel, target, onClick } = linkInfo;
134
136
  const icon = ensureIcon(linkInfo.icon);
@@ -154,7 +156,7 @@ export const ContactBubble = (props) => {
154
156
  '\n\n',
155
157
  isBrowser && (React.createElement("button", { className: "ContactBubble__closebtn", "aria-controls": domid, "aria-label": txt.closeBtnLong, onClick: () => closeBubble(), type: "button" }, txt.closeBtn))));
156
158
  return isBrowser ? (React.createElement("div", { className: "ContactBubble__wrapper", ref: wrapperRef },
157
- React.createElement("button", { className: "ContactBubble__openbtn", "aria-controls": domid, "aria-expanded": open, "aria-label": txt.openBtnLong, onClick: open ? () => closeBubble() : openBubble, type: "button" }, txt.openBtn),
159
+ React.createElement("button", { className: "ContactBubble__openbtn", "aria-controls": domid, "aria-expanded": open, "aria-label": openLabelLong, onClick: open ? () => closeBubble() : openBubble, type: "button" }, openLabel),
158
160
  '\n\n',
159
161
  menu)) : (menu);
160
162
  };
@@ -14,7 +14,7 @@ export type FileInputProps = FormFieldWrappingProps & {
14
14
  * Default: no restrictions.
15
15
  */
16
16
  accept?: string | Array<string>;
17
- dropzoneText: string | JSX.Element;
17
+ dropzoneText?: string | JSX.Element;
18
18
  removeFileText?: string;
19
19
  lang?: HannaLang;
20
20
  showFileSize?: boolean;
package/esm/FileInput.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { __rest } from "tslib";
2
2
  import React, { useEffect, useRef, useState } from 'react';
3
3
  import { modifiedClass } from '@hugsmidjan/qj/classUtils';
4
- import { DEFAULT_LANG } from '@reykjavik/hanna-utils/i18n';
4
+ import { DEFAULT_LANG, ensureHannaLang } from '@reykjavik/hanna-utils/i18n';
5
5
  import { useDropzone } from './_mixed_export_resolution_/ReactDropzone.js';
6
6
  import { addPreview, formatBytes, getFileListUpdate, releasePreview, } from './FileInput/_FileInput.utils.js';
7
7
  import { DefaultFileList } from './FileInput/_FileInputFileList.js';
@@ -12,6 +12,20 @@ const defaultRemoveFileText = {
12
12
  en: 'Remove',
13
13
  pl: 'Usuń',
14
14
  };
15
+ const defaultDropzoneText = {
16
+ is: () => (React.createElement(React.Fragment, null,
17
+ "Drag\u00F0u skr\u00E1 hinga\u00F0, e\u00F0a ",
18
+ React.createElement("strong", null, "smelltu"),
19
+ " til a\u00F0 velja.")),
20
+ en: () => (React.createElement(React.Fragment, null,
21
+ "Drag files here, or ",
22
+ React.createElement("strong", null, "click"),
23
+ " to select.")),
24
+ pl: () => (React.createElement(React.Fragment, null,
25
+ "Przeci\u0105gnij plik tutaj, lub ",
26
+ React.createElement("strong", null, "kliknij"),
27
+ " by wybra\u0107.")),
28
+ };
15
29
  const defaultOnFilesRejected = (rejectedFiles) => {
16
30
  window.alert(`Error:\n${rejectedFiles
17
31
  .map((elm) => {
@@ -28,11 +42,11 @@ const arrayToFileList = (arr) => {
28
42
  };
29
43
  export const FileInput = (props) => {
30
44
  var _a, _b, _c;
31
- const lang = props.lang || DEFAULT_LANG;
45
+ const lang = ensureHannaLang(props.lang) || DEFAULT_LANG;
32
46
  const _d = groupFormFieldWrapperProps(props), { dropzoneProps, // eslint-disable-line deprecation/deprecation
33
47
  multiple = (_b = (_a = props.dropzoneProps) === null || _a === void 0 ? void 0 : _a.multiple) !== null && _b !== void 0 ? _b : true, // eslint-disable-line deprecation/deprecation
34
48
  accept = (_c = props.dropzoneProps) === null || _c === void 0 ? void 0 : _c.accept, // eslint-disable-line deprecation/deprecation
35
- dropzoneText, removeFileText = defaultRemoveFileText[lang] || defaultRemoveFileText[DEFAULT_LANG], FileList = DefaultFileList, onFilesUpdated = () => undefined, onFilesRejected, showFileSize, showImagePreviews, value = [], fieldWrapperProps } = _d, inputElementProps = __rest(_d, ["dropzoneProps", "multiple", "accept", "dropzoneText", "removeFileText", "FileList", "onFilesUpdated", "onFilesRejected", "showFileSize", "showImagePreviews", "value", "fieldWrapperProps"]);
49
+ dropzoneText = defaultDropzoneText[lang](), removeFileText = defaultRemoveFileText[lang], FileList = DefaultFileList, onFilesUpdated = () => undefined, onFilesRejected, showFileSize, showImagePreviews, value = [], fieldWrapperProps } = _d, inputElementProps = __rest(_d, ["dropzoneProps", "multiple", "accept", "dropzoneText", "removeFileText", "FileList", "onFilesUpdated", "onFilesRejected", "showFileSize", "showImagePreviews", "value", "fieldWrapperProps"]);
36
50
  const domid = useDomid(props.id);
37
51
  const fileInputWrapper = useRef(null);
38
52
  const fileInput = useRef(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reykjavik/hanna-react",
3
- "version": "0.10.123",
3
+ "version": "0.10.124",
4
4
  "author": "Reykjavík (http://www.reykjavik.is)",
5
5
  "contributors": [
6
6
  "Hugsmiðjan ehf (http://www.hugsmidjan.is)",
@@ -18,7 +18,7 @@
18
18
  "@hugsmidjan/qj": "^4.22.1",
19
19
  "@hugsmidjan/react": "^0.4.32",
20
20
  "@reykjavik/hanna-css": "^0.4.14",
21
- "@reykjavik/hanna-utils": "^0.2.14",
21
+ "@reykjavik/hanna-utils": "^0.2.15",
22
22
  "@types/react-autosuggest": "^10.1.0",
23
23
  "@types/react-datepicker": "^4.8.0",
24
24
  "@types/react-transition-group": "^4.4.0",