@limetech/lime-elements 39.45.2 → 39.45.3

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.
@@ -29155,8 +29155,15 @@ function NullField(props) {
29155
29155
  return null;
29156
29156
  }
29157
29157
 
29158
- // Static matchers for standard '.' separator used during normalization inside handleChange
29158
+ // Matches a string that ends in a . character, optionally followed by a sequence of
29159
+ // digits followed by any number of 0 characters up until the end of the line.
29160
+ // Ensuring that there is at least one prefixed character is important so that
29161
+ // you don't incorrectly match against "0".
29159
29162
  const trailingCharMatcherWithPrefix = /\.([0-9]*0)*$/;
29163
+ // This is used for trimming the trailing 0 and . characters without affecting
29164
+ // the rest of the string. Its possible to use one RegEx with groups for this
29165
+ // functionality, but it is fairly complex compared to simply defining two
29166
+ // different matchers.
29160
29167
  const trailingCharMatcher = /[0.]0*$/;
29161
29168
  /**
29162
29169
  * The NumberField class has some special handling for dealing with trailing
@@ -29179,8 +29186,6 @@ function NumberField(props) {
29179
29186
  const { registry, onChange, formData, value: initialValue } = props;
29180
29187
  const [lastValue, setLastValue] = reactExports.useState(initialValue);
29181
29188
  const { StringField } = registry.fields;
29182
- const separator = getDecimalSeparator();
29183
- const escapedSeparator = separator === '.' ? '\\.' : separator;
29184
29189
  let value = formData;
29185
29190
  /** Handle the change from the `StringField` to properly convert to a number
29186
29191
  *
@@ -29189,11 +29194,9 @@ function NumberField(props) {
29189
29194
  const handleChange = reactExports.useCallback((newValue, path, errorSchema, id) => {
29190
29195
  // Cache the original value in component state
29191
29196
  setLastValue(newValue);
29192
- // Convert locale separator to standard '.' first
29193
- const standardValue = typeof newValue === 'string' ? newValue.replace(separator, '.') : newValue;
29194
29197
  // Normalize decimals that don't start with a zero character in advance so
29195
29198
  // that the rest of the normalization logic is simpler
29196
- const normalizedValue = `${standardValue}`.startsWith('.') ? `0${standardValue}` : standardValue;
29199
+ const normalizedValue = `${newValue}`.startsWith('.') ? `0${newValue}` : newValue;
29197
29200
  // Check that the value is a string (this can happen if the widget used is a
29198
29201
  // <select>, due to an enum declaration etc) then, if the value ends in a
29199
29202
  // trailing decimal point or multiple zeroes, strip the trailing values
@@ -29201,33 +29204,19 @@ function NumberField(props) {
29201
29204
  ? asNumber(normalizedValue.replace(trailingCharMatcher, ''))
29202
29205
  : asNumber(normalizedValue);
29203
29206
  onChange(processed, path, errorSchema, id);
29204
- }, [onChange, separator]);
29207
+ }, [onChange]);
29205
29208
  if (typeof lastValue === 'string' && typeof value === 'number') {
29206
29209
  // Construct a regular expression that checks for a string that consists
29207
- // of the formData value suffixed with zero or one locale separator characters and zero
29210
+ // of the formData value suffixed with zero or one '.' characters and zero
29208
29211
  // or more '0' characters
29209
- const re = new RegExp(`^(${String(value).replace('.', escapedSeparator)})?${escapedSeparator}?0*$`);
29212
+ const re = new RegExp(`^(${String(value).replace('.', '\\.')})?\\.?0*$`);
29210
29213
  // If the cached "lastValue" is a match, use that instead of the formData
29211
29214
  // value to prevent the input value from changing in the UI
29212
29215
  if (lastValue.match(re)) {
29213
29216
  value = lastValue;
29214
29217
  }
29215
29218
  }
29216
- // Format value to use the locale separator for rendering if it is a number
29217
- let displayValue = value;
29218
- if (typeof value === 'number' && separator !== '.') {
29219
- const { schema, uiSchema } = props;
29220
- const { schemaUtils } = registry;
29221
- const enumOptions = schemaUtils.isSelect(schema) ? optionsList(schema, uiSchema) : undefined;
29222
- const defaultWidget = enumOptions ? 'select' : 'text';
29223
- const { widget = defaultWidget } = getUiOptions(uiSchema);
29224
- // Do not convert the value to a locale-specific string for radio, select,
29225
- // or hidden widgets because option matching relies on the original numeric value.
29226
- if (widget !== 'radio' && widget !== 'select' && widget !== 'hidden') {
29227
- displayValue = String(value).replace('.', separator);
29228
- }
29229
- }
29230
- return jsxRuntimeExports.jsx(StringField, { ...props, formData: displayValue, onChange: handleChange });
29219
+ return jsxRuntimeExports.jsx(StringField, { ...props, formData: value, onChange: handleChange });
29231
29220
  }
29232
29221
 
29233
29222
  var q={af:"\u2061",applyfunction:"\u2061",ic:"\u2063",invisiblecomma:"\u2063",invisibletimes:"\u2062",it:"\u2062",lrm:"\u200E",negativemediumspace:"\u200B",negativethickspace:"\u200B",negativethinspace:"\u200B",negativeverythinspace:"\u200B",nobreak:"\u2060",rlm:"\u200F",shy:"\xAD",zerowidthspace:"\u200B",zwj:"\u200D",zwnj:"\u200C",downbreve:"\u0311",tdot:"\u20DB",tripledot:"\u20DB",dotdot:"\u20DC",tab:" ",newline:`
@@ -29320,12 +29309,6 @@ function getDefaultValue(translateString, type) {
29320
29309
  return translateString(TranslatableString.NewStringDefault);
29321
29310
  }
29322
29311
  }
29323
- function isAdditionalPropertySchema(schema) {
29324
- return Boolean(schema?.[ADDITIONAL_PROPERTY_FLAG]);
29325
- }
29326
- function getAdditionalPropertyOrder(schemaProperties) {
29327
- return Object.keys(schemaProperties).filter((property) => isAdditionalPropertySchema(schemaProperties[property]));
29328
- }
29329
29312
  /** The `ObjectFieldProperty` component is used to render the `SchemaField` for a child property of an object
29330
29313
  */
29331
29314
  function ObjectFieldPropertyFn(props) {
@@ -29390,15 +29373,10 @@ function ObjectField$1(props) {
29390
29373
  formDataRef.current = formData;
29391
29374
  const schema = reactExports.useMemo(() => schemaUtils.retrieveSchema(rawSchema, formData, true), [schemaUtils, rawSchema, formData]);
29392
29375
  const uiOptions = reactExports.useMemo(() => getUiOptions(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
29393
- const schemaProperties = reactExports.useMemo(() => schema.properties ?? {}, [schema.properties]);
29376
+ const { properties: schemaProperties = {} } = schema;
29394
29377
  // All the children will use childFieldPathId if present in the props, falling back to the fieldPathId
29395
29378
  const childFieldPathId = props.childFieldPathId ?? fieldPathId;
29396
29379
  const lastRenamedProperty = reactExports.useRef({ previousKey: '', currentKey: undefined });
29397
- const [additionalPropertyOrder, setAdditionalPropertyOrder] = reactExports.useState(() => getAdditionalPropertyOrder(schemaProperties));
29398
- const definedPropertyOrder = reactExports.useMemo(() => {
29399
- const additionalPropertySet = new Set(getAdditionalPropertyOrder(schemaProperties));
29400
- return Object.keys(schemaProperties).filter((property) => !additionalPropertySet.has(property));
29401
- }, [schemaProperties]);
29402
29380
  const templateTitle = uiOptions.title ?? schema.title ?? title ?? name;
29403
29381
  const description = uiOptions.description ?? schema.description;
29404
29382
  const renderOptionalField = shouldRenderOptionalField(registry, schema, required, uiSchema);
@@ -29461,7 +29439,6 @@ function ObjectField$1(props) {
29461
29439
  lastRenamedProperty.current.currentKey = newKey;
29462
29440
  lastRenamedProperty.current.previousKey = getAvailableKey(newKey, newFormData);
29463
29441
  }
29464
- setAdditionalPropertyOrder((order) => [...order, newKey]);
29465
29442
  onChange(newFormData, childFieldPathId.path);
29466
29443
  }, [formData, onChange, translateString, schemaUtils, childFieldPathId, getAvailableKey, schema]);
29467
29444
  /** Returns a callback function that deals with the rename of a key for an additional property for a schema. That
@@ -29490,7 +29467,6 @@ function ObjectField$1(props) {
29490
29467
  lastRenamedProperty.current.previousKey = oldKey;
29491
29468
  }
29492
29469
  lastRenamedProperty.current.currentKey = actualNewKey;
29493
- setAdditionalPropertyOrder((order) => order.map((property) => (property === oldKey ? actualNewKey : property)));
29494
29470
  onChange(renamedObj, childFieldPathId.path);
29495
29471
  }
29496
29472
  }, [onChange, childFieldPathId, getAvailableKey]);
@@ -29498,7 +29474,6 @@ function ObjectField$1(props) {
29498
29474
  * value for the path plus the key to be removed
29499
29475
  */
29500
29476
  const handleRemoveProperty = reactExports.useCallback((key) => {
29501
- setAdditionalPropertyOrder((order) => order.filter((property) => property !== key));
29502
29477
  onChange(ADDITIONAL_PROPERTY_KEY_REMOVE, [...childFieldPathId.path, key]);
29503
29478
  }, [onChange, childFieldPathId]);
29504
29479
  /** Returns the stable React key for a property. For the most recently renamed
@@ -29514,9 +29489,8 @@ function ObjectField$1(props) {
29514
29489
  }, []);
29515
29490
  if (!renderOptionalField || hasFormData) {
29516
29491
  try {
29517
- const definedPropertySet = new Set(definedPropertyOrder);
29518
- const currentAdditionalProperties = additionalPropertyOrder.filter((property) => Object.hasOwn(schemaProperties, property) && !definedPropertySet.has(property));
29519
- orderedProperties = orderProperties([...definedPropertyOrder, ...currentAdditionalProperties], uiOptions.order);
29492
+ const properties = Object.keys(schemaProperties);
29493
+ orderedProperties = orderProperties(properties, uiOptions.order);
29520
29494
  }
29521
29495
  catch (err) {
29522
29496
  return (jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsx("p", { className: 'rjsf-config-error', style: { color: 'red' }, children: jsxRuntimeExports.jsx(AZ, { options: { disableParsingRawHTML: true }, children: translateString(TranslatableString.InvalidObjectField, [name || 'root', err.message]) }) }), jsxRuntimeExports.jsx("pre", { children: JSON.stringify(schema) })] }));
@@ -29529,7 +29503,7 @@ function ObjectField$1(props) {
29529
29503
  title: uiOptions.label === false ? '' : templateTitle,
29530
29504
  description: uiOptions.label === false ? undefined : description,
29531
29505
  properties: orderedProperties.map((propertyName) => {
29532
- const addedByAdditionalProperties = isAdditionalPropertySchema(schema.properties?.[propertyName]);
29506
+ const addedByAdditionalProperties = Boolean(schema.properties?.[propertyName]?.[ADDITIONAL_PROPERTY_FLAG]);
29533
29507
  const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[propertyName];
29534
29508
  const hidden = getUiOptions(fieldUiSchema).widget === 'hidden';
29535
29509
  const content = (jsxRuntimeExports.jsx(ObjectFieldProperty, { propertyName: propertyName, required: isRequired(schema, propertyName), schema: _baseIteratee.get(schema, [PROPERTIES_KEY, propertyName], {}), uiSchema: fieldUiSchema, errorSchema: _baseIteratee.get(errorSchema, [propertyName]), fieldPathId: childFieldPathId, formData: _baseIteratee.get(formData, [propertyName]), handleKeyRename: handleKeyRename, handleRemoveProperty: handleRemoveProperty, addedByAdditionalProperties: addedByAdditionalProperties, onChange: onChange, onBlur: onBlur, onFocus: onFocus, registry: registry, disabled: disabled, readonly: readonly, hideError: hideError }, getStableKey(propertyName)));