react-asc 23.7.3 → 25.0.1
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/components/Button/Button.d.ts +2 -2
- package/components/FloatingActionButton/FloatingActionButton.d.ts +1 -1
- package/components/Icon/Icon.d.ts +2 -1
- package/components/IconButton/IconButton.d.ts +1 -1
- package/components/List/ListItemAvatar.d.ts +1 -1
- package/components/List/ListItemIcon.d.ts +1 -1
- package/components/LoadingIndicator/loading-indicator.service.d.ts +1 -0
- package/components/Modal/GlobalModal.d.ts +3 -2
- package/components/Modal/modal.service.d.ts +5 -4
- package/components/Snackbar/snackbar.service.d.ts +3 -2
- package/components/SpeedDial/SpeedDialAction.d.ts +1 -1
- package/components/Tabs/Tab.d.ts +0 -2
- package/components/Tabs/TabContext.d.ts +8 -0
- package/components/Tabs/Tabs.d.ts +2 -6
- package/hooks/useWindowSize.d.ts +3 -2
- package/index.es.js +113 -43
- package/index.js +113 -42
- package/package.json +5 -5
- package/react-asc.scss +2 -0
|
@@ -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.
|
|
9
|
-
endIcon?: React.
|
|
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.
|
|
4
|
+
icon?: React.ReactNode;
|
|
5
5
|
color?: COLOR;
|
|
6
6
|
size?: SIZE;
|
|
7
7
|
fixed?: 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.
|
|
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.
|
|
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.
|
|
3
|
+
icon: React.ReactNode;
|
|
4
4
|
}
|
|
5
5
|
export declare const ListItemIcon: ({ icon, ...rest }: IListItemIconProps) => JSX.Element;
|
|
6
6
|
export {};
|
|
@@ -8,7 +8,8 @@ interface IModalProps {
|
|
|
8
8
|
description?: string | ReactElement;
|
|
9
9
|
formControls?: IControls;
|
|
10
10
|
modalType?: MODALTYPE;
|
|
11
|
-
onOk
|
|
11
|
+
onOk: (values?: IFormValues) => void;
|
|
12
|
+
onChange?: (values?: IFormValues) => void;
|
|
12
13
|
onCancel?: () => void;
|
|
13
14
|
onBackdropClick?: () => void;
|
|
14
15
|
isDismissable?: boolean;
|
|
@@ -16,5 +17,5 @@ interface IModalProps {
|
|
|
16
17
|
fullScreen?: boolean;
|
|
17
18
|
size?: SIZE;
|
|
18
19
|
}
|
|
19
|
-
export declare const GlobalModal: ({ title, description, formControls, onOk, onCancel, onBackdropClick, isDismissable, buttons, size, fullScreen }: IModalProps) => JSX.Element;
|
|
20
|
+
export declare const GlobalModal: ({ title, description, formControls, onOk, onChange, onCancel, onBackdropClick, isDismissable, buttons, size, fullScreen }: IModalProps) => JSX.Element;
|
|
20
21
|
export {};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { IControls
|
|
1
|
+
import { IControls } from '../Form';
|
|
2
2
|
import { ReactElement } from 'react';
|
|
3
3
|
import { IModalButton } from './modal.interfaces';
|
|
4
4
|
import { SIZE } from '../component.enums';
|
|
5
5
|
export interface IModalService {
|
|
6
|
-
show(title: string, description: string | ReactElement, options?: IModalOptions): Promise<void
|
|
6
|
+
show(title: string, description: string | ReactElement, options?: IModalOptions): Promise<void>;
|
|
7
7
|
}
|
|
8
8
|
export interface IModalOptions {
|
|
9
|
-
formControls?: IControls;
|
|
10
9
|
isDismissable?: boolean;
|
|
11
10
|
buttons?: Array<IModalButton>;
|
|
12
11
|
fullScreen?: boolean;
|
|
@@ -14,7 +13,9 @@ export interface IModalOptions {
|
|
|
14
13
|
}
|
|
15
14
|
declare class ModalService implements IModalService {
|
|
16
15
|
private container;
|
|
17
|
-
|
|
16
|
+
private root;
|
|
17
|
+
show(title: string, description: string | ReactElement, options?: IModalOptions): Promise<void>;
|
|
18
|
+
showForm<T>(title: string, formControls: IControls, options?: IModalOptions): Promise<T>;
|
|
18
19
|
private hide;
|
|
19
20
|
}
|
|
20
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.
|
|
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
|
-
|
|
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.
|
|
4
|
+
icon: React.ReactNode;
|
|
5
5
|
tooltipTitle?: string;
|
|
6
6
|
color?: COLOR;
|
|
7
7
|
onClick?: (e: React.MouseEvent) => void;
|
package/components/Tabs/Tab.d.ts
CHANGED
|
@@ -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
|
|
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?: (
|
|
10
|
+
onChange?: (value: string) => void;
|
|
15
11
|
value?: string;
|
|
16
12
|
}
|
|
17
13
|
export declare const Tabs: (props: ITabsProps) => JSX.Element;
|
package/hooks/useWindowSize.d.ts
CHANGED
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
|
|
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
|
|
@@ -111,7 +111,7 @@ const Alert = (props) => {
|
|
|
111
111
|
return (React.createElement("div", Object.assign({ className: getCssClasses() }, rest), children));
|
|
112
112
|
};
|
|
113
113
|
|
|
114
|
-
var css_248z$12 = ".AppBar-module_appbar__Neyh3 {\n padding: 0.5rem var(--1);\n display: flex;\n z-index: 1000;\n min-height: 64px;\n flex-shrink: 0;\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_primary__xMqXD {\n color: var(--primary-contrast-text);\n background-color: var(--primary);\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_secondary__8MkLA {\n color: var(--secondary-contrast-text);\n background-color: var(--secondary);\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_accent__vHbkp {\n color: var(--accent-contrast-text);\n background-color: var(--accent);\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_light__HGy3y {\n color: var(--light-contrast-text);\n background-color: var(--light);\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_dark__ILq96 {\n color: var(--dark-contrast-text);\n background-color: var(--dark);\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_shadow__gQN8s {\n box-shadow: var(--
|
|
114
|
+
var css_248z$12 = ".AppBar-module_appbar__Neyh3 {\n padding: 0.5rem var(--1);\n display: flex;\n z-index: 1000;\n min-height: 64px;\n flex-shrink: 0;\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_primary__xMqXD {\n color: var(--primary-contrast-text);\n background-color: var(--primary);\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_secondary__8MkLA {\n color: var(--secondary-contrast-text);\n background-color: var(--secondary);\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_accent__vHbkp {\n color: var(--accent-contrast-text);\n background-color: var(--accent);\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_light__HGy3y {\n color: var(--light-contrast-text);\n background-color: var(--light);\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_dark__ILq96 {\n color: var(--dark-contrast-text);\n background-color: var(--dark);\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_shadow__gQN8s {\n box-shadow: 0 4px 2px -2px var(--sadowColor);\n}";
|
|
115
115
|
var styles$12 = {"appbar":"AppBar-module_appbar__Neyh3","primary":"AppBar-module_primary__xMqXD","secondary":"AppBar-module_secondary__8MkLA","accent":"AppBar-module_accent__vHbkp","light":"AppBar-module_light__HGy3y","dark":"AppBar-module_dark__ILq96","shadow":"AppBar-module_shadow__gQN8s"};
|
|
116
116
|
styleInject(css_248z$12);
|
|
117
117
|
|
|
@@ -451,7 +451,9 @@ const AutoComplete = (props) => {
|
|
|
451
451
|
useEffect(() => {
|
|
452
452
|
setOptions(options);
|
|
453
453
|
}, [options]);
|
|
454
|
-
useDebounce(() => {
|
|
454
|
+
useDebounce(() => {
|
|
455
|
+
onChange && onChange(searchText);
|
|
456
|
+
}, debounce, [searchText]);
|
|
455
457
|
useEffect(() => {
|
|
456
458
|
if (isShow === true) {
|
|
457
459
|
document.body.classList.add('modal-open');
|
|
@@ -1125,7 +1127,7 @@ const Select = (props) => {
|
|
|
1125
1127
|
!multiple && renderSingleViewModel(),
|
|
1126
1128
|
multiple &&
|
|
1127
1129
|
React.createElement("div", { className: styles$B.chipContainer }, renderMultipleViewModel()),
|
|
1128
|
-
React.createElement(Icon, { className: "ml-
|
|
1130
|
+
React.createElement(Icon, { className: "ml-auto" },
|
|
1129
1131
|
React.createElement(ChevronDownSolidIcon, null))),
|
|
1130
1132
|
isShow &&
|
|
1131
1133
|
React.createElement(Portal, { className: 'backdrop-root' },
|
|
@@ -1791,6 +1793,39 @@ const LoadingIndicatorContainer = ({ children, isFixed }) => {
|
|
|
1791
1793
|
return (React.createElement("div", { className: getCssClasses() }, children));
|
|
1792
1794
|
};
|
|
1793
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
|
+
|
|
1794
1829
|
class LoadingIndicatorService {
|
|
1795
1830
|
show() {
|
|
1796
1831
|
if (this.container) {
|
|
@@ -1799,12 +1834,14 @@ class LoadingIndicatorService {
|
|
|
1799
1834
|
this.container = document.createElement('div');
|
|
1800
1835
|
this.container.classList.add('snackbar-container');
|
|
1801
1836
|
document.body.appendChild(this.container);
|
|
1802
|
-
|
|
1803
|
-
|
|
1837
|
+
this.root = client_1(this.container);
|
|
1838
|
+
this.root.render(React.createElement(LoadingIndicatorContainer, { isFixed: true },
|
|
1839
|
+
React.createElement(LoadingIndicator, null)));
|
|
1804
1840
|
}
|
|
1805
1841
|
hide() {
|
|
1842
|
+
var _a;
|
|
1806
1843
|
if (this.container) {
|
|
1807
|
-
|
|
1844
|
+
(_a = this.root) === null || _a === void 0 ? void 0 : _a.unmount();
|
|
1808
1845
|
document.body.removeChild(this.container);
|
|
1809
1846
|
this.container = undefined;
|
|
1810
1847
|
this.handler && clearTimeout(this.handler);
|
|
@@ -1862,7 +1899,6 @@ const Modal = (props) => {
|
|
|
1862
1899
|
};
|
|
1863
1900
|
}, []);
|
|
1864
1901
|
const handleClickBackdrop = () => {
|
|
1865
|
-
console.warn('backdrop clicked');
|
|
1866
1902
|
onBackdropClick && onBackdropClick();
|
|
1867
1903
|
};
|
|
1868
1904
|
return (React.createElement(React.Fragment, null,
|
|
@@ -1878,7 +1914,6 @@ const Modal = (props) => {
|
|
|
1878
1914
|
React.createElement(Backdrop, { onClick: handleClickBackdrop })));
|
|
1879
1915
|
};
|
|
1880
1916
|
|
|
1881
|
-
// export enum MODALRESULT { OK = 'OK', CANCEL = 'CANCEL', DELETE = 'DELETE' }
|
|
1882
1917
|
var MODALTYPE;
|
|
1883
1918
|
(function (MODALTYPE) {
|
|
1884
1919
|
MODALTYPE["BASIC"] = "BASIC";
|
|
@@ -1892,7 +1927,7 @@ var MODALBUTTONTYPE;
|
|
|
1892
1927
|
MODALBUTTONTYPE["DEFAULT"] = "DEFAULT";
|
|
1893
1928
|
})(MODALBUTTONTYPE || (MODALBUTTONTYPE = {}));
|
|
1894
1929
|
|
|
1895
|
-
const GlobalModal = ({ title, description, formControls, onOk, onCancel, onBackdropClick, isDismissable = false, buttons = [
|
|
1930
|
+
const GlobalModal = ({ title, description, formControls, onOk, onChange, onCancel, onBackdropClick, isDismissable = false, buttons = [
|
|
1896
1931
|
{ label: 'Cancel', type: MODALBUTTONTYPE.CANCEL, color: COLOR.secondary, variant: VARIANT.text, shadow: false },
|
|
1897
1932
|
{ label: 'Ok', type: MODALBUTTONTYPE.OK, variant: VARIANT.contained, focus: true },
|
|
1898
1933
|
], size = SIZE.md, fullScreen = false }) => {
|
|
@@ -1937,11 +1972,29 @@ const GlobalModal = ({ title, description, formControls, onOk, onCancel, onBackd
|
|
|
1937
1972
|
description && React.createElement("div", null, description),
|
|
1938
1973
|
modalType === MODALTYPE.FORM &&
|
|
1939
1974
|
React.createElement(Fragment, null,
|
|
1940
|
-
React.createElement(Form, { ref: myForm, controls: myControls, validateOnBlur: true, onSubmit: onSubmit }))));
|
|
1975
|
+
React.createElement(Form, { ref: myForm, controls: myControls, validateOnBlur: true, onSubmit: onSubmit, onChange: onChange }))));
|
|
1941
1976
|
};
|
|
1942
1977
|
|
|
1943
1978
|
class ModalService {
|
|
1944
1979
|
show(title, description, options) {
|
|
1980
|
+
return new Promise((resolve, reject) => {
|
|
1981
|
+
if (!this.container) {
|
|
1982
|
+
this.container = document.createElement('div');
|
|
1983
|
+
document.body.appendChild(this.container);
|
|
1984
|
+
const handleOk = () => {
|
|
1985
|
+
resolve();
|
|
1986
|
+
this.hide();
|
|
1987
|
+
};
|
|
1988
|
+
const handleCancel = () => {
|
|
1989
|
+
reject();
|
|
1990
|
+
this.hide();
|
|
1991
|
+
};
|
|
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 }));
|
|
1994
|
+
}
|
|
1995
|
+
});
|
|
1996
|
+
}
|
|
1997
|
+
showForm(title, formControls, options) {
|
|
1945
1998
|
return new Promise((resolve, reject) => {
|
|
1946
1999
|
if (!this.container) {
|
|
1947
2000
|
this.container = document.createElement('div');
|
|
@@ -1950,17 +2003,23 @@ class ModalService {
|
|
|
1950
2003
|
resolve(values);
|
|
1951
2004
|
this.hide();
|
|
1952
2005
|
};
|
|
2006
|
+
// TODO - for AutoComplete
|
|
2007
|
+
// const handleOnChange = (values?: IFormValues) => {
|
|
2008
|
+
// console.info(values);
|
|
2009
|
+
// }
|
|
1953
2010
|
const handleCancel = () => {
|
|
1954
2011
|
reject();
|
|
1955
2012
|
this.hide();
|
|
1956
2013
|
};
|
|
1957
|
-
|
|
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 }));
|
|
1958
2016
|
}
|
|
1959
2017
|
});
|
|
1960
2018
|
}
|
|
1961
2019
|
hide() {
|
|
2020
|
+
var _a;
|
|
1962
2021
|
if (this.container) {
|
|
1963
|
-
|
|
2022
|
+
(_a = this.root) === null || _a === void 0 ? void 0 : _a.unmount();
|
|
1964
2023
|
document.body.removeChild(this.container);
|
|
1965
2024
|
this.container = undefined;
|
|
1966
2025
|
}
|
|
@@ -2197,12 +2256,14 @@ class SnackbarService {
|
|
|
2197
2256
|
resolve();
|
|
2198
2257
|
this.hide();
|
|
2199
2258
|
};
|
|
2200
|
-
|
|
2259
|
+
this.root = client_1(this.container);
|
|
2260
|
+
this.root.render(React.createElement(Snackbar, { color: mergedOptions.color, actionText: mergedOptions.actionText, onOk: handleOk }, message));
|
|
2201
2261
|
});
|
|
2202
2262
|
}
|
|
2203
2263
|
hide() {
|
|
2264
|
+
var _a;
|
|
2204
2265
|
if (this.container) {
|
|
2205
|
-
|
|
2266
|
+
(_a = this.root) === null || _a === void 0 ? void 0 : _a.unmount();
|
|
2206
2267
|
document.body.removeChild(this.container);
|
|
2207
2268
|
this.container = undefined;
|
|
2208
2269
|
this.handler && clearTimeout(this.handler);
|
|
@@ -2603,6 +2664,13 @@ const TableCell = (props) => {
|
|
|
2603
2664
|
React.createElement("td", Object.assign({}, rest), children)) }, children));
|
|
2604
2665
|
};
|
|
2605
2666
|
|
|
2667
|
+
const TabContext = createContext({
|
|
2668
|
+
fixed: false,
|
|
2669
|
+
selectedValue: '',
|
|
2670
|
+
setSelectedValue: () => { }
|
|
2671
|
+
});
|
|
2672
|
+
const useTabContext = () => useContext(TabContext);
|
|
2673
|
+
|
|
2606
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}";
|
|
2607
2675
|
var styles$4 = {"tabIndicator":"TabIndicator-module_tabIndicator__jSJhH","primary":"TabIndicator-module_primary__Q5jEo","accent":"TabIndicator-module_accent__qbgIG"};
|
|
2608
2676
|
styleInject(css_248z$4);
|
|
@@ -2626,40 +2694,40 @@ var styles$3 = {"tabs":"Tabs-module_tabs__YyRTZ"};
|
|
|
2626
2694
|
styleInject(css_248z$3);
|
|
2627
2695
|
|
|
2628
2696
|
const Tabs = (props) => {
|
|
2629
|
-
const { children, className, fixed, color, indicatorColor
|
|
2630
|
-
const [selectedValue, setSelectedValue] = useState(
|
|
2631
|
-
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
|
+
if (value !== undefined && value !== prevSelectedValueRef.current) {
|
|
2708
|
+
setSelectedValue(value);
|
|
2709
|
+
}
|
|
2710
|
+
}, [value]);
|
|
2632
2711
|
useEffect(() => {
|
|
2633
2712
|
React.Children.toArray(children).forEach((child, index) => {
|
|
2634
|
-
if (child.props.value ===
|
|
2713
|
+
if (child.props.value === selectedValue) {
|
|
2635
2714
|
setSelectedIndex(index);
|
|
2715
|
+
onChange && onChange(selectedValue);
|
|
2636
2716
|
}
|
|
2637
2717
|
});
|
|
2638
|
-
}, [children,
|
|
2718
|
+
}, [children, selectedValue]);
|
|
2639
2719
|
const getCssClasses = () => {
|
|
2640
2720
|
const cssClasses = [];
|
|
2641
2721
|
cssClasses.push(styles$3.tabs);
|
|
2642
2722
|
className && cssClasses.push(className);
|
|
2643
2723
|
return cssClasses.filter(css => css).join(' ');
|
|
2644
2724
|
};
|
|
2645
|
-
const handleClickTab = (event, newValue, index) => {
|
|
2646
|
-
setSelectedValue(newValue);
|
|
2647
|
-
setSelectedIndex(index);
|
|
2648
|
-
onChange && onChange({ event, newValue });
|
|
2649
|
-
};
|
|
2650
|
-
const renderTabs = (child, index) => {
|
|
2651
|
-
return React.isValidElement(child) && cloneElement(child, {
|
|
2652
|
-
key: child.props.value,
|
|
2653
|
-
isActive: child.props.value === selectedValue,
|
|
2654
|
-
fixed: fixed,
|
|
2655
|
-
onClick: (e) => handleClickTab(e.event, e.value, index),
|
|
2656
|
-
});
|
|
2657
|
-
};
|
|
2658
2725
|
return (React.createElement(ButtonContext.Provider, { value: { color: color || COLOR.light } },
|
|
2659
|
-
React.createElement(
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2726
|
+
React.createElement(TabContext.Provider, { value: tabContext },
|
|
2727
|
+
React.createElement("div", { className: getCssClasses() },
|
|
2728
|
+
children,
|
|
2729
|
+
children &&
|
|
2730
|
+
React.createElement(TabIndicator, { color: indicatorColor, width: (100 / React.Children.toArray(children).length) + '%', index: selectedIndex, amount: React.Children.toArray(children).length })))));
|
|
2663
2731
|
};
|
|
2664
2732
|
|
|
2665
2733
|
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}";
|
|
@@ -2667,17 +2735,19 @@ var styles$2 = {"tab":"Tab-module_tab__Q8w1f"};
|
|
|
2667
2735
|
styleInject(css_248z$2);
|
|
2668
2736
|
|
|
2669
2737
|
const Tab = (props) => {
|
|
2670
|
-
const { label, className,
|
|
2738
|
+
const { label, className, disabled, value, onClick } = props;
|
|
2739
|
+
const { selectedValue, setSelectedValue } = useTabContext();
|
|
2671
2740
|
const getCssClasses = () => {
|
|
2672
2741
|
const cssClasses = [];
|
|
2673
2742
|
cssClasses.push(styles$2.tab);
|
|
2674
|
-
if (isActive) {
|
|
2675
|
-
cssClasses.push(`show active`);
|
|
2676
|
-
}
|
|
2677
2743
|
className && cssClasses.push(className);
|
|
2678
2744
|
return cssClasses.filter(css => css).join(' ');
|
|
2679
2745
|
};
|
|
2680
|
-
|
|
2746
|
+
const handleClick = (event) => {
|
|
2747
|
+
onClick && onClick({ event, value });
|
|
2748
|
+
setSelectedValue(value);
|
|
2749
|
+
};
|
|
2750
|
+
return (React.createElement(Button, { className: getCssClasses(), onClick: handleClick, isActive: selectedValue === value, disabled: disabled }, label));
|
|
2681
2751
|
};
|
|
2682
2752
|
|
|
2683
2753
|
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
|
|
@@ -119,7 +120,7 @@ const Alert = (props) => {
|
|
|
119
120
|
return (React__default["default"].createElement("div", Object.assign({ className: getCssClasses() }, rest), children));
|
|
120
121
|
};
|
|
121
122
|
|
|
122
|
-
var css_248z$12 = ".AppBar-module_appbar__Neyh3 {\n padding: 0.5rem var(--1);\n display: flex;\n z-index: 1000;\n min-height: 64px;\n flex-shrink: 0;\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_primary__xMqXD {\n color: var(--primary-contrast-text);\n background-color: var(--primary);\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_secondary__8MkLA {\n color: var(--secondary-contrast-text);\n background-color: var(--secondary);\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_accent__vHbkp {\n color: var(--accent-contrast-text);\n background-color: var(--accent);\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_light__HGy3y {\n color: var(--light-contrast-text);\n background-color: var(--light);\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_dark__ILq96 {\n color: var(--dark-contrast-text);\n background-color: var(--dark);\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_shadow__gQN8s {\n box-shadow: var(--
|
|
123
|
+
var css_248z$12 = ".AppBar-module_appbar__Neyh3 {\n padding: 0.5rem var(--1);\n display: flex;\n z-index: 1000;\n min-height: 64px;\n flex-shrink: 0;\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_primary__xMqXD {\n color: var(--primary-contrast-text);\n background-color: var(--primary);\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_secondary__8MkLA {\n color: var(--secondary-contrast-text);\n background-color: var(--secondary);\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_accent__vHbkp {\n color: var(--accent-contrast-text);\n background-color: var(--accent);\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_light__HGy3y {\n color: var(--light-contrast-text);\n background-color: var(--light);\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_dark__ILq96 {\n color: var(--dark-contrast-text);\n background-color: var(--dark);\n}\n.AppBar-module_appbar__Neyh3.AppBar-module_shadow__gQN8s {\n box-shadow: 0 4px 2px -2px var(--sadowColor);\n}";
|
|
123
124
|
var styles$12 = {"appbar":"AppBar-module_appbar__Neyh3","primary":"AppBar-module_primary__xMqXD","secondary":"AppBar-module_secondary__8MkLA","accent":"AppBar-module_accent__vHbkp","light":"AppBar-module_light__HGy3y","dark":"AppBar-module_dark__ILq96","shadow":"AppBar-module_shadow__gQN8s"};
|
|
124
125
|
styleInject(css_248z$12);
|
|
125
126
|
|
|
@@ -459,7 +460,9 @@ const AutoComplete = (props) => {
|
|
|
459
460
|
React.useEffect(() => {
|
|
460
461
|
setOptions(options);
|
|
461
462
|
}, [options]);
|
|
462
|
-
useDebounce(() => {
|
|
463
|
+
useDebounce(() => {
|
|
464
|
+
onChange && onChange(searchText);
|
|
465
|
+
}, debounce, [searchText]);
|
|
463
466
|
React.useEffect(() => {
|
|
464
467
|
if (isShow === true) {
|
|
465
468
|
document.body.classList.add('modal-open');
|
|
@@ -1133,7 +1136,7 @@ const Select = (props) => {
|
|
|
1133
1136
|
!multiple && renderSingleViewModel(),
|
|
1134
1137
|
multiple &&
|
|
1135
1138
|
React__default["default"].createElement("div", { className: styles$B.chipContainer }, renderMultipleViewModel()),
|
|
1136
|
-
React__default["default"].createElement(Icon, { className: "ml-
|
|
1139
|
+
React__default["default"].createElement(Icon, { className: "ml-auto" },
|
|
1137
1140
|
React__default["default"].createElement(ChevronDownSolidIcon, null))),
|
|
1138
1141
|
isShow &&
|
|
1139
1142
|
React__default["default"].createElement(Portal, { className: 'backdrop-root' },
|
|
@@ -1799,6 +1802,39 @@ const LoadingIndicatorContainer = ({ children, isFixed }) => {
|
|
|
1799
1802
|
return (React__default["default"].createElement("div", { className: getCssClasses() }, children));
|
|
1800
1803
|
};
|
|
1801
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
|
+
|
|
1802
1838
|
class LoadingIndicatorService {
|
|
1803
1839
|
show() {
|
|
1804
1840
|
if (this.container) {
|
|
@@ -1807,12 +1843,14 @@ class LoadingIndicatorService {
|
|
|
1807
1843
|
this.container = document.createElement('div');
|
|
1808
1844
|
this.container.classList.add('snackbar-container');
|
|
1809
1845
|
document.body.appendChild(this.container);
|
|
1810
|
-
|
|
1811
|
-
|
|
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)));
|
|
1812
1849
|
}
|
|
1813
1850
|
hide() {
|
|
1851
|
+
var _a;
|
|
1814
1852
|
if (this.container) {
|
|
1815
|
-
|
|
1853
|
+
(_a = this.root) === null || _a === void 0 ? void 0 : _a.unmount();
|
|
1816
1854
|
document.body.removeChild(this.container);
|
|
1817
1855
|
this.container = undefined;
|
|
1818
1856
|
this.handler && clearTimeout(this.handler);
|
|
@@ -1870,7 +1908,6 @@ const Modal = (props) => {
|
|
|
1870
1908
|
};
|
|
1871
1909
|
}, []);
|
|
1872
1910
|
const handleClickBackdrop = () => {
|
|
1873
|
-
console.warn('backdrop clicked');
|
|
1874
1911
|
onBackdropClick && onBackdropClick();
|
|
1875
1912
|
};
|
|
1876
1913
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
@@ -1886,7 +1923,6 @@ const Modal = (props) => {
|
|
|
1886
1923
|
React__default["default"].createElement(Backdrop, { onClick: handleClickBackdrop })));
|
|
1887
1924
|
};
|
|
1888
1925
|
|
|
1889
|
-
// export enum MODALRESULT { OK = 'OK', CANCEL = 'CANCEL', DELETE = 'DELETE' }
|
|
1890
1926
|
exports.MODALTYPE = void 0;
|
|
1891
1927
|
(function (MODALTYPE) {
|
|
1892
1928
|
MODALTYPE["BASIC"] = "BASIC";
|
|
@@ -1900,7 +1936,7 @@ exports.MODALBUTTONTYPE = void 0;
|
|
|
1900
1936
|
MODALBUTTONTYPE["DEFAULT"] = "DEFAULT";
|
|
1901
1937
|
})(exports.MODALBUTTONTYPE || (exports.MODALBUTTONTYPE = {}));
|
|
1902
1938
|
|
|
1903
|
-
const GlobalModal = ({ title, description, formControls, onOk, onCancel, onBackdropClick, isDismissable = false, buttons = [
|
|
1939
|
+
const GlobalModal = ({ title, description, formControls, onOk, onChange, onCancel, onBackdropClick, isDismissable = false, buttons = [
|
|
1904
1940
|
{ label: 'Cancel', type: exports.MODALBUTTONTYPE.CANCEL, color: exports.COLOR.secondary, variant: exports.VARIANT.text, shadow: false },
|
|
1905
1941
|
{ label: 'Ok', type: exports.MODALBUTTONTYPE.OK, variant: exports.VARIANT.contained, focus: true },
|
|
1906
1942
|
], size = exports.SIZE.md, fullScreen = false }) => {
|
|
@@ -1945,11 +1981,29 @@ const GlobalModal = ({ title, description, formControls, onOk, onCancel, onBackd
|
|
|
1945
1981
|
description && React__default["default"].createElement("div", null, description),
|
|
1946
1982
|
modalType === exports.MODALTYPE.FORM &&
|
|
1947
1983
|
React__default["default"].createElement(React.Fragment, null,
|
|
1948
|
-
React__default["default"].createElement(Form, { ref: myForm, controls: myControls, validateOnBlur: true, onSubmit: onSubmit }))));
|
|
1984
|
+
React__default["default"].createElement(Form, { ref: myForm, controls: myControls, validateOnBlur: true, onSubmit: onSubmit, onChange: onChange }))));
|
|
1949
1985
|
};
|
|
1950
1986
|
|
|
1951
1987
|
class ModalService {
|
|
1952
1988
|
show(title, description, options) {
|
|
1989
|
+
return new Promise((resolve, reject) => {
|
|
1990
|
+
if (!this.container) {
|
|
1991
|
+
this.container = document.createElement('div');
|
|
1992
|
+
document.body.appendChild(this.container);
|
|
1993
|
+
const handleOk = () => {
|
|
1994
|
+
resolve();
|
|
1995
|
+
this.hide();
|
|
1996
|
+
};
|
|
1997
|
+
const handleCancel = () => {
|
|
1998
|
+
reject();
|
|
1999
|
+
this.hide();
|
|
2000
|
+
};
|
|
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 }));
|
|
2003
|
+
}
|
|
2004
|
+
});
|
|
2005
|
+
}
|
|
2006
|
+
showForm(title, formControls, options) {
|
|
1953
2007
|
return new Promise((resolve, reject) => {
|
|
1954
2008
|
if (!this.container) {
|
|
1955
2009
|
this.container = document.createElement('div');
|
|
@@ -1958,17 +2012,23 @@ class ModalService {
|
|
|
1958
2012
|
resolve(values);
|
|
1959
2013
|
this.hide();
|
|
1960
2014
|
};
|
|
2015
|
+
// TODO - for AutoComplete
|
|
2016
|
+
// const handleOnChange = (values?: IFormValues) => {
|
|
2017
|
+
// console.info(values);
|
|
2018
|
+
// }
|
|
1961
2019
|
const handleCancel = () => {
|
|
1962
2020
|
reject();
|
|
1963
2021
|
this.hide();
|
|
1964
2022
|
};
|
|
1965
|
-
|
|
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 }));
|
|
1966
2025
|
}
|
|
1967
2026
|
});
|
|
1968
2027
|
}
|
|
1969
2028
|
hide() {
|
|
2029
|
+
var _a;
|
|
1970
2030
|
if (this.container) {
|
|
1971
|
-
|
|
2031
|
+
(_a = this.root) === null || _a === void 0 ? void 0 : _a.unmount();
|
|
1972
2032
|
document.body.removeChild(this.container);
|
|
1973
2033
|
this.container = undefined;
|
|
1974
2034
|
}
|
|
@@ -2205,12 +2265,14 @@ class SnackbarService {
|
|
|
2205
2265
|
resolve();
|
|
2206
2266
|
this.hide();
|
|
2207
2267
|
};
|
|
2208
|
-
|
|
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));
|
|
2209
2270
|
});
|
|
2210
2271
|
}
|
|
2211
2272
|
hide() {
|
|
2273
|
+
var _a;
|
|
2212
2274
|
if (this.container) {
|
|
2213
|
-
|
|
2275
|
+
(_a = this.root) === null || _a === void 0 ? void 0 : _a.unmount();
|
|
2214
2276
|
document.body.removeChild(this.container);
|
|
2215
2277
|
this.container = undefined;
|
|
2216
2278
|
this.handler && clearTimeout(this.handler);
|
|
@@ -2611,6 +2673,13 @@ const TableCell = (props) => {
|
|
|
2611
2673
|
React__default["default"].createElement("td", Object.assign({}, rest), children)) }, children));
|
|
2612
2674
|
};
|
|
2613
2675
|
|
|
2676
|
+
const TabContext = React.createContext({
|
|
2677
|
+
fixed: false,
|
|
2678
|
+
selectedValue: '',
|
|
2679
|
+
setSelectedValue: () => { }
|
|
2680
|
+
});
|
|
2681
|
+
const useTabContext = () => React.useContext(TabContext);
|
|
2682
|
+
|
|
2614
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}";
|
|
2615
2684
|
var styles$4 = {"tabIndicator":"TabIndicator-module_tabIndicator__jSJhH","primary":"TabIndicator-module_primary__Q5jEo","accent":"TabIndicator-module_accent__qbgIG"};
|
|
2616
2685
|
styleInject(css_248z$4);
|
|
@@ -2634,40 +2703,40 @@ var styles$3 = {"tabs":"Tabs-module_tabs__YyRTZ"};
|
|
|
2634
2703
|
styleInject(css_248z$3);
|
|
2635
2704
|
|
|
2636
2705
|
const Tabs = (props) => {
|
|
2637
|
-
const { children, className, fixed, color, indicatorColor
|
|
2638
|
-
const [selectedValue, setSelectedValue] = React.useState(
|
|
2639
|
-
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
|
+
if (value !== undefined && value !== prevSelectedValueRef.current) {
|
|
2717
|
+
setSelectedValue(value);
|
|
2718
|
+
}
|
|
2719
|
+
}, [value]);
|
|
2640
2720
|
React.useEffect(() => {
|
|
2641
2721
|
React__default["default"].Children.toArray(children).forEach((child, index) => {
|
|
2642
|
-
if (child.props.value ===
|
|
2722
|
+
if (child.props.value === selectedValue) {
|
|
2643
2723
|
setSelectedIndex(index);
|
|
2724
|
+
onChange && onChange(selectedValue);
|
|
2644
2725
|
}
|
|
2645
2726
|
});
|
|
2646
|
-
}, [children,
|
|
2727
|
+
}, [children, selectedValue]);
|
|
2647
2728
|
const getCssClasses = () => {
|
|
2648
2729
|
const cssClasses = [];
|
|
2649
2730
|
cssClasses.push(styles$3.tabs);
|
|
2650
2731
|
className && cssClasses.push(className);
|
|
2651
2732
|
return cssClasses.filter(css => css).join(' ');
|
|
2652
2733
|
};
|
|
2653
|
-
const handleClickTab = (event, newValue, index) => {
|
|
2654
|
-
setSelectedValue(newValue);
|
|
2655
|
-
setSelectedIndex(index);
|
|
2656
|
-
onChange && onChange({ event, newValue });
|
|
2657
|
-
};
|
|
2658
|
-
const renderTabs = (child, index) => {
|
|
2659
|
-
return React__default["default"].isValidElement(child) && React.cloneElement(child, {
|
|
2660
|
-
key: child.props.value,
|
|
2661
|
-
isActive: child.props.value === selectedValue,
|
|
2662
|
-
fixed: fixed,
|
|
2663
|
-
onClick: (e) => handleClickTab(e.event, e.value, index),
|
|
2664
|
-
});
|
|
2665
|
-
};
|
|
2666
2734
|
return (React__default["default"].createElement(ButtonContext.Provider, { value: { color: color || exports.COLOR.light } },
|
|
2667
|
-
React__default["default"].createElement(
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2735
|
+
React__default["default"].createElement(TabContext.Provider, { value: tabContext },
|
|
2736
|
+
React__default["default"].createElement("div", { className: getCssClasses() },
|
|
2737
|
+
children,
|
|
2738
|
+
children &&
|
|
2739
|
+
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 })))));
|
|
2671
2740
|
};
|
|
2672
2741
|
|
|
2673
2742
|
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}";
|
|
@@ -2675,17 +2744,19 @@ var styles$2 = {"tab":"Tab-module_tab__Q8w1f"};
|
|
|
2675
2744
|
styleInject(css_248z$2);
|
|
2676
2745
|
|
|
2677
2746
|
const Tab = (props) => {
|
|
2678
|
-
const { label, className,
|
|
2747
|
+
const { label, className, disabled, value, onClick } = props;
|
|
2748
|
+
const { selectedValue, setSelectedValue } = useTabContext();
|
|
2679
2749
|
const getCssClasses = () => {
|
|
2680
2750
|
const cssClasses = [];
|
|
2681
2751
|
cssClasses.push(styles$2.tab);
|
|
2682
|
-
if (isActive) {
|
|
2683
|
-
cssClasses.push(`show active`);
|
|
2684
|
-
}
|
|
2685
2752
|
className && cssClasses.push(className);
|
|
2686
2753
|
return cssClasses.filter(css => css).join(' ');
|
|
2687
2754
|
};
|
|
2688
|
-
|
|
2755
|
+
const handleClick = (event) => {
|
|
2756
|
+
onClick && onClick({ event, value });
|
|
2757
|
+
setSelectedValue(value);
|
|
2758
|
+
};
|
|
2759
|
+
return (React__default["default"].createElement(Button, { className: getCssClasses(), onClick: handleClick, isActive: selectedValue === value, disabled: disabled }, label));
|
|
2689
2760
|
};
|
|
2690
2761
|
|
|
2691
2762
|
const TabPanel = (props) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-asc",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "25.0.1",
|
|
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.
|
|
13
|
-
"react": "
|
|
14
|
-
"react-dom": "
|
|
15
|
-
"modern-normalize": "
|
|
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"
|