@oliasoft-open-source/react-ui-library 4.7.2-beta-6 → 4.7.2-beta-8

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 +4 -3
  2. package/dist/index.js +18 -4
  3. package/dist/index.js.map +1 -1
  4. package/dist/storybook/assets/{Color-KGDBMAHA-BK9G9-AG.js → Color-KGDBMAHA-DlviuZHV.js} +1 -1
  5. package/dist/storybook/assets/{DocsRenderer-PKQXORMH-CusQM_Sq.js → DocsRenderer-PKQXORMH--T8weHN2.js} +1 -1
  6. package/dist/storybook/assets/{buttons-and-links-k3kswtk0.js → buttons-and-links-qaJ-_9Ao.js} +1 -1
  7. package/dist/storybook/assets/{chunk-HLWAVYOI-DM5lzE5a.js → chunk-HLWAVYOI-DBaaUqte.js} +1 -1
  8. package/dist/storybook/assets/{color-DUhEdppM.js → color-D8lo1sI7.js} +1 -1
  9. package/dist/storybook/assets/{iframe-D7Fs6VQt.js → iframe-DTq8HQN_.js} +2 -2
  10. package/dist/storybook/assets/{index-BOi4hGgT.js → index-BffEsnEA.js} +4 -4
  11. package/dist/storybook/assets/{index-wQV01InA.js → index-u5yugdxL.js} +1 -1
  12. package/dist/storybook/assets/{input-validation-DLZbF-b-.js → input-validation-DfC4m7rW.js} +1 -1
  13. package/dist/storybook/assets/{inputs-B4u-8viF.js → inputs-BiftI9DC.js} +1 -1
  14. package/dist/storybook/assets/{layout-forms-DMQXr2dA.js → layout-forms-BAIz7zgE.js} +1 -1
  15. package/dist/storybook/assets/{layout-general-D2DGppvs.js → layout-general-CWhovZnB.js} +1 -1
  16. package/dist/storybook/assets/{padding-and-spacing-CLe_yhXT.js → padding-and-spacing-BBGMEHS0.js} +1 -1
  17. package/dist/storybook/assets/{preview-C69NgT9i.js → preview-BEkR6e06.js} +2 -2
  18. package/dist/storybook/assets/{preview-gkB5ItiE.js → preview-Dc_WvvGi.js} +1 -1
  19. package/dist/storybook/assets/{unit-input.stories-BWg6005S.js → unit-input.stories-D_6ljfJQ.js} +9 -9
  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,5 +1,4 @@
1
1
  import { ChangeEvent } from 'react';
2
- import { Context } from 'react';
3
2
  import { CSSProperties } from 'react';
4
3
  import { default as default_2 } from 'react';
5
4
  import { DependencyList } from 'react';
@@ -867,7 +866,7 @@ export declare interface INativeSelectProps {
867
866
  maxTooltipWidth?: TStringOrNumber;
868
867
  }
869
868
 
870
- export declare const initializeContext: (initContext: Context<any>) => void;
869
+ export declare const initializeContext: (value: UnitContextType) => void;
871
870
 
872
871
  export declare const Input: default_2.ForwardRefExoticComponent<IInputProps & default_2.RefAttributes<HTMLInputElement>>;
873
872
 
@@ -1855,7 +1854,9 @@ export declare type TTriggerType = 'Text' | 'Button' | 'DropDownButton' | 'Compo
1855
1854
 
1856
1855
  declare type TUnitTableCellShape = TCellShape | IUnitTableStaticCell | IUnitTableInputCell | IUnitTableNumberInputCell;
1857
1856
 
1858
- 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;
1857
+ declare type UnitContextType = any;
1858
+
1859
+ export declare const UnitInput: default_2.FC<IUnitInputProps>;
1859
1860
 
1860
1861
  export declare const UnitTable: ({ table, unitConfig, convertBackToStorageUnit, enableCosmeticRounding, enableDisplayRounding, }: IUnitTableProps) => JSX_2.Element;
1861
1862
 
package/dist/index.js CHANGED
@@ -70125,16 +70125,29 @@ const isKnownUnit = (valueWithUnit, defaultUnit) => {
70125
70125
  return isUnitKnown(defaultUnit) && isUnitKnown(unitFromValue);
70126
70126
  };
70127
70127
  const UnitContext = createContext(null);
70128
- const initializeContext = (initContext) => {
70129
- if (!UnitContext.Provider) {
70130
- UnitContext.Provider = initContext.Provider;
70128
+ const UnitContextProvider = ({ children, value }) => {
70129
+ return /* @__PURE__ */ jsx(UnitContext.Provider, { value, children });
70130
+ };
70131
+ let isInitialized = false;
70132
+ let providedValue = null;
70133
+ const initializeContext = (value) => {
70134
+ if (!isInitialized) {
70135
+ providedValue = value;
70136
+ isInitialized = true;
70137
+ }
70138
+ };
70139
+ const WithUnitContext = (Component2) => (props) => {
70140
+ if (!isInitialized) {
70141
+ console.log("Context not initialized. Call initializeContext first.");
70142
+ return /* @__PURE__ */ jsx(Component2, { ...props });
70131
70143
  }
70144
+ return /* @__PURE__ */ jsx(UnitContextProvider, { value: providedValue, children: /* @__PURE__ */ jsx(Component2, { ...props }) });
70132
70145
  };
70133
70146
  const predefinedMenuActive = "_predefinedMenuActive_1yvt4_1";
70134
70147
  const styles = {
70135
70148
  predefinedMenuActive
70136
70149
  };
70137
- const UnitInput = ({
70150
+ const UnitInputComponent = ({
70138
70151
  name: name2,
70139
70152
  placeholder: placeholder3 = "",
70140
70153
  disabled: disabled2 = false,
@@ -70456,6 +70469,7 @@ const UnitInput = ({
70456
70469
  }
70457
70470
  );
70458
70471
  };
70472
+ const UnitInput = WithUnitContext(UnitInputComponent);
70459
70473
  const normalizeUnits = (unitConfig) => unitConfig.reduce(
70460
70474
  ({ preferredUnits, storageUnits }, { unitKey, preferredUnit, storageUnit }) => {
70461
70475
  preferredUnits[unitKey] = preferredUnit;