@oliasoft-open-source/react-ui-library 4.7.3-beta-3 → 4.7.3-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.
Files changed (22) hide show
  1. package/dist/index.d.ts +3 -2
  2. package/dist/index.js +9 -28
  3. package/dist/index.js.map +1 -1
  4. package/dist/storybook/assets/{Color-KGDBMAHA-Ck2diywb.js → Color-KGDBMAHA-NxfrngWu.js} +1 -1
  5. package/dist/storybook/assets/{DocsRenderer-PKQXORMH-CO2Q7pkj.js → DocsRenderer-PKQXORMH-BKwgpZes.js} +1 -1
  6. package/dist/storybook/assets/{buttons-and-links-DsIYBu4t.js → buttons-and-links-zoC7TwzM.js} +1 -1
  7. package/dist/storybook/assets/{chunk-HLWAVYOI-CtLnxQiQ.js → chunk-HLWAVYOI-b3gM-xPN.js} +1 -1
  8. package/dist/storybook/assets/{color-Cm4zop4f.js → color-Byg8B_-G.js} +1 -1
  9. package/dist/storybook/assets/{iframe-BRbyeatW.js → iframe-9dtcUGvc.js} +2 -2
  10. package/dist/storybook/assets/{index-BuBRmFoY.js → index-C6MDeJbG.js} +4 -4
  11. package/dist/storybook/assets/{index-DknIsB0y.js → index-DQOq-Hor.js} +1 -1
  12. package/dist/storybook/assets/{input-validation-DHXUjjTW.js → input-validation-Cjzh-uP9.js} +1 -1
  13. package/dist/storybook/assets/{inputs-DOBN-gBG.js → inputs-Clw9Zn9N.js} +1 -1
  14. package/dist/storybook/assets/{layout-forms-CWJU-MMJ.js → layout-forms-BPAdD5VV.js} +1 -1
  15. package/dist/storybook/assets/{layout-general-DIKhH47g.js → layout-general-C7ibgLmy.js} +1 -1
  16. package/dist/storybook/assets/{padding-and-spacing-2bE7HUNT.js → padding-and-spacing-D7cLnhaP.js} +1 -1
  17. package/dist/storybook/assets/{preview-DP1caVnC.js → preview-Da45f8XP.js} +2 -2
  18. package/dist/storybook/assets/{preview-C7oeNNbC.js → preview-xNOOrD8N.js} +1 -1
  19. package/dist/storybook/assets/{unit-input.stories-BaU6h22E.js → unit-input.stories-DsvikA1H.js} +24 -24
  20. package/dist/storybook/iframe.html +1 -1
  21. package/dist/storybook/project.json +1 -1
  22. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ChangeEvent } from 'react';
2
+ import { Context } from 'react';
2
3
  import { CSSProperties } from 'react';
3
4
  import { default as default_2 } from 'react';
4
5
  import { DependencyList } from 'react';
@@ -866,7 +867,7 @@ export declare interface INativeSelectProps {
866
867
  maxTooltipWidth?: TStringOrNumber;
867
868
  }
868
869
 
869
- export declare const initializeContext: (value: UnitContextType) => void;
870
+ export declare const initializeContext: (context: Context<UnitContextType | null>) => void;
870
871
 
871
872
  export declare const Input: default_2.ForwardRefExoticComponent<IInputProps & default_2.RefAttributes<HTMLInputElement>>;
872
873
 
@@ -1856,7 +1857,7 @@ declare type TUnitTableCellShape = TCellShape | IUnitTableStaticCell | IUnitTabl
1856
1857
 
1857
1858
  declare type UnitContextType = any;
1858
1859
 
1859
- export declare const UnitInput: default_2.FC<IUnitInputProps>;
1860
+ 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, }: IUnitInputProps) => JSX_2.Element;
1860
1861
 
1861
1862
  export declare const UnitTable: ({ table, unitConfig, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, }: IUnitTableProps) => JSX_2.Element;
1862
1863
 
package/dist/index.js CHANGED
@@ -70127,33 +70127,22 @@ const isKnownUnit = (valueWithUnit, defaultUnit) => {
70127
70127
  const unitFromValue = getUnit(valueWithUnit || "");
70128
70128
  return isUnitKnown(defaultUnit) && isUnitKnown(unitFromValue);
70129
70129
  };
70130
- const UnitContext = createContext(null);
70131
- const UnitContextProvider = ({ children, value }) => {
70132
- return /* @__PURE__ */ jsx(UnitContext.Provider, { value, children });
70133
- };
70130
+ let UnitContext = createContext(null);
70134
70131
  const useUnitContext = () => {
70135
70132
  return useContext(UnitContext);
70136
70133
  };
70137
70134
  let isInitialized = false;
70138
- let providedValue = null;
70139
- const initializeContext = (value) => {
70135
+ const initializeContext = (context2) => {
70140
70136
  if (!isInitialized) {
70141
- providedValue = value;
70142
70137
  isInitialized = true;
70138
+ UnitContext = context2;
70143
70139
  }
70144
70140
  };
70145
- const WithUnitContext = (Component2) => (props) => {
70146
- if (!isInitialized) {
70147
- console.log("Context not initialized. Call initializeContext first.");
70148
- return /* @__PURE__ */ jsx(Component2, { ...props });
70149
- }
70150
- return /* @__PURE__ */ jsx(UnitContextProvider, { value: providedValue, children: /* @__PURE__ */ jsx(Component2, { ...props }) });
70151
- };
70152
70141
  const predefinedMenuActive = "_predefinedMenuActive_1yvt4_1";
70153
70142
  const styles = {
70154
70143
  predefinedMenuActive
70155
70144
  };
70156
- const UnitInputComponent = ({
70145
+ const UnitInput = ({
70157
70146
  name: name2,
70158
70147
  placeholder: placeholder3 = "",
70159
70148
  disabled: disabled2 = false,
@@ -70174,7 +70163,7 @@ const UnitInputComponent = ({
70174
70163
  },
70175
70164
  onSwitchUnit = () => {
70176
70165
  },
70177
- unitTemplate: externalUnitTemplate,
70166
+ unitTemplate,
70178
70167
  doNotConvertValue = false,
70179
70168
  testId,
70180
70169
  warning: warning2 = null,
@@ -70187,24 +70176,17 @@ const UnitInputComponent = ({
70187
70176
  allowEmpty = false,
70188
70177
  autoValue
70189
70178
  }) => {
70190
- const context2 = useUnitContext();
70191
- const unitTemplate = externalUnitTemplate ?? (context2 == null ? void 0 : context2.unitTemplate);
70192
- const [currentUnitTemplate, setCurrentUnitTemplate] = useState(unitTemplate);
70193
- console.log("currentUnitTemplate ->>>>", currentUnitTemplate);
70194
- useEffect(() => {
70195
- if (unitTemplate) {
70196
- setCurrentUnitTemplate(unitTemplate);
70197
- }
70198
- }, [unitTemplate]);
70199
70179
  if (typeof value === "number") {
70200
70180
  value = `${value}`;
70201
70181
  }
70182
+ const context2 = useUnitContext();
70183
+ console.log("context in component ->>>>", context2, context2 == null ? void 0 : context2.unitTemplate);
70202
70184
  const runAfterUpdate = useRunAfterUpdate();
70203
70185
  const [propValue = "", propUnit = ""] = value !== void 0 ? split$1(value) : [];
70204
70186
  const propAutoUnit = autoValue ? getUnit(autoValue) : "";
70205
70187
  const defaultUnit = useMemo$1(
70206
- () => getPreferredUnit(unitkey, currentUnitTemplate),
70207
- [unitkey, currentUnitTemplate]
70188
+ () => getPreferredUnit(unitkey, unitTemplate),
70189
+ [unitkey, unitTemplate]
70208
70190
  );
70209
70191
  const knownUnit = isKnownUnit(value, defaultUnit);
70210
70192
  const initDisplayUnit = initUnit || propUnit || defaultUnit;
@@ -70482,7 +70464,6 @@ const UnitInputComponent = ({
70482
70464
  }
70483
70465
  );
70484
70466
  };
70485
- const UnitInput = WithUnitContext(UnitInputComponent);
70486
70467
  const normalizeUnits = (unitConfig) => unitConfig.reduce(
70487
70468
  ({ preferredUnits, storageUnits }, { unitKey, preferredUnit, storageUnit }) => {
70488
70469
  preferredUnits[unitKey] = preferredUnit;