@trackunit/custom-field-components 0.0.319 → 0.0.323
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 +5 -5
- package/index.js +5 -5
- package/package.json +6 -6
package/index.cjs
CHANGED
|
@@ -326,14 +326,14 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
|
|
|
326
326
|
const typedDefinition = field.definition;
|
|
327
327
|
const typedValue = field.value;
|
|
328
328
|
const rules = getEmailValidationRules(typedDefinition);
|
|
329
|
-
return (jsxRuntime.jsx(reactFormComponents.TextField, Object.assign({ id: key, label: title, placeholder: (_g = typedDefinition.title) !== null && _g !== void 0 ? _g : "", defaultValue: (_j = (_h = typedValue.stringValue) !== null && _h !== void 0 ? _h : typedDefinition.defaultStringValue) !== null && _j !== void 0 ? _j : "", actions: !typedDefinition.uiEditable &&
|
|
329
|
+
return (jsxRuntime.jsx(reactFormComponents.TextField, Object.assign({ id: key, label: title, placeholder: (_g = typedDefinition.title) !== null && _g !== void 0 ? _g : "", defaultValue: (_j = (_h = typedValue.stringValue) !== null && _h !== void 0 ? _h : typedDefinition.defaultStringValue) !== null && _j !== void 0 ? _j : "", dataTestId: `emailField`, actions: !typedDefinition.uiEditable &&
|
|
330
330
|
(typedValue.stringValue || typedDefinition.defaultStringValue) && (jsxRuntime.jsx(reactFormComponents.ActionButton, { value: (_k = typedValue.stringValue) !== null && _k !== void 0 ? _k : typedDefinition.defaultStringValue, type: "EMAIL" })), readOnly: !typedDefinition.uiEditable, helpText: description, errorMessage: errorMessage }, validation.register(key, rules))));
|
|
331
331
|
}
|
|
332
332
|
case irisAppRuntimeCoreApi.CustomFieldType.PHONE_NUMBER: {
|
|
333
333
|
const typedDefinition = field.definition;
|
|
334
334
|
const typedValue = field.value;
|
|
335
335
|
const rules = getPhoneNumberValidationRules(typedDefinition);
|
|
336
|
-
return (jsxRuntime.jsx(reactFormComponents.TextField, Object.assign({ label: title, id: key, placeholder: (_l = typedDefinition.title) !== null && _l !== void 0 ? _l : "", defaultValue: (_o = (_m = typedValue.stringValue) !== null && _m !== void 0 ? _m : typedDefinition.defaultStringValue) !== null && _o !== void 0 ? _o : "", actions: !typedDefinition.uiEditable &&
|
|
336
|
+
return (jsxRuntime.jsx(reactFormComponents.TextField, Object.assign({ label: title, id: key, placeholder: (_l = typedDefinition.title) !== null && _l !== void 0 ? _l : "", defaultValue: (_o = (_m = typedValue.stringValue) !== null && _m !== void 0 ? _m : typedDefinition.defaultStringValue) !== null && _o !== void 0 ? _o : "", dataTestId: `phoneNumberField`, actions: !typedDefinition.uiEditable &&
|
|
337
337
|
(typedValue.stringValue || typedDefinition.defaultStringValue) && (jsxRuntime.jsx(reactFormComponents.ActionButton, { value: (_p = typedValue.stringValue) !== null && _p !== void 0 ? _p : typedDefinition.defaultStringValue, type: "PHONE_NUMBER" })), readOnly: !typedDefinition.uiEditable, helpText: description, errorMessage: errorMessage === "" ? "Must be a phone number" : undefined }, validation.register(key, rules))));
|
|
338
338
|
}
|
|
339
339
|
case irisAppRuntimeCoreApi.CustomFieldType.STRING: {
|
|
@@ -351,10 +351,10 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
|
|
|
351
351
|
placeholder: (_t = typedDefinition.title) !== null && _t !== void 0 ? _t : "",
|
|
352
352
|
addonAfter: unit,
|
|
353
353
|
};
|
|
354
|
-
return (jsxRuntime.jsx(reactFormComponents.FormGroup, Object.assign({ htmlFor: isEditing ? key || "number-field" : `${key}-number-field`, label: title, isInvalid: errorMessage ? true : false, helpText: errorMessage || description, dataTestId: `numberField-FormGroup`, disabled: !typedDefinition.uiEditable }, { children: isEditing ? (jsxRuntime.jsx(reactFormComponents.NumberInput, Object.assign({ id: key || "number-field", dataTestId:
|
|
354
|
+
return (jsxRuntime.jsx(reactFormComponents.FormGroup, Object.assign({ htmlFor: isEditing ? key || "number-field" : `${key}-number-field`, label: title, isInvalid: errorMessage ? true : false, helpText: errorMessage || description, dataTestId: typedDefinition.key ? `${typedDefinition.key}-FormGroup` : `numberField-FormGroup`, disabled: !typedDefinition.uiEditable }, { children: isEditing ? (jsxRuntime.jsx(reactFormComponents.NumberInput, Object.assign({ id: key || "number-field", dataTestId: typedDefinition.key ? typedDefinition.key : `numberField`, defaultValue: (_v = (_u = typedValue.numberValue) !== null && _u !== void 0 ? _u : typedDefinition.defaultNumberValue) !== null && _v !== void 0 ? _v : "", readOnly: !typedDefinition.uiEditable, step: typedDefinition.isInteger ? 1 : "any", min: (_w = typedDefinition.minimumNumber) !== null && _w !== void 0 ? _w : undefined, max: (_x = typedDefinition.maximumNumber) !== null && _x !== void 0 ? _x : undefined }, validation.register(key, rules), { onBlur: () => setIsEditing(!isEditing), onChange: e => {
|
|
355
355
|
setNumberValue(e.target.value);
|
|
356
356
|
validation.register(key, rules).onChange(e);
|
|
357
|
-
} }, numberProps))) : (jsxRuntime.jsx(reactFormComponents.BaseInput, Object.assign({ type: "text", id: `${key}-number-field`, dataTestId:
|
|
357
|
+
} }, numberProps))) : (jsxRuntime.jsx(reactFormComponents.BaseInput, Object.assign({ type: "text", id: `${key}-number-field`, dataTestId: typedDefinition.key ? typedDefinition.key : `numberField`, defaultValue: parseFloat(Number(numberValue).toPrecision(4)), readOnly: true, actions: jsxRuntime.jsx(ActionContainer, { children: jsxRuntime.jsx(StyledIconButton, { dataTestId: `${typedDefinition.key}-editIconButtonId`, size: "small", color: "tertiary", icon: jsxRuntime.jsx(reactComponents.Icon, { size: "small", name: "PencilIcon" }), onClick: () => setIsEditing(!isEditing) }) }) }, numberProps))) })));
|
|
358
358
|
}
|
|
359
359
|
case irisAppRuntimeCoreApi.CustomFieldType.BOOLEAN: {
|
|
360
360
|
const typedDefinition = field.definition;
|
|
@@ -366,7 +366,7 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
|
|
|
366
366
|
const typedDefinition = field.definition;
|
|
367
367
|
const typedValue = field.value;
|
|
368
368
|
const rules = getDropdownValidationRules();
|
|
369
|
-
return (jsxRuntime.jsx(DropdownCustomField, { label: typedDefinition.title || "", id: key || "dropdown-field", defaultValue: (_2 = (_1 = typedValue.stringArrayValue) !== null && _1 !== void 0 ? _1 : typedDefinition.defaultStringArrayValue) !== null && _2 !== void 0 ? _2 : undefined, disabled: !typedDefinition.uiEditable, allValues: (_3 = typedDefinition.allValues) !== null && _3 !== void 0 ? _3 : undefined, multiSelect: (_4 = typedDefinition.multiSelect) !== null && _4 !== void 0 ? _4 : false, register: validation.register, validationRules: rules, helpText: description, setValue: validation.setValue, errorMessage: errorMessage, dataTestId:
|
|
369
|
+
return (jsxRuntime.jsx(DropdownCustomField, { label: typedDefinition.title || "", id: key || "dropdown-field", defaultValue: (_2 = (_1 = typedValue.stringArrayValue) !== null && _1 !== void 0 ? _1 : typedDefinition.defaultStringArrayValue) !== null && _2 !== void 0 ? _2 : undefined, disabled: !typedDefinition.uiEditable, allValues: (_3 = typedDefinition.allValues) !== null && _3 !== void 0 ? _3 : undefined, multiSelect: (_4 = typedDefinition.multiSelect) !== null && _4 !== void 0 ? _4 : false, register: validation.register, validationRules: rules, helpText: description, setValue: validation.setValue, errorMessage: errorMessage, dataTestId: `${typedDefinition.key}-dropdownField` }, key));
|
|
370
370
|
}
|
|
371
371
|
case irisAppRuntimeCoreApi.CustomFieldType.DATE: {
|
|
372
372
|
const typedDefinition = field.definition;
|
package/index.js
CHANGED
|
@@ -303,14 +303,14 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
|
|
|
303
303
|
const typedDefinition = field.definition;
|
|
304
304
|
const typedValue = field.value;
|
|
305
305
|
const rules = getEmailValidationRules(typedDefinition);
|
|
306
|
-
return (jsx(TextField, Object.assign({ id: key, label: title, placeholder: (_g = typedDefinition.title) !== null && _g !== void 0 ? _g : "", defaultValue: (_j = (_h = typedValue.stringValue) !== null && _h !== void 0 ? _h : typedDefinition.defaultStringValue) !== null && _j !== void 0 ? _j : "", actions: !typedDefinition.uiEditable &&
|
|
306
|
+
return (jsx(TextField, Object.assign({ id: key, label: title, placeholder: (_g = typedDefinition.title) !== null && _g !== void 0 ? _g : "", defaultValue: (_j = (_h = typedValue.stringValue) !== null && _h !== void 0 ? _h : typedDefinition.defaultStringValue) !== null && _j !== void 0 ? _j : "", dataTestId: `emailField`, actions: !typedDefinition.uiEditable &&
|
|
307
307
|
(typedValue.stringValue || typedDefinition.defaultStringValue) && (jsx(ActionButton, { value: (_k = typedValue.stringValue) !== null && _k !== void 0 ? _k : typedDefinition.defaultStringValue, type: "EMAIL" })), readOnly: !typedDefinition.uiEditable, helpText: description, errorMessage: errorMessage }, validation.register(key, rules))));
|
|
308
308
|
}
|
|
309
309
|
case CustomFieldType.PHONE_NUMBER: {
|
|
310
310
|
const typedDefinition = field.definition;
|
|
311
311
|
const typedValue = field.value;
|
|
312
312
|
const rules = getPhoneNumberValidationRules(typedDefinition);
|
|
313
|
-
return (jsx(TextField, Object.assign({ label: title, id: key, placeholder: (_l = typedDefinition.title) !== null && _l !== void 0 ? _l : "", defaultValue: (_o = (_m = typedValue.stringValue) !== null && _m !== void 0 ? _m : typedDefinition.defaultStringValue) !== null && _o !== void 0 ? _o : "", actions: !typedDefinition.uiEditable &&
|
|
313
|
+
return (jsx(TextField, Object.assign({ label: title, id: key, placeholder: (_l = typedDefinition.title) !== null && _l !== void 0 ? _l : "", defaultValue: (_o = (_m = typedValue.stringValue) !== null && _m !== void 0 ? _m : typedDefinition.defaultStringValue) !== null && _o !== void 0 ? _o : "", dataTestId: `phoneNumberField`, actions: !typedDefinition.uiEditable &&
|
|
314
314
|
(typedValue.stringValue || typedDefinition.defaultStringValue) && (jsx(ActionButton, { value: (_p = typedValue.stringValue) !== null && _p !== void 0 ? _p : typedDefinition.defaultStringValue, type: "PHONE_NUMBER" })), readOnly: !typedDefinition.uiEditable, helpText: description, errorMessage: errorMessage === "" ? "Must be a phone number" : undefined }, validation.register(key, rules))));
|
|
315
315
|
}
|
|
316
316
|
case CustomFieldType.STRING: {
|
|
@@ -328,10 +328,10 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
|
|
|
328
328
|
placeholder: (_t = typedDefinition.title) !== null && _t !== void 0 ? _t : "",
|
|
329
329
|
addonAfter: unit,
|
|
330
330
|
};
|
|
331
|
-
return (jsx(FormGroup, Object.assign({ htmlFor: isEditing ? key || "number-field" : `${key}-number-field`, label: title, isInvalid: errorMessage ? true : false, helpText: errorMessage || description, dataTestId: `numberField-FormGroup`, disabled: !typedDefinition.uiEditable }, { children: isEditing ? (jsx(NumberInput, Object.assign({ id: key || "number-field", dataTestId:
|
|
331
|
+
return (jsx(FormGroup, Object.assign({ htmlFor: isEditing ? key || "number-field" : `${key}-number-field`, label: title, isInvalid: errorMessage ? true : false, helpText: errorMessage || description, dataTestId: typedDefinition.key ? `${typedDefinition.key}-FormGroup` : `numberField-FormGroup`, disabled: !typedDefinition.uiEditable }, { children: isEditing ? (jsx(NumberInput, Object.assign({ id: key || "number-field", dataTestId: typedDefinition.key ? typedDefinition.key : `numberField`, defaultValue: (_v = (_u = typedValue.numberValue) !== null && _u !== void 0 ? _u : typedDefinition.defaultNumberValue) !== null && _v !== void 0 ? _v : "", readOnly: !typedDefinition.uiEditable, step: typedDefinition.isInteger ? 1 : "any", min: (_w = typedDefinition.minimumNumber) !== null && _w !== void 0 ? _w : undefined, max: (_x = typedDefinition.maximumNumber) !== null && _x !== void 0 ? _x : undefined }, validation.register(key, rules), { onBlur: () => setIsEditing(!isEditing), onChange: e => {
|
|
332
332
|
setNumberValue(e.target.value);
|
|
333
333
|
validation.register(key, rules).onChange(e);
|
|
334
|
-
} }, numberProps))) : (jsx(BaseInput, Object.assign({ type: "text", id: `${key}-number-field`, dataTestId:
|
|
334
|
+
} }, numberProps))) : (jsx(BaseInput, Object.assign({ type: "text", id: `${key}-number-field`, dataTestId: typedDefinition.key ? typedDefinition.key : `numberField`, defaultValue: parseFloat(Number(numberValue).toPrecision(4)), readOnly: true, actions: jsx(ActionContainer, { children: jsx(StyledIconButton, { dataTestId: `${typedDefinition.key}-editIconButtonId`, size: "small", color: "tertiary", icon: jsx(Icon, { size: "small", name: "PencilIcon" }), onClick: () => setIsEditing(!isEditing) }) }) }, numberProps))) })));
|
|
335
335
|
}
|
|
336
336
|
case CustomFieldType.BOOLEAN: {
|
|
337
337
|
const typedDefinition = field.definition;
|
|
@@ -343,7 +343,7 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
|
|
|
343
343
|
const typedDefinition = field.definition;
|
|
344
344
|
const typedValue = field.value;
|
|
345
345
|
const rules = getDropdownValidationRules();
|
|
346
|
-
return (jsx(DropdownCustomField, { label: typedDefinition.title || "", id: key || "dropdown-field", defaultValue: (_2 = (_1 = typedValue.stringArrayValue) !== null && _1 !== void 0 ? _1 : typedDefinition.defaultStringArrayValue) !== null && _2 !== void 0 ? _2 : undefined, disabled: !typedDefinition.uiEditable, allValues: (_3 = typedDefinition.allValues) !== null && _3 !== void 0 ? _3 : undefined, multiSelect: (_4 = typedDefinition.multiSelect) !== null && _4 !== void 0 ? _4 : false, register: validation.register, validationRules: rules, helpText: description, setValue: validation.setValue, errorMessage: errorMessage, dataTestId:
|
|
346
|
+
return (jsx(DropdownCustomField, { label: typedDefinition.title || "", id: key || "dropdown-field", defaultValue: (_2 = (_1 = typedValue.stringArrayValue) !== null && _1 !== void 0 ? _1 : typedDefinition.defaultStringArrayValue) !== null && _2 !== void 0 ? _2 : undefined, disabled: !typedDefinition.uiEditable, allValues: (_3 = typedDefinition.allValues) !== null && _3 !== void 0 ? _3 : undefined, multiSelect: (_4 = typedDefinition.multiSelect) !== null && _4 !== void 0 ? _4 : false, register: validation.register, validationRules: rules, helpText: description, setValue: validation.setValue, errorMessage: errorMessage, dataTestId: `${typedDefinition.key}-dropdownField` }, key));
|
|
347
347
|
}
|
|
348
348
|
case CustomFieldType.DATE: {
|
|
349
349
|
const typedDefinition = field.definition;
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/custom-field-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.323",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@trackunit/iris-app-runtime-core": "0.3.
|
|
8
|
-
"@trackunit/iris-app-runtime-core-api": "0.3.
|
|
9
|
-
"@trackunit/react-components": "0.1.
|
|
10
|
-
"@trackunit/react-core-contexts-test": "0.1.
|
|
11
|
-
"@trackunit/react-form-components": "0.0.
|
|
7
|
+
"@trackunit/iris-app-runtime-core": "0.3.33",
|
|
8
|
+
"@trackunit/iris-app-runtime-core-api": "0.3.28",
|
|
9
|
+
"@trackunit/react-components": "0.1.84",
|
|
10
|
+
"@trackunit/react-core-contexts-test": "0.1.51",
|
|
11
|
+
"@trackunit/react-form-components": "0.0.20",
|
|
12
12
|
"@trackunit/tailwind-styled-components": "0.0.56",
|
|
13
13
|
"libphonenumber-js": "1.10.26",
|
|
14
14
|
"react": "18.2.0",
|