armtek-uikit-react 1.0.94 → 1.0.95

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.
@@ -16,12 +16,14 @@
16
16
  padding: $size-step 0;
17
17
  border-radius: $radius;
18
18
  box-shadow: $box-shadow;
19
- position: absolute;
19
+ //position: absolute;
20
20
  left:0;
21
21
  top:100%;
22
- width:100%;
22
+ //width:100%;
23
23
  background: #fff;
24
24
  z-index: 100;
25
+ max-height: 400px;
26
+ overflow: auto;
25
27
  }
26
28
  .options_inline{
27
29
  position: static;
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"armtek-uikit-react","version":"1.0.94","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"}}
1
+ {"name":"armtek-uikit-react","version":"1.0.95","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"}}
@@ -54,7 +54,7 @@ export const DateField = /*#__PURE__*/forwardRef((props, ref) => {
54
54
  }), open && /*#__PURE__*/_jsx(BackDrop, {
55
55
  onClick: () => setOpen(false),
56
56
  children: /*#__PURE__*/_jsx(PopperBase, {
57
- anchorEl: btnRef,
57
+ anchorEl: btnRef.current,
58
58
  open: open,
59
59
  placement: 'bottom-end',
60
60
  children: /*#__PURE__*/_jsx("div", {
@@ -4,11 +4,11 @@ import TextField from "../TextField/TextField";
4
4
  import { forwardRef, useRef, useState } from 'react';
5
5
  import clsx from 'clsx';
6
6
  import ListItem from "../../List/ListItem";
7
- import useClickOutside from "../../../lib/hooks/useClickOutside";
8
7
  import css from "./Select.module.scss";
9
8
  import ButtonIcon from "../../ButtonIcon";
10
9
  import Adornment from "../../Adornment";
11
10
  import { SelectSummary, SelectSummaryChips } from "./SelectSummary";
11
+ import Popover from "../../Popover";
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { Fragment as _Fragment } from "react/jsx-runtime";
14
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -41,11 +41,30 @@ function Select(props) {
41
41
  let [focused, setFocused] = useState(false);
42
42
  let [q, setQ] = useState('');
43
43
  let selectRef = useRef(null);
44
- let optRef = useClickOutside(() => setActive(false));
45
- const handleOpen = flag => {
46
- if (!inputProps.disabled) setActive(prev => flag !== undefined ? flag : !prev);
44
+ const [anchorEl, setAnchorEl] = useState(null);
45
+
46
+ // let selectEl!: HTMLSelectElement
47
+ //
48
+ // useEffect(() => {
49
+ // selectEl = document.createElement('select')
50
+ // selectEl.onchange = (e) => {
51
+ // console.log(e)
52
+ // }
53
+ // return () => {
54
+ // selectEl.remove()
55
+ // }
56
+ // }, [])
57
+
58
+ const handleOpen = e => {
59
+ if (!inputProps.disabled) {
60
+ setActive(true);
61
+ if (e.target instanceof HTMLDivElement) setAnchorEl(e.currentTarget);
62
+ }
47
63
  };
48
64
  const handleSelect = option => {
65
+ // selectEl.sele = option.value
66
+ // selectEl?.dispatchEvent(new Event('change', { bubbles: true }))
67
+
49
68
  let v = getOptionValue(option);
50
69
  let mSelected = Array.isArray(selected) ? selected : [selected];
51
70
  let newValueS = v;
@@ -121,13 +140,12 @@ function Select(props) {
121
140
  if (!!search) options = options.filter(item => item.text.toLowerCase().includes(q.toLowerCase()));
122
141
  let valueArr = realValue ? Array.isArray(realValue) ? realValue : [realValue] : [];
123
142
  let selectedOptions = options.filter(item => valueArr.includes(getOptionValue(item)));
124
- return /*#__PURE__*/_jsx(_Fragment, {
125
- children: /*#__PURE__*/_jsxs("div", {
143
+ return /*#__PURE__*/_jsxs(_Fragment, {
144
+ children: [/*#__PURE__*/_jsxs("div", {
126
145
  className: css.select,
127
- ref: optRef,
128
146
  children: [/*#__PURE__*/_jsxs("div", {
129
147
  className: css.select__input_wrapper,
130
- onClick: () => handleOpen(true),
148
+ onClick: handleOpen,
131
149
  children: [/*#__PURE__*/_jsx("select", {
132
150
  multiple: multiple,
133
151
  ref: selectRef,
@@ -156,7 +174,13 @@ function Select(props) {
156
174
  options: selectedOptions,
157
175
  disabled: inputProps.disabled,
158
176
  onDelete: handleSelect
159
- }), realActive && /*#__PURE__*/_jsx(SelectOptions, {
177
+ })]
178
+ }), anchorEl && /*#__PURE__*/_jsx(Popover, {
179
+ anchorEl: anchorEl,
180
+ open: realActive,
181
+ onClose: () => setActive(false),
182
+ placement: 'bottom-start',
183
+ children: /*#__PURE__*/_jsx(SelectOptions, {
160
184
  disabled: inputProps.disabled,
161
185
  options: options,
162
186
  multiple: multiple,
@@ -167,8 +191,8 @@ function Select(props) {
167
191
  onClearAll: handleResetAll,
168
192
  onSelectAll: handleSelectAll,
169
193
  onSubmit: handleSubmit
170
- })]
171
- })
194
+ })
195
+ })]
172
196
  });
173
197
  }
174
198
  const SelectOptions = /*#__PURE__*/forwardRef((props, ref) => {
@@ -1,2 +1,3 @@
1
1
  export { default } from './Select';
2
2
  export * from './Select';
3
+ export * from './SelectSummary';
@@ -1,2 +1,3 @@
1
1
  export { default } from "./Select";
2
- export * from "./Select";
2
+ export * from "./Select";
3
+ export * from "./SelectSummary";
@@ -1,6 +1,7 @@
1
1
  import { PopperBaseProps } from '../../ui/Popper';
2
2
  export type PopoverProps = {
3
3
  onClose?: () => void;
4
+ matchWidth?: boolean;
4
5
  } & PopperBaseProps;
5
6
  export declare const Popover: (props: PopoverProps) => import("react/jsx-runtime").JSX.Element | null;
6
7
  export default Popover;
@@ -5,6 +5,7 @@ import { Fragment as _Fragment } from "react/jsx-runtime";
5
5
  export const Popover = props => {
6
6
  const {
7
7
  onClose,
8
+ matchWidth = true,
8
9
  children,
9
10
  ...poperProps
10
11
  } = props;
@@ -14,7 +15,12 @@ export const Popover = props => {
14
15
  onClick: onClose,
15
16
  children: /*#__PURE__*/_jsx(PopperBase, {
16
17
  ...poperProps,
17
- children: children
18
+ children: /*#__PURE__*/_jsx("div", {
19
+ style: matchWidth ? {
20
+ width: poperProps.anchorEl.clientWidth
21
+ } : undefined,
22
+ children: children
23
+ })
18
24
  })
19
25
  })
20
26
  });
@@ -1,7 +1,7 @@
1
- import { MutableRefObject, ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  export type PopperBaseProps = {
3
3
  children: ReactNode;
4
- anchorEl: MutableRefObject<any>;
4
+ anchorEl: Element;
5
5
  open?: boolean;
6
6
  placement?: 'bottom-end' | 'bottom-start' | 'bottom' | 'left-end' | 'left-start' | 'left' | 'right-end' | 'right-start' | 'right' | 'top-end' | 'top-start' | 'top';
7
7
  };
@@ -13,7 +13,7 @@ export const PopperBase = props => {
13
13
  } = props;
14
14
  const tooltipRef = useRef(null);
15
15
  useEffect(() => {
16
- const popper = createPopper(anchorEl.current, tooltipRef.current, {
16
+ const popper = createPopper(anchorEl, tooltipRef.current, {
17
17
  placement: placement,
18
18
  modifiers: [{
19
19
  name: 'offset',
@@ -69,10 +69,10 @@ function Tooltip(props) {
69
69
  childrenProps.onMouseLeave = composeEventHandler(handleMouseLeave, childrenProps.onMouseLeave);
70
70
  childrenProps.ref = anchorEl;
71
71
  return /*#__PURE__*/_jsxs(_Fragment, {
72
- children: [/*#__PURE__*/cloneElement(children, childrenProps), /*#__PURE__*/_jsx(Popper, {
72
+ children: [/*#__PURE__*/cloneElement(children, childrenProps), anchorEl.current && /*#__PURE__*/_jsx(Popper, {
73
73
  placement: placement,
74
74
  open: openState,
75
- anchorEl: anchorEl,
75
+ anchorEl: anchorEl.current,
76
76
  children: /*#__PURE__*/_jsx("span", {
77
77
  className: css.tooltip__item,
78
78
  children: text