@oliasoft-open-source/react-ui-library 4.15.0-beta-2 → 4.15.0-beta-4

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/index.d.ts CHANGED
@@ -1047,10 +1047,9 @@ export declare interface IPortalProps {
1047
1047
  }
1048
1048
 
1049
1049
  declare interface IPredefinedOption {
1050
- value: string;
1050
+ value?: string;
1051
1051
  label: string;
1052
1052
  valueKey?: string;
1053
- unit?: string;
1054
1053
  }
1055
1054
 
1056
1055
  export declare interface IPrintHeaderProps {
@@ -1191,6 +1190,13 @@ declare interface ISelectSelectedOption {
1191
1190
  testId?: string;
1192
1191
  }
1193
1192
 
1193
+ export declare interface ISettingFieldProps {
1194
+ helpText: string;
1195
+ children: ReactNode;
1196
+ selectedOption: 'all_users' | 'superusers_admin';
1197
+ handleSelectChange: (value: 'all_users' | 'superusers_admin') => void;
1198
+ }
1199
+
1194
1200
  export declare interface ISideBarProps {
1195
1201
  options: {
1196
1202
  title: string;
@@ -1570,14 +1576,17 @@ export declare interface IUnitInputProps {
1570
1576
  unitkey?: string;
1571
1577
  initUnit?: string;
1572
1578
  noConversion?: boolean;
1579
+ doNotConvertValue?: boolean;
1573
1580
  testId?: string;
1574
1581
  warning?: string | boolean | null;
1575
1582
  predefinedOptions?: IPredefinedOption[] | null;
1576
- initialPredefinedOption?: string;
1577
- predefinedOptionLinked?: boolean;
1583
+ initialPredefinedOption?: boolean;
1584
+ shouldLinkAutomaticly?: boolean;
1585
+ selectedPredefinedOptionKey?: string;
1578
1586
  validationCallback?: (name: string, error: string | null) => any;
1579
1587
  disabledValidation?: boolean;
1580
1588
  allowEmpty?: boolean;
1589
+ autoValue?: string;
1581
1590
  onChange?: TOnChangeEventHandler;
1582
1591
  onSwitchUnit?: (unit: string) => void;
1583
1592
  onClick?: MouseEventHandler<HTMLInputElement>;
@@ -1696,6 +1705,8 @@ export declare const Row: ({ alignItems, justifyContent, children, flex, height,
1696
1705
 
1697
1706
  export declare const Select: (props: ISelectProps) => JSX_2.Element;
1698
1707
 
1708
+ export declare const SettingField: ({ helpText, children, selectedOption, handleSelectChange, }: ISettingFieldProps) => JSX_2.Element;
1709
+
1699
1710
  export declare const SideBar: default_2.MemoExoticComponent<({ options, startOpen, onShiftClickToggleOpen, top, }: ISideBarProps) => JSX_2.Element>;
1700
1711
 
1701
1712
  export declare const Slider: ({ name, label, width, labelWidth, value, min, max, step, marks, showArrows, showTooltip, tooltipFormatter, disabled, range, small, vertical, onChange, }: ISliderProps) => JSX_2.Element;
@@ -1884,7 +1895,7 @@ declare type TUnitTableCellShape = TCellShape | IUnitTableStaticCell | IUnitTabl
1884
1895
 
1885
1896
  declare type UnitContextType = any;
1886
1897
 
1887
- export declare const UnitInput: ({ name, placeholder, disabled, disabledUnit, error, left, small, width, value, unitkey, initUnit, noConversion, onChange, onClick, onFocus, onSwitchUnit, unitTemplate, testId, warning, predefinedOptions, initialPredefinedOption, predefinedOptionLinked, validationCallback, disabledValidation, allowEmpty, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, roundDisplayValue, }: IUnitInputProps) => JSX_2.Element;
1898
+ export declare const UnitInput: ({ name, placeholder, disabled, disabledUnit, error, left, small, width, value, unitkey, initUnit, noConversion, onChange, onClick, onFocus, onSwitchUnit, unitTemplate, doNotConvertValue, testId, warning, predefinedOptions, initialPredefinedOption, shouldLinkAutomaticly, selectedPredefinedOptionKey, validationCallback, disabledValidation, allowEmpty, autoValue, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, roundDisplayValue, }: IUnitInputProps) => JSX_2.Element;
1888
1899
 
1889
1900
  export declare const UnitTable: ({ table, unitConfig, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, }: IUnitTableProps) => JSX_2.Element;
1890
1901
 
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ import React__default, { useContext, isValidElement, useState, useRef, useEffect
15
15
  import * as PropTypes from "prop-types";
16
16
  import PropTypes__default from "prop-types";
17
17
  import ReactDOM, { createPortal, unstable_batchedUpdates, render } from "react-dom";
18
- import { noop as noop$3, set, get as get$2, isString as isString$3, isNumber as isNumber$1, isBoolean as isBoolean$2, isFunction as isFunction$3, isEmpty, isArray as isArray$1, toNumber, debounce as debounce$2, isObject as isObject$5, isNil, isEqual as isEqual$4 } from "lodash";
18
+ import { noop as noop$3, set, get as get$2, isString as isString$3, isNumber as isNumber$1, isBoolean as isBoolean$2, isFunction as isFunction$3, isEmpty, isArray as isArray$1, toNumber, debounce as debounce$2, isObject as isObject$5, isEqual as isEqual$4 } from "lodash";
19
19
  import { toString as toString$1, isScientificStringNum, roundToPrecision, toNum, validateNumber, cleanNumStr, stripLeadingZeros, roundToFixed, roundByMagnitude, unitFromQuantity, getUnit, KNOWN_UNITS, ALT_UNITS, isValueWithUnit, getValue as getValue$1, withUnit, convertSamePrecision, convertAndGetValue, split as split$1, label as label$b, isValidNum, getAltUnitsListByQuantity, altUnitsList, getUnitsForQuantity, roundByMagnitudeToFixed } from "@oliasoft-open-source/units";
20
20
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
21
21
  function getDefaultExportFromCjs(x2) {
@@ -70249,7 +70249,6 @@ const safeConvertValue = ({
70249
70249
  }) => {
70250
70250
  const rawValue = getValue$1(value);
70251
70251
  const isInvalidInput = isWrongValue(rawValue);
70252
- const availableUnits = ALT_UNITS[unitkey];
70253
70252
  if (isValueWithUnknownUnit(value)) {
70254
70253
  return { value: rawValue };
70255
70254
  }
@@ -70259,9 +70258,6 @@ const safeConvertValue = ({
70259
70258
  if (!isValueWithUnit(value)) {
70260
70259
  return { value };
70261
70260
  }
70262
- if (!(availableUnits == null ? void 0 : availableUnits.includes(getUnit(value)))) {
70263
- return { value: rawValue };
70264
- }
70265
70261
  return convertUnit({
70266
70262
  value,
70267
70263
  unitkey,
@@ -70296,144 +70292,6 @@ const initializeContext = (context2) => {
70296
70292
  UnitContext = context2;
70297
70293
  }
70298
70294
  };
70299
- const extractValue = (value) => {
70300
- if (isNil(value)) return value;
70301
- return isValueWithUnit(value) ? getValue$1(value) : value;
70302
- };
70303
- const PredefinedOptionsMenu = ({
70304
- predefinedOptions,
70305
- displayLayer,
70306
- unitkey: rootUnitKey,
70307
- unitTemplate,
70308
- onPredefinedOptionSelect,
70309
- disabled: disabled2,
70310
- initialPredefinedOption,
70311
- predefinedOptionLinked,
70312
- predefinedOptionsMenuState,
70313
- setPredefinedOptionsMenuState,
70314
- testId
70315
- }) => {
70316
- const extractedValue = extractValue(displayLayer == null ? void 0 : displayLayer.value);
70317
- const [foundPredefinedMenuOption, setFoundPredefinedMenuOption] = useState(void 0);
70318
- const convertPredefinedOptions = ({
70319
- value,
70320
- unit: optionUnitKey
70321
- }) => {
70322
- if (!value || !rootUnitKey) return value;
70323
- if (!isValueWithUnit(value)) return value;
70324
- const selectedUnitKey = optionUnitKey || rootUnitKey;
70325
- const preferredOptionUnit = getPreferredUnit(selectedUnitKey, unitTemplate);
70326
- const { value: resultValue } = safeConvertValue({
70327
- value,
70328
- toUnit: preferredOptionUnit,
70329
- unitkey: selectedUnitKey,
70330
- defaultFromUnit: "",
70331
- doNotConvertValue: false
70332
- });
70333
- return withUnit(resultValue, preferredOptionUnit);
70334
- };
70335
- const createPredefinedOption = (el2) => {
70336
- const convertedValue = convertPredefinedOptions(el2);
70337
- const [inputValue = "", unit2 = ""] = split$1(convertedValue);
70338
- return {
70339
- type: MenuType.OPTION,
70340
- inline: true,
70341
- onClick: () => {
70342
- const validation = validateNumber(inputValue);
70343
- const optionState = {
70344
- predefinedSelected: true,
70345
- predefinedOption: el2
70346
- };
70347
- if (validation.valid && !disabled2) {
70348
- setPredefinedOptionsMenuState(PredefinedOptionsMenuState.PREDEFINED);
70349
- onPredefinedOptionSelect(convertedValue, optionState);
70350
- setFoundPredefinedMenuOption(el2);
70351
- }
70352
- },
70353
- label: /* @__PURE__ */ jsxs(Fragment$1, { children: [
70354
- /* @__PURE__ */ jsx(Text, { children: el2.label }),
70355
- /* @__PURE__ */ jsx(Spacer, { width: "20px", height: "0" })
70356
- ] }),
70357
- description: `${inputValue} ${unit2}`,
70358
- selected: isEqual$4(foundPredefinedMenuOption, el2) && predefinedOptionsMenuState === PredefinedOptionsMenuState.PREDEFINED
70359
- };
70360
- };
70361
- const initialPredefinedOptionObject = useMemo$1(() => {
70362
- return predefinedOptions.find(
70363
- (option2) => [option2.value, option2.label, option2.valueKey].includes(
70364
- initialPredefinedOption
70365
- )
70366
- );
70367
- }, [initialPredefinedOption, predefinedOptionLinked]);
70368
- useEffect(() => {
70369
- if (initialPredefinedOptionObject) {
70370
- setPredefinedOptionsMenuState(PredefinedOptionsMenuState.PREDEFINED);
70371
- setFoundPredefinedMenuOption(initialPredefinedOptionObject);
70372
- if (predefinedOptionLinked) {
70373
- onPredefinedOptionSelect(initialPredefinedOptionObject.value, {
70374
- predefinedSelected: true,
70375
- predefinedOption: initialPredefinedOptionObject
70376
- });
70377
- }
70378
- }
70379
- }, [
70380
- initialPredefinedOptionObject == null ? void 0 : initialPredefinedOptionObject.value,
70381
- initialPredefinedOptionObject == null ? void 0 : initialPredefinedOptionObject.label
70382
- ]);
70383
- useEffect(() => {
70384
- const foundOption = predefinedOptionLinked && predefinedOptions.find((option2) => {
70385
- const convertedValue = convertPredefinedOptions(option2);
70386
- return convertedValue === withUnit(displayLayer == null ? void 0 : displayLayer.value, (displayLayer == null ? void 0 : displayLayer.unit) ?? "");
70387
- });
70388
- if (foundOption || initialPredefinedOptionObject) {
70389
- setPredefinedOptionsMenuState(PredefinedOptionsMenuState.PREDEFINED);
70390
- setFoundPredefinedMenuOption(
70391
- foundOption || initialPredefinedOptionObject
70392
- );
70393
- } else {
70394
- setPredefinedOptionsMenuState(PredefinedOptionsMenuState.CUSTOM);
70395
- setFoundPredefinedMenuOption(void 0);
70396
- }
70397
- }, [extractedValue, predefinedOptionLinked]);
70398
- const sectionsPredefinedMenu = [
70399
- {
70400
- type: MenuType.OPTION,
70401
- inline: true,
70402
- onClick: () => {
70403
- if (!disabled2) {
70404
- setPredefinedOptionsMenuState(PredefinedOptionsMenuState.CUSTOM);
70405
- }
70406
- },
70407
- label: "Custom",
70408
- selected: predefinedOptionsMenuState === PredefinedOptionsMenuState.CUSTOM
70409
- },
70410
- ...predefinedOptions.map(createPredefinedOption)
70411
- ];
70412
- return /* @__PURE__ */ jsx(
70413
- Menu,
70414
- {
70415
- testId: testId && `${testId}-predefined-menu`,
70416
- maxHeight: 380,
70417
- groupOrder: "first",
70418
- disabled: disabled2,
70419
- menu: {
70420
- colored: true,
70421
- trigger: "Component",
70422
- component: /* @__PURE__ */ jsx(
70423
- Button$1,
70424
- {
70425
- groupOrder: "first",
70426
- active: predefinedOptionsMenuState === PredefinedOptionsMenuState.PREDEFINED,
70427
- icon: predefinedOptionsMenuState === PredefinedOptionsMenuState.PREDEFINED ? "link" : "unlink"
70428
- }
70429
- ),
70430
- small: true,
70431
- sections: sectionsPredefinedMenu
70432
- },
70433
- tooltip: predefinedOptionsMenuState === PredefinedOptionsMenuState.PREDEFINED ? foundPredefinedMenuOption == null ? void 0 : foundPredefinedMenuOption.label : ""
70434
- }
70435
- );
70436
- };
70437
70295
  const predefinedMenuActive = "_predefinedMenuActive_ye9w9_1";
70438
70296
  const inputWrapper = "_inputWrapper_ye9w9_4";
70439
70297
  const styles = {
@@ -70458,14 +70316,17 @@ const UnitInput = ({
70458
70316
  onFocus = noop$3,
70459
70317
  onSwitchUnit = noop$3,
70460
70318
  unitTemplate,
70319
+ doNotConvertValue = false,
70461
70320
  testId,
70462
70321
  warning: warning2 = null,
70463
70322
  predefinedOptions,
70464
- initialPredefinedOption = "",
70465
- predefinedOptionLinked = true,
70323
+ initialPredefinedOption = false,
70324
+ shouldLinkAutomaticly = true,
70325
+ selectedPredefinedOptionKey,
70466
70326
  validationCallback = () => ({ name: "", error: null }),
70467
70327
  disabledValidation = false,
70468
70328
  allowEmpty = false,
70329
+ autoValue,
70469
70330
  convertBackToStorageUnit = false,
70470
70331
  enableCosmeticRounding = true,
70471
70332
  enableDisplayRounding = false,
@@ -70473,11 +70334,11 @@ const UnitInput = ({
70473
70334
  }) => {
70474
70335
  const context2 = useUnitContext();
70475
70336
  const runAfterUpdate = useRunAfterUpdate();
70476
- const [predefinedOptionsMenuState, setPredefinedOptionsMenuState] = useState(PredefinedOptionsMenuState.CUSTOM);
70477
70337
  if (typeof value === "number") {
70478
70338
  value = `${value}`;
70479
70339
  }
70480
70340
  const [propValue = "", propUnit = ""] = value !== void 0 ? split$1(value) : [];
70341
+ const propAutoUnit = autoValue ? getUnit(autoValue) : "";
70481
70342
  const preferredUnit = useMemo$1(
70482
70343
  () => getPreferredUnit(unitkey, unitTemplate || (context2 == null ? void 0 : context2.unitTemplate)),
70483
70344
  [unitkey, unitTemplate, context2 == null ? void 0 : context2.unitTemplate]
@@ -70490,15 +70351,39 @@ const UnitInput = ({
70490
70351
  toUnit: initDisplayUnit,
70491
70352
  unitkey,
70492
70353
  defaultFromUnit: propUnit,
70493
- doNotConvertValue: noConversion
70354
+ doNotConvertValue
70494
70355
  });
70495
- const initDisplayLayer = convertedValue !== "" ? { value: convertedValue, unit: initDisplayUnit } : { value: propValue, unit: propUnit };
70356
+ const { value: convertedAutoValue } = safeConvertValue({
70357
+ value: autoValue,
70358
+ toUnit: initDisplayUnit,
70359
+ unitkey,
70360
+ defaultFromUnit: propAutoUnit,
70361
+ doNotConvertValue
70362
+ });
70363
+ const initDisplayLayer = convertedValue !== "" ? { value: convertedValue, unit: initDisplayUnit } : convertedAutoValue !== "" ? { value: convertedAutoValue, unit: initDisplayUnit } : { value: propValue, unit: propUnit };
70496
70364
  const [displayLayer, setDisplayLayer] = useState(initDisplayLayer);
70497
70365
  const derivedAllowEmpty = allowEmpty || (displayLayer == null ? void 0 : displayLayer.value) === void 0;
70498
- const disableInternalErrorValidationMessages = !!disabledValidation || disabled2;
70366
+ const [predefinedOptionsMenuState, setPredefinedOptionsMenuState] = useState(
70367
+ initialPredefinedOption ? PredefinedOptionsMenuState.PREDEFINED : PredefinedOptionsMenuState.CUSTOM
70368
+ );
70369
+ const isAutoValue = propValue === "" && autoValue;
70370
+ const disableInternalErrorValidationMessages = !!(disabledValidation || autoValue || disabled2);
70371
+ const foundPredefinedMenuOption = predefinedOptions && predefinedOptions.find((el2) => {
70372
+ if (!(el2 == null ? void 0 : el2.value)) return;
70373
+ if (selectedPredefinedOptionKey) {
70374
+ return selectedPredefinedOptionKey === el2.valueKey;
70375
+ }
70376
+ const predefinedMenuItemUnit = isValueWithUnit(el2.value) ? getUnit(el2.value) : "";
70377
+ const { value: resultValue = value } = convertUnit({
70378
+ value: String(value),
70379
+ unitkey,
70380
+ toUnit: predefinedMenuItemUnit
70381
+ });
70382
+ return withUnit(resultValue, predefinedMenuItemUnit) === el2.value;
70383
+ });
70499
70384
  const getAlternativeUnits = () => {
70500
- const valueToList = value ?? "";
70501
- const initToUnit = displayLayer == null ? void 0 : displayLayer.unit;
70385
+ const valueToList = isAutoValue ? autoValue : value ?? "";
70386
+ const initToUnit = displayLayer.unit;
70502
70387
  const shouldConvert = checkConversion({
70503
70388
  value: valueToList,
70504
70389
  unitkey,
@@ -70556,7 +70441,7 @@ const UnitInput = ({
70556
70441
  toUnit: initDisplayUnit,
70557
70442
  unitkey,
70558
70443
  defaultFromUnit: propUnit,
70559
- doNotConvertValue: noConversion
70444
+ doNotConvertValue
70560
70445
  });
70561
70446
  newValue = resultValue;
70562
70447
  newUnit = initDisplayUnit;
@@ -70566,29 +70451,96 @@ const UnitInput = ({
70566
70451
  toUnit: displayLayer.unit,
70567
70452
  unitkey,
70568
70453
  defaultFromUnit: propUnit,
70569
- doNotConvertValue: noConversion
70454
+ doNotConvertValue
70570
70455
  });
70571
70456
  newValue = resultValue;
70572
70457
  newUnit = displayLayer.unit;
70573
70458
  }
70574
- if (newValue !== void 0 && !(initialPredefinedOption && !predefinedOptionLinked)) {
70459
+ if (newValue !== void 0) {
70575
70460
  setDisplayLayer({ value: newValue, unit: newUnit });
70576
70461
  }
70462
+ if (predefinedOptions) {
70463
+ if (foundPredefinedMenuOption && shouldLinkAutomaticly) {
70464
+ setPredefinedOptionsMenuState(PredefinedOptionsMenuState.PREDEFINED);
70465
+ } else {
70466
+ setPredefinedOptionsMenuState(PredefinedOptionsMenuState.CUSTOM);
70467
+ }
70468
+ }
70577
70469
  }
70578
- }, [initDisplayUnit, value, error2]);
70470
+ }, [initDisplayUnit, value, error2, shouldLinkAutomaticly]);
70579
70471
  const alternativeUnits = getAlternativeUnits();
70580
70472
  const displayUnitLabel = label$b(displayLayer.unit) || displayLayer.unit || "";
70581
70473
  const noConvert = noConversion || !alternativeUnits || alternativeUnits && alternativeUnits.length === 1;
70582
70474
  const stringName = getStringName(name2);
70475
+ let sectionsPredefinedMenu;
70476
+ const createPredefinedOption = (el2) => {
70477
+ const elementValue = (el2 == null ? void 0 : el2.value) ? el2.value : "";
70478
+ const [value2 = "", unit2 = ""] = isValueWithUnit(elementValue) ? split$1(elementValue) : [elementValue];
70479
+ return {
70480
+ type: MenuType.OPTION,
70481
+ inline: true,
70482
+ onClick: () => {
70483
+ const validation = validateNumber(value2);
70484
+ if (validation.valid && !disabled2) {
70485
+ setPredefinedOptionsMenuState(PredefinedOptionsMenuState.PREDEFINED);
70486
+ onChange({
70487
+ target: {
70488
+ value: elementValue,
70489
+ name: typeof name2 === "string" ? name2 : (name2 == null ? void 0 : name2.fieldName) || "",
70490
+ predefinedSelected: true,
70491
+ predefinedOption: el2
70492
+ }
70493
+ });
70494
+ }
70495
+ },
70496
+ label: /* @__PURE__ */ jsxs(Fragment$1, { children: [
70497
+ /* @__PURE__ */ jsx(Text, { children: el2.label }),
70498
+ /* @__PURE__ */ jsx(Spacer, { width: "20px", height: "0" })
70499
+ ] }),
70500
+ description: isValueWithUnit(elementValue) ? `${value2} ${unit2}` : elementValue,
70501
+ selected: foundPredefinedMenuOption === el2 && predefinedOptionsMenuState === PredefinedOptionsMenuState.PREDEFINED
70502
+ };
70503
+ };
70504
+ sectionsPredefinedMenu = [
70505
+ {
70506
+ type: MenuType.OPTION,
70507
+ inline: true,
70508
+ onClick: () => {
70509
+ if (predefinedOptionsMenuState !== PredefinedOptionsMenuState.CUSTOM && !disabled2) {
70510
+ onChange({
70511
+ target: {
70512
+ value: withUnit(displayLayer.value, displayLayer.unit),
70513
+ name: typeof name2 === "string" ? name2 : (name2 == null ? void 0 : name2.fieldName) || ""
70514
+ }
70515
+ });
70516
+ }
70517
+ },
70518
+ label: "Custom",
70519
+ selected: predefinedOptionsMenuState === PredefinedOptionsMenuState.CUSTOM
70520
+ }
70521
+ ];
70522
+ if (predefinedOptions == null ? void 0 : predefinedOptions.length) {
70523
+ const dynamicOptions = predefinedOptions.map(createPredefinedOption);
70524
+ sectionsPredefinedMenu = [...sectionsPredefinedMenu, ...dynamicOptions];
70525
+ }
70583
70526
  const getPlaceholder = (placeholder22) => {
70584
- if (isValueWithUnit(placeholder22)) {
70527
+ if (isAutoValue) {
70528
+ const { value: resultValue } = safeConvertValue({
70529
+ value: autoValue,
70530
+ toUnit: displayLayer.unit,
70531
+ unitkey,
70532
+ defaultFromUnit: propAutoUnit,
70533
+ doNotConvertValue
70534
+ });
70535
+ return resultValue;
70536
+ } else if (isValueWithUnit(placeholder22)) {
70585
70537
  const placeholderUnit = getUnit(placeholder22);
70586
70538
  const { value: resultValue } = safeConvertValue({
70587
70539
  value: placeholder22,
70588
70540
  toUnit: displayLayer.unit,
70589
70541
  unitkey,
70590
70542
  defaultFromUnit: placeholderUnit,
70591
- doNotConvertValue: noConversion
70543
+ doNotConvertValue
70592
70544
  });
70593
70545
  return resultValue;
70594
70546
  }
@@ -70600,44 +70552,32 @@ const UnitInput = ({
70600
70552
  className: predefinedOptionsMenuState === PredefinedOptionsMenuState.PREDEFINED ? cx$2(styles.predefinedMenuActive) : "",
70601
70553
  children: /* @__PURE__ */ jsxs(InputGroup, { small: small2, width: width2, children: [
70602
70554
  predefinedOptions && /* @__PURE__ */ jsx(
70603
- PredefinedOptionsMenu,
70555
+ Tooltip,
70604
70556
  {
70605
- testId,
70606
- unitTemplate: unitTemplate || (context2 == null ? void 0 : context2.unitTemplate),
70607
- unitkey,
70608
- predefinedOptions,
70609
- displayLayer,
70610
- onPredefinedOptionSelect: (newValue, optionState) => {
70611
- var _a2;
70612
- if (predefinedOptionLinked && ((_a2 = optionState == null ? void 0 : optionState.predefinedOption) == null ? void 0 : _a2.unit)) {
70613
- onChange({
70614
- target: {
70615
- value: withUnit(displayLayer == null ? void 0 : displayLayer.value, displayLayer == null ? void 0 : displayLayer.unit),
70616
- name: stringName,
70617
- predefinedSelected: optionState == null ? void 0 : optionState.predefinedSelected,
70618
- predefinedOption: optionState == null ? void 0 : optionState.predefinedOption
70619
- }
70620
- });
70621
- } else {
70622
- onChange({
70623
- target: {
70624
- value: newValue,
70625
- name: stringName,
70626
- predefinedSelected: optionState == null ? void 0 : optionState.predefinedSelected,
70627
- predefinedOption: optionState == null ? void 0 : optionState.predefinedOption
70628
- }
70629
- });
70630
- setDisplayLayer({
70631
- value: newValue,
70632
- unit: getUnit(newValue) || displayLayer.unit
70633
- });
70557
+ text: predefinedOptionsMenuState === PredefinedOptionsMenuState.PREDEFINED ? foundPredefinedMenuOption == null ? void 0 : foundPredefinedMenuOption.label : "",
70558
+ children: /* @__PURE__ */ jsx(
70559
+ Menu,
70560
+ {
70561
+ maxHeight: 380,
70562
+ groupOrder: "first",
70563
+ testId: testId && `${testId}-predefined-menu`,
70564
+ disabled: disabled2,
70565
+ menu: {
70566
+ colored: true,
70567
+ trigger: "Component",
70568
+ component: /* @__PURE__ */ jsx(
70569
+ Button$1,
70570
+ {
70571
+ groupOrder: "first",
70572
+ active: predefinedOptionsMenuState === PredefinedOptionsMenuState.PREDEFINED,
70573
+ icon: predefinedOptionsMenuState === PredefinedOptionsMenuState.PREDEFINED ? "link" : "unlink"
70574
+ }
70575
+ ),
70576
+ small: small2,
70577
+ sections: sectionsPredefinedMenu
70578
+ }
70634
70579
  }
70635
- },
70636
- disabled: disabled2,
70637
- initialPredefinedOption,
70638
- predefinedOptionLinked,
70639
- predefinedOptionsMenuState,
70640
- setPredefinedOptionsMenuState
70580
+ )
70641
70581
  }
70642
70582
  ),
70643
70583
  /* @__PURE__ */ jsx("div", { className: styles.inputWrapper, children: /* @__PURE__ */ jsx(
@@ -70685,7 +70625,7 @@ const UnitInput = ({
70685
70625
  inline: true,
70686
70626
  onClick: (evt) => {
70687
70627
  evt.stopPropagation();
70688
- onClickUnit(value2, altUnit);
70628
+ onClickUnit(isAutoValue ? "" : value2, altUnit);
70689
70629
  },
70690
70630
  description: displayUnit,
70691
70631
  selected: displayUnit === displayUnitLabel,
@@ -71012,6 +70952,38 @@ const SmartUploadModal = ({
71012
70952
  }
71013
70953
  ) });
71014
70954
  };
70955
+ const SettingField = ({
70956
+ helpText,
70957
+ children,
70958
+ selectedOption,
70959
+ handleSelectChange
70960
+ }) => {
70961
+ const options = [
70962
+ { label: "All users", value: "all_users" },
70963
+ { label: "Superusers and Admin only", value: "superusers_admin" }
70964
+ ];
70965
+ const onSelectChange = (event) => {
70966
+ handleSelectChange(event.target.value);
70967
+ };
70968
+ return /* @__PURE__ */ jsxs("div", { style: { position: "relative", marginBottom: "16px" }, children: [
70969
+ /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", children: [
70970
+ /* @__PURE__ */ jsx(
70971
+ Select,
70972
+ {
70973
+ name: "userType",
70974
+ options,
70975
+ value: selectedOption,
70976
+ onChange: onSelectChange,
70977
+ "aria-label": "Select user type",
70978
+ width: "auto"
70979
+ }
70980
+ ),
70981
+ children
70982
+ ] }),
70983
+ /* @__PURE__ */ jsx(Text, { muted: true, children: helpText }),
70984
+ /* @__PURE__ */ jsx(Divider, {})
70985
+ ] });
70986
+ };
71015
70987
  export {
71016
70988
  Accordion,
71017
70989
  AccordionWithDefaultToggle,
@@ -71075,6 +71047,7 @@ export {
71075
71047
  RichTextInput,
71076
71048
  Row$1 as Row,
71077
71049
  Select,
71050
+ SettingField,
71078
71051
  SideBar,
71079
71052
  Slider,
71080
71053
  SmartUploadModal,