armtek-uikit-react 1.0.75 → 1.0.76
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/assets/Accordion.scss +12 -0
- package/assets/Dropdown.scss +4 -1
- package/package.json +1 -1
- package/ui/Accordion/Accordion.d.ts +15 -0
- package/ui/Accordion/Accordion.js +91 -0
- package/ui/Accordion/Accordion.module.scss +1 -0
- package/ui/Accordion/index.d.ts +2 -0
- package/ui/Accordion/index.js +2 -0
- package/ui/Dropdown/Dropdown.d.ts +4 -3
- package/ui/Dropdown/Dropdown.js +21 -16
package/assets/Dropdown.scss
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"armtek-uikit-react","version":"1.0.
|
|
1
|
+
{"name":"armtek-uikit-react","version":"1.0.76","description":"Armtek UIKit for React","repository":{"type":"git","url":"ssh://git@gl.corp:10022/int/uikit/uikit_react.git"},"author":"","license":"ISC","dependencies":{"build":"^0.1.4","clsx":"^2.0.0","rc-slider":"^10.2.1","react":"*","react-datepicker":"^4.16.0","react-dom":"*","react-transition-group":"^4.4.5"},"peerDependencies":{"react":"*","react-dom":"*"},"scripts":{"pub":"npm version patch && npm publish"}}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
import { DropDownProps } from '../Dropdown';
|
|
3
|
+
type ClassNames = 'AccordionHead' | 'AccordionBody' | 'AccordionTitle' | 'AccordionToggle';
|
|
4
|
+
type OwnProps = {
|
|
5
|
+
title: string | ReactNode;
|
|
6
|
+
classNames?: Record<ClassNames, string>;
|
|
7
|
+
expanded?: boolean;
|
|
8
|
+
defaultExpanded?: boolean;
|
|
9
|
+
onChange?: () => void;
|
|
10
|
+
transitionProps?: DropDownProps['transitionProps'];
|
|
11
|
+
triggerOnIcon?: boolean;
|
|
12
|
+
};
|
|
13
|
+
type AccordionProps = OwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof OwnProps>;
|
|
14
|
+
declare const Accordion: (props: AccordionProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export default Accordion;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import css from "./Accordion.module.scss";
|
|
6
|
+
import Dropdown from "../Dropdown";
|
|
7
|
+
import ButtonIcon from "../ButtonIcon";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
+
const Accordion = props => {
|
|
12
|
+
let {
|
|
13
|
+
title,
|
|
14
|
+
children,
|
|
15
|
+
className,
|
|
16
|
+
classNames,
|
|
17
|
+
expanded,
|
|
18
|
+
defaultExpanded,
|
|
19
|
+
onChange,
|
|
20
|
+
triggerOnIcon,
|
|
21
|
+
transitionProps,
|
|
22
|
+
...divPops
|
|
23
|
+
} = props;
|
|
24
|
+
const [isExpanded, setIsExpanded] = useState(!!defaultExpanded);
|
|
25
|
+
const openProp = expanded !== undefined ? expanded : isExpanded;
|
|
26
|
+
const [contentHidden, setContentHidden] = useState(!openProp);
|
|
27
|
+
const iconCode = openProp ? 'expand_less' : 'expand_more';
|
|
28
|
+
const handleExpand = () => {
|
|
29
|
+
if (expanded === undefined) setIsExpanded(prev => !prev);
|
|
30
|
+
if (onChange) onChange();
|
|
31
|
+
};
|
|
32
|
+
const handleHeadClick = () => {
|
|
33
|
+
if (!triggerOnIcon) handleExpand();
|
|
34
|
+
};
|
|
35
|
+
const handleIconClick = e => {
|
|
36
|
+
e.stopPropagation();
|
|
37
|
+
handleExpand();
|
|
38
|
+
};
|
|
39
|
+
const handleExit = () => {
|
|
40
|
+
if (!(transitionProps != null && transitionProps.unmountOnExit)) setContentHidden(true);
|
|
41
|
+
if (transitionProps != null && transitionProps.onExit) transitionProps.onExit();
|
|
42
|
+
};
|
|
43
|
+
const handleEnter = isAppearing => {
|
|
44
|
+
if (!(transitionProps != null && transitionProps.unmountOnExit)) setContentHidden(false);
|
|
45
|
+
if (transitionProps != null && transitionProps.onEnter) transitionProps.onEnter(isAppearing);
|
|
46
|
+
};
|
|
47
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
48
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
49
|
+
...divPops,
|
|
50
|
+
className: clsx(css.Accordion, className),
|
|
51
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
52
|
+
className: clsx(css.AccordionHead, classNames == null ? void 0 : classNames.AccordionHead),
|
|
53
|
+
onClick: handleHeadClick,
|
|
54
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
55
|
+
className: clsx(classNames == null ? void 0 : classNames.AccordionTitle),
|
|
56
|
+
children: title
|
|
57
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
58
|
+
className: clsx(classNames == null ? void 0 : classNames.AccordionTitle, css.AccordionToggle),
|
|
59
|
+
children: /*#__PURE__*/_jsx(ButtonIcon, {
|
|
60
|
+
onClick: handleIconClick,
|
|
61
|
+
size: 'small',
|
|
62
|
+
color: 'neutral',
|
|
63
|
+
variant: 'transparent',
|
|
64
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
65
|
+
className: "mi",
|
|
66
|
+
children: iconCode
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
})]
|
|
70
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
71
|
+
className: clsx(classNames == null ? void 0 : classNames.AccordionBody),
|
|
72
|
+
children: /*#__PURE__*/_jsx(Dropdown, {
|
|
73
|
+
transitionProps: {
|
|
74
|
+
unmountOnExit: true,
|
|
75
|
+
...transitionProps,
|
|
76
|
+
onExit: handleExit,
|
|
77
|
+
onEnter: handleEnter
|
|
78
|
+
},
|
|
79
|
+
expanded: openProp,
|
|
80
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
81
|
+
style: {
|
|
82
|
+
display: contentHidden ? 'none' : 'block'
|
|
83
|
+
},
|
|
84
|
+
children: children
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
})]
|
|
88
|
+
})
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
export default Accordion;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "./../../assets/Accordion";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ComponentPropsWithoutRef } from 'react';
|
|
2
|
-
|
|
2
|
+
import { CSSTransitionProps } from 'react-transition-group/CSSTransition';
|
|
3
|
+
export type DropDownProps = {
|
|
3
4
|
expanded?: boolean;
|
|
4
|
-
|
|
5
|
+
transitionProps?: Partial<CSSTransitionProps<HTMLElement>>;
|
|
5
6
|
} & ComponentPropsWithoutRef<'div'>;
|
|
6
|
-
declare function Dropdown(props:
|
|
7
|
+
declare function Dropdown(props: DropDownProps): import("react/jsx-runtime").JSX.Element;
|
|
7
8
|
export default Dropdown;
|
package/ui/Dropdown/Dropdown.js
CHANGED
|
@@ -12,7 +12,7 @@ function Dropdown(props) {
|
|
|
12
12
|
children,
|
|
13
13
|
className,
|
|
14
14
|
expanded,
|
|
15
|
-
|
|
15
|
+
transitionProps,
|
|
16
16
|
...divProps
|
|
17
17
|
} = props;
|
|
18
18
|
const nodeRef = useRef(null);
|
|
@@ -25,22 +25,27 @@ function Dropdown(props) {
|
|
|
25
25
|
children: /*#__PURE__*/_jsx("div", {
|
|
26
26
|
...divProps,
|
|
27
27
|
className: clsx('Arm-dropdown', css.Dropdown, className),
|
|
28
|
-
children: /*#__PURE__*/_jsx(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
29
|
+
className: clsx({
|
|
30
|
+
// [css.Dropdown__ContentWrapper_hidden]: !expanded
|
|
31
|
+
}),
|
|
32
|
+
children: /*#__PURE__*/_jsx(CSSTransition, {
|
|
33
|
+
classNames: {
|
|
34
|
+
'enter': css.Dropdown__ContentWrapperEnter,
|
|
35
|
+
'enterActive': css.Dropdown__ContentWrapperEnterActive,
|
|
36
|
+
'exit': css.Dropdown__ContentWrapperExit,
|
|
37
|
+
'exitActive': css.Dropdown__ContentWrapperExitActive
|
|
38
|
+
},
|
|
39
|
+
in: expanded,
|
|
40
|
+
timeout: duration,
|
|
41
|
+
nodeRef: nodeRef,
|
|
42
|
+
...transitionProps,
|
|
41
43
|
children: /*#__PURE__*/_jsx("div", {
|
|
42
|
-
|
|
43
|
-
children:
|
|
44
|
+
ref: nodeRef,
|
|
45
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
46
|
+
className: css.Dropdown__Content,
|
|
47
|
+
children: children
|
|
48
|
+
})
|
|
44
49
|
})
|
|
45
50
|
})
|
|
46
51
|
})
|