@ostack.tech/ui 0.14.0 → 0.14.1

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/dist/ostack-ui.js CHANGED
@@ -5619,17 +5619,6 @@ const Checkbox = forwardRef(function Checkbox2({
5619
5619
  const dataTableColumnLabelId = useDataTableColumnLabelId();
5620
5620
  const descriptionIds = useFieldDescriptionIds();
5621
5621
  const errorMessageIds = useFieldErrorMessageIds();
5622
- const { generatedId, controlId, codeId } = useRegisterFieldControl(
5623
- id,
5624
- "BUTTON",
5625
- codeProps?.id,
5626
- Boolean(code),
5627
- required,
5628
- status
5629
- );
5630
- const labelId = children && (labelProps?.id ?? prefix(`checkbox-label-${generatedId}`));
5631
- const loadingDescriptionId = loading && loadingDescription && prefix(`control-loading-${generatedId}`);
5632
- const checkboxRef = useRef(null);
5633
5622
  const containerRef = useRef(null);
5634
5623
  const labelRef = useRef(null);
5635
5624
  const isInTableCell = useIsInTableCell();
@@ -5650,6 +5639,17 @@ const Checkbox = forwardRef(function Checkbox2({
5650
5639
  status = controlContext?.status ?? status ?? formStatus;
5651
5640
  disabled = controlContext?.disabled || disabled || formDisabled;
5652
5641
  readOnly = controlContext?.readOnly || readOnly;
5642
+ const { generatedId, controlId, codeId } = useRegisterFieldControl(
5643
+ id,
5644
+ "BUTTON",
5645
+ codeProps?.id,
5646
+ Boolean(code),
5647
+ required,
5648
+ status
5649
+ );
5650
+ const labelId = children && (labelProps?.id ?? prefix(`checkbox-label-${generatedId}`));
5651
+ const loadingDescriptionId = loading && loadingDescription && prefix(`control-loading-${generatedId}`);
5652
+ const checkboxRef = useRef(null);
5653
5653
  const requiredInGroup = useIsRequiredInGroup();
5654
5654
  const groupDescriptionIds = useCheckboxGroupDescriptionIds(controlId);
5655
5655
  const softDisabled = controlContext?.softDisabled || loading || ariaDisabled === "true" || ariaDisabled === true;
@@ -9108,7 +9108,7 @@ const SelectNative = forwardRef(function SelectNative2({ actualElement, multiple
9108
9108
  [hasEmptyOption, optionStates]
9109
9109
  );
9110
9110
  const options = useMemo(
9111
- () => optionStates.map(({ value: value2, disabled }) => /* @__PURE__ */ jsx("option", { value: value2, disabled, children: value2 }, value2)),
9111
+ () => optionStates.map(({ value: value2, disabled }) => /* @__PURE__ */ jsx("option", { value: value2, disabled }, value2)),
9112
9112
  [optionStates]
9113
9113
  );
9114
9114
  return /* @__PURE__ */ jsx(
@@ -10248,6 +10248,15 @@ const CheckboxGroup = forwardRef(function CheckboxGroup2({
10248
10248
  const prefix = usePrefix();
10249
10249
  const [locale7] = useLocale();
10250
10250
  loadingDescription ??= locale7.Input.loadingDescription;
10251
+ const initialValue = value ?? defaultValue ?? [];
10252
+ const {
10253
+ status: formStatus,
10254
+ disabled: formDisabled,
10255
+ onChange: formOnChange,
10256
+ onBlur: formOnBlur
10257
+ } = useRegisterFormControl(name, initialValue, validate, validationMode);
10258
+ status ??= formStatus;
10259
+ disabled ||= formDisabled;
10251
10260
  const labelId = useFieldLabelId();
10252
10261
  const dataTableColumnLabelId = useDataTableColumnLabelId();
10253
10262
  const descriptionIds = useFieldDescriptionIds();
@@ -10262,15 +10271,6 @@ const CheckboxGroup = forwardRef(function CheckboxGroup2({
10262
10271
  );
10263
10272
  const loadingDescriptionId = loading && loadingDescription ? prefix(`control-loading-${generatedId}`) : void 0;
10264
10273
  const checkboxGroupRef = useRef(null);
10265
- const initialValue = value ?? defaultValue ?? [];
10266
- const {
10267
- status: formStatus,
10268
- disabled: formDisabled,
10269
- onChange: formOnChange,
10270
- onBlur: formOnBlur
10271
- } = useRegisterFormControl(name, initialValue, validate, validationMode);
10272
- status ??= formStatus;
10273
- disabled ||= formDisabled;
10274
10274
  const isInTableCell = useIsInTableCell();
10275
10275
  inline ??= isInTableCell;
10276
10276
  variant ??= isInTableCell ? "cell" : "default";
@@ -11025,24 +11025,6 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
11025
11025
  const { format: formatDate, parse: parseDate } = useDateTransformer({
11026
11026
  format: format2
11027
11027
  });
11028
- const dataTableColumnLabelId = useDataTableColumnLabelId();
11029
- const labelId = useFieldLabelId();
11030
- const descriptionIds = useFieldDescriptionIds();
11031
- const errorMessageIds = useFieldErrorMessageIds();
11032
- const { printHidden } = usePrintClassNames();
11033
- const { generatedId, controlId, codeId } = useRegisterFieldControl(
11034
- startInputProps?.id,
11035
- "INPUT",
11036
- codeProps?.id,
11037
- Boolean(code),
11038
- required,
11039
- status
11040
- );
11041
- const setFieldControlFocused = useSetFieldControlFocused();
11042
- const startInputLabelId = startInputLabel && prefix(`control-start-label-${generatedId}`);
11043
- const endInputLabelId = endInputLabel && prefix(`control-end-label-${generatedId}`);
11044
- const loadingDescriptionId = loading && loadingDescription && prefix(`control-loading-${generatedId}`);
11045
- const formatDescriptionId = formatDescription && typeof formatDescription !== "boolean" ? prefix(`control-format-${generatedId}`) : void 0;
11046
11028
  const isInTableCell = useIsInTableCell();
11047
11029
  variant ??= isInTableCell ? "cell" : "default";
11048
11030
  const [formattedValue, setFormattedValue] = useControllableState(
@@ -11112,6 +11094,24 @@ const DateRangeInput = forwardRef(function DateRangeInput2({
11112
11094
  );
11113
11095
  status ??= formStatus;
11114
11096
  disabled ||= formDisabled;
11097
+ const dataTableColumnLabelId = useDataTableColumnLabelId();
11098
+ const labelId = useFieldLabelId();
11099
+ const descriptionIds = useFieldDescriptionIds();
11100
+ const errorMessageIds = useFieldErrorMessageIds();
11101
+ const { printHidden } = usePrintClassNames();
11102
+ const { generatedId, controlId, codeId } = useRegisterFieldControl(
11103
+ startInputProps?.id,
11104
+ "INPUT",
11105
+ codeProps?.id,
11106
+ Boolean(code),
11107
+ required,
11108
+ status
11109
+ );
11110
+ const setFieldControlFocused = useSetFieldControlFocused();
11111
+ const startInputLabelId = startInputLabel && prefix(`control-start-label-${generatedId}`);
11112
+ const endInputLabelId = endInputLabel && prefix(`control-end-label-${generatedId}`);
11113
+ const loadingDescriptionId = loading && loadingDescription && prefix(`control-loading-${generatedId}`);
11114
+ const formatDescriptionId = formatDescription && typeof formatDescription !== "boolean" ? prefix(`control-format-${generatedId}`) : void 0;
11115
11115
  const startDisabled = disabled || startInputProps?.disabled;
11116
11116
  const endDisabled = disabled || endInputProps?.disabled;
11117
11117
  const bothDisabled = startDisabled && endDisabled;
@@ -13385,6 +13385,43 @@ const NumericInput = forwardRef(function NumericInput2({
13385
13385
  exclusiveMaxString
13386
13386
  });
13387
13387
  }
13388
+ const allowNegative = (!minString || compareNumericStrings(minString, "0") < 0) && (!exclusiveMinString || compareNumericStrings(exclusiveMinString, "0") < 0);
13389
+ const formatProps = useMemo(
13390
+ () => ({
13391
+ valueIsNumericString: valueIsUnformattedString,
13392
+ decimalScale: scale ?? void 0,
13393
+ fixedDecimalScale: fixedScale,
13394
+ decimalSeparator,
13395
+ thousandSeparator: groupDigits ? groupSeparator : "",
13396
+ thousandsGroupStyle: groupDigits ? groupingStyle : "none",
13397
+ prefix,
13398
+ suffix,
13399
+ allowNegative
13400
+ }),
13401
+ [
13402
+ allowNegative,
13403
+ decimalSeparator,
13404
+ fixedScale,
13405
+ groupDigits,
13406
+ groupSeparator,
13407
+ groupingStyle,
13408
+ prefix,
13409
+ scale,
13410
+ suffix,
13411
+ valueIsUnformattedString
13412
+ ]
13413
+ );
13414
+ const [inputEl, setInputEl] = useState(null);
13415
+ const [value, setValue] = useControllableState(defaultValue, controlledValue);
13416
+ const stringValue = useMemo(
13417
+ () => valueToStringValue(value, valueIsInteger, formatProps),
13418
+ [formatProps, value, valueIsInteger]
13419
+ );
13420
+ const rnfString = useMemo(
13421
+ () => valueToRNFString(value, valueIsInteger, formatProps),
13422
+ [formatProps, value, valueIsInteger]
13423
+ );
13424
+ const prevStringValueRef = useRef(stringValue);
13388
13425
  const isAllowed = useCallback(
13389
13426
  (values) => {
13390
13427
  const valueRepresentations = transformNumberFormatValues(
@@ -13393,34 +13430,47 @@ const NumericInput = forwardRef(function NumericInput2({
13393
13430
  scale
13394
13431
  );
13395
13432
  const { stringValue: stringValue2 } = valueRepresentations;
13433
+ const prevStringValue = prevStringValueRef.current;
13396
13434
  if (stringValue2) {
13397
13435
  if (precision != null) {
13398
13436
  const isNegative = isNumericStringNegative(stringValue2);
13437
+ const prevIsNegative = isNumericStringNegative(prevStringValue);
13399
13438
  if (valueIsInteger) {
13400
- if (stringValue2.length - (isNegative ? 1 : 0) > precision) {
13401
- return false;
13439
+ const curPrecision = stringValue2.length - (isNegative ? 1 : 0);
13440
+ if (curPrecision > precision) {
13441
+ const prevPrecision = prevStringValue.length - (prevIsNegative ? 1 : 0);
13442
+ if (curPrecision > prevPrecision) {
13443
+ return false;
13444
+ }
13402
13445
  }
13403
13446
  } else {
13404
13447
  const decimalSeparatorIndex = stringValue2.indexOf(".");
13405
13448
  const decimal = decimalSeparatorIndex === -1 ? stringValue2 : stringValue2.slice(0, decimalSeparatorIndex);
13406
- if (decimal.length - (isNegative ? 1 : 0) > precision - scale) {
13407
- return false;
13449
+ const curDecimalPrecision = decimal.length - (isNegative ? 1 : 0);
13450
+ if (curDecimalPrecision > precision - scale) {
13451
+ const prevDecimalSeparatorIndex = prevStringValue.indexOf(".");
13452
+ const prevDecimal = prevDecimalSeparatorIndex === -1 ? prevStringValue : prevStringValue.slice(0, prevDecimalSeparatorIndex);
13453
+ const prevDecimalPrecision = prevDecimal.length - (prevIsNegative ? 1 : 0);
13454
+ if (curDecimalPrecision > prevDecimalPrecision) {
13455
+ return false;
13456
+ }
13408
13457
  }
13409
13458
  }
13410
13459
  }
13411
- if (minString && (compareNumericStrings(minString, "0") < 0 && compareNumericStrings(stringValue2, minString) < 0 || compareNumericStrings(minString, "0") >= 0 && compareNumericStrings(stringValue2, "0") < 0)) {
13460
+ if (minString && (compareNumericStrings(minString, "0") < 0 && compareNumericStrings(stringValue2, minString) < 0 || compareNumericStrings(minString, "0") >= 0 && compareNumericStrings(stringValue2, "0") < 0) && compareNumericStrings(stringValue2, prevStringValue) < 0) {
13412
13461
  return false;
13413
13462
  }
13414
- if (maxString && (compareNumericStrings(maxString, "0") > 0 && compareNumericStrings(stringValue2, maxString) > 0 || compareNumericStrings(maxString, "0") <= 0 && compareNumericStrings(stringValue2, "0") > 0)) {
13463
+ if (maxString && (compareNumericStrings(maxString, "0") > 0 && compareNumericStrings(stringValue2, maxString) > 0 || compareNumericStrings(maxString, "0") <= 0 && compareNumericStrings(stringValue2, "0") > 0) && compareNumericStrings(stringValue2, prevStringValue) > 0) {
13415
13464
  return false;
13416
13465
  }
13417
- if (exclusiveMinString && (compareNumericStrings(exclusiveMinString, "0") < 0 && compareNumericStrings(stringValue2, exclusiveMinString) <= 0 || compareNumericStrings(exclusiveMinString, "0") >= 0 && compareNumericStrings(stringValue2, "0") < 0)) {
13466
+ if (exclusiveMinString && (compareNumericStrings(exclusiveMinString, "0") < 0 && compareNumericStrings(stringValue2, exclusiveMinString) <= 0 || compareNumericStrings(exclusiveMinString, "0") >= 0 && compareNumericStrings(stringValue2, "0") < 0) && compareNumericStrings(stringValue2, prevStringValue) < 0) {
13418
13467
  return false;
13419
13468
  }
13420
- if (exclusiveMaxString && (compareNumericStrings(exclusiveMaxString, "0") > 0 && compareNumericStrings(stringValue2, exclusiveMaxString) >= 0 || compareNumericStrings(exclusiveMaxString, "0") <= 0 && compareNumericStrings(stringValue2, "0") > 0)) {
13469
+ if (exclusiveMaxString && (compareNumericStrings(exclusiveMaxString, "0") > 0 && compareNumericStrings(stringValue2, exclusiveMaxString) >= 0 || compareNumericStrings(exclusiveMaxString, "0") <= 0 && compareNumericStrings(stringValue2, "0") > 0) && compareNumericStrings(stringValue2, prevStringValue) > 0) {
13421
13470
  return false;
13422
13471
  }
13423
13472
  }
13473
+ prevStringValueRef.current = stringValue2;
13424
13474
  return true;
13425
13475
  },
13426
13476
  [
@@ -13433,42 +13483,6 @@ const NumericInput = forwardRef(function NumericInput2({
13433
13483
  exclusiveMaxString
13434
13484
  ]
13435
13485
  );
13436
- const allowNegative = (!minString || compareNumericStrings(minString, "0") < 0) && (!exclusiveMinString || compareNumericStrings(exclusiveMinString, "0") < 0);
13437
- const formatProps = useMemo(
13438
- () => ({
13439
- valueIsNumericString: valueIsUnformattedString,
13440
- decimalScale: scale ?? void 0,
13441
- fixedDecimalScale: fixedScale,
13442
- decimalSeparator,
13443
- thousandSeparator: groupDigits ? groupSeparator : "",
13444
- thousandsGroupStyle: groupDigits ? groupingStyle : "none",
13445
- prefix,
13446
- suffix,
13447
- allowNegative
13448
- }),
13449
- [
13450
- allowNegative,
13451
- decimalSeparator,
13452
- fixedScale,
13453
- groupDigits,
13454
- groupSeparator,
13455
- groupingStyle,
13456
- prefix,
13457
- scale,
13458
- suffix,
13459
- valueIsUnformattedString
13460
- ]
13461
- );
13462
- const [inputEl, setInputEl] = useState(null);
13463
- const [value, setValue] = useControllableState(defaultValue, controlledValue);
13464
- const stringValue = useMemo(
13465
- () => valueToStringValue(value, valueIsInteger, formatProps),
13466
- [formatProps, value, valueIsInteger]
13467
- );
13468
- const rnfString = useMemo(
13469
- () => valueToRNFString(value, valueIsInteger, formatProps),
13470
- [formatProps, value, valueIsInteger]
13471
- );
13472
13486
  const {
13473
13487
  status: formStatus,
13474
13488
  disabled: formDisabled,
@@ -13649,6 +13663,7 @@ const Radio = forwardRef(function Radio2({
13649
13663
  "div",
13650
13664
  {
13651
13665
  "data-status": status,
13666
+ "data-accent": controlStatusToAccent(status),
13652
13667
  ...rootProps,
13653
13668
  onFocus: combineEventHandlers(rootProps?.onFocus, handleRootFocus),
13654
13669
  className: cx(prefix("radio__root"), rootProps?.className),
@@ -13776,6 +13791,15 @@ const RadioGroup = forwardRef(function RadioGroup2({
13776
13791
  defaultValue ?? "",
13777
13792
  controlledValue
13778
13793
  );
13794
+ const {
13795
+ status: formStatus,
13796
+ disabled: formDisabled,
13797
+ setValue: formSetValue,
13798
+ onChange: formOnChange,
13799
+ onBlur: formOnBlur
13800
+ } = useRegisterFormControl(name, value, validate, validationMode);
13801
+ status ??= formStatus;
13802
+ disabled ||= formDisabled;
13779
13803
  const { generatedId, controlId, codeId } = useRegisterFieldControl(
13780
13804
  id,
13781
13805
  "DIV",
@@ -13786,15 +13810,6 @@ const RadioGroup = forwardRef(function RadioGroup2({
13786
13810
  );
13787
13811
  const loadingDescriptionId = loading && loadingDescription && prefix(`control-loading-${generatedId}`);
13788
13812
  const [radioGroupEl, setRadioGroupEl] = useState(null);
13789
- const {
13790
- status: formStatus,
13791
- disabled: formDisabled,
13792
- setValue: formSetValue,
13793
- onChange: formOnChange,
13794
- onBlur: formOnBlur
13795
- } = useRegisterFormControl(name, value, validate, validationMode);
13796
- status ??= formStatus;
13797
- disabled ||= formDisabled;
13798
13813
  const isInTableCell = useIsInTableCell();
13799
13814
  inline ??= isInTableCell;
13800
13815
  variant ??= isInTableCell ? "cell" : "default";