react-asc 25.0.2 → 25.0.3

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.
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import { Context } from 'react';
2
2
  export interface ITableContext {
3
3
  variant: 'head' | 'body';
4
4
  }
5
- export declare const TableContext: import("react").Context<ITableContext>;
5
+ export declare const TableContext: Context<ITableContext>;
6
6
  export declare const useTableContext: () => ITableContext;
@@ -1,8 +1,8 @@
1
- import { Dispatch } from 'react';
1
+ import { Context, Dispatch } from 'react';
2
2
  export interface ITabsContext {
3
- fixed: boolean;
4
- selectedValue: string;
5
- setSelectedValue: Dispatch<string>;
3
+ fixed?: boolean;
4
+ selectedValue?: string;
5
+ setSelectedValue?: Dispatch<string>;
6
6
  }
7
- export declare const TabContext: import("react").Context<ITabsContext>;
7
+ export declare const TabContext: Context<ITabsContext>;
8
8
  export declare const useTabContext: () => ITabsContext;
@@ -19,7 +19,7 @@ export declare enum POSITION {
19
19
  right = "right",
20
20
  left = "left"
21
21
  }
22
- export declare const STATUS: {
23
- HOVERED: string;
24
- NORMAL: string;
25
- };
22
+ export declare enum STATUS {
23
+ HOVERED = "hovered",
24
+ NORMAL = "normal"
25
+ }
package/index.es.js CHANGED
@@ -2,7 +2,7 @@ import React, { useRef, useEffect, useState, useMemo, createContext, useContext,
2
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
@@ -55,10 +55,11 @@ var POSITION;
55
55
  POSITION["right"] = "right";
56
56
  POSITION["left"] = "left";
57
57
  })(POSITION || (POSITION = {}));
58
- const STATUS = {
59
- HOVERED: 'hovered',
60
- NORMAL: 'normal',
61
- };
58
+ var STATUS;
59
+ (function (STATUS) {
60
+ STATUS["HOVERED"] = "hovered";
61
+ STATUS["NORMAL"] = "normal";
62
+ })(STATUS || (STATUS = {}));
62
63
 
63
64
  function styleInject(css, ref) {
64
65
  if ( ref === void 0 ) ref = {};
@@ -2664,11 +2665,7 @@ const TableCell = (props) => {
2664
2665
  React.createElement("td", Object.assign({}, rest), children)) }, children));
2665
2666
  };
2666
2667
 
2667
- const TabContext = createContext({
2668
- fixed: false,
2669
- selectedValue: '',
2670
- setSelectedValue: () => { }
2671
- });
2668
+ const TabContext = createContext({});
2672
2669
  const useTabContext = () => useContext(TabContext);
2673
2670
 
2674
2671
  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}";
@@ -2704,19 +2701,21 @@ const Tabs = (props) => {
2704
2701
  });
2705
2702
  const prevSelectedValueRef = useRef();
2706
2703
  useEffect(() => {
2707
- // TODO - check if prev needs to be set
2708
2704
  if (value !== undefined && value !== prevSelectedValueRef.current) {
2705
+ prevSelectedValueRef.current = value;
2709
2706
  setSelectedValue(value);
2710
2707
  }
2711
2708
  }, [value]);
2712
2709
  useEffect(() => {
2713
- React.Children.toArray(children).forEach((child, index) => {
2714
- if (child.props.value === selectedValue) {
2715
- setSelectedIndex(index);
2716
- onChange && onChange(selectedValue);
2717
- }
2718
- });
2719
- }, [children, selectedValue]);
2710
+ if (selectedValue && children) {
2711
+ React.Children.toArray(children).forEach((child, index) => {
2712
+ if (child.props.value === selectedValue) {
2713
+ setSelectedIndex(index);
2714
+ onChange && onChange(selectedValue);
2715
+ }
2716
+ });
2717
+ }
2718
+ }, [selectedValue]);
2720
2719
  const getCssClasses = () => {
2721
2720
  const cssClasses = [];
2722
2721
  cssClasses.push(styles$3.tabs);
@@ -2746,7 +2745,7 @@ const Tab = (props) => {
2746
2745
  };
2747
2746
  const handleClick = (event) => {
2748
2747
  onClick && onClick({ event, value });
2749
- setSelectedValue(value);
2748
+ setSelectedValue && setSelectedValue(value);
2750
2749
  };
2751
2750
  return (React.createElement(Button, { className: getCssClasses(), onClick: handleClick, isActive: selectedValue === value, disabled: disabled }, label));
2752
2751
  };
package/index.js CHANGED
@@ -11,7 +11,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
11
11
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
12
12
  var reactDom__default = /*#__PURE__*/_interopDefaultLegacy(reactDom);
13
13
 
14
- /******************************************************************************
14
+ /*! *****************************************************************************
15
15
  Copyright (c) Microsoft Corporation.
16
16
 
17
17
  Permission to use, copy, modify, and/or distribute this software for any
@@ -64,10 +64,11 @@ exports.POSITION = void 0;
64
64
  POSITION["right"] = "right";
65
65
  POSITION["left"] = "left";
66
66
  })(exports.POSITION || (exports.POSITION = {}));
67
- const STATUS = {
68
- HOVERED: 'hovered',
69
- NORMAL: 'normal',
70
- };
67
+ exports.STATUS = void 0;
68
+ (function (STATUS) {
69
+ STATUS["HOVERED"] = "hovered";
70
+ STATUS["NORMAL"] = "normal";
71
+ })(exports.STATUS || (exports.STATUS = {}));
71
72
 
72
73
  function styleInject(css, ref) {
73
74
  if ( ref === void 0 ) ref = {};
@@ -1766,13 +1767,13 @@ styleInject(css_248z$q);
1766
1767
 
1767
1768
  const Link = (props) => {
1768
1769
  const { href = '#', className, target, children } = props, rest = __rest(props, ["href", "className", "target", "children"]);
1769
- const [status, setStatus] = React.useState(STATUS.NORMAL);
1770
+ const [status, setStatus] = React.useState(exports.STATUS.NORMAL);
1770
1771
  const [cssClassName] = useCssClasses([styles$q.link, className, status]);
1771
1772
  const onMouseEnter = () => {
1772
- setStatus(STATUS.HOVERED);
1773
+ setStatus(exports.STATUS.HOVERED);
1773
1774
  };
1774
1775
  const onMouseLeave = () => {
1775
- setStatus(STATUS.NORMAL);
1776
+ setStatus(exports.STATUS.NORMAL);
1776
1777
  };
1777
1778
  return (React__default["default"].createElement("a", Object.assign({ className: cssClassName, href: href, target: target, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave }, rest), children));
1778
1779
  };
@@ -2673,11 +2674,7 @@ const TableCell = (props) => {
2673
2674
  React__default["default"].createElement("td", Object.assign({}, rest), children)) }, children));
2674
2675
  };
2675
2676
 
2676
- const TabContext = React.createContext({
2677
- fixed: false,
2678
- selectedValue: '',
2679
- setSelectedValue: () => { }
2680
- });
2677
+ const TabContext = React.createContext({});
2681
2678
  const useTabContext = () => React.useContext(TabContext);
2682
2679
 
2683
2680
  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}";
@@ -2713,19 +2710,21 @@ const Tabs = (props) => {
2713
2710
  });
2714
2711
  const prevSelectedValueRef = React.useRef();
2715
2712
  React.useEffect(() => {
2716
- // TODO - check if prev needs to be set
2717
2713
  if (value !== undefined && value !== prevSelectedValueRef.current) {
2714
+ prevSelectedValueRef.current = value;
2718
2715
  setSelectedValue(value);
2719
2716
  }
2720
2717
  }, [value]);
2721
2718
  React.useEffect(() => {
2722
- React__default["default"].Children.toArray(children).forEach((child, index) => {
2723
- if (child.props.value === selectedValue) {
2724
- setSelectedIndex(index);
2725
- onChange && onChange(selectedValue);
2726
- }
2727
- });
2728
- }, [children, selectedValue]);
2719
+ if (selectedValue && children) {
2720
+ React__default["default"].Children.toArray(children).forEach((child, index) => {
2721
+ if (child.props.value === selectedValue) {
2722
+ setSelectedIndex(index);
2723
+ onChange && onChange(selectedValue);
2724
+ }
2725
+ });
2726
+ }
2727
+ }, [selectedValue]);
2729
2728
  const getCssClasses = () => {
2730
2729
  const cssClasses = [];
2731
2730
  cssClasses.push(styles$3.tabs);
@@ -2755,7 +2754,7 @@ const Tab = (props) => {
2755
2754
  };
2756
2755
  const handleClick = (event) => {
2757
2756
  onClick && onClick({ event, value });
2758
- setSelectedValue(value);
2757
+ setSelectedValue && setSelectedValue(value);
2759
2758
  };
2760
2759
  return (React__default["default"].createElement(Button, { className: getCssClasses(), onClick: handleClick, isActive: selectedValue === value, disabled: disabled }, label));
2761
2760
  };
@@ -3041,7 +3040,6 @@ exports.PlusSolidIcon = PlusSolidIcon;
3041
3040
  exports.Portal = Portal;
3042
3041
  exports.ProgressBar = ProgressBar;
3043
3042
  exports.Row = Row;
3044
- exports.STATUS = STATUS;
3045
3043
  exports.SecondSelect = SecondSelect;
3046
3044
  exports.Select = Select;
3047
3045
  exports.Sidebar = Sidebar;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-asc",
3
- "version": "25.0.2",
3
+ "version": "25.0.3",
4
4
  "description": "handcrafted react components",
5
5
  "main": "index.js",
6
6
  "module": "index.es.js",