react-asc 24.0.0 → 25.0.2

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.
@@ -5,8 +5,8 @@ export interface IButtonProps extends React.ComponentProps<'button'> {
5
5
  isActive?: boolean;
6
6
  isRounded?: boolean;
7
7
  variant?: VARIANT;
8
- startIcon?: React.SVGProps<SVGSVGElement>;
9
- endIcon?: React.SVGProps<SVGSVGElement>;
8
+ startIcon?: React.ReactNode;
9
+ endIcon?: React.ReactNode;
10
10
  shadow?: boolean;
11
11
  block?: boolean;
12
12
  }
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { COLOR, SIZE } from '../component.enums';
3
3
  export interface IFloatingActionButtonProps extends React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> {
4
- icon?: React.SVGProps<SVGSVGElement>;
4
+ icon?: React.ReactNode;
5
5
  color?: COLOR;
6
6
  size?: SIZE;
7
7
  fixed?: boolean;
@@ -1 +1 @@
1
- export declare const MaxValidator: (valueA: number, valueB: number) => boolean;
1
+ export declare const MaxValidator: (val: string, valueB: number) => boolean;
@@ -1 +1 @@
1
- export declare const MinValidator: (valueA: number, valueB: number) => boolean;
1
+ export declare const MinValidator: (val: string, minLength: number) => boolean;
@@ -1,6 +1,7 @@
1
- import { ComponentProps } from 'react';
1
+ import React, { ComponentProps } from 'react';
2
2
  import { COLOR } from '../component.enums';
3
3
  export interface IIconProps extends ComponentProps<'div'> {
4
4
  iconColor?: COLOR;
5
+ children?: React.ReactNode;
5
6
  }
6
7
  export declare const Icon: (props: IIconProps) => JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { COLOR, SIZE, VARIANT } from '../component.enums';
3
3
  export interface IIconButtonProps extends React.ComponentProps<'button'> {
4
- icon?: React.SVGProps<SVGSVGElement>;
4
+ icon?: React.ReactNode;
5
5
  color?: COLOR;
6
6
  size?: SIZE;
7
7
  isActive?: boolean;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  interface IListItemAvatarProps extends React.ComponentProps<'div'> {
3
- avatar: React.SVGProps<SVGSVGElement> | React.ImgHTMLAttributes<HTMLImageElement>;
3
+ avatar: React.ReactNode;
4
4
  }
5
5
  export declare const ListItemAvatar: ({ avatar, ...rest }: IListItemAvatarProps) => JSX.Element;
6
6
  export {};
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  interface IListItemIconProps extends React.ComponentProps<'div'> {
3
- icon: React.SVGProps<SVGSVGElement>;
3
+ icon: React.ReactNode;
4
4
  }
5
5
  export declare const ListItemIcon: ({ icon, ...rest }: IListItemIconProps) => JSX.Element;
6
6
  export {};
@@ -4,6 +4,7 @@ export interface ILoadingIndicatorService {
4
4
  declare class LoadingIndicatorService implements ILoadingIndicatorService {
5
5
  private container;
6
6
  private handler;
7
+ private root;
7
8
  show(): void;
8
9
  hide(): void;
9
10
  }
@@ -11,13 +11,11 @@ export interface IModalOptions {
11
11
  fullScreen?: boolean;
12
12
  size?: SIZE;
13
13
  }
14
- export interface IModalFormOptions extends IModalOptions {
15
- formControls?: IControls;
16
- }
17
14
  declare class ModalService implements IModalService {
18
15
  private container;
16
+ private root;
19
17
  show(title: string, description: string | ReactElement, options?: IModalOptions): Promise<void>;
20
- showForm<T>(title: string, options?: IModalFormOptions): Promise<T>;
18
+ showForm<T>(title: string, formControls: IControls, options?: IModalOptions): Promise<T>;
21
19
  private hide;
22
20
  }
23
21
  export declare const modalService: ModalService;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { COLOR } from '../component.enums';
3
3
  export interface ISnackbarService {
4
- show(message: React.ReactChildren | string, options?: ISnackbarOptions): Promise<void>;
4
+ show(message: React.ReactNode | string, options?: ISnackbarOptions): Promise<void>;
5
5
  }
6
6
  export interface ISnackbarOptions {
7
7
  actionText?: string;
@@ -12,7 +12,8 @@ export interface ISnackbarOptions {
12
12
  declare class SnackbarService implements ISnackbarService {
13
13
  private container;
14
14
  private handler;
15
- show(message: React.ReactChildren | string, options?: ISnackbarOptions): Promise<void>;
15
+ private root;
16
+ show(message: React.ReactNode | string, options?: ISnackbarOptions): Promise<void>;
16
17
  private hide;
17
18
  }
18
19
  export declare const snackbarService: SnackbarService;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { COLOR } from '../component.enums';
3
3
  export interface ISpeedDialActionProps extends React.DetailedHTMLProps<React.HtmlHTMLAttributes<HTMLDivElement>, HTMLDivElement> {
4
- icon: React.SVGProps<SVGSVGElement>;
4
+ icon: React.ReactNode;
5
5
  tooltipTitle?: string;
6
6
  color?: COLOR;
7
7
  onClick?: (e: React.MouseEvent) => void;
@@ -2,8 +2,6 @@ import React, { ReactNode } from 'react';
2
2
  export interface ITabProps {
3
3
  label: ReactNode;
4
4
  value: string;
5
- isActive?: boolean;
6
- fixed?: boolean;
7
5
  disabled?: boolean;
8
6
  className?: string;
9
7
  onClick?: (e: {
@@ -0,0 +1,8 @@
1
+ import { Dispatch } from 'react';
2
+ export interface ITabsContext {
3
+ fixed: boolean;
4
+ selectedValue: string;
5
+ setSelectedValue: Dispatch<string>;
6
+ }
7
+ export declare const TabContext: import("react").Context<ITabsContext>;
8
+ export declare const useTabContext: () => ITabsContext;
@@ -1,17 +1,13 @@
1
- import React, { ReactElement } from 'react';
1
+ import { ReactElement } from 'react';
2
2
  import { COLOR } from '../component.enums';
3
3
  import { ITabProps } from './Tab';
4
- export interface ITabOnChangeEvent {
5
- event: React.MouseEvent;
6
- newValue: string;
7
- }
8
4
  export interface ITabsProps {
9
5
  color?: COLOR;
10
6
  indicatorColor?: COLOR;
11
7
  children?: ReactElement<ITabProps> | Array<ReactElement<ITabProps>>;
12
8
  className?: string;
13
9
  fixed?: boolean;
14
- onChange?: (e: ITabOnChangeEvent) => void;
10
+ onChange?: (value: string) => void;
15
11
  value?: string;
16
12
  }
17
13
  export declare const Tabs: (props: ITabsProps) => JSX.Element;
package/index.es.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import React, { useRef, useEffect, useState, useMemo, createContext, useContext, Fragment, Component, createRef, cloneElement } from 'react';
2
- import { createPortal, render, unmountComponentAtNode } from 'react-dom';
2
+ import reactDom, { createPortal } from 'react-dom';
3
3
  import { createPopper } from '@popperjs/core';
4
4
 
5
- /*! *****************************************************************************
5
+ /******************************************************************************
6
6
  Copyright (c) Microsoft Corporation.
7
7
 
8
8
  Permission to use, copy, modify, and/or distribute this software for any
@@ -1233,9 +1233,9 @@ const EmailValidator = (value) => {
1233
1233
 
1234
1234
  const IsEqualValidator = (valueA, valueB) => valueA === valueB;
1235
1235
 
1236
- const MaxValidator = (valueA, valueB) => valueA <= valueB;
1236
+ const MaxValidator = (val, valueB) => val.length <= valueB;
1237
1237
 
1238
- const MinValidator = (valueA, valueB) => valueA >= valueB;
1238
+ const MinValidator = (val, minLength) => val.length >= minLength;
1239
1239
 
1240
1240
  // values, isSubmitting, handleChange, handleBlur, handleSubmit
1241
1241
  class Form extends Component {
@@ -1288,12 +1288,12 @@ class Form extends Component {
1288
1288
  break;
1289
1289
  case 'min':
1290
1290
  if (!MinValidator(fieldValue, parseInt(validatorParam))) {
1291
- errors.push({ validator: validatorName, message: `Number is less than ${validatorParam}` });
1291
+ errors.push({ validator: validatorName, message: `Minimum number of ${validatorParam} characters not met` });
1292
1292
  }
1293
1293
  break;
1294
1294
  case 'max':
1295
1295
  if (!MaxValidator(fieldValue, parseInt(validatorParam))) {
1296
- errors.push({ validator: validatorName, message: `Number is greater than ${validatorParam}` });
1296
+ errors.push({ validator: validatorName, message: `Maximum number of ${validatorParam} characters exceeded` });
1297
1297
  }
1298
1298
  break;
1299
1299
  case 'match':
@@ -1793,6 +1793,39 @@ const LoadingIndicatorContainer = ({ children, isFixed }) => {
1793
1793
  return (React.createElement("div", { className: getCssClasses() }, children));
1794
1794
  };
1795
1795
 
1796
+ function createCommonjsModule(fn, module) {
1797
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
1798
+ }
1799
+
1800
+ var client = createCommonjsModule(function (module, exports) {
1801
+
1802
+
1803
+ if (process.env.NODE_ENV === 'production') {
1804
+ exports.createRoot = reactDom.createRoot;
1805
+ exports.hydrateRoot = reactDom.hydrateRoot;
1806
+ } else {
1807
+ var i = reactDom.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
1808
+ exports.createRoot = function(c, o) {
1809
+ i.usingClientEntryPoint = true;
1810
+ try {
1811
+ return reactDom.createRoot(c, o);
1812
+ } finally {
1813
+ i.usingClientEntryPoint = false;
1814
+ }
1815
+ };
1816
+ exports.hydrateRoot = function(c, h, o) {
1817
+ i.usingClientEntryPoint = true;
1818
+ try {
1819
+ return reactDom.hydrateRoot(c, h, o);
1820
+ } finally {
1821
+ i.usingClientEntryPoint = false;
1822
+ }
1823
+ };
1824
+ }
1825
+ });
1826
+ var client_1 = client.createRoot;
1827
+ client.hydrateRoot;
1828
+
1796
1829
  class LoadingIndicatorService {
1797
1830
  show() {
1798
1831
  if (this.container) {
@@ -1801,12 +1834,14 @@ class LoadingIndicatorService {
1801
1834
  this.container = document.createElement('div');
1802
1835
  this.container.classList.add('snackbar-container');
1803
1836
  document.body.appendChild(this.container);
1804
- render(React.createElement(LoadingIndicatorContainer, { isFixed: true },
1805
- React.createElement(LoadingIndicator, null)), this.container);
1837
+ this.root = client_1(this.container);
1838
+ this.root.render(React.createElement(LoadingIndicatorContainer, { isFixed: true },
1839
+ React.createElement(LoadingIndicator, null)));
1806
1840
  }
1807
1841
  hide() {
1842
+ var _a;
1808
1843
  if (this.container) {
1809
- unmountComponentAtNode(this.container);
1844
+ (_a = this.root) === null || _a === void 0 ? void 0 : _a.unmount();
1810
1845
  document.body.removeChild(this.container);
1811
1846
  this.container = undefined;
1812
1847
  this.handler && clearTimeout(this.handler);
@@ -1879,7 +1914,6 @@ const Modal = (props) => {
1879
1914
  React.createElement(Backdrop, { onClick: handleClickBackdrop })));
1880
1915
  };
1881
1916
 
1882
- // export enum MODALRESULT { OK = 'OK', CANCEL = 'CANCEL', DELETE = 'DELETE' }
1883
1917
  var MODALTYPE;
1884
1918
  (function (MODALTYPE) {
1885
1919
  MODALTYPE["BASIC"] = "BASIC";
@@ -1934,10 +1968,10 @@ const GlobalModal = ({ title, description, formControls, onOk, onChange, onCance
1934
1968
  }
1935
1969
  button.handler && button.handler();
1936
1970
  };
1937
- return (React.createElement(Modal, { size: size, fullScreen: fullScreen, header: title, onHeaderCloseClick: onCancel, onBackdropClick: onBackdropClick, isDismissable: isDismissable, footer: React.createElement(Fragment, null, buttons.map((button, index) => (React.createElement(Button, { key: index, variant: button.variant, color: button.color, autoFocus: button.autoFocus, shadow: button.shadow, onClick: () => handleClickButton(button) }, button.label)))) },
1971
+ return (React.createElement(Modal, { size: size, fullScreen: fullScreen, header: title, onHeaderCloseClick: onCancel, onBackdropClick: onBackdropClick, isDismissable: isDismissable, footer: React.createElement(React.Fragment, null, buttons.map((button, index) => (React.createElement(Button, { key: index, variant: button.variant, color: button.color, autoFocus: button.autoFocus, shadow: button.shadow, onClick: () => handleClickButton(button) }, button.label)))) },
1938
1972
  description && React.createElement("div", null, description),
1939
1973
  modalType === MODALTYPE.FORM &&
1940
- React.createElement(Fragment, null,
1974
+ React.createElement(React.Fragment, null,
1941
1975
  React.createElement(Form, { ref: myForm, controls: myControls, validateOnBlur: true, onSubmit: onSubmit, onChange: onChange }))));
1942
1976
  };
1943
1977
 
@@ -1955,35 +1989,38 @@ class ModalService {
1955
1989
  reject();
1956
1990
  this.hide();
1957
1991
  };
1958
- render(React.createElement(GlobalModal, { fullScreen: options && options.fullScreen, size: options && options.size, title: title, description: description, onCancel: handleCancel, onBackdropClick: handleCancel, onOk: handleOk, isDismissable: options && options.isDismissable, buttons: options && options.buttons }), this.container);
1992
+ this.root = client_1(this.container);
1993
+ this.root.render(React.createElement(GlobalModal, { fullScreen: options && options.fullScreen, size: options && options.size, title: title, description: description, onCancel: handleCancel, onBackdropClick: handleCancel, onOk: handleOk, isDismissable: options && options.isDismissable, buttons: options && options.buttons }));
1959
1994
  }
1960
1995
  });
1961
1996
  }
1962
- showForm(title, options) {
1997
+ showForm(title, formControls, options) {
1963
1998
  return new Promise((resolve, reject) => {
1964
1999
  if (!this.container) {
1965
2000
  this.container = document.createElement('div');
1966
- document.body.appendChild(this.container);
2001
+ this.container.classList.add('modal-container');
1967
2002
  const handleOk = (values) => {
1968
2003
  resolve(values);
1969
2004
  this.hide();
1970
2005
  };
1971
2006
  // TODO - for AutoComplete
1972
- const handleOnChange = (values) => {
1973
- console.info(values);
1974
- };
2007
+ // const handleOnChange = (values?: IFormValues) => {
2008
+ // console.info(values);
2009
+ // }
1975
2010
  const handleCancel = () => {
1976
2011
  reject();
1977
2012
  this.hide();
1978
2013
  };
1979
- render(React.createElement(GlobalModal, { fullScreen: options && options.fullScreen, size: options && options.size, title: title, formControls: options && options.formControls, onCancel: handleCancel, onBackdropClick: handleCancel, onOk: handleOk, onChange: handleOnChange, isDismissable: options && options.isDismissable, buttons: options && options.buttons }), this.container);
2014
+ this.root = client_1(this.container);
2015
+ this.root.render(React.createElement(GlobalModal, { fullScreen: options && options.fullScreen, size: options && options.size, title: title, formControls: formControls, onCancel: handleCancel, onBackdropClick: handleCancel, onOk: handleOk, isDismissable: options && options.isDismissable, buttons: options && options.buttons }));
1980
2016
  }
1981
2017
  });
1982
2018
  }
1983
2019
  hide() {
2020
+ var _a;
1984
2021
  if (this.container) {
1985
- unmountComponentAtNode(this.container);
1986
- document.body.removeChild(this.container);
2022
+ (_a = this.root) === null || _a === void 0 ? void 0 : _a.unmount();
2023
+ // document.body.removeChild(this.container);
1987
2024
  this.container = undefined;
1988
2025
  }
1989
2026
  }
@@ -2219,12 +2256,14 @@ class SnackbarService {
2219
2256
  resolve();
2220
2257
  this.hide();
2221
2258
  };
2222
- render(React.createElement(Snackbar, { color: mergedOptions.color, actionText: mergedOptions.actionText, onOk: handleOk }, message), this.container);
2259
+ this.root = client_1(this.container);
2260
+ this.root.render(React.createElement(Snackbar, { color: mergedOptions.color, actionText: mergedOptions.actionText, onOk: handleOk }, message));
2223
2261
  });
2224
2262
  }
2225
2263
  hide() {
2264
+ var _a;
2226
2265
  if (this.container) {
2227
- unmountComponentAtNode(this.container);
2266
+ (_a = this.root) === null || _a === void 0 ? void 0 : _a.unmount();
2228
2267
  document.body.removeChild(this.container);
2229
2268
  this.container = undefined;
2230
2269
  this.handler && clearTimeout(this.handler);
@@ -2625,6 +2664,13 @@ const TableCell = (props) => {
2625
2664
  React.createElement("td", Object.assign({}, rest), children)) }, children));
2626
2665
  };
2627
2666
 
2667
+ const TabContext = createContext({
2668
+ fixed: false,
2669
+ selectedValue: '',
2670
+ setSelectedValue: () => { }
2671
+ });
2672
+ const useTabContext = () => useContext(TabContext);
2673
+
2628
2674
  var css_248z$4 = ".TabIndicator-module_tabIndicator__jSJhH {\n bottom: 0;\n height: 2px;\n position: absolute;\n transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\n}\n.TabIndicator-module_tabIndicator__jSJhH.TabIndicator-module_primary__Q5jEo {\n background-color: var(--primary);\n}\n.TabIndicator-module_tabIndicator__jSJhH.TabIndicator-module_accent__qbgIG {\n background-color: var(--accent);\n}";
2629
2675
  var styles$4 = {"tabIndicator":"TabIndicator-module_tabIndicator__jSJhH","primary":"TabIndicator-module_primary__Q5jEo","accent":"TabIndicator-module_accent__qbgIG"};
2630
2676
  styleInject(css_248z$4);
@@ -2648,40 +2694,41 @@ var styles$3 = {"tabs":"Tabs-module_tabs__YyRTZ"};
2648
2694
  styleInject(css_248z$3);
2649
2695
 
2650
2696
  const Tabs = (props) => {
2651
- const { children, className, fixed, color, indicatorColor, onChange, value } = props;
2652
- const [selectedValue, setSelectedValue] = useState(value);
2653
- const [selectedIndex, setSelectedIndex] = useState();
2697
+ const { children, className, fixed = false, color, indicatorColor = COLOR.accent, value, onChange } = props;
2698
+ const [selectedValue, setSelectedValue] = useState('');
2699
+ const [selectedIndex, setSelectedIndex] = useState(0);
2700
+ const tabContext = ({
2701
+ selectedValue,
2702
+ setSelectedValue,
2703
+ fixed
2704
+ });
2705
+ const prevSelectedValueRef = useRef();
2706
+ useEffect(() => {
2707
+ // TODO - check if prev needs to be set
2708
+ if (value !== undefined && value !== prevSelectedValueRef.current) {
2709
+ setSelectedValue(value);
2710
+ }
2711
+ }, [value]);
2654
2712
  useEffect(() => {
2655
2713
  React.Children.toArray(children).forEach((child, index) => {
2656
- if (child.props.value === value) {
2714
+ if (child.props.value === selectedValue) {
2657
2715
  setSelectedIndex(index);
2716
+ onChange && onChange(selectedValue);
2658
2717
  }
2659
2718
  });
2660
- }, [children, value]);
2719
+ }, [children, selectedValue]);
2661
2720
  const getCssClasses = () => {
2662
2721
  const cssClasses = [];
2663
2722
  cssClasses.push(styles$3.tabs);
2664
2723
  className && cssClasses.push(className);
2665
2724
  return cssClasses.filter(css => css).join(' ');
2666
2725
  };
2667
- const handleClickTab = (event, newValue, index) => {
2668
- setSelectedValue(newValue);
2669
- setSelectedIndex(index);
2670
- onChange && onChange({ event, newValue });
2671
- };
2672
- const renderTabs = (child, index) => {
2673
- return React.isValidElement(child) && cloneElement(child, {
2674
- key: child.props.value,
2675
- isActive: child.props.value === selectedValue,
2676
- fixed: fixed,
2677
- onClick: (e) => handleClickTab(e.event, e.value, index),
2678
- });
2679
- };
2680
2726
  return (React.createElement(ButtonContext.Provider, { value: { color: color || COLOR.light } },
2681
- React.createElement("div", { className: getCssClasses() },
2682
- children && React.Children.toArray(children).map((child, index) => renderTabs(child, index)),
2683
- children &&
2684
- React.createElement(TabIndicator, { color: indicatorColor, width: (100 / React.Children.toArray(children).length) + '%', index: selectedIndex, amount: React.Children.toArray(children).length }))));
2727
+ React.createElement(TabContext.Provider, { value: tabContext },
2728
+ React.createElement("div", { className: getCssClasses() },
2729
+ children,
2730
+ children &&
2731
+ React.createElement(TabIndicator, { color: indicatorColor, width: (100 / React.Children.toArray(children).length) + '%', index: selectedIndex, amount: React.Children.toArray(children).length })))));
2685
2732
  };
2686
2733
 
2687
2734
  var css_248z$2 = ".Tab-module_tab__Q8w1f {\n padding: 6px 12px;\n overflow: hidden;\n position: relative;\n font-size: 0.875rem;\n min-width: 72px;\n box-sizing: border-box;\n min-height: 48px;\n text-align: center;\n font-weight: 500;\n line-height: 1.75;\n white-space: normal;\n letter-spacing: 0.02857em;\n text-transform: uppercase;\n border-radius: 0;\n flex-grow: 1;\n flex-basis: 0;\n transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\n}";
@@ -2689,17 +2736,19 @@ var styles$2 = {"tab":"Tab-module_tab__Q8w1f"};
2689
2736
  styleInject(css_248z$2);
2690
2737
 
2691
2738
  const Tab = (props) => {
2692
- const { label, className, isActive, disabled, value, onClick } = props;
2739
+ const { label, className, disabled, value, onClick } = props;
2740
+ const { selectedValue, setSelectedValue } = useTabContext();
2693
2741
  const getCssClasses = () => {
2694
2742
  const cssClasses = [];
2695
2743
  cssClasses.push(styles$2.tab);
2696
- if (isActive) {
2697
- cssClasses.push(`show active`);
2698
- }
2699
2744
  className && cssClasses.push(className);
2700
2745
  return cssClasses.filter(css => css).join(' ');
2701
2746
  };
2702
- return (React.createElement(Button, { className: getCssClasses(), onClick: (event) => onClick && onClick({ event, value }), isActive: isActive, disabled: disabled }, label));
2747
+ const handleClick = (event) => {
2748
+ onClick && onClick({ event, value });
2749
+ setSelectedValue(value);
2750
+ };
2751
+ return (React.createElement(Button, { className: getCssClasses(), onClick: handleClick, isActive: selectedValue === value, disabled: disabled }, label));
2703
2752
  };
2704
2753
 
2705
2754
  const TabPanel = (props) => {
package/index.js CHANGED
@@ -9,8 +9,9 @@ var core = require('@popperjs/core');
9
9
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
10
 
11
11
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
12
+ var reactDom__default = /*#__PURE__*/_interopDefaultLegacy(reactDom);
12
13
 
13
- /*! *****************************************************************************
14
+ /******************************************************************************
14
15
  Copyright (c) Microsoft Corporation.
15
16
 
16
17
  Permission to use, copy, modify, and/or distribute this software for any
@@ -1241,9 +1242,9 @@ const EmailValidator = (value) => {
1241
1242
 
1242
1243
  const IsEqualValidator = (valueA, valueB) => valueA === valueB;
1243
1244
 
1244
- const MaxValidator = (valueA, valueB) => valueA <= valueB;
1245
+ const MaxValidator = (val, valueB) => val.length <= valueB;
1245
1246
 
1246
- const MinValidator = (valueA, valueB) => valueA >= valueB;
1247
+ const MinValidator = (val, minLength) => val.length >= minLength;
1247
1248
 
1248
1249
  // values, isSubmitting, handleChange, handleBlur, handleSubmit
1249
1250
  class Form extends React.Component {
@@ -1296,12 +1297,12 @@ class Form extends React.Component {
1296
1297
  break;
1297
1298
  case 'min':
1298
1299
  if (!MinValidator(fieldValue, parseInt(validatorParam))) {
1299
- errors.push({ validator: validatorName, message: `Number is less than ${validatorParam}` });
1300
+ errors.push({ validator: validatorName, message: `Minimum number of ${validatorParam} characters not met` });
1300
1301
  }
1301
1302
  break;
1302
1303
  case 'max':
1303
1304
  if (!MaxValidator(fieldValue, parseInt(validatorParam))) {
1304
- errors.push({ validator: validatorName, message: `Number is greater than ${validatorParam}` });
1305
+ errors.push({ validator: validatorName, message: `Maximum number of ${validatorParam} characters exceeded` });
1305
1306
  }
1306
1307
  break;
1307
1308
  case 'match':
@@ -1801,6 +1802,39 @@ const LoadingIndicatorContainer = ({ children, isFixed }) => {
1801
1802
  return (React__default["default"].createElement("div", { className: getCssClasses() }, children));
1802
1803
  };
1803
1804
 
1805
+ function createCommonjsModule(fn, module) {
1806
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
1807
+ }
1808
+
1809
+ var client = createCommonjsModule(function (module, exports) {
1810
+
1811
+
1812
+ if (process.env.NODE_ENV === 'production') {
1813
+ exports.createRoot = reactDom__default["default"].createRoot;
1814
+ exports.hydrateRoot = reactDom__default["default"].hydrateRoot;
1815
+ } else {
1816
+ var i = reactDom__default["default"].__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
1817
+ exports.createRoot = function(c, o) {
1818
+ i.usingClientEntryPoint = true;
1819
+ try {
1820
+ return reactDom__default["default"].createRoot(c, o);
1821
+ } finally {
1822
+ i.usingClientEntryPoint = false;
1823
+ }
1824
+ };
1825
+ exports.hydrateRoot = function(c, h, o) {
1826
+ i.usingClientEntryPoint = true;
1827
+ try {
1828
+ return reactDom__default["default"].hydrateRoot(c, h, o);
1829
+ } finally {
1830
+ i.usingClientEntryPoint = false;
1831
+ }
1832
+ };
1833
+ }
1834
+ });
1835
+ var client_1 = client.createRoot;
1836
+ client.hydrateRoot;
1837
+
1804
1838
  class LoadingIndicatorService {
1805
1839
  show() {
1806
1840
  if (this.container) {
@@ -1809,12 +1843,14 @@ class LoadingIndicatorService {
1809
1843
  this.container = document.createElement('div');
1810
1844
  this.container.classList.add('snackbar-container');
1811
1845
  document.body.appendChild(this.container);
1812
- reactDom.render(React__default["default"].createElement(LoadingIndicatorContainer, { isFixed: true },
1813
- React__default["default"].createElement(LoadingIndicator, null)), this.container);
1846
+ this.root = client_1(this.container);
1847
+ this.root.render(React__default["default"].createElement(LoadingIndicatorContainer, { isFixed: true },
1848
+ React__default["default"].createElement(LoadingIndicator, null)));
1814
1849
  }
1815
1850
  hide() {
1851
+ var _a;
1816
1852
  if (this.container) {
1817
- reactDom.unmountComponentAtNode(this.container);
1853
+ (_a = this.root) === null || _a === void 0 ? void 0 : _a.unmount();
1818
1854
  document.body.removeChild(this.container);
1819
1855
  this.container = undefined;
1820
1856
  this.handler && clearTimeout(this.handler);
@@ -1887,7 +1923,6 @@ const Modal = (props) => {
1887
1923
  React__default["default"].createElement(Backdrop, { onClick: handleClickBackdrop })));
1888
1924
  };
1889
1925
 
1890
- // export enum MODALRESULT { OK = 'OK', CANCEL = 'CANCEL', DELETE = 'DELETE' }
1891
1926
  exports.MODALTYPE = void 0;
1892
1927
  (function (MODALTYPE) {
1893
1928
  MODALTYPE["BASIC"] = "BASIC";
@@ -1942,10 +1977,10 @@ const GlobalModal = ({ title, description, formControls, onOk, onChange, onCance
1942
1977
  }
1943
1978
  button.handler && button.handler();
1944
1979
  };
1945
- return (React__default["default"].createElement(Modal, { size: size, fullScreen: fullScreen, header: title, onHeaderCloseClick: onCancel, onBackdropClick: onBackdropClick, isDismissable: isDismissable, footer: React__default["default"].createElement(React.Fragment, null, buttons.map((button, index) => (React__default["default"].createElement(Button, { key: index, variant: button.variant, color: button.color, autoFocus: button.autoFocus, shadow: button.shadow, onClick: () => handleClickButton(button) }, button.label)))) },
1980
+ return (React__default["default"].createElement(Modal, { size: size, fullScreen: fullScreen, header: title, onHeaderCloseClick: onCancel, onBackdropClick: onBackdropClick, isDismissable: isDismissable, footer: React__default["default"].createElement(React__default["default"].Fragment, null, buttons.map((button, index) => (React__default["default"].createElement(Button, { key: index, variant: button.variant, color: button.color, autoFocus: button.autoFocus, shadow: button.shadow, onClick: () => handleClickButton(button) }, button.label)))) },
1946
1981
  description && React__default["default"].createElement("div", null, description),
1947
1982
  modalType === exports.MODALTYPE.FORM &&
1948
- React__default["default"].createElement(React.Fragment, null,
1983
+ React__default["default"].createElement(React__default["default"].Fragment, null,
1949
1984
  React__default["default"].createElement(Form, { ref: myForm, controls: myControls, validateOnBlur: true, onSubmit: onSubmit, onChange: onChange }))));
1950
1985
  };
1951
1986
 
@@ -1963,35 +1998,38 @@ class ModalService {
1963
1998
  reject();
1964
1999
  this.hide();
1965
2000
  };
1966
- reactDom.render(React__default["default"].createElement(GlobalModal, { fullScreen: options && options.fullScreen, size: options && options.size, title: title, description: description, onCancel: handleCancel, onBackdropClick: handleCancel, onOk: handleOk, isDismissable: options && options.isDismissable, buttons: options && options.buttons }), this.container);
2001
+ this.root = client_1(this.container);
2002
+ this.root.render(React__default["default"].createElement(GlobalModal, { fullScreen: options && options.fullScreen, size: options && options.size, title: title, description: description, onCancel: handleCancel, onBackdropClick: handleCancel, onOk: handleOk, isDismissable: options && options.isDismissable, buttons: options && options.buttons }));
1967
2003
  }
1968
2004
  });
1969
2005
  }
1970
- showForm(title, options) {
2006
+ showForm(title, formControls, options) {
1971
2007
  return new Promise((resolve, reject) => {
1972
2008
  if (!this.container) {
1973
2009
  this.container = document.createElement('div');
1974
- document.body.appendChild(this.container);
2010
+ this.container.classList.add('modal-container');
1975
2011
  const handleOk = (values) => {
1976
2012
  resolve(values);
1977
2013
  this.hide();
1978
2014
  };
1979
2015
  // TODO - for AutoComplete
1980
- const handleOnChange = (values) => {
1981
- console.info(values);
1982
- };
2016
+ // const handleOnChange = (values?: IFormValues) => {
2017
+ // console.info(values);
2018
+ // }
1983
2019
  const handleCancel = () => {
1984
2020
  reject();
1985
2021
  this.hide();
1986
2022
  };
1987
- reactDom.render(React__default["default"].createElement(GlobalModal, { fullScreen: options && options.fullScreen, size: options && options.size, title: title, formControls: options && options.formControls, onCancel: handleCancel, onBackdropClick: handleCancel, onOk: handleOk, onChange: handleOnChange, isDismissable: options && options.isDismissable, buttons: options && options.buttons }), this.container);
2023
+ this.root = client_1(this.container);
2024
+ this.root.render(React__default["default"].createElement(GlobalModal, { fullScreen: options && options.fullScreen, size: options && options.size, title: title, formControls: formControls, onCancel: handleCancel, onBackdropClick: handleCancel, onOk: handleOk, isDismissable: options && options.isDismissable, buttons: options && options.buttons }));
1988
2025
  }
1989
2026
  });
1990
2027
  }
1991
2028
  hide() {
2029
+ var _a;
1992
2030
  if (this.container) {
1993
- reactDom.unmountComponentAtNode(this.container);
1994
- document.body.removeChild(this.container);
2031
+ (_a = this.root) === null || _a === void 0 ? void 0 : _a.unmount();
2032
+ // document.body.removeChild(this.container);
1995
2033
  this.container = undefined;
1996
2034
  }
1997
2035
  }
@@ -2227,12 +2265,14 @@ class SnackbarService {
2227
2265
  resolve();
2228
2266
  this.hide();
2229
2267
  };
2230
- reactDom.render(React__default["default"].createElement(Snackbar, { color: mergedOptions.color, actionText: mergedOptions.actionText, onOk: handleOk }, message), this.container);
2268
+ this.root = client_1(this.container);
2269
+ this.root.render(React__default["default"].createElement(Snackbar, { color: mergedOptions.color, actionText: mergedOptions.actionText, onOk: handleOk }, message));
2231
2270
  });
2232
2271
  }
2233
2272
  hide() {
2273
+ var _a;
2234
2274
  if (this.container) {
2235
- reactDom.unmountComponentAtNode(this.container);
2275
+ (_a = this.root) === null || _a === void 0 ? void 0 : _a.unmount();
2236
2276
  document.body.removeChild(this.container);
2237
2277
  this.container = undefined;
2238
2278
  this.handler && clearTimeout(this.handler);
@@ -2633,6 +2673,13 @@ const TableCell = (props) => {
2633
2673
  React__default["default"].createElement("td", Object.assign({}, rest), children)) }, children));
2634
2674
  };
2635
2675
 
2676
+ const TabContext = React.createContext({
2677
+ fixed: false,
2678
+ selectedValue: '',
2679
+ setSelectedValue: () => { }
2680
+ });
2681
+ const useTabContext = () => React.useContext(TabContext);
2682
+
2636
2683
  var css_248z$4 = ".TabIndicator-module_tabIndicator__jSJhH {\n bottom: 0;\n height: 2px;\n position: absolute;\n transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\n}\n.TabIndicator-module_tabIndicator__jSJhH.TabIndicator-module_primary__Q5jEo {\n background-color: var(--primary);\n}\n.TabIndicator-module_tabIndicator__jSJhH.TabIndicator-module_accent__qbgIG {\n background-color: var(--accent);\n}";
2637
2684
  var styles$4 = {"tabIndicator":"TabIndicator-module_tabIndicator__jSJhH","primary":"TabIndicator-module_primary__Q5jEo","accent":"TabIndicator-module_accent__qbgIG"};
2638
2685
  styleInject(css_248z$4);
@@ -2656,40 +2703,41 @@ var styles$3 = {"tabs":"Tabs-module_tabs__YyRTZ"};
2656
2703
  styleInject(css_248z$3);
2657
2704
 
2658
2705
  const Tabs = (props) => {
2659
- const { children, className, fixed, color, indicatorColor, onChange, value } = props;
2660
- const [selectedValue, setSelectedValue] = React.useState(value);
2661
- const [selectedIndex, setSelectedIndex] = React.useState();
2706
+ const { children, className, fixed = false, color, indicatorColor = exports.COLOR.accent, value, onChange } = props;
2707
+ const [selectedValue, setSelectedValue] = React.useState('');
2708
+ const [selectedIndex, setSelectedIndex] = React.useState(0);
2709
+ const tabContext = ({
2710
+ selectedValue,
2711
+ setSelectedValue,
2712
+ fixed
2713
+ });
2714
+ const prevSelectedValueRef = React.useRef();
2715
+ React.useEffect(() => {
2716
+ // TODO - check if prev needs to be set
2717
+ if (value !== undefined && value !== prevSelectedValueRef.current) {
2718
+ setSelectedValue(value);
2719
+ }
2720
+ }, [value]);
2662
2721
  React.useEffect(() => {
2663
2722
  React__default["default"].Children.toArray(children).forEach((child, index) => {
2664
- if (child.props.value === value) {
2723
+ if (child.props.value === selectedValue) {
2665
2724
  setSelectedIndex(index);
2725
+ onChange && onChange(selectedValue);
2666
2726
  }
2667
2727
  });
2668
- }, [children, value]);
2728
+ }, [children, selectedValue]);
2669
2729
  const getCssClasses = () => {
2670
2730
  const cssClasses = [];
2671
2731
  cssClasses.push(styles$3.tabs);
2672
2732
  className && cssClasses.push(className);
2673
2733
  return cssClasses.filter(css => css).join(' ');
2674
2734
  };
2675
- const handleClickTab = (event, newValue, index) => {
2676
- setSelectedValue(newValue);
2677
- setSelectedIndex(index);
2678
- onChange && onChange({ event, newValue });
2679
- };
2680
- const renderTabs = (child, index) => {
2681
- return React__default["default"].isValidElement(child) && React.cloneElement(child, {
2682
- key: child.props.value,
2683
- isActive: child.props.value === selectedValue,
2684
- fixed: fixed,
2685
- onClick: (e) => handleClickTab(e.event, e.value, index),
2686
- });
2687
- };
2688
2735
  return (React__default["default"].createElement(ButtonContext.Provider, { value: { color: color || exports.COLOR.light } },
2689
- React__default["default"].createElement("div", { className: getCssClasses() },
2690
- children && React__default["default"].Children.toArray(children).map((child, index) => renderTabs(child, index)),
2691
- children &&
2692
- React__default["default"].createElement(TabIndicator, { color: indicatorColor, width: (100 / React__default["default"].Children.toArray(children).length) + '%', index: selectedIndex, amount: React__default["default"].Children.toArray(children).length }))));
2736
+ React__default["default"].createElement(TabContext.Provider, { value: tabContext },
2737
+ React__default["default"].createElement("div", { className: getCssClasses() },
2738
+ children,
2739
+ children &&
2740
+ React__default["default"].createElement(TabIndicator, { color: indicatorColor, width: (100 / React__default["default"].Children.toArray(children).length) + '%', index: selectedIndex, amount: React__default["default"].Children.toArray(children).length })))));
2693
2741
  };
2694
2742
 
2695
2743
  var css_248z$2 = ".Tab-module_tab__Q8w1f {\n padding: 6px 12px;\n overflow: hidden;\n position: relative;\n font-size: 0.875rem;\n min-width: 72px;\n box-sizing: border-box;\n min-height: 48px;\n text-align: center;\n font-weight: 500;\n line-height: 1.75;\n white-space: normal;\n letter-spacing: 0.02857em;\n text-transform: uppercase;\n border-radius: 0;\n flex-grow: 1;\n flex-basis: 0;\n transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\n}";
@@ -2697,17 +2745,19 @@ var styles$2 = {"tab":"Tab-module_tab__Q8w1f"};
2697
2745
  styleInject(css_248z$2);
2698
2746
 
2699
2747
  const Tab = (props) => {
2700
- const { label, className, isActive, disabled, value, onClick } = props;
2748
+ const { label, className, disabled, value, onClick } = props;
2749
+ const { selectedValue, setSelectedValue } = useTabContext();
2701
2750
  const getCssClasses = () => {
2702
2751
  const cssClasses = [];
2703
2752
  cssClasses.push(styles$2.tab);
2704
- if (isActive) {
2705
- cssClasses.push(`show active`);
2706
- }
2707
2753
  className && cssClasses.push(className);
2708
2754
  return cssClasses.filter(css => css).join(' ');
2709
2755
  };
2710
- return (React__default["default"].createElement(Button, { className: getCssClasses(), onClick: (event) => onClick && onClick({ event, value }), isActive: isActive, disabled: disabled }, label));
2756
+ const handleClick = (event) => {
2757
+ onClick && onClick({ event, value });
2758
+ setSelectedValue(value);
2759
+ };
2760
+ return (React__default["default"].createElement(Button, { className: getCssClasses(), onClick: handleClick, isActive: selectedValue === value, disabled: disabled }, label));
2711
2761
  };
2712
2762
 
2713
2763
  const TabPanel = (props) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-asc",
3
- "version": "24.0.0",
3
+ "version": "25.0.2",
4
4
  "description": "handcrafted react components",
5
5
  "main": "index.js",
6
6
  "module": "index.es.js",
@@ -9,10 +9,10 @@
9
9
  "homepage": "https://react-asc.netlify.app",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@popperjs/core": "2.9.2",
13
- "react": "17.0.2",
14
- "react-dom": "17.0.2",
15
- "modern-normalize": "^1.1.0"
12
+ "@popperjs/core": "2.11.5",
13
+ "react": "18.2.0",
14
+ "react-dom": "18.2.0",
15
+ "modern-normalize": "1.1.0"
16
16
  },
17
17
  "scripts": {
18
18
  "pub": "npm publish --access public"