armtek-uikit-react 1.0.74 → 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 +41 -0
- 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 +8 -0
- package/ui/Dropdown/Dropdown.js +55 -0
- package/ui/Dropdown/Dropdown.module.scss +1 -0
- package/ui/Dropdown/index.d.ts +2 -0
- package/ui/Dropdown/index.js +2 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
@import "variables";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
.Dropdown {
|
|
5
|
+
|
|
6
|
+
&__ContentWrapper {
|
|
7
|
+
&_hidden{
|
|
8
|
+
display: none;
|
|
9
|
+
}
|
|
10
|
+
&Enter {
|
|
11
|
+
opacity: 0;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
max-height: 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&EnterActive {
|
|
17
|
+
opacity: 1;
|
|
18
|
+
max-height: var(--content-height);
|
|
19
|
+
transition: opacity 0.3s, max-height 1s cubic-bezier(0, 1, 0, 1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&Exit {
|
|
23
|
+
opacity: 1;
|
|
24
|
+
max-height: var(--content-height);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&ExitActive {
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
opacity: 0;
|
|
30
|
+
max-height: 0;
|
|
31
|
+
transition: opacity 0.3s, max-height 1s cubic-bezier(0, 1, 0, 1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&__Content {
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
transition: all 0.3s;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
}
|
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";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import { CSSTransitionProps } from 'react-transition-group/CSSTransition';
|
|
3
|
+
export type DropDownProps = {
|
|
4
|
+
expanded?: boolean;
|
|
5
|
+
transitionProps?: Partial<CSSTransitionProps<HTMLElement>>;
|
|
6
|
+
} & ComponentPropsWithoutRef<'div'>;
|
|
7
|
+
declare function Dropdown(props: DropDownProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default Dropdown;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { CSSTransition } from 'react-transition-group';
|
|
6
|
+
import css from "./Dropdown.module.scss";
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
9
|
+
function Dropdown(props) {
|
|
10
|
+
var _nodeRef$current;
|
|
11
|
+
const {
|
|
12
|
+
children,
|
|
13
|
+
className,
|
|
14
|
+
expanded,
|
|
15
|
+
transitionProps,
|
|
16
|
+
...divProps
|
|
17
|
+
} = props;
|
|
18
|
+
const nodeRef = useRef(null);
|
|
19
|
+
const contentHeight = (_nodeRef$current = nodeRef.current) == null ? void 0 : _nodeRef$current.scrollHeight;
|
|
20
|
+
const duration = 1000;
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (nodeRef.current && contentHeight) nodeRef.current.style.setProperty("--content-height", String(contentHeight) + 'px');
|
|
23
|
+
}, [contentHeight]);
|
|
24
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
25
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
26
|
+
...divProps,
|
|
27
|
+
className: clsx('Arm-dropdown', css.Dropdown, className),
|
|
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,
|
|
43
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
44
|
+
ref: nodeRef,
|
|
45
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
46
|
+
className: css.Dropdown__Content,
|
|
47
|
+
children: children
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export default Dropdown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "./../../assets/Dropdown.scss";
|