diginet-core-ui 1.3.90 → 1.3.91

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.
@@ -1,13 +1,12 @@
1
1
  /** @jsxRuntime classic */
2
2
  /** @jsx jsx */
3
- import { forwardRef, Fragment, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
4
- import PropTypes from 'prop-types';
5
- import { jsx, css, keyframes } from '@emotion/core';
6
- import OptionWrapper from "../others/option-wrapper";
7
- import { useIntersection } from "../../utils/intersectionObserver";
8
- import { classNames } from "../../utils";
3
+ import { css, jsx, keyframes } from '@emotion/core';
9
4
  import AvatarDefault from "../../assets/avatar/default.svg";
10
- import { itemsCenter, displayInlineFlex, overflowHidden, parseWidthHeight, positionRelative } from "../../styles/general";
5
+ import OptionWrapper from "../others/option-wrapper";
6
+ import PropTypes from 'prop-types';
7
+ import { forwardRef, Fragment, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
8
+ import { borderRadius, displayInlineFlex, itemsCenter, objectCover, overflowHidden, parseWidthHeight, positionRelative } from "../../styles/general";
9
+ import { classNames, useIntersection } from "../../utils";
11
10
  const blurKeyframe = keyframes`
12
11
  0% { -webkit-filter: blur(4px);}
13
12
  25% { -webkit-filter: blur(3px);}
@@ -29,6 +28,7 @@ const Image = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
29
28
  style,
30
29
  width
31
30
  }, reference) => {
31
+ if (!reference) reference = useRef(null);
32
32
  if (!defaultSrc) defaultSrc = AvatarDefault;
33
33
  const ref = useRef(null);
34
34
  const [srcState, setSrcState] = useState(src);
@@ -53,6 +53,9 @@ const Image = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
53
53
  };
54
54
  }
55
55
  }
56
+ return () => {
57
+ setSrcState(defaultSrc);
58
+ };
56
59
  }, [src]);
57
60
  useImperativeHandle(reference, () => {
58
61
  const currentRef = ref.current || {};
@@ -66,21 +69,16 @@ const Image = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
66
69
  });
67
70
  const renderImage = () => {
68
71
  const defaultImage = jsx("img", {
72
+ css: objectCover,
69
73
  src: defaultSrc,
70
74
  alt: '',
71
- style: {
72
- objectFit: 'cover'
73
- },
74
75
  width: width,
75
76
  height: height
76
77
  });
77
78
  const image = jsx(Fragment, null, !onLoaded && defaultImage, jsx("img", {
78
- css: blurAnimationCSS,
79
+ css: [blurAnimationCSS, objectCover],
79
80
  src: srcState,
80
81
  alt: alt || srcState,
81
- style: {
82
- objectFit: 'cover'
83
- },
84
82
  onLoad: () => setOnLoaded(true),
85
83
  width: width,
86
84
  height: height
@@ -105,7 +103,7 @@ const ImageCSS = (width, height, circular) => css`
105
103
  ${itemsCenter};
106
104
  ${overflowHidden};
107
105
  ${parseWidthHeight(width, height)};
108
- ${circular && `border-radius: 50%`};
106
+ ${circular && borderRadius('50%')};
109
107
  `;
110
108
  const blurAnimationCSS = css`
111
109
  animation: ${blurKeyframe} 1s ease;
@@ -29,6 +29,7 @@ export { default as Badge } from "./badge";
29
29
  // BUTTON
30
30
  export { default as Button } from "./button";
31
31
  export { default as ButtonIcon } from "./button/icon";
32
+ export { default as ButtonMore } from "./button/more";
32
33
 
33
34
  // BREADCRUMB
34
35
  export { default as Breadcrumb } from "./breadcrumb";
@@ -120,7 +121,6 @@ export { default as PopoverFooter } from "./popover/footer";
120
121
  export { default as Popup } from "./popup/v2";
121
122
  export { default as PopupV2 } from "./popup/v2";
122
123
  export { default as DangerPopup } from "./popup/danger_popup";
123
- export { default as ProposalsPopup } from "./popup/proposals_popup";
124
124
 
125
125
  // SLIDER
126
126
  export { default as Slider } from "./slider/slider-container";
@@ -2,6 +2,7 @@
2
2
  /** @jsx jsx */
3
3
  import { useState, forwardRef, useEffect } from 'react';
4
4
  import { jsx } from '@emotion/core';
5
+ import sx from "../../../styles/sx";
5
6
  const OptionWrapper = WrappedComponent => {
6
7
  return /*#__PURE__*/forwardRef((props, ref) => {
7
8
  const [options, setOptions] = useState({});
@@ -28,7 +29,8 @@ const OptionWrapper = WrappedComponent => {
28
29
  action: {
29
30
  option
30
31
  },
31
- ref: ref
32
+ ref: ref,
33
+ css: sx(props === null || props === void 0 ? void 0 : props.sx)
32
34
  });
33
35
  });
34
36
  };
@@ -8,7 +8,7 @@ import { forwardRef, Fragment, memo, useCallback, useEffect, useImperativeHandle
8
8
  import { createPortal } from 'react-dom';
9
9
  import { animations } from "../../../styles/animation";
10
10
  import { hexToRGBA } from "../../../styles/color-helper";
11
- import { itemsCenter, border, boxBorder, borderRadius4px, borderRadius50, breakWord, cursorPointer, displayBlock, truncate, flexCol, flexRow, justifyCenter, justifyEnd, overflowAuto, overflowHidden, parseHeight, parseMaxWidthHeight, parseMinHeight, parseMinWidth, parseWidth, parseWidthHeight, positionFixed, positionRelative } from "../../../styles/general";
11
+ import { bgColor, border, borderRadius, borderRadius50, boxBorder, breakWord, cursorPointer, displayBlock, displayFlex, flexCol, flexRow, inset, itemsCenter, justifyCenter, justifyEnd, mg, mgb, mgr, mgt, overflowAuto, overflowHidden, parseHeight, parseMaxWidthHeight, parseMinHeight, parseMinWidth, parseWidth, parseWidthHeight, pd, positionFixed, positionRelative, textColor, textEllipsis, textUnderline, truncate, z } from "../../../styles/general";
12
12
  import { useTheme } from "../../../theme";
13
13
  import { classNames, refType as ref, useDelayUnmount } from "../../../utils";
14
14
  const {
@@ -26,9 +26,7 @@ const {
26
26
  'scrollbar-tabbar': fillScrollbarTabbar,
27
27
  hover: fillHover
28
28
  }
29
- },
30
- spacing,
31
- zIndex: zIndexCORE
29
+ }
32
30
  } = useTheme();
33
31
  const colorMap = new Map([['yesno', semanticInfo], ['success', semanticSuccess], ['warning', semanticWarning], ['danger', semanticDanger], ['info', semanticInfo]]);
34
32
  const titleMap = new Map([['yesno', 'notify'], ['success', 'confirm'], ['warning', 'warning'], ['danger', 'error'], ['info', 'notify']]);
@@ -57,6 +55,7 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
57
55
  yesText,
58
56
  ...props
59
57
  }, reference) => {
58
+ if (!reference) reference = useRef(null);
60
59
  const ref = useRef(null);
61
60
  const statusAction = useRef('');
62
61
  const [openState, setOpenState] = useState(open);
@@ -86,14 +85,14 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
86
85
  };
87
86
  const popup = jsx(Fragment, null, PopupHeaderView(newProps.title, newProps.type), jsx("div", {
88
87
  className: 'DGN-UI-Popup-Body'
89
- }, newProps.icon !== false && jsx("div", {
88
+ }, newProps.icon !== false ? jsx("div", {
90
89
  className: 'DGN-UI-Popup-Body-Icon'
91
90
  }, jsx(Icon, {
92
91
  name: newProps.icon === true ? iconMap.get(newProps.type) : newProps.icon,
93
92
  width: 40,
94
93
  height: 40,
95
94
  color: colorMap.get(newProps.type)
96
- })), jsx("div", {
95
+ })) : null, jsx("div", {
97
96
  className: 'DGN-UI-Popup-Body-Description'
98
97
  }, jsx(Typography, {
99
98
  type: 'p2'
@@ -174,28 +173,28 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
174
173
  const PopupBodyView = (icon, type, subtitle, description) => {
175
174
  return jsx("div", {
176
175
  className: 'DGN-UI-Popup-Body'
177
- }, icon !== false && jsx("div", {
176
+ }, icon !== false ? jsx("div", {
178
177
  className: 'DGN-UI-Popup-Body-Icon'
179
178
  }, jsx(Icon, {
180
179
  name: icon === true ? iconMap.get(type) : icon,
181
180
  width: 40,
182
181
  height: 40,
183
182
  color: colorMap.get(type)
184
- })), jsx("div", {
183
+ })) : null, jsx("div", {
185
184
  className: 'DGN-UI-Popup-Body-Description'
186
185
  }, jsx(Typography, {
187
186
  type: 'p2'
188
- }, subtitle && jsx(Typography, {
187
+ }, subtitle ? jsx(Typography, {
189
188
  className: 'DGN-UI-Popup-Body-Subtitle',
190
189
  fullWidth: true
191
- }, subtitle), jsx(Typography, {
190
+ }, subtitle) : null, jsx(Typography, {
192
191
  ref: onRefChange,
193
192
  type: 'p2',
194
193
  className: 'DGN-UI-Popup-Body-Detail'
195
- }, description), (subtitle && descriptionLines > 1 || descriptionLines > 3) && jsx("span", {
194
+ }, description), subtitle && descriptionLines > 1 || descriptionLines > 3 ? jsx("span", {
196
195
  className: 'DGN-More-Action',
197
196
  onClick: () => setShowMoreDescription(!showMoreDescription)
198
- }, getGlobal(showMoreDescription ? 'showLess' : 'showMore')))));
197
+ }, getGlobal(showMoreDescription ? 'showLess' : 'showMore')) : null)));
199
198
  };
200
199
  const PopupActionView = (onConfirm, confirmProps, onCancel, cancelProps, type, yesText, noText) => {
201
200
  return onConfirm || onCancel || type === 'yesno' ? jsx("div", {
@@ -226,29 +225,29 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
226
225
  style: style,
227
226
  className: classNames('DGN-UI-Portal DGN-UI-Popup-Portal', className)
228
227
  }, jsx("div", {
229
- className: `DGN-UI-Popup ${openState ? 'DGN-Show' : 'DGN-Hide'}`,
228
+ className: classNames('DGN-UI-Popup', openState ? 'DGN-Show' : 'DGN-Hide'),
230
229
  ...props
231
230
  }, custom ? custom : jsx(Fragment, null, PopupHeaderView(title, type), PopupBodyView(icon, type, subtitle, description), PopupActionView(onConfirm, confirmProps, onCancel, cancelProps, type, yesText, noText)))), document.body);
232
231
  }));
233
232
  const PopupRootCSS = (width, top, type, description, subtitle, showMoreDescription, descriptionLines) => css`
233
+ ${displayFlex};
234
234
  ${flexRow};
235
235
  ${positionFixed};
236
236
  ${justifyCenter};
237
237
  ${breakWord};
238
238
  ${parseWidthHeight('100%')};
239
- top: 0;
240
- left: 0;
241
- inset: 0;
242
- background-color: rgba(21, 26, 48, 0.5);
243
- z-index: ${zIndexCORE(2)};
239
+ ${inset(0)};
240
+ ${bgColor('rgba(21, 26, 48, 0.5)')}
241
+ ${z(2)};
244
242
  .DGN-UI-Popup {
243
+ ${displayFlex};
245
244
  ${flexCol};
246
- ${borderRadius4px};
247
245
  ${boxBorder};
246
+ ${borderRadius(4)};
248
247
  ${parseWidthHeight(width, 'fit-content')};
249
248
  ${parseMaxWidthHeight('80%')};
249
+ ${bgColor(systemWhite)};
250
250
  margin: ${isNaN(top) ? top : top + 'px'} auto auto;
251
- background-color: ${systemWhite};
252
251
  box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.25);
253
252
  &.DGN-Show {
254
253
  animation: ${fadeInDown} 0.2s ease;
@@ -258,40 +257,43 @@ const PopupRootCSS = (width, top, type, description, subtitle, showMoreDescripti
258
257
  animation-fill-mode: forwards;
259
258
  }
260
259
  .DGN-UI-Popup-Header {
260
+ ${displayFlex};
261
261
  ${flexRow};
262
262
  ${itemsCenter};
263
263
  ${parseMinHeight(40)};
264
- padding: ${spacing([0, 2, 0, 4])};
265
- border-radius: 4px 4px 0px 0px;
264
+ ${pd([0, 2, 0, 4])};
265
+ ${borderRadius('4px 4px 0px 0px')};
266
266
  .DGN-UI-Popup-Header-Title {
267
+ ${displayFlex};
267
268
  ${flexRow};
268
269
  ${truncate};
269
270
  ${parseWidth('calc(100% - 24px)')};
270
271
  }
271
272
  color: ${colorMap.get(type)};
272
- background-color: ${hexToRGBA(colorMap.get(type), 0.15)};
273
+ ${bgColor(hexToRGBA(colorMap.get(type), 0.15))};
273
274
  }
274
275
  .DGN-UI-Popup-Body {
276
+ ${displayFlex};
275
277
  ${flexRow};
276
278
  ${positionRelative};
277
279
  ${overflowAuto};
280
+ ${pd([4])};
278
281
  flex: 1 1 auto;
279
- padding: ${spacing([4])};
280
282
  &::-webkit-scrollbar {
281
- ${borderRadius4px};
283
+ ${borderRadius(4)};
282
284
  ${parseWidth(24)};
283
285
  background-color: ${systemWhite} !important;
284
286
  }
285
287
  &::-webkit-scrollbar-thumb {
286
288
  ${border(8, 'transparent')};
287
- border-radius: 24px;
289
+ ${borderRadius(24)};
288
290
  mix-blend-mode: normal;
289
291
  background-color: ${fillScrollbarTabbar} !important;
290
292
  background-clip: content-box;
291
293
  }
292
294
  &::-webkit-scrollbar-thumb:hover {
293
295
  ${border(8, 'transparent')};
294
- border-radius: 24px;
296
+ ${borderRadius(24)};
295
297
  mix-blend-mode: normal;
296
298
  background-color: ${fillHover} !important;
297
299
  background-clip: content-box;
@@ -300,20 +302,21 @@ const PopupRootCSS = (width, top, type, description, subtitle, showMoreDescripti
300
302
  ${displayBlock};
301
303
  ${borderRadius50};
302
304
  ${parseWidth(40)};
303
- margin-right: ${spacing([4])};
305
+ ${mgr([4])};
304
306
  }
305
307
  .DGN-UI-Popup-Body-Description {
308
+ ${displayFlex};
306
309
  ${flexRow};
307
310
  ${positionRelative};
308
311
  ${itemsCenter};
309
312
  ${parseMinHeight(40)};
310
313
  ${parseHeight('max-content')};
311
314
  .DGN-UI-Popup-Body-Subtitle {
312
- margin-bottom: ${(description === null || description === void 0 ? void 0 : description.length) > 0 ? spacing([2]) : spacing([0])};
315
+ ${mgb([(description === null || description === void 0 ? void 0 : description.length) > 0 ? 2 : 0])};
313
316
  }
314
317
  .DGN-UI-Popup-Body-Detail {
315
318
  ${overflowHidden};
316
- text-overflow: ellipsis;
319
+ ${textEllipsis};
317
320
  display: -webkit-box;
318
321
  -webkit-line-clamp: ${showMoreDescription ? 'none' : subtitle && descriptionLines > 1 ? 1 : descriptionLines > 3 ? 3 : 'none'};
319
322
  -webkit-box-orient: vertical;
@@ -321,23 +324,24 @@ const PopupRootCSS = (width, top, type, description, subtitle, showMoreDescripti
321
324
  .DGN-More-Action {
322
325
  ${displayBlock};
323
326
  ${cursorPointer};
324
- width: fit-content;
325
- margin-top: ${spacing([4])};
326
- margin-bottom: ${type === 'yesno' ? spacing([0]) : spacing([2])};
327
- text-decoration: underline;
328
- color: ${semanticInfo};
327
+ ${parseWidth('fit-content')};
328
+ ${mgt([4])};
329
+ ${mgb([type === 'yesno' ? 0 : 2])};
330
+ ${textUnderline};
331
+ ${textColor('semantic.info')};
329
332
  }
330
333
  }
331
334
  }
332
335
  .DGN-UI-Popup-Action {
336
+ ${displayFlex};
333
337
  ${flexRow};
334
338
  ${justifyEnd};
335
- padding: ${spacing([2, 4, 4, 4])};
339
+ ${pd([2, 4, 4, 4])};
336
340
  .DGN-UI-Button {
337
341
  ${parseMinWidth(80)};
338
- margin: 0;
342
+ ${mg(0)};
339
343
  &.filled {
340
- margin-right: ${spacing([2])};
344
+ ${mgr([2])};
341
345
  }
342
346
  }
343
347
  }
@@ -345,6 +349,7 @@ const PopupRootCSS = (width, top, type, description, subtitle, showMoreDescripti
345
349
  `;
346
350
  Popup.defaultProps = {
347
351
  className: '',
352
+ description: '',
348
353
  icon: true,
349
354
  open: false,
350
355
  pressESCToClose: false,
@@ -243,14 +243,14 @@ Rating.propTypes = {
243
243
  className: PropTypes.string,
244
244
  /** Style inline of component. */
245
245
  style: PropTypes.object,
246
- /**
247
- * Callback fired when the value changes.
248
- *
249
- function(event: React.SyntheticEvent, value: number) => void
250
- *
251
- * event: The event source of the callback.
252
- *
253
- * value: The new value.
246
+ /**
247
+ * Callback fired when the value changes.
248
+ *
249
+ function(event: React.SyntheticEvent, value: number) => void
250
+ *
251
+ * event: The event source of the callback.
252
+ *
253
+ * value: The new value.
254
254
  */
255
255
  onRating: PropTypes.func
256
256
  };
@@ -93,8 +93,8 @@ TabContainer.propTypes = {
93
93
  width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
94
94
  /** Any props else. */
95
95
  props: PropTypes.any,
96
- /**
97
- * Ref methods.
96
+ /**
97
+ * Ref methods.
98
98
  */
99
99
  reference: ref
100
100
  };
@@ -142,8 +142,8 @@ TabHeader.propTypes = {
142
142
  width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
143
143
  /** Any props else. */
144
144
  props: PropTypes.any,
145
- /**
146
- * Ref methods.
145
+ /**
146
+ * Ref methods.
147
147
  */
148
148
  reference: ref
149
149
  };
@@ -79,8 +79,8 @@ TabPanel.propTypes = {
79
79
  style: PropTypes.object,
80
80
  /** Any props else. */
81
81
  props: PropTypes.any,
82
- /**
83
- * Ref methods.
82
+ /**
83
+ * Ref methods.
84
84
  */
85
85
  reference: ref
86
86
  };
@@ -189,8 +189,8 @@ TabItem.propTypes = {
189
189
  style: PropTypes.object,
190
190
  /** Any props else. */
191
191
  props: PropTypes.any,
192
- /**
193
- * Ref methods.
192
+ /**
193
+ * Ref methods.
194
194
  */
195
195
  reference: ref
196
196
  };
@@ -416,9 +416,9 @@ Transfer.propTypes = {
416
416
  height: oneOfType([string, number]),
417
417
  /** field name used for icon display */
418
418
  iconExpr: string,
419
- /** field name used for text display<br/>
420
- * Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
421
- * Note: don't use 'id - name', return undefined
419
+ /** field name used for text display<br/>
420
+ * Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
421
+ * Note: don't use 'id - name', return undefined
422
422
  */
423
423
  displayExpr: oneOfType([string, array]),
424
424
  /** display header to select all choices if true */