diginet-core-ui 1.3.51-beta.1 → 1.3.51-beta.2
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/form-control/dropdown/index.js +35 -35
- package/components/popover/index.js +45 -17
- package/package.json +1 -1
- package/styles/general.js +11 -11
|
@@ -1809,14 +1809,14 @@ Dropdown.propTypes = {
|
|
|
1809
1809
|
/** display this icon if not found the icon follow iconExpr */
|
|
1810
1810
|
iconDefault: PropTypes.string,
|
|
1811
1811
|
|
|
1812
|
-
/** field name used for icon display<br/>
|
|
1813
|
-
* Example:<br/>
|
|
1814
|
-
* string: 'icon'<br/>
|
|
1815
|
-
* object: {<br/>
|
|
1816
|
-
* key: 'icon',<br/>
|
|
1817
|
-
* prefix: 'https://imglink.com',<br/>
|
|
1818
|
-
* suffix: '.jpg'<br/>
|
|
1819
|
-
* }
|
|
1812
|
+
/** field name used for icon display<br/>
|
|
1813
|
+
* Example:<br/>
|
|
1814
|
+
* string: 'icon'<br/>
|
|
1815
|
+
* object: {<br/>
|
|
1816
|
+
* key: 'icon',<br/>
|
|
1817
|
+
* prefix: 'https://imglink.com',<br/>
|
|
1818
|
+
* suffix: '.jpg'<br/>
|
|
1819
|
+
* }
|
|
1820
1820
|
*/
|
|
1821
1821
|
iconExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
|
|
1822
1822
|
key: PropTypes.string,
|
|
@@ -1831,9 +1831,9 @@ Dropdown.propTypes = {
|
|
|
1831
1831
|
/** the displayed value for each change */
|
|
1832
1832
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1833
1833
|
|
|
1834
|
-
/** field name used for text display<br/>
|
|
1835
|
-
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1836
|
-
* Note: don't use 'id - name', return undefined
|
|
1834
|
+
/** field name used for text display<br/>
|
|
1835
|
+
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1836
|
+
* Note: don't use 'id - name', return undefined
|
|
1837
1837
|
*/
|
|
1838
1838
|
displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1839
1839
|
|
|
@@ -1843,10 +1843,10 @@ Dropdown.propTypes = {
|
|
|
1843
1843
|
/** the field name used for the returned result */
|
|
1844
1844
|
valueExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1845
1845
|
|
|
1846
|
-
/**
|
|
1847
|
-
* duration wait enter search content on search<br/>
|
|
1848
|
-
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1849
|
-
* If true, used default delayOnInput
|
|
1846
|
+
/**
|
|
1847
|
+
* duration wait enter search content on search<br/>
|
|
1848
|
+
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1849
|
+
* If true, used default delayOnInput
|
|
1850
1850
|
*/
|
|
1851
1851
|
searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
|
|
1852
1852
|
|
|
@@ -1913,19 +1913,19 @@ Dropdown.propTypes = {
|
|
|
1913
1913
|
/** The array of elements that appear in the dropdown */
|
|
1914
1914
|
dataSource: PropTypes.array,
|
|
1915
1915
|
|
|
1916
|
-
/** function displays items by custom<br/>
|
|
1917
|
-
* renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
|
|
1918
|
-
* --> such as: displayExpr={'name - role'}
|
|
1916
|
+
/** function displays items by custom<br/>
|
|
1917
|
+
* renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
|
|
1918
|
+
* --> such as: displayExpr={'name - role'}
|
|
1919
1919
|
*/
|
|
1920
1920
|
renderItem: PropTypes.func,
|
|
1921
1921
|
|
|
1922
|
-
/** function displays selected items by custom, example:<br/>
|
|
1923
|
-
* renderItem={(data, index) => index + ' - ' + data.name}<br/>
|
|
1922
|
+
/** function displays selected items by custom, example:<br/>
|
|
1923
|
+
* renderItem={(data, index) => index + ' - ' + data.name}<br/>
|
|
1924
1924
|
*/
|
|
1925
1925
|
renderSelectedItem: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
1926
1926
|
|
|
1927
|
-
/** the function will run when entering input<br/>
|
|
1928
|
-
* if undefined: the filter function will run (default)
|
|
1927
|
+
/** the function will run when entering input<br/>
|
|
1928
|
+
* if undefined: the filter function will run (default)
|
|
1929
1929
|
*/
|
|
1930
1930
|
onInput: PropTypes.func,
|
|
1931
1931
|
|
|
@@ -1944,19 +1944,19 @@ Dropdown.propTypes = {
|
|
|
1944
1944
|
/** the contents in Dropdown box (Exp: TreeView) */
|
|
1945
1945
|
children: PropTypes.node,
|
|
1946
1946
|
|
|
1947
|
-
/**
|
|
1948
|
-
* ref methods
|
|
1949
|
-
*
|
|
1950
|
-
* how to get component element? ref.current
|
|
1951
|
-
*
|
|
1952
|
-
* how to call method? ref.current.instance.{method}
|
|
1953
|
-
*
|
|
1954
|
-
* * showDropdown(): Show dropdown
|
|
1955
|
-
* * closeDropdown(): Close dropdown
|
|
1956
|
-
* * onClear(): Clear selected value
|
|
1957
|
-
* * setPreviousValue(): Set value to previous value
|
|
1958
|
-
* * setValue(value): Set value of dropdown
|
|
1959
|
-
* * @param {value} - string || number || array
|
|
1947
|
+
/**
|
|
1948
|
+
* ref methods
|
|
1949
|
+
*
|
|
1950
|
+
* how to get component element? ref.current
|
|
1951
|
+
*
|
|
1952
|
+
* how to call method? ref.current.instance.{method}
|
|
1953
|
+
*
|
|
1954
|
+
* * showDropdown(): Show dropdown
|
|
1955
|
+
* * closeDropdown(): Close dropdown
|
|
1956
|
+
* * onClear(): Clear selected value
|
|
1957
|
+
* * setPreviousValue(): Set value to previous value
|
|
1958
|
+
* * setValue(value): Set value of dropdown
|
|
1959
|
+
* * @param {value} - string || number || array
|
|
1960
1960
|
*/
|
|
1961
1961
|
reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
1962
1962
|
current: PropTypes.instanceOf(Element)
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import { memo, useState, useEffect, useMemo, useRef, forwardRef, useImperativeHandle } from 'react';
|
|
4
|
+
import React, { memo, useState, useEffect, useMemo, useRef, forwardRef, useImperativeHandle } from 'react';
|
|
5
5
|
import { createPortal } from 'react-dom';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { jsx, css } from '@emotion/core';
|
|
8
|
-
import { typography } from '../../styles/typography';
|
|
9
8
|
import { borderRadius4px, displayBlock, flexRow, parseWidthHeight, positionAbsolute, positionFixed, positionRelative } from '../../styles/general';
|
|
10
|
-
import
|
|
9
|
+
import theme from '../../theme/settings';
|
|
11
10
|
const {
|
|
11
|
+
colors: {
|
|
12
|
+
system: {
|
|
13
|
+
white
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
typography: {
|
|
17
|
+
paragraph1
|
|
18
|
+
},
|
|
12
19
|
zIndex: zIndexCORE
|
|
13
|
-
} =
|
|
14
|
-
const {
|
|
15
|
-
paragraph1
|
|
16
|
-
} = typography;
|
|
20
|
+
} = theme;
|
|
17
21
|
|
|
18
22
|
const getArrowPosition = (anchorOrigin, transformOrigin, translate) => {
|
|
19
23
|
if (anchorOrigin.horizontal === 'right' && transformOrigin.horizontal === 'left') {
|
|
@@ -131,6 +135,14 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
131
135
|
const [openState, setOpenState] = useState(open);
|
|
132
136
|
const [element, setElement] = useState(null);
|
|
133
137
|
|
|
138
|
+
const _PortalPopoverCSS = PortalPopoverCSS(zIndex, fullScreen);
|
|
139
|
+
|
|
140
|
+
const _PopoverContainerCSS = PopoverContainerCSS(width, height);
|
|
141
|
+
|
|
142
|
+
const _PopoverRootCSS = PopoverRootCSS(bgColor);
|
|
143
|
+
|
|
144
|
+
const _PopoverArrowCSS = PopoverArrowCSS(bgColor);
|
|
145
|
+
|
|
134
146
|
if (direction) {
|
|
135
147
|
const directionObject = getDirectionPopover(direction);
|
|
136
148
|
anchorOrigin = directionObject.anchorOrigin;
|
|
@@ -272,7 +284,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
272
284
|
break;
|
|
273
285
|
}
|
|
274
286
|
|
|
275
|
-
Object.assign(ref.current.querySelector(`.css-${
|
|
287
|
+
Object.assign(ref.current.querySelector(`.css-${_PopoverArrowCSS.name}`).style, arrowPosition, {
|
|
276
288
|
transform: translate.transform
|
|
277
289
|
});
|
|
278
290
|
}
|
|
@@ -341,27 +353,43 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
341
353
|
|
|
342
354
|
return currentRef;
|
|
343
355
|
});
|
|
356
|
+
|
|
357
|
+
const renderAnchor = () => {
|
|
358
|
+
var _anchor;
|
|
359
|
+
|
|
360
|
+
if (!((_anchor = anchor) !== null && _anchor !== void 0 && _anchor.type)) return null;
|
|
361
|
+
const AnchorTag = /*#__PURE__*/React.cloneElement(anchor, {
|
|
362
|
+
onClick: () => {
|
|
363
|
+
setOpenState(true);
|
|
364
|
+
},
|
|
365
|
+
ref: ref => {
|
|
366
|
+
anchor = ref;
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
return AnchorTag;
|
|
370
|
+
};
|
|
371
|
+
|
|
344
372
|
const PopoverView = useMemo(() => {
|
|
345
373
|
if (openState) {
|
|
346
374
|
const node = jsx("div", {
|
|
347
375
|
className: 'DGN-UI-Portal DGN-UI-Popover',
|
|
348
|
-
css:
|
|
376
|
+
css: _PortalPopoverCSS
|
|
349
377
|
}, jsx("div", {
|
|
350
|
-
css:
|
|
378
|
+
css: _PopoverContainerCSS,
|
|
351
379
|
ref: ref,
|
|
352
380
|
...props
|
|
353
381
|
}, jsx("div", {
|
|
354
|
-
css:
|
|
382
|
+
css: _PopoverRootCSS,
|
|
355
383
|
style: style
|
|
356
384
|
}, arrow && jsx("span", {
|
|
357
|
-
css:
|
|
385
|
+
css: _PopoverArrowCSS
|
|
358
386
|
}), children)));
|
|
359
387
|
return /*#__PURE__*/createPortal(node, document.body);
|
|
360
388
|
}
|
|
361
389
|
|
|
362
390
|
return null;
|
|
363
391
|
}, [openState, zIndex, fullScreen, style, arrow, children, width, height, bgColor]);
|
|
364
|
-
return PopoverView;
|
|
392
|
+
return jsx(React.Fragment, null, renderAnchor(), PopoverView);
|
|
365
393
|
}));
|
|
366
394
|
|
|
367
395
|
const PortalPopoverCSS = (zIndex, fullScreen) => css`
|
|
@@ -410,7 +438,7 @@ Popover.defaultProps = {
|
|
|
410
438
|
arrow: false,
|
|
411
439
|
width: 150,
|
|
412
440
|
height: 'auto',
|
|
413
|
-
bgColor:
|
|
441
|
+
bgColor: white,
|
|
414
442
|
zIndex: zIndexCORE(1),
|
|
415
443
|
anchorOrigin: {
|
|
416
444
|
vertical: 'bottom',
|
|
@@ -423,10 +451,10 @@ Popover.defaultProps = {
|
|
|
423
451
|
style: {}
|
|
424
452
|
};
|
|
425
453
|
Popover.propTypes = {
|
|
426
|
-
/** If true
|
|
454
|
+
/** If `true`, the component is shown. */
|
|
427
455
|
open: PropTypes.bool,
|
|
428
456
|
|
|
429
|
-
/** If true
|
|
457
|
+
/** If `true`, arrow is shown. */
|
|
430
458
|
arrow: PropTypes.bool,
|
|
431
459
|
|
|
432
460
|
/** allow close Popover when press ESC. */
|
|
@@ -439,7 +467,7 @@ Popover.propTypes = {
|
|
|
439
467
|
style: PropTypes.object,
|
|
440
468
|
|
|
441
469
|
/** An HTML element, or a function that returns one. It's used to set the position of the popover. */
|
|
442
|
-
anchor: PropTypes.oneOfType([PropTypes.instanceOf(Element), PropTypes.func, PropTypes.object]),
|
|
470
|
+
anchor: PropTypes.oneOfType([PropTypes.instanceOf(Element), PropTypes.func, PropTypes.object, PropTypes.node]),
|
|
443
471
|
|
|
444
472
|
/**
|
|
445
473
|
* This is the point on the anchor where the popover's anchor will attach to.
|
package/package.json
CHANGED
package/styles/general.js
CHANGED
|
@@ -4,10 +4,10 @@ import { color } from './colors';
|
|
|
4
4
|
import { parseToPixel } from './utils';
|
|
5
5
|
export const rootSpacing = 4;
|
|
6
6
|
export let rootZIndex = 1500;
|
|
7
|
-
/**
|
|
8
|
-
* get value spacing with rootZIndex
|
|
9
|
-
* @param number
|
|
10
|
-
* @return {number}
|
|
7
|
+
/**
|
|
8
|
+
* get value spacing with rootZIndex
|
|
9
|
+
* @param number
|
|
10
|
+
* @return {number}
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
export const zIndex = number => {
|
|
@@ -15,10 +15,10 @@ export const zIndex = number => {
|
|
|
15
15
|
if (isNaN(number)) return rootZIndex;
|
|
16
16
|
return rootZIndex + number;
|
|
17
17
|
};
|
|
18
|
-
/**
|
|
19
|
-
* get value spacing with rootSpacing
|
|
20
|
-
* @param {(number|number[])} vl - default 1
|
|
21
|
-
* @returns {(number|string)}
|
|
18
|
+
/**
|
|
19
|
+
* get value spacing with rootSpacing
|
|
20
|
+
* @param {(number|number[])} vl - default 1
|
|
21
|
+
* @returns {(number|string)}
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
export const getSpacing = (vl = 1) => {
|
|
@@ -27,9 +27,9 @@ export const getSpacing = (vl = 1) => {
|
|
|
27
27
|
return `${vl.flatMap(i => Number(i !== null && i !== void 0 ? i : 0) * rootSpacing).join('px ')}px`;
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
-
/**
|
|
31
|
-
* replace rootZIndex
|
|
32
|
-
* @param number
|
|
30
|
+
/**
|
|
31
|
+
* replace rootZIndex
|
|
32
|
+
* @param number
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
35
|
export const setZIndex = number => {
|