diginet-core-ui 1.3.43-beta.2 → 1.3.43-beta.5

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.
@@ -5,26 +5,29 @@ import { memo, useState, useRef, useEffect, useMemo, forwardRef, useImperativeHa
5
5
  import PropTypes from 'prop-types';
6
6
  import { jsx, css } from '@emotion/core';
7
7
  import OptionWrapper from '../others/option-wrapper';
8
- import { ButtonIcon, NumberInput, Dropdown } from '../';
8
+ import { ButtonIcon, NumberInput, Dropdown, Typography, Divider } from '../';
9
9
  import { getGlobal } from '../../global';
10
- import { typography } from '../../styles/typography';
11
- import { color as colors } from '../../styles/colors';
10
+ import theme from '../../theme/settings';
12
11
  import { alignCenter, borderBox, flexRow, noMargin, noPadding, border, textCenter, cursorPointer } from '../../styles/general';
13
12
  const {
14
- paragraph2
15
- } = typography;
16
- const {
17
- system: {
18
- active,
19
- white
13
+ colors: {
14
+ system: {
15
+ active,
16
+ white
17
+ },
18
+ line: {
19
+ system,
20
+ category
21
+ },
22
+ text: {
23
+ main
24
+ }
20
25
  },
21
- line: {
22
- system
26
+ typography: {
27
+ paragraph2
23
28
  },
24
- text: {
25
- main
26
- }
27
- } = colors;
29
+ spacing
30
+ } = theme;
28
31
 
29
32
  const getLastPage = (totalItems, itemsPerPage) => {
30
33
  let _lastPage = 0;
@@ -39,6 +42,7 @@ const getLastPage = (totalItems, itemsPerPage) => {
39
42
 
40
43
  let timeout = null;
41
44
  const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
45
+ id,
42
46
  typeShort,
43
47
  bgColor,
44
48
  style,
@@ -50,6 +54,8 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
50
54
  onChangePage,
51
55
  onChangePerPage
52
56
  }, reference) => {
57
+ var _currentPageState$toS;
58
+
53
59
  const ref = useRef(null);
54
60
  const [totalItemsState, setTotalItemsState] = useState(totalItems);
55
61
  const [itemsPerPageState, setItemsPerPageState] = useState(itemsPerPage || listPerPage[0] || 10);
@@ -58,7 +64,9 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
58
64
  const [disablePrevState, setDisablePrevState] = useState(true);
59
65
  const [disableNextState, setDisableNextState] = useState(!(totalItems > itemsPerPage));
60
66
 
61
- const _pagingInfoCSS = pagingInfoCSS(bgColor);
67
+ const _pagingInfoCSS = pagingInfoCSS(bgColor, typeShort);
68
+
69
+ const _dynamicWidthCSS = dynamicWidthCSS(((_currentPageState$toS = currentPageState.toString()) === null || _currentPageState$toS === void 0 ? void 0 : _currentPageState$toS.length) || 3);
62
70
 
63
71
  const _onChangePage = (page, isInit = false) => {
64
72
  const lastPage = getLastPage(totalItemsState, itemsPerPageState);
@@ -171,6 +179,7 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
171
179
  return jsx("div", {
172
180
  ref: ref,
173
181
  css: _pagingInfoCSS,
182
+ id: id,
174
183
  style: style,
175
184
  className: ['DGN-UI-PagingInfo', className].join(' ').trim().replace(/\s+/g, ' ')
176
185
  }, jsx(ButtonIcon, {
@@ -188,6 +197,7 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
188
197
  disabled: disablePrevState,
189
198
  onClick: () => _onChangePage(currentPageState - 1)
190
199
  }), jsx(NumberInput, {
200
+ css: _dynamicWidthCSS,
191
201
  disabledNegative: true,
192
202
  className: 'inputPage',
193
203
  value: currentPageState ? String(currentPageState + 1) : '1',
@@ -195,7 +205,12 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
195
205
  max: lastPage,
196
206
  onKeyDown: checkKeyPress,
197
207
  onChange: e => onTypePaging(e === null || e === void 0 ? void 0 : e.value)
198
- }), "/", ` ${lastPage}`, jsx(ButtonIcon, {
208
+ }), "/", jsx(Typography, {
209
+ type: 'p2',
210
+ style: {
211
+ margin: '0 2px'
212
+ }
213
+ }, lastPage), jsx(ButtonIcon, {
199
214
  circular: true,
200
215
  viewType: 'text',
201
216
  size: 'small',
@@ -209,10 +224,14 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
209
224
  name: 'ArrowDoubleRight',
210
225
  disabled: disableNextState,
211
226
  onClick: () => _onChangePage(lastPage - 1)
227
+ }), typeShort && jsx(Divider, {
228
+ direction: 'vertical',
229
+ height: 24,
230
+ color: category
212
231
  }), !typeShort && jsx("span", {
213
232
  className: "txt-line-number"
214
- }, getGlobal('lineNumber')), !typeShort && jsx(Dropdown, {
215
- viewType: 'outlined',
233
+ }, getGlobal('lineNumber')), jsx(Dropdown, {
234
+ viewType: 'underlined',
216
235
  dataSource: listPerPageData,
217
236
  value: itemsPerPageState,
218
237
  onChange: e => _onChangePerPage(e === null || e === void 0 ? void 0 : e.value),
@@ -225,13 +244,17 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
225
244
  dropdownItemStyle: {
226
245
  color: active
227
246
  }
247
+ }), typeShort && jsx(Divider, {
248
+ direction: 'vertical',
249
+ height: 24,
250
+ color: category
228
251
  }), jsx("span", {
229
252
  className: 'total-items'
230
- }, getGlobal('total') + ':', " ", totalItemsState));
253
+ }, !typeShort && getGlobal('total') + ':', " ", totalItemsState));
231
254
  }, [typeShort, bgColor, style, className, totalItemsState, itemsPerPageState, currentPageState, listPerPageState, disablePrevState, disableNextState]);
232
255
  }));
233
256
 
234
- const pagingInfoCSS = bgColor => css`
257
+ const pagingInfoCSS = (bgColor, typeShort) => css`
235
258
  ${flexRow};
236
259
  ${alignCenter};
237
260
  ${paragraph2};
@@ -240,33 +263,36 @@ const pagingInfoCSS = bgColor => css`
240
263
  height: 40px;
241
264
  border-left: none;
242
265
  border-right: none;
243
- padding: 4px 0;
266
+ padding: ${spacing()}px 0;
244
267
  background-color: ${bgColor};
245
268
  color: ${main};
246
269
  .inputPage {
247
270
  ${noMargin};
248
271
  ${textCenter};
249
- width: 1%;
250
- min-width: 24px;
272
+ min-width: 28px;
251
273
  .DGN-UI-InputBase {
252
274
  ${noPadding};
253
275
  input {
254
276
  ${paragraph2};
255
277
  ${textCenter};
256
278
  color: ${active};
279
+ text-align: left;
257
280
  }
258
281
  }
259
282
  }
260
283
  .txt-line-number {
261
- margin-left: 16px;
284
+ margin-left: ${spacing(4)}px;
285
+ }
286
+ .DGN-UI-Divider {
287
+ margin: 0px ${spacing(2)}px;
262
288
  }
263
289
  .DGN-UI-Dropdown {
264
- margin-left: 8px;
290
+ margin-left: ${typeShort ? '0px' : `${spacing(2)}px`};
265
291
  margin-bottom: 0;
266
- min-width: 56px;
292
+ min-width: 52px;
267
293
  .DGN-UI-Dropdown-Form {
268
- min-height: 32px;
269
- padding: 0 0 0 8px;
294
+ min-height: 24px;
295
+ padding: 0;
270
296
  input {
271
297
  ${paragraph2};
272
298
  ${noPadding};
@@ -274,15 +300,26 @@ const pagingInfoCSS = bgColor => css`
274
300
  }
275
301
  .DGN-UI-Dropdown-Icon {
276
302
  margin-left: 6px;
277
- margin-right: 6px;
303
+ div,
304
+ span,
305
+ svg {
306
+ width: 20px;
307
+ min-width: 20px;
308
+ height: 20px;
309
+ min-height: 20px;
310
+ }
278
311
  }
279
312
  }
280
313
  }
281
314
  .total-items {
282
- margin-left: 16px;
315
+ margin-left: ${typeShort ? '0px' : `${spacing(4)}px`};
283
316
  }
284
317
  `;
285
318
 
319
+ const dynamicWidthCSS = characters => css`
320
+ width: ${characters}ch;
321
+ `;
322
+
286
323
  PagingInfo.defaultProps = {
287
324
  typeShort: false,
288
325
  bgColor: white,
@@ -293,34 +330,34 @@ PagingInfo.defaultProps = {
293
330
  listPerPage: [10, 15, 20, 30, 50]
294
331
  };
295
332
  PagingInfo.propTypes = {
296
- /** compact type for mobile */
333
+ /** Compact type for mobile. */
297
334
  typeShort: PropTypes.bool,
298
335
 
299
- /** background color for paging */
336
+ /** Background color for paging. */
300
337
  bgColor: PropTypes.string,
301
338
 
302
- /** style inline for Paging */
339
+ /** Style inline of component. */
303
340
  style: PropTypes.object,
304
341
 
305
- /** className for Paging */
342
+ /** Class for component. */
306
343
  className: PropTypes.string,
307
344
 
308
- /** current of paging */
345
+ /** Specifies the current page. */
309
346
  currentPage: PropTypes.number,
310
347
 
311
- /** total items of paging */
348
+ /** Total items of paging. */
312
349
  totalItems: PropTypes.number,
313
350
 
314
- /** the quantity of items on per page */
351
+ /** The quantity of items per page. */
315
352
  itemsPerPage: PropTypes.number,
316
353
 
317
- /** the list to choose the number of elements to display per page */
354
+ /** The list to choose the number of elements to display per page. */
318
355
  listPerPage: PropTypes.array,
319
356
 
320
- /** the function will run after change page number */
357
+ /** The function will run after change page number. */
321
358
  onChangePage: PropTypes.func,
322
359
 
323
- /** the function will run after change quantity on per page */
360
+ /** The function will run after change quantity on per page. */
324
361
  onChangePerPage: PropTypes.func,
325
362
 
326
363
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.43-beta.2",
3
+ "version": "1.3.43-beta.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",