@trackunit/custom-field-components 0.0.689 → 0.0.691
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/index.cjs.js +13 -4
- package/index.esm.js +13 -4
- package/package.json +1 -1
- package/src/translation.d.ts +2 -2
package/index.cjs.js
CHANGED
|
@@ -33,6 +33,7 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
|
33
33
|
|
|
34
34
|
var defaultTranslations = {
|
|
35
35
|
"customfield.unit.acre": "acre",
|
|
36
|
+
"customfield.unit.amperehour": "Ah",
|
|
36
37
|
"customfield.unit.bar": "bar",
|
|
37
38
|
"customfield.unit.centimetre": "cm",
|
|
38
39
|
"customfield.unit.cubic_foot": "ft³",
|
|
@@ -70,6 +71,7 @@ var defaultTranslations = {
|
|
|
70
71
|
"customfield.unit.square_metre": "m²",
|
|
71
72
|
"customfield.unit.ton": "ton",
|
|
72
73
|
"customfield.unit.ton_us": "ton (US)",
|
|
74
|
+
"customfield.unit.volt": "V",
|
|
73
75
|
"customfield.unit.watt": "W",
|
|
74
76
|
"customfield.unit.yard": "yd"
|
|
75
77
|
};
|
|
@@ -213,23 +215,30 @@ const DropdownCustomField = ({ defaultValue, dataTestId, onChange, onBlur, id, d
|
|
|
213
215
|
const htmlForId = id ? id : "dropdown-custom-field-" + uuid.v4();
|
|
214
216
|
const [selectedValue, setSelectedValue] = React__namespace.useState(defaultValue ? defaultValue.map(convertToValueFormat) : []);
|
|
215
217
|
const onChangeHandler = React__namespace.useCallback((selected) => {
|
|
218
|
+
var _a;
|
|
216
219
|
if (selected) {
|
|
217
220
|
const values = Array.isArray(selected) ? selected : [selected];
|
|
218
|
-
|
|
219
|
-
|
|
221
|
+
if (selectedValue.length === 1 && values.length === 1 && values[0].value === ((_a = selectedValue[0]) === null || _a === void 0 ? void 0 : _a.value)) {
|
|
222
|
+
setSelectedValue([]);
|
|
223
|
+
setValue && setValue(id, [], { shouldDirty: true, shouldValidate: true });
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
setSelectedValue(values);
|
|
227
|
+
setValue && setValue(id, values, { shouldDirty: true, shouldValidate: true });
|
|
228
|
+
}
|
|
220
229
|
}
|
|
221
230
|
else {
|
|
222
231
|
setSelectedValue([]);
|
|
223
232
|
setValue && setValue(id, []);
|
|
224
233
|
}
|
|
225
|
-
}, [
|
|
234
|
+
}, [id, selectedValue, setValue]);
|
|
226
235
|
const options = React__namespace.useMemo(() => {
|
|
227
236
|
return allValues ? allValues.map(convertToValueFormat) : [];
|
|
228
237
|
}, [allValues]);
|
|
229
238
|
React__namespace.useEffect(() => {
|
|
230
239
|
register && register(id, Object.assign(Object.assign({}, validationRules), { value: selectedValue }));
|
|
231
240
|
}, [register, validationRules, selectedValue, id]);
|
|
232
|
-
return (jsxRuntime.jsx(reactFormComponents.FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, helpAddon: helpAddon || null, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsxRuntime.jsx(reactFormComponents.Select, { "aria-labelledby": htmlForId + "-label", dataTestId: dataTestId, disabled: disabled, hasError: renderAsInvalid, inputId: htmlForId, isClearable: true, isMulti: multiSelect, onChange: onChangeHandler, options: options, value: selectedValue }) }));
|
|
241
|
+
return (jsxRuntime.jsx(reactFormComponents.FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, helpAddon: helpAddon || null, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsxRuntime.jsx(reactFormComponents.Select, { "aria-labelledby": htmlForId + "-label", dataTestId: dataTestId, disabled: disabled, hasError: renderAsInvalid, inputId: htmlForId, isClearable: true, isDisabled: disabled, isMulti: multiSelect, onChange: onChangeHandler, options: options, value: selectedValue }) }));
|
|
233
242
|
};
|
|
234
243
|
|
|
235
244
|
/**
|
package/index.esm.js
CHANGED
|
@@ -10,6 +10,7 @@ import { isValidPhoneNumber } from 'libphonenumber-js';
|
|
|
10
10
|
|
|
11
11
|
var defaultTranslations = {
|
|
12
12
|
"customfield.unit.acre": "acre",
|
|
13
|
+
"customfield.unit.amperehour": "Ah",
|
|
13
14
|
"customfield.unit.bar": "bar",
|
|
14
15
|
"customfield.unit.centimetre": "cm",
|
|
15
16
|
"customfield.unit.cubic_foot": "ft³",
|
|
@@ -47,6 +48,7 @@ var defaultTranslations = {
|
|
|
47
48
|
"customfield.unit.square_metre": "m²",
|
|
48
49
|
"customfield.unit.ton": "ton",
|
|
49
50
|
"customfield.unit.ton_us": "ton (US)",
|
|
51
|
+
"customfield.unit.volt": "V",
|
|
50
52
|
"customfield.unit.watt": "W",
|
|
51
53
|
"customfield.unit.yard": "yd"
|
|
52
54
|
};
|
|
@@ -190,23 +192,30 @@ const DropdownCustomField = ({ defaultValue, dataTestId, onChange, onBlur, id, d
|
|
|
190
192
|
const htmlForId = id ? id : "dropdown-custom-field-" + v4();
|
|
191
193
|
const [selectedValue, setSelectedValue] = React.useState(defaultValue ? defaultValue.map(convertToValueFormat) : []);
|
|
192
194
|
const onChangeHandler = React.useCallback((selected) => {
|
|
195
|
+
var _a;
|
|
193
196
|
if (selected) {
|
|
194
197
|
const values = Array.isArray(selected) ? selected : [selected];
|
|
195
|
-
|
|
196
|
-
|
|
198
|
+
if (selectedValue.length === 1 && values.length === 1 && values[0].value === ((_a = selectedValue[0]) === null || _a === void 0 ? void 0 : _a.value)) {
|
|
199
|
+
setSelectedValue([]);
|
|
200
|
+
setValue && setValue(id, [], { shouldDirty: true, shouldValidate: true });
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
setSelectedValue(values);
|
|
204
|
+
setValue && setValue(id, values, { shouldDirty: true, shouldValidate: true });
|
|
205
|
+
}
|
|
197
206
|
}
|
|
198
207
|
else {
|
|
199
208
|
setSelectedValue([]);
|
|
200
209
|
setValue && setValue(id, []);
|
|
201
210
|
}
|
|
202
|
-
}, [
|
|
211
|
+
}, [id, selectedValue, setValue]);
|
|
203
212
|
const options = React.useMemo(() => {
|
|
204
213
|
return allValues ? allValues.map(convertToValueFormat) : [];
|
|
205
214
|
}, [allValues]);
|
|
206
215
|
React.useEffect(() => {
|
|
207
216
|
register && register(id, Object.assign(Object.assign({}, validationRules), { value: selectedValue }));
|
|
208
217
|
}, [register, validationRules, selectedValue, id]);
|
|
209
|
-
return (jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, helpAddon: helpAddon || null, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsx(Select, { "aria-labelledby": htmlForId + "-label", dataTestId: dataTestId, disabled: disabled, hasError: renderAsInvalid, inputId: htmlForId, isClearable: true, isMulti: multiSelect, onChange: onChangeHandler, options: options, value: selectedValue }) }));
|
|
218
|
+
return (jsx(FormGroup, { dataTestId: dataTestId && `${dataTestId}-FormGroup`, helpAddon: helpAddon || null, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsx(Select, { "aria-labelledby": htmlForId + "-label", dataTestId: dataTestId, disabled: disabled, hasError: renderAsInvalid, inputId: htmlForId, isClearable: true, isDisabled: disabled, isMulti: multiSelect, onChange: onChangeHandler, options: options, value: selectedValue }) }));
|
|
210
219
|
};
|
|
211
220
|
|
|
212
221
|
/**
|
package/package.json
CHANGED
package/src/translation.d.ts
CHANGED
|
@@ -15,8 +15,8 @@ export declare const translations: TranslationResource<TranslationKeys>;
|
|
|
15
15
|
/**
|
|
16
16
|
* Local useTranslation for this specific library
|
|
17
17
|
*/
|
|
18
|
-
export declare const useTranslation: () => [TransForLibs<"customfield.unit.acre" | "customfield.unit.bar" | "customfield.unit.centimetre" | "customfield.unit.cubic_foot" | "customfield.unit.cubic_metre" | "customfield.unit.foot" | "customfield.unit.gallon_liquid" | "customfield.unit.gram" | "customfield.unit.hectare" | "customfield.unit.hour" | "customfield.unit.inch" | "customfield.unit.kilogram" | "customfield.unit.kilogram_per_hour" | "customfield.unit.kilogram_per_second" | "customfield.unit.kilometre" | "customfield.unit.kilometre_per_hour" | "customfield.unit.kilopascal" | "customfield.unit.kilowatt" | "customfield.unit.kilowatthour" | "customfield.unit.litre" | "customfield.unit.metre" | "customfield.unit.metre_per_second" | "customfield.unit.metre_per_second_squared" | "customfield.unit.mile" | "customfield.unit.mile_per_hour" | "customfield.unit.millimetre" | "customfield.unit.newton" | "customfield.unit.ounce" | "customfield.unit.pascal" | "customfield.unit.pound" | "customfield.unit.pound_per_hour" | "customfield.unit.pound_per_second" | "customfield.unit.pound_per_square_inch" | "customfield.unit.square_foot" | "customfield.unit.square_kilometre" | "customfield.unit.square_metre" | "customfield.unit.ton" | "customfield.unit.ton_us" | "customfield.unit.watt" | "customfield.unit.yard">, import("i18next").i18n, boolean] & {
|
|
19
|
-
t: TransForLibs<"customfield.unit.acre" | "customfield.unit.bar" | "customfield.unit.centimetre" | "customfield.unit.cubic_foot" | "customfield.unit.cubic_metre" | "customfield.unit.foot" | "customfield.unit.gallon_liquid" | "customfield.unit.gram" | "customfield.unit.hectare" | "customfield.unit.hour" | "customfield.unit.inch" | "customfield.unit.kilogram" | "customfield.unit.kilogram_per_hour" | "customfield.unit.kilogram_per_second" | "customfield.unit.kilometre" | "customfield.unit.kilometre_per_hour" | "customfield.unit.kilopascal" | "customfield.unit.kilowatt" | "customfield.unit.kilowatthour" | "customfield.unit.litre" | "customfield.unit.metre" | "customfield.unit.metre_per_second" | "customfield.unit.metre_per_second_squared" | "customfield.unit.mile" | "customfield.unit.mile_per_hour" | "customfield.unit.millimetre" | "customfield.unit.newton" | "customfield.unit.ounce" | "customfield.unit.pascal" | "customfield.unit.pound" | "customfield.unit.pound_per_hour" | "customfield.unit.pound_per_second" | "customfield.unit.pound_per_square_inch" | "customfield.unit.square_foot" | "customfield.unit.square_kilometre" | "customfield.unit.square_metre" | "customfield.unit.ton" | "customfield.unit.ton_us" | "customfield.unit.watt" | "customfield.unit.yard">;
|
|
18
|
+
export declare const useTranslation: () => [TransForLibs<"customfield.unit.acre" | "customfield.unit.amperehour" | "customfield.unit.bar" | "customfield.unit.centimetre" | "customfield.unit.cubic_foot" | "customfield.unit.cubic_metre" | "customfield.unit.foot" | "customfield.unit.gallon_liquid" | "customfield.unit.gram" | "customfield.unit.hectare" | "customfield.unit.hour" | "customfield.unit.inch" | "customfield.unit.kilogram" | "customfield.unit.kilogram_per_hour" | "customfield.unit.kilogram_per_second" | "customfield.unit.kilometre" | "customfield.unit.kilometre_per_hour" | "customfield.unit.kilopascal" | "customfield.unit.kilowatt" | "customfield.unit.kilowatthour" | "customfield.unit.litre" | "customfield.unit.metre" | "customfield.unit.metre_per_second" | "customfield.unit.metre_per_second_squared" | "customfield.unit.mile" | "customfield.unit.mile_per_hour" | "customfield.unit.millimetre" | "customfield.unit.newton" | "customfield.unit.ounce" | "customfield.unit.pascal" | "customfield.unit.pound" | "customfield.unit.pound_per_hour" | "customfield.unit.pound_per_second" | "customfield.unit.pound_per_square_inch" | "customfield.unit.square_foot" | "customfield.unit.square_kilometre" | "customfield.unit.square_metre" | "customfield.unit.ton" | "customfield.unit.ton_us" | "customfield.unit.volt" | "customfield.unit.watt" | "customfield.unit.yard">, import("i18next").i18n, boolean] & {
|
|
19
|
+
t: TransForLibs<"customfield.unit.acre" | "customfield.unit.amperehour" | "customfield.unit.bar" | "customfield.unit.centimetre" | "customfield.unit.cubic_foot" | "customfield.unit.cubic_metre" | "customfield.unit.foot" | "customfield.unit.gallon_liquid" | "customfield.unit.gram" | "customfield.unit.hectare" | "customfield.unit.hour" | "customfield.unit.inch" | "customfield.unit.kilogram" | "customfield.unit.kilogram_per_hour" | "customfield.unit.kilogram_per_second" | "customfield.unit.kilometre" | "customfield.unit.kilometre_per_hour" | "customfield.unit.kilopascal" | "customfield.unit.kilowatt" | "customfield.unit.kilowatthour" | "customfield.unit.litre" | "customfield.unit.metre" | "customfield.unit.metre_per_second" | "customfield.unit.metre_per_second_squared" | "customfield.unit.mile" | "customfield.unit.mile_per_hour" | "customfield.unit.millimetre" | "customfield.unit.newton" | "customfield.unit.ounce" | "customfield.unit.pascal" | "customfield.unit.pound" | "customfield.unit.pound_per_hour" | "customfield.unit.pound_per_second" | "customfield.unit.pound_per_square_inch" | "customfield.unit.square_foot" | "customfield.unit.square_kilometre" | "customfield.unit.square_metre" | "customfield.unit.ton" | "customfield.unit.ton_us" | "customfield.unit.volt" | "customfield.unit.watt" | "customfield.unit.yard">;
|
|
20
20
|
i18n: import("i18next").i18n;
|
|
21
21
|
ready: boolean;
|
|
22
22
|
};
|