@reykjavik/hanna-react 0.10.120 → 0.10.121
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 +8 -0
- package/Datepicker.js +1 -1
- package/FormField.js +8 -1
- package/_abstract/_TogglerInput.d.ts +3 -2
- package/_abstract/_TogglerInput.js +7 -1
- package/esm/Datepicker.js +2 -2
- package/esm/FormField.js +8 -1
- package/esm/_abstract/_TogglerInput.d.ts +3 -2
- package/esm/_abstract/_TogglerInput.js +7 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,11 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
- ... <!-- Add new lines here. -->
|
|
6
6
|
|
|
7
|
+
## 0.10.121
|
|
8
|
+
|
|
9
|
+
_2024-03-14_
|
|
10
|
+
|
|
11
|
+
- fix: Translate `FormField` and `Checkbox` required label to 'en' and 'pl'
|
|
12
|
+
- fix: `DatePicker` only partially reflected the current `DEFAULT_LANG`
|
|
13
|
+
|
|
7
14
|
## 0.10.120
|
|
8
15
|
|
|
9
16
|
_2024-03-06_
|
|
10
17
|
|
|
11
18
|
- feat: Add props `inputValue`, `defaultInputValue` to `AutosuggestSearch`
|
|
19
|
+
- fix: `AutosuggestSearch` not calling `onInput` when input is emptied
|
|
12
20
|
|
|
13
21
|
## 0.10.119
|
|
14
22
|
|
package/Datepicker.js
CHANGED
|
@@ -153,7 +153,7 @@ const Datepicker = (props) => {
|
|
|
153
153
|
return elm;
|
|
154
154
|
}) }, addFocusProps()),
|
|
155
155
|
isoMode && (react_1.default.createElement("input", { type: "hidden", name: name, value: value === null || value === void 0 ? void 0 : value.toISOString().slice(0, 10) })),
|
|
156
|
-
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: normalizedDateFormats, onChange: (date) => {
|
|
156
|
+
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 || i18n_1.DEFAULT_LANG, dateFormat: normalizedDateFormats, onChange: (date) => {
|
|
157
157
|
date = date || undefined;
|
|
158
158
|
setValue(date);
|
|
159
159
|
onChange && onChange(date);
|
package/FormField.js
CHANGED
|
@@ -4,6 +4,7 @@ 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 i18n_1 = require("@reykjavik/hanna-utils/i18n");
|
|
7
8
|
const env_js_1 = require("./utils/env.js");
|
|
8
9
|
const useDomid_js_1 = require("./utils/useDomid.js");
|
|
9
10
|
const utils_js_1 = require("./utils.js");
|
|
@@ -14,6 +15,12 @@ const inputClassNames = {
|
|
|
14
15
|
control: 'FormField__control',
|
|
15
16
|
};
|
|
16
17
|
// ---------------------------------------------------------------------------
|
|
18
|
+
const defaultReqText = {
|
|
19
|
+
is: 'Þarf að fylla út',
|
|
20
|
+
en: 'Required',
|
|
21
|
+
pl: 'Wymagane',
|
|
22
|
+
};
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
17
24
|
// eslint-disable-next-line complexity
|
|
18
25
|
const FormField = (props) => {
|
|
19
26
|
const { extraClassName, className, small, group, LabelTag = group ? 'h4' : undefined, label, assistText, hideLabel, empty, filled, readOnly, disabled, invalid, errorMessage, required, reqText, // TODO: i18n
|
|
@@ -57,7 +64,7 @@ const FormField = (props) => {
|
|
|
57
64
|
const labelId = LabelTag ? `label:${domid}` : undefined;
|
|
58
65
|
const reqStar = required && reqText !== false && (react_1.default.createElement("abbr", { className: "FormField__label__reqstar",
|
|
59
66
|
// FIXME: add mo-better i18n thinking
|
|
60
|
-
title: `${reqText ||
|
|
67
|
+
title: `${reqText || defaultReqText[i18n_1.DEFAULT_LANG]}: ` }, "*"));
|
|
61
68
|
const inputProps = {
|
|
62
69
|
id: domid,
|
|
63
70
|
disabled: disabled,
|
|
@@ -4,12 +4,13 @@ export type TogglerInputProps = {
|
|
|
4
4
|
label: string | JSX.Element;
|
|
5
5
|
children?: never;
|
|
6
6
|
invalid?: boolean;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Hidden label prefix text to indicate that the field is required.
|
|
8
9
|
*
|
|
9
10
|
* If your field is required but should not say so in its label
|
|
10
11
|
* then set this prop to `false`
|
|
11
12
|
*
|
|
12
|
-
* Default: `"Þarf að
|
|
13
|
+
* Default: `"Þarf að haka í" / "Must be checked" / "Należy sprawdzić"`.
|
|
13
14
|
* */
|
|
14
15
|
reqText?: string | false;
|
|
15
16
|
hideLabel?: boolean;
|
|
@@ -4,7 +4,13 @@ exports.TogglerInput = 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 i18n_js_1 = require("@reykjavik/hanna-utils/i18n.js");
|
|
7
8
|
const useDomid_js_1 = require("../utils/useDomid.js");
|
|
9
|
+
const defaultReqText = {
|
|
10
|
+
is: 'Þarf að haka í',
|
|
11
|
+
en: 'Must be checked',
|
|
12
|
+
pl: 'Należy sprawdzić',
|
|
13
|
+
};
|
|
8
14
|
// eslint-disable-next-line complexity
|
|
9
15
|
const TogglerInput = (props) => {
|
|
10
16
|
const { bem, modifier, className, label, hideLabel, invalid, errorMessage, Wrapper = 'div', required, reqText, type, id, innerWrap, wrapperProps, inputProps } = props, restInputProps = tslib_1.__rest(props, ["bem", "modifier", "className", "label", "hideLabel", "invalid", "errorMessage", "Wrapper", "required", "reqText", "type", "id", "innerWrap", "wrapperProps", "inputProps"]);
|
|
@@ -12,7 +18,7 @@ const TogglerInput = (props) => {
|
|
|
12
18
|
const errorId = errorMessage && `error${domid}`;
|
|
13
19
|
const reqStar = required && reqText !== false && (react_1.default.createElement("abbr", { className: `${bem}__label__reqstar`,
|
|
14
20
|
// FIXME: add mo-better i18n thinking
|
|
15
|
-
title: `${reqText ||
|
|
21
|
+
title: `${reqText || defaultReqText[i18n_js_1.DEFAULT_LANG]}: ` }, "*"));
|
|
16
22
|
const readOnly = restInputProps.readOnly || (inputProps || {}).readOnly;
|
|
17
23
|
const labelContent = (react_1.default.createElement(react_1.default.Fragment, null,
|
|
18
24
|
' ',
|
package/esm/Datepicker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
|
-
import { getTexts } from '@reykjavik/hanna-utils/i18n';
|
|
2
|
+
import { DEFAULT_LANG, getTexts, } from '@reykjavik/hanna-utils/i18n';
|
|
3
3
|
// For more info on localization see: https://stackoverflow.com/questions/54399084/change-locale-in-react-datepicker/58306958#58306958
|
|
4
4
|
import is from 'date-fns/locale/is/index.js';
|
|
5
5
|
import pl from 'date-fns/locale/pl/index.js';
|
|
@@ -148,7 +148,7 @@ export const Datepicker = (props) => {
|
|
|
148
148
|
return elm;
|
|
149
149
|
}) }, addFocusProps()),
|
|
150
150
|
isoMode && (React.createElement("input", { type: "hidden", name: name, value: value === null || value === void 0 ? void 0 : value.toISOString().slice(0, 10) })),
|
|
151
|
-
React.createElement(ReactDatePicker, Object.assign({ id: domid, required: inputProps.required, disabled: inputProps.disabled, readOnly: inputProps.readOnly, selected: value, name: isoMode ? undefined : name, locale: lang, dateFormat: normalizedDateFormats, onChange: (date) => {
|
|
151
|
+
React.createElement(ReactDatePicker, Object.assign({ id: domid, required: inputProps.required, disabled: inputProps.disabled, readOnly: inputProps.readOnly, selected: value, name: isoMode ? undefined : name, locale: lang || DEFAULT_LANG, dateFormat: normalizedDateFormats, onChange: (date) => {
|
|
152
152
|
date = date || undefined;
|
|
153
153
|
setValue(date);
|
|
154
154
|
onChange && onChange(date);
|
package/esm/FormField.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React, { useCallback, useState } from 'react';
|
|
3
3
|
import { modifiedClass } from '@hugsmidjan/qj/classUtils';
|
|
4
|
+
import { DEFAULT_LANG } from '@reykjavik/hanna-utils/i18n';
|
|
4
5
|
import { isPreact } from './utils/env.js';
|
|
5
6
|
import { useDomid } from './utils/useDomid.js';
|
|
6
7
|
import { useIsBrowserSide } from './utils.js';
|
|
@@ -11,6 +12,12 @@ const inputClassNames = {
|
|
|
11
12
|
control: 'FormField__control',
|
|
12
13
|
};
|
|
13
14
|
// ---------------------------------------------------------------------------
|
|
15
|
+
const defaultReqText = {
|
|
16
|
+
is: 'Þarf að fylla út',
|
|
17
|
+
en: 'Required',
|
|
18
|
+
pl: 'Wymagane',
|
|
19
|
+
};
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
14
21
|
// eslint-disable-next-line complexity
|
|
15
22
|
export const FormField = (props) => {
|
|
16
23
|
const { extraClassName, className, small, group, LabelTag = group ? 'h4' : undefined, label, assistText, hideLabel, empty, filled, readOnly, disabled, invalid, errorMessage, required, reqText, // TODO: i18n
|
|
@@ -54,7 +61,7 @@ export const FormField = (props) => {
|
|
|
54
61
|
const labelId = LabelTag ? `label:${domid}` : undefined;
|
|
55
62
|
const reqStar = required && reqText !== false && (React.createElement("abbr", { className: "FormField__label__reqstar",
|
|
56
63
|
// FIXME: add mo-better i18n thinking
|
|
57
|
-
title: `${reqText ||
|
|
64
|
+
title: `${reqText || defaultReqText[DEFAULT_LANG]}: ` }, "*"));
|
|
58
65
|
const inputProps = {
|
|
59
66
|
id: domid,
|
|
60
67
|
disabled: disabled,
|
|
@@ -4,12 +4,13 @@ export type TogglerInputProps = {
|
|
|
4
4
|
label: string | JSX.Element;
|
|
5
5
|
children?: never;
|
|
6
6
|
invalid?: boolean;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Hidden label prefix text to indicate that the field is required.
|
|
8
9
|
*
|
|
9
10
|
* If your field is required but should not say so in its label
|
|
10
11
|
* then set this prop to `false`
|
|
11
12
|
*
|
|
12
|
-
* Default: `"Þarf að
|
|
13
|
+
* Default: `"Þarf að haka í" / "Must be checked" / "Należy sprawdzić"`.
|
|
13
14
|
* */
|
|
14
15
|
reqText?: string | false;
|
|
15
16
|
hideLabel?: boolean;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { modifiedClass } from '@hugsmidjan/qj/classUtils';
|
|
4
|
+
import { DEFAULT_LANG } from '@reykjavik/hanna-utils/i18n.js';
|
|
4
5
|
import { useDomid } from '../utils/useDomid.js';
|
|
6
|
+
const defaultReqText = {
|
|
7
|
+
is: 'Þarf að haka í',
|
|
8
|
+
en: 'Must be checked',
|
|
9
|
+
pl: 'Należy sprawdzić',
|
|
10
|
+
};
|
|
5
11
|
// eslint-disable-next-line complexity
|
|
6
12
|
export const TogglerInput = (props) => {
|
|
7
13
|
const { bem, modifier, className, label, hideLabel, invalid, errorMessage, Wrapper = 'div', required, reqText, type, id, innerWrap, wrapperProps, inputProps } = props, restInputProps = __rest(props, ["bem", "modifier", "className", "label", "hideLabel", "invalid", "errorMessage", "Wrapper", "required", "reqText", "type", "id", "innerWrap", "wrapperProps", "inputProps"]);
|
|
@@ -9,7 +15,7 @@ export const TogglerInput = (props) => {
|
|
|
9
15
|
const errorId = errorMessage && `error${domid}`;
|
|
10
16
|
const reqStar = required && reqText !== false && (React.createElement("abbr", { className: `${bem}__label__reqstar`,
|
|
11
17
|
// FIXME: add mo-better i18n thinking
|
|
12
|
-
title: `${reqText ||
|
|
18
|
+
title: `${reqText || defaultReqText[DEFAULT_LANG]}: ` }, "*"));
|
|
13
19
|
const readOnly = restInputProps.readOnly || (inputProps || {}).readOnly;
|
|
14
20
|
const labelContent = (React.createElement(React.Fragment, null,
|
|
15
21
|
' ',
|