@trackunit/custom-field-components 0.0.360 → 0.0.362
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 +9 -19
- package/index.js +9 -19
- package/package.json +3 -3
- package/src/utils.d.ts +0 -7
package/index.cjs
CHANGED
|
@@ -285,16 +285,6 @@ const getPhoneNumberValidationRules = (definition) => {
|
|
|
285
285
|
? Object.assign(Object.assign({}, pattern), defaultRules) : defaultRules;
|
|
286
286
|
};
|
|
287
287
|
|
|
288
|
-
/**
|
|
289
|
-
* Converts a string with uppercase characters and spaces to lowercase with dashes.
|
|
290
|
-
*
|
|
291
|
-
* @param {string} str - The input string.
|
|
292
|
-
* @returns {string} - The string converted.
|
|
293
|
-
*/
|
|
294
|
-
const dashLowerCase = (str) => {
|
|
295
|
-
return str.replace(/[\sA-Z]/g, match => (match === " " ? "-" : match.toLowerCase()));
|
|
296
|
-
};
|
|
297
|
-
|
|
298
288
|
/**
|
|
299
289
|
* A component that renders a custom field based on the field definition
|
|
300
290
|
*
|
|
@@ -329,28 +319,28 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
|
|
|
329
319
|
const typedDefinition = field.definition;
|
|
330
320
|
const typedValue = field.value;
|
|
331
321
|
const rules = getWebAddressValidationRules(typedDefinition);
|
|
332
|
-
return (jsxRuntime.jsx(reactFormComponents.TextField, Object.assign({ id: key, label: title, placeholder: (_c = typedDefinition.title) !== null && _c !== void 0 ? _c : "", defaultValue: (_e = (_d = typedValue.stringValue) !== null && _d !== void 0 ? _d : typedDefinition.defaultStringValue) !== null && _e !== void 0 ? _e : "", dataTestId: `${typedDefinition.
|
|
322
|
+
return (jsxRuntime.jsx(reactFormComponents.TextField, Object.assign({ id: key, label: title, placeholder: (_c = typedDefinition.title) !== null && _c !== void 0 ? _c : "", defaultValue: (_e = (_d = typedValue.stringValue) !== null && _d !== void 0 ? _d : typedDefinition.defaultStringValue) !== null && _e !== void 0 ? _e : "", dataTestId: `${typedDefinition.key}`, actions: !typedDefinition.uiEditable &&
|
|
333
323
|
(typedValue.stringValue || typedDefinition.defaultStringValue) && (jsxRuntime.jsx(reactFormComponents.ActionButton, { value: (_f = typedValue.stringValue) !== null && _f !== void 0 ? _f : typedDefinition.defaultStringValue, type: "WEB_ADDRESS" })), readOnly: !typedDefinition.uiEditable, helpText: description, errorMessage: errorMessage }, validation.register(key, rules))));
|
|
334
324
|
}
|
|
335
325
|
case irisAppRuntimeCoreApi.CustomFieldType.EMAIL: {
|
|
336
326
|
const typedDefinition = field.definition;
|
|
337
327
|
const typedValue = field.value;
|
|
338
328
|
const rules = getEmailValidationRules(typedDefinition);
|
|
339
|
-
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: `${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 : "", dataTestId: `${typedDefinition.key}`, actions: !typedDefinition.uiEditable &&
|
|
340
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))));
|
|
341
331
|
}
|
|
342
332
|
case irisAppRuntimeCoreApi.CustomFieldType.PHONE_NUMBER: {
|
|
343
333
|
const typedDefinition = field.definition;
|
|
344
334
|
const typedValue = field.value;
|
|
345
335
|
const rules = getPhoneNumberValidationRules(typedDefinition);
|
|
346
|
-
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: `${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 : "", dataTestId: `${typedDefinition.key}`, actions: !typedDefinition.uiEditable &&
|
|
347
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))));
|
|
348
338
|
}
|
|
349
339
|
case irisAppRuntimeCoreApi.CustomFieldType.STRING: {
|
|
350
340
|
const typedDefinition = field.definition;
|
|
351
341
|
const typedValue = field.value;
|
|
352
342
|
const rules = getStringValidationRules(typedDefinition);
|
|
353
|
-
return (jsxRuntime.jsx(reactFormComponents.TextField, Object.assign({ label: title, id: key || "string-field", placeholder: (_q = typedDefinition.title) !== null && _q !== void 0 ? _q : "", defaultValue: (_s = (_r = typedValue.stringValue) !== null && _r !== void 0 ? _r : typedDefinition.defaultStringValue) !== null && _s !== void 0 ? _s : "", readOnly: !typedDefinition.uiEditable, helpText: description, errorMessage: errorMessage, dataTestId: `${typedDefinition.
|
|
343
|
+
return (jsxRuntime.jsx(reactFormComponents.TextField, Object.assign({ label: title, id: key || "string-field", placeholder: (_q = typedDefinition.title) !== null && _q !== void 0 ? _q : "", defaultValue: (_s = (_r = typedValue.stringValue) !== null && _r !== void 0 ? _r : typedDefinition.defaultStringValue) !== null && _s !== void 0 ? _s : "", readOnly: !typedDefinition.uiEditable, helpText: description, errorMessage: errorMessage, dataTestId: `${typedDefinition.key}` }, validation.register(key, rules))));
|
|
354
344
|
}
|
|
355
345
|
case irisAppRuntimeCoreApi.CustomFieldType.NUMBER: {
|
|
356
346
|
const typedDefinition = field.definition;
|
|
@@ -361,22 +351,22 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
|
|
|
361
351
|
placeholder: (_t = typedDefinition.title) !== null && _t !== void 0 ? _t : "",
|
|
362
352
|
addonAfter: unit,
|
|
363
353
|
};
|
|
364
|
-
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:
|
|
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}-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 => {
|
|
365
355
|
setNumberValue(e.target.value);
|
|
366
356
|
validation.register(key, rules).onChange(e);
|
|
367
|
-
} }, numberProps))) : (jsxRuntime.jsx(reactFormComponents.BaseInput, Object.assign({ type: "text", id: `${key}-number-field`, dataTestId: typedDefinition.
|
|
357
|
+
} }, numberProps))) : (jsxRuntime.jsx(reactFormComponents.BaseInput, Object.assign({ type: "text", id: `${key}-number-field`, dataTestId: `${typedDefinition.key}`, 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))) })));
|
|
368
358
|
}
|
|
369
359
|
case irisAppRuntimeCoreApi.CustomFieldType.BOOLEAN: {
|
|
370
360
|
const typedDefinition = field.definition;
|
|
371
361
|
const typedValue = field.value;
|
|
372
362
|
const rules = getBooleanValidationRules();
|
|
373
|
-
return (jsxRuntime.jsx(BooleanCustomField, { label: (_y = typedDefinition.title) !== null && _y !== void 0 ? _y : "", id: key || "boolean-field", defaultValue: (_0 = (_z = typedValue.booleanValue) !== null && _z !== void 0 ? _z : typedDefinition.defaultBooleanValue) !== null && _0 !== void 0 ? _0 : undefined, readOnly: !typedDefinition.uiEditable, register: validation.register, validationRules: rules, helpText: description, setValue: validation.setValue, errorMessage: errorMessage, dataTestId: `${typedDefinition.
|
|
363
|
+
return (jsxRuntime.jsx(BooleanCustomField, { label: (_y = typedDefinition.title) !== null && _y !== void 0 ? _y : "", id: key || "boolean-field", defaultValue: (_0 = (_z = typedValue.booleanValue) !== null && _z !== void 0 ? _z : typedDefinition.defaultBooleanValue) !== null && _0 !== void 0 ? _0 : undefined, readOnly: !typedDefinition.uiEditable, register: validation.register, validationRules: rules, helpText: description, setValue: validation.setValue, errorMessage: errorMessage, dataTestId: `${typedDefinition.key}` }, key));
|
|
374
364
|
}
|
|
375
365
|
case irisAppRuntimeCoreApi.CustomFieldType.DROPDOWN: {
|
|
376
366
|
const typedDefinition = field.definition;
|
|
377
367
|
const typedValue = field.value;
|
|
378
368
|
const rules = getDropdownValidationRules();
|
|
379
|
-
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.
|
|
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}` }, key));
|
|
380
370
|
}
|
|
381
371
|
case irisAppRuntimeCoreApi.CustomFieldType.DATE: {
|
|
382
372
|
const typedDefinition = field.definition;
|
|
@@ -389,7 +379,7 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
|
|
|
389
379
|
else if (typedDefinition.defaultDateValue !== undefined && typedDefinition.defaultDateValue !== null) {
|
|
390
380
|
defaultValue = new Date(typedDefinition.defaultDateValue);
|
|
391
381
|
}
|
|
392
|
-
return (jsxRuntime.jsx(DateCustomField, { dataTestId: `${typedDefinition.
|
|
382
|
+
return (jsxRuntime.jsx(DateCustomField, { dataTestId: `${typedDefinition.key}`, id: key || "date-field", defaultValue: defaultValue, readOnly: !typedDefinition.uiEditable, register: validation.register, label: typedDefinition.title || "", validationRules: rules, helpText: description, errorMessage: errorMessage, setValue: validation.setValue, title: field.definition.title || "" }, key));
|
|
393
383
|
}
|
|
394
384
|
default:
|
|
395
385
|
throw new Error(`Type not supported: ${type}`);
|
package/index.js
CHANGED
|
@@ -262,16 +262,6 @@ const getPhoneNumberValidationRules = (definition) => {
|
|
|
262
262
|
? Object.assign(Object.assign({}, pattern), defaultRules) : defaultRules;
|
|
263
263
|
};
|
|
264
264
|
|
|
265
|
-
/**
|
|
266
|
-
* Converts a string with uppercase characters and spaces to lowercase with dashes.
|
|
267
|
-
*
|
|
268
|
-
* @param {string} str - The input string.
|
|
269
|
-
* @returns {string} - The string converted.
|
|
270
|
-
*/
|
|
271
|
-
const dashLowerCase = (str) => {
|
|
272
|
-
return str.replace(/[\sA-Z]/g, match => (match === " " ? "-" : match.toLowerCase()));
|
|
273
|
-
};
|
|
274
|
-
|
|
275
265
|
/**
|
|
276
266
|
* A component that renders a custom field based on the field definition
|
|
277
267
|
*
|
|
@@ -306,28 +296,28 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
|
|
|
306
296
|
const typedDefinition = field.definition;
|
|
307
297
|
const typedValue = field.value;
|
|
308
298
|
const rules = getWebAddressValidationRules(typedDefinition);
|
|
309
|
-
return (jsx(TextField, Object.assign({ id: key, label: title, placeholder: (_c = typedDefinition.title) !== null && _c !== void 0 ? _c : "", defaultValue: (_e = (_d = typedValue.stringValue) !== null && _d !== void 0 ? _d : typedDefinition.defaultStringValue) !== null && _e !== void 0 ? _e : "", dataTestId: `${typedDefinition.
|
|
299
|
+
return (jsx(TextField, Object.assign({ id: key, label: title, placeholder: (_c = typedDefinition.title) !== null && _c !== void 0 ? _c : "", defaultValue: (_e = (_d = typedValue.stringValue) !== null && _d !== void 0 ? _d : typedDefinition.defaultStringValue) !== null && _e !== void 0 ? _e : "", dataTestId: `${typedDefinition.key}`, actions: !typedDefinition.uiEditable &&
|
|
310
300
|
(typedValue.stringValue || typedDefinition.defaultStringValue) && (jsx(ActionButton, { value: (_f = typedValue.stringValue) !== null && _f !== void 0 ? _f : typedDefinition.defaultStringValue, type: "WEB_ADDRESS" })), readOnly: !typedDefinition.uiEditable, helpText: description, errorMessage: errorMessage }, validation.register(key, rules))));
|
|
311
301
|
}
|
|
312
302
|
case CustomFieldType.EMAIL: {
|
|
313
303
|
const typedDefinition = field.definition;
|
|
314
304
|
const typedValue = field.value;
|
|
315
305
|
const rules = getEmailValidationRules(typedDefinition);
|
|
316
|
-
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: `${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 : "", dataTestId: `${typedDefinition.key}`, actions: !typedDefinition.uiEditable &&
|
|
317
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))));
|
|
318
308
|
}
|
|
319
309
|
case CustomFieldType.PHONE_NUMBER: {
|
|
320
310
|
const typedDefinition = field.definition;
|
|
321
311
|
const typedValue = field.value;
|
|
322
312
|
const rules = getPhoneNumberValidationRules(typedDefinition);
|
|
323
|
-
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: `${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 : "", dataTestId: `${typedDefinition.key}`, actions: !typedDefinition.uiEditable &&
|
|
324
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))));
|
|
325
315
|
}
|
|
326
316
|
case CustomFieldType.STRING: {
|
|
327
317
|
const typedDefinition = field.definition;
|
|
328
318
|
const typedValue = field.value;
|
|
329
319
|
const rules = getStringValidationRules(typedDefinition);
|
|
330
|
-
return (jsx(TextField, Object.assign({ label: title, id: key || "string-field", placeholder: (_q = typedDefinition.title) !== null && _q !== void 0 ? _q : "", defaultValue: (_s = (_r = typedValue.stringValue) !== null && _r !== void 0 ? _r : typedDefinition.defaultStringValue) !== null && _s !== void 0 ? _s : "", readOnly: !typedDefinition.uiEditable, helpText: description, errorMessage: errorMessage, dataTestId: `${typedDefinition.
|
|
320
|
+
return (jsx(TextField, Object.assign({ label: title, id: key || "string-field", placeholder: (_q = typedDefinition.title) !== null && _q !== void 0 ? _q : "", defaultValue: (_s = (_r = typedValue.stringValue) !== null && _r !== void 0 ? _r : typedDefinition.defaultStringValue) !== null && _s !== void 0 ? _s : "", readOnly: !typedDefinition.uiEditable, helpText: description, errorMessage: errorMessage, dataTestId: `${typedDefinition.key}` }, validation.register(key, rules))));
|
|
331
321
|
}
|
|
332
322
|
case CustomFieldType.NUMBER: {
|
|
333
323
|
const typedDefinition = field.definition;
|
|
@@ -338,22 +328,22 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
|
|
|
338
328
|
placeholder: (_t = typedDefinition.title) !== null && _t !== void 0 ? _t : "",
|
|
339
329
|
addonAfter: unit,
|
|
340
330
|
};
|
|
341
|
-
return (jsx(FormGroup, Object.assign({ htmlFor: isEditing ? key || "number-field" : `${key}-number-field`, label: title, isInvalid: errorMessage ? true : false, helpText: errorMessage || description, 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}-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 => {
|
|
342
332
|
setNumberValue(e.target.value);
|
|
343
333
|
validation.register(key, rules).onChange(e);
|
|
344
|
-
} }, numberProps))) : (jsx(BaseInput, Object.assign({ type: "text", id: `${key}-number-field`, dataTestId: typedDefinition.
|
|
334
|
+
} }, numberProps))) : (jsx(BaseInput, Object.assign({ type: "text", id: `${key}-number-field`, dataTestId: `${typedDefinition.key}`, 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))) })));
|
|
345
335
|
}
|
|
346
336
|
case CustomFieldType.BOOLEAN: {
|
|
347
337
|
const typedDefinition = field.definition;
|
|
348
338
|
const typedValue = field.value;
|
|
349
339
|
const rules = getBooleanValidationRules();
|
|
350
|
-
return (jsx(BooleanCustomField, { label: (_y = typedDefinition.title) !== null && _y !== void 0 ? _y : "", id: key || "boolean-field", defaultValue: (_0 = (_z = typedValue.booleanValue) !== null && _z !== void 0 ? _z : typedDefinition.defaultBooleanValue) !== null && _0 !== void 0 ? _0 : undefined, readOnly: !typedDefinition.uiEditable, register: validation.register, validationRules: rules, helpText: description, setValue: validation.setValue, errorMessage: errorMessage, dataTestId: `${typedDefinition.
|
|
340
|
+
return (jsx(BooleanCustomField, { label: (_y = typedDefinition.title) !== null && _y !== void 0 ? _y : "", id: key || "boolean-field", defaultValue: (_0 = (_z = typedValue.booleanValue) !== null && _z !== void 0 ? _z : typedDefinition.defaultBooleanValue) !== null && _0 !== void 0 ? _0 : undefined, readOnly: !typedDefinition.uiEditable, register: validation.register, validationRules: rules, helpText: description, setValue: validation.setValue, errorMessage: errorMessage, dataTestId: `${typedDefinition.key}` }, key));
|
|
351
341
|
}
|
|
352
342
|
case CustomFieldType.DROPDOWN: {
|
|
353
343
|
const typedDefinition = field.definition;
|
|
354
344
|
const typedValue = field.value;
|
|
355
345
|
const rules = getDropdownValidationRules();
|
|
356
|
-
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.
|
|
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}` }, key));
|
|
357
347
|
}
|
|
358
348
|
case CustomFieldType.DATE: {
|
|
359
349
|
const typedDefinition = field.definition;
|
|
@@ -366,7 +356,7 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
|
|
|
366
356
|
else if (typedDefinition.defaultDateValue !== undefined && typedDefinition.defaultDateValue !== null) {
|
|
367
357
|
defaultValue = new Date(typedDefinition.defaultDateValue);
|
|
368
358
|
}
|
|
369
|
-
return (jsx(DateCustomField, { dataTestId: `${typedDefinition.
|
|
359
|
+
return (jsx(DateCustomField, { dataTestId: `${typedDefinition.key}`, id: key || "date-field", defaultValue: defaultValue, readOnly: !typedDefinition.uiEditable, register: validation.register, label: typedDefinition.title || "", validationRules: rules, helpText: description, errorMessage: errorMessage, setValue: validation.setValue, title: field.definition.title || "" }, key));
|
|
370
360
|
}
|
|
371
361
|
default:
|
|
372
362
|
throw new Error(`Type not supported: ${type}`);
|
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.362",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@trackunit/iris-app-runtime-core": "0.3.46",
|
|
8
8
|
"@trackunit/iris-app-runtime-core-api": "0.3.40",
|
|
9
9
|
"@trackunit/react-components": "0.1.99",
|
|
10
|
-
"@trackunit/react-core-contexts-test": "0.1.
|
|
11
|
-
"@trackunit/react-form-components": "0.0.
|
|
10
|
+
"@trackunit/react-core-contexts-test": "0.1.70",
|
|
11
|
+
"@trackunit/react-form-components": "0.0.44",
|
|
12
12
|
"@trackunit/tailwind-styled-components": "0.0.56",
|
|
13
13
|
"libphonenumber-js": "1.10.30",
|
|
14
14
|
"react": "18.2.0",
|
package/src/utils.d.ts
DELETED