diginet-core-ui 1.3.38 → 1.3.40

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.
@@ -4,25 +4,22 @@
4
4
  import { memo, useState, useRef, useEffect, useMemo, forwardRef, useImperativeHandle } from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { jsx, css } from '@emotion/core';
7
+ import OptionWrapper from '../others/option-wrapper';
7
8
  import { ButtonIcon, NumberInput, Dropdown } from '../';
8
9
  import { getGlobal } from '../../global';
9
10
  import { typography } from '../../styles/typography';
10
11
  import { color as colors } from '../../styles/colors';
11
- import { alignCenter, borderBox, borderRadius4px, flexRow, noMargin, noPadding, border, textCenter, outlineNone, backgroundTransparent, cursorPointer } from '../../styles/general';
12
- import { hexToRGBA } from '../../styles/color-helper';
12
+ import { alignCenter, borderBox, flexRow, noMargin, noPadding, border, textCenter, cursorPointer } from '../../styles/general';
13
13
  const {
14
14
  paragraph2
15
15
  } = typography;
16
16
  const {
17
17
  system: {
18
- active
19
- },
20
- semantic: {
21
- info
18
+ active,
19
+ white
22
20
  },
23
21
  line: {
24
- system,
25
- normal
22
+ system
26
23
  },
27
24
  text: {
28
25
  main
@@ -52,98 +49,16 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
52
49
  listPerPage,
53
50
  onChangePage,
54
51
  onChangePerPage
55
- }, ref) => {
56
- if (!ref) {
57
- ref = useRef(null);
58
- }
59
-
52
+ }, reference) => {
53
+ const ref = useRef(null);
60
54
  const [totalItemsState, setTotalItemsState] = useState(totalItems);
61
55
  const [itemsPerPageState, setItemsPerPageState] = useState(itemsPerPage || listPerPage[0] || 10);
62
56
  const [currentPageState, setCurrentPageState] = useState(currentPage);
63
57
  const [listPerPageState, setListPerPageState] = useState(listPerPage);
64
58
  const [disablePrevState, setDisablePrevState] = useState(true);
65
59
  const [disableNextState, setDisableNextState] = useState(!(totalItems > itemsPerPage));
66
- const pagingInfo = css`
67
- ${flexRow}
68
- ${alignCenter}
69
- ${paragraph2}
70
- ${borderBox}
71
- ${border(1, system)}
72
- height: 40px;
73
- border-left: none;
74
- border-right: none;
75
- padding: 4px 0;
76
- background-color: ${bgColor};
77
- color: ${main};
78
- .inputPage {
79
- ${noMargin}
80
- ${textCenter}
81
- width: 1%;
82
- min-width: 24px;
83
- .DGN-UI-InputBase {
84
- ${noPadding}
85
- input {
86
- ${paragraph2}
87
- ${textCenter}
88
- color: ${active};
89
- }
90
- }
91
- }
92
- .slash {
93
- margin: 0 4px;
94
- }
95
- .txt-line-number {
96
- margin-left: 16px;
97
- }
98
- .DGN-UI-Dropdown {
99
- margin-bottom: 0;
100
- margin-left: ${typeShort ? 0 : '8px'};
101
- min-width: 56px;
102
- .DGN-UI-Dropdown-Form {
103
- min-height: 32px;
104
- padding: 0 0 0 8px;
105
- input {
106
- ${paragraph2}
107
- ${noPadding}
108
- ${cursorPointer}
109
- }
110
- .DGN-UI-Dropdown-Icon {
111
- margin-left: 6px;
112
- margin-right: 6px;
113
- }
114
- }
115
- }
116
- /* .pagePer {
117
- ${borderRadius4px}
118
- ${borderBox}
119
- ${paragraph2}
120
- ${outlineNone}
121
- ${backgroundTransparent}
122
- ${border(1, normal)}
123
- color: ${active};
124
- margin-left: ${typeShort ? 0 : '8px'};
125
- padding: 6px 6px 6px 8px;
126
- min-width: 56px;
127
- min-height: 32px;
128
- width: max-content;
129
- &:hover {
130
- border-color: ${active};
131
- background-color: ${hexToRGBA(active, 0.8)};
132
- }
133
- &:active,
134
- &:focus {
135
- border-color: ${info};
136
- }
137
- option {
138
- ${paragraph2}
139
- color: ${active};
140
- background-color: white;
141
- }
142
- } */
143
- .total-items {
144
- margin-left: ${typeShort ? 0 : '16px'};
145
- }
146
- `;
60
+
61
+ const _pagingInfoCSS = pagingInfoCSS(bgColor);
147
62
 
148
63
  const _onChangePage = (page, isInit = false) => {
149
64
  const lastPage = getLastPage(totalItemsState, itemsPerPageState);
@@ -221,8 +136,17 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
221
136
  useEffect(() => {
222
137
  setListPerPageState(listPerPage);
223
138
  }, [listPerPage]);
224
- useImperativeHandle(ref, () => {
139
+ useImperativeHandle(reference, () => {
225
140
  const currentRef = ref.current || {};
141
+ const _instance = {
142
+ onChangePage: page => _onChangePage(page),
143
+ onChangePerPage: per => _onChangePerPage(per),
144
+ setTotalItems: items => setTotalItemsState(items)
145
+ }; // methods
146
+
147
+ _instance.__proto__ = {}; // hidden methods
148
+
149
+ currentRef.instance = _instance;
226
150
 
227
151
  currentRef.onChangePage = page => _onChangePage(page);
228
152
 
@@ -234,16 +158,21 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
234
158
  });
235
159
  return useMemo(() => {
236
160
  const lastPage = getLastPage(totalItemsState, itemsPerPageState);
237
- let listPerPageData = [];
161
+ let listPerPageData = !listPerPageState.includes(itemsPerPageState) ? [{
162
+ name: itemsPerPageState,
163
+ id: itemsPerPageState
164
+ }] : [];
238
165
  listPerPageState.map(item => listPerPageData = [...listPerPageData, {
239
166
  name: item,
240
167
  id: item
241
168
  }]);
169
+ listPerPageData = [...new Map(listPerPageData.map(v => [JSON.stringify(v), v])).values()];
170
+ listPerPageData.sort((a, b) => a.id - b.id);
242
171
  return jsx("div", {
243
172
  ref: ref,
244
- css: pagingInfo,
173
+ css: _pagingInfoCSS,
245
174
  style: style,
246
- className: ['DGN-UI-PageInfo', className].join(' ').trim().replace(/\s+/g, ' ')
175
+ className: ['DGN-UI-PagingInfo', className].join(' ').trim().replace(/\s+/g, ' ')
247
176
  }, jsx(ButtonIcon, {
248
177
  circular: true,
249
178
  viewType: 'text',
@@ -280,35 +209,83 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
280
209
  name: 'ArrowDoubleRight',
281
210
  disabled: disableNextState,
282
211
  onClick: () => _onChangePage(lastPage - 1)
283
- }), typeShort && jsx("span", {
284
- className: 'slash'
285
- }, "|"), !typeShort && jsx("span", {
212
+ }), !typeShort && jsx("span", {
286
213
  className: "txt-line-number"
287
- }, getGlobal('lineNumber')), jsx(Dropdown, {
214
+ }, getGlobal('lineNumber')), !typeShort && jsx(Dropdown, {
288
215
  viewType: 'outlined',
289
216
  dataSource: listPerPageData,
290
- defaultValue: itemsPerPageState,
217
+ value: itemsPerPageState,
291
218
  onChange: e => _onChangePerPage(e === null || e === void 0 ? void 0 : e.value),
292
219
  inputStyle: {
293
220
  width: `${Math.max(...listPerPageState).toString().length}ch`
294
221
  },
295
222
  inputProps: {
296
223
  readOnly: true
297
- } // dropdownItemStyle={{padding: '4px 8px', minHeight: 18, color: active}}
298
- ,
224
+ },
299
225
  dropdownItemStyle: {
300
226
  color: active
301
227
  }
302
- }), typeShort && jsx("span", {
303
- className: 'slash'
304
- }, "|"), jsx("span", {
228
+ }), jsx("span", {
305
229
  className: 'total-items'
306
- }, !typeShort ? getGlobal('total') + ':' : '', " ", totalItemsState));
230
+ }, getGlobal('total') + ':', " ", totalItemsState));
307
231
  }, [typeShort, bgColor, style, className, totalItemsState, itemsPerPageState, currentPageState, listPerPageState, disablePrevState, disableNextState]);
308
232
  }));
233
+
234
+ const pagingInfoCSS = bgColor => css`
235
+ ${flexRow};
236
+ ${alignCenter};
237
+ ${paragraph2};
238
+ ${borderBox};
239
+ ${border(1, system)};
240
+ height: 40px;
241
+ border-left: none;
242
+ border-right: none;
243
+ padding: 4px 0;
244
+ background-color: ${bgColor};
245
+ color: ${main};
246
+ .inputPage {
247
+ ${noMargin};
248
+ ${textCenter};
249
+ width: 1%;
250
+ min-width: 24px;
251
+ .DGN-UI-InputBase {
252
+ ${noPadding};
253
+ input {
254
+ ${paragraph2};
255
+ ${textCenter};
256
+ color: ${active};
257
+ }
258
+ }
259
+ }
260
+ .txt-line-number {
261
+ margin-left: 16px;
262
+ }
263
+ .DGN-UI-Dropdown {
264
+ margin-left: 8px;
265
+ margin-bottom: 0;
266
+ min-width: 56px;
267
+ .DGN-UI-Dropdown-Form {
268
+ min-height: 32px;
269
+ padding: 0 0 0 8px;
270
+ input {
271
+ ${paragraph2};
272
+ ${noPadding};
273
+ ${cursorPointer};
274
+ }
275
+ .DGN-UI-Dropdown-Icon {
276
+ margin-left: 6px;
277
+ margin-right: 6px;
278
+ }
279
+ }
280
+ }
281
+ .total-items {
282
+ margin-left: 16px;
283
+ }
284
+ `;
285
+
309
286
  PagingInfo.defaultProps = {
310
287
  typeShort: false,
311
- bgColor: '#FFF',
288
+ bgColor: white,
312
289
  style: {},
313
290
  className: '',
314
291
  totalItems: 0,
@@ -325,7 +302,7 @@ PagingInfo.propTypes = {
325
302
  /** style inline for Paging */
326
303
  style: PropTypes.object,
327
304
 
328
- /** style inline for Paging */
305
+ /** className for Paging */
329
306
  className: PropTypes.string,
330
307
 
331
308
  /** current of paging */
@@ -344,6 +321,21 @@ PagingInfo.propTypes = {
344
321
  onChangePage: PropTypes.func,
345
322
 
346
323
  /** the function will run after change quantity on per page */
347
- onChangePerPage: PropTypes.func
324
+ onChangePerPage: PropTypes.func,
325
+
326
+ /**
327
+ * ref methods (ref.current.instance.*method*)
328
+ *
329
+ * * onChangePage(page): Change page number
330
+ * * @param {page} - number
331
+ * * onChangePerPage(per): Change quantity on per page
332
+ * * @param {per} - number
333
+ * * setTotalItems(items): Set total items
334
+ * * @param {items} - number
335
+ */
336
+ reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
337
+ current: PropTypes.instanceOf(Element)
338
+ })])
348
339
  };
349
- export default PagingInfo;
340
+ export { PagingInfo };
341
+ export default OptionWrapper(PagingInfo);
@@ -53,7 +53,7 @@ const SliderItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
53
53
  `,
54
54
  frame: css`
55
55
  display: block;
56
- height: 100%;
56
+ height: 85vh;
57
57
  margin: 0;
58
58
  padding: 0;
59
59
  width: 100%;
@@ -91,11 +91,9 @@ const SliderItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
91
91
  if (googleDocsRegex.test(link)) {
92
92
  return `https://docs.google.com/viewer?srcid=${link.split('=')[1]}&pid=explorer&efh=false&a=v&chrome=false&embedded=true`;
93
93
  }
94
-
95
- return link;
96
94
  }
97
95
 
98
- return null;
96
+ return link;
99
97
  };
100
98
 
101
99
  const getViewer = (filePath, fileType) => {
@@ -116,7 +114,7 @@ const SliderItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
116
114
  className: IDs.frame,
117
115
  css: styles.frame,
118
116
  frameBorder: 0,
119
- src: `http://view.officeapps.live.com/op/view.aspx?src=${filePath}`,
117
+ src: `https://view.officeapps.live.com/op/view.aspx?src=${filePath}`,
120
118
  title: fileName
121
119
  });
122
120
  }
@@ -177,7 +177,7 @@ const TextRoot = (color, type, lineClamp) => css`
177
177
  ${positionRelative};
178
178
  ${breakWord};
179
179
  ${paragraph1};
180
- white-space: normal;
180
+ white-space: break-spaces;
181
181
  color: ${colorMap.get(color) || colors[color] || color};
182
182
  max-width: max-content;
183
183
  &.DGN-Typography-${type} {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.38",
3
+ "version": "1.3.40",
4
4
  "description": "The DigiNet core ui",
5
5
  "homepage": "https://diginet.com.vn",
6
6
  "main": "index.js",
package/readme.md CHANGED
@@ -38,8 +38,15 @@ npm test
38
38
  ```
39
39
 
40
40
  ## Changelog
41
- ## 1.3.38
41
+ ## 1.3.40
42
+ \[Fixed\]: Slider - Fix bug can't view https file
43
+ \[Fixed\]: Typhography - Fix word-wrap css
44
+ \[Fixed\]: Slider - Fix bug not showing pdf file with blob url
45
+
46
+ ## 1.3.39
42
47
  \[Added\]: MenuIcon - MHRM29N0003
48
+
49
+ ## 1.3.38
43
50
  \[Added\]: System - Phát triển chuẩn zIndex
44
51
  \[Changed\]: NumberInput - Phát triển lại component NumberInput
45
52
  \[Fixed\]: Accordion - Fix bug Accordion auto expand when render; Add prop style, id; Fix css