@ercioko/meblotex-api 0.2.0 → 0.2.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.
Files changed (193) hide show
  1. package/.eslintrc +6 -0
  2. package/.nvmrc +1 -0
  3. package/.prettierrc +11 -0
  4. package/package.json +5 -16
  5. package/src/api/Api.ts +140 -0
  6. package/src/api/Endpoint.ts +76 -0
  7. package/src/api/createApi.ts +116 -0
  8. package/src/api/error.ts +17 -0
  9. package/{dist/api/index.d.ts → src/api/index.ts} +1 -0
  10. package/src/api/status.ts +3 -0
  11. package/src/api/utils/getAlert.ts +75 -0
  12. package/src/app_types.ts +695 -0
  13. package/src/components/ApiHostProvider.tsx +13 -0
  14. package/src/components/StatusTag.tsx +83 -0
  15. package/src/components/Table/DataTableWrapper.tsx +28 -0
  16. package/src/components/Table/FloatingActions.tsx +152 -0
  17. package/src/components/Table/Spinner.tsx +35 -0
  18. package/src/components/Table/Summary.tsx +18 -0
  19. package/src/components/Table/Table.tsx +474 -0
  20. package/src/components/Table/addIndexToObject.ts +6 -0
  21. package/src/components/Table/areProvidedColumnsDifferent.ts +26 -0
  22. package/src/components/Table/clicked.js +12 -0
  23. package/src/components/Table/displayActions.tsx +19 -0
  24. package/src/components/Table/hooks/useFetchPage.tsx +83 -0
  25. package/src/components/Table/hooks/useGetCellRenderer.tsx +197 -0
  26. package/src/components/Table/hooks/useGetColumnsWithCheckbox.tsx +34 -0
  27. package/src/components/Table/hooks/useGetDeleteRow.tsx +37 -0
  28. package/src/components/Table/hooks/useGetResizeColumn.ts +33 -0
  29. package/src/components/Table/hooks/useGetRowCheckbox.tsx +25 -0
  30. package/src/components/Table/hooks/useLoadDataSource.ts +24 -0
  31. package/src/components/Table/hooks/usePageSize.tsx +20 -0
  32. package/src/components/Table/hooks/useRenderRowActions.tsx +45 -0
  33. package/src/components/Table/hooks/useResizeColumns.ts +61 -0
  34. package/src/components/Table/index.ts +1 -0
  35. package/src/components/Table/providers/OrderProvider.tsx +20 -0
  36. package/src/components/Table/styles.ts +208 -0
  37. package/src/config.ts +7 -0
  38. package/src/db_types.ts +220 -0
  39. package/src/hooks/useApi.ts +43 -0
  40. package/src/hooks/useEndpoint.ts +35 -0
  41. package/src/lib/jednostkaNazwa.ts +6 -0
  42. package/src/lib/typDokumentuNazwa.ts +8 -0
  43. package/src/utils/Query.ts +30 -0
  44. package/src/utils/getWZNumber.ts +13 -0
  45. package/src/utils/getZamowienieDokumentNumber.ts +11 -0
  46. package/{dist/src/utils/index.js → src/utils/index.ts} +2 -2
  47. package/tsconfig.json +25 -0
  48. package/tsconfig.tsbuildinfo +1 -0
  49. package/dist/api/Api.d.ts +0 -33
  50. package/dist/api/Api.js +0 -152
  51. package/dist/api/Endpoint.d.ts +0 -13
  52. package/dist/api/Endpoint.js +0 -126
  53. package/dist/api/createApi.d.ts +0 -52
  54. package/dist/api/createApi.js +0 -81
  55. package/dist/api/error.d.ts +0 -15
  56. package/dist/api/error.js +0 -18
  57. package/dist/api/index.js +0 -34
  58. package/dist/api/status.d.ts +0 -3
  59. package/dist/api/status.js +0 -6
  60. package/dist/api/utils/getAlert.d.ts +0 -6
  61. package/dist/api/utils/getAlert.js +0 -65
  62. package/dist/api/utils/index.js +0 -8
  63. package/dist/app_types.d.ts +0 -607
  64. package/dist/app_types.js +0 -75
  65. package/dist/components/ApiHostProvider.d.ts +0 -7
  66. package/dist/components/ApiHostProvider.js +0 -35
  67. package/dist/components/StatusTag.d.ts +0 -11
  68. package/dist/components/StatusTag.js +0 -86
  69. package/dist/components/Table/DataTableWrapper.d.ts +0 -3
  70. package/dist/components/Table/DataTableWrapper.js +0 -44
  71. package/dist/components/Table/FloatingActions.d.ts +0 -14
  72. package/dist/components/Table/FloatingActions.js +0 -32
  73. package/dist/components/Table/Spinner.d.ts +0 -2
  74. package/dist/components/Table/Spinner.js +0 -26
  75. package/dist/components/Table/Summary.js +0 -16
  76. package/dist/components/Table/Table.d.ts +0 -28
  77. package/dist/components/Table/Table.js +0 -330
  78. package/dist/components/Table/addIndexToObject.d.ts +0 -3
  79. package/dist/components/Table/addIndexToObject.js +0 -17
  80. package/dist/components/Table/areProvidedColumnsDifferent.d.ts +0 -2
  81. package/dist/components/Table/areProvidedColumnsDifferent.js +0 -16
  82. package/dist/components/Table/clicked.js +0 -11
  83. package/dist/components/Table/displayActions.js +0 -11
  84. package/dist/components/Table/hooks/useFetchPage.d.ts +0 -18
  85. package/dist/components/Table/hooks/useFetchPage.js +0 -123
  86. package/dist/components/Table/hooks/useGetCellRenderer.d.ts +0 -25
  87. package/dist/components/Table/hooks/useGetCellRenderer.js +0 -166
  88. package/dist/components/Table/hooks/useGetColumnsWithCheckbox.d.ts +0 -5
  89. package/dist/components/Table/hooks/useGetColumnsWithCheckbox.js +0 -53
  90. package/dist/components/Table/hooks/useGetDeleteRow.d.ts +0 -9
  91. package/dist/components/Table/hooks/useGetDeleteRow.js +0 -74
  92. package/dist/components/Table/hooks/useGetResizeColumn.d.ts +0 -8
  93. package/dist/components/Table/hooks/useGetResizeColumn.js +0 -28
  94. package/dist/components/Table/hooks/useGetRowCheckbox.d.ts +0 -5
  95. package/dist/components/Table/hooks/useGetRowCheckbox.js +0 -54
  96. package/dist/components/Table/hooks/useLoadDataSource.d.ts +0 -10
  97. package/dist/components/Table/hooks/useLoadDataSource.js +0 -20
  98. package/dist/components/Table/hooks/usePageSize.d.ts +0 -5
  99. package/dist/components/Table/hooks/usePageSize.js +0 -16
  100. package/dist/components/Table/hooks/useRenderRowActions.d.ts +0 -6
  101. package/dist/components/Table/hooks/useRenderRowActions.js +0 -51
  102. package/dist/components/Table/hooks/useResizeColumns.d.ts +0 -9
  103. package/dist/components/Table/hooks/useResizeColumns.js +0 -60
  104. package/dist/components/Table/index.d.ts +0 -1
  105. package/dist/components/Table/index.js +0 -8
  106. package/dist/components/Table/providers/OrderProvider.d.ts +0 -9
  107. package/dist/components/Table/providers/OrderProvider.js +0 -17
  108. package/dist/components/Table/styles.d.ts +0 -6
  109. package/dist/components/Table/styles.js +0 -37
  110. package/dist/components/index.js +0 -26
  111. package/dist/config.d.ts +0 -6
  112. package/dist/config.js +0 -8
  113. package/dist/db_types.d.ts +0 -208
  114. package/dist/db_types.js +0 -2
  115. package/dist/hooks/index.js +0 -10
  116. package/dist/hooks/useApi.d.ts +0 -2
  117. package/dist/hooks/useApi.js +0 -42
  118. package/dist/hooks/useEndpoint.d.ts +0 -2
  119. package/dist/hooks/useEndpoint.js +0 -34
  120. package/dist/index.js +0 -19
  121. package/dist/lib/index.js +0 -18
  122. package/dist/lib/jednostka.d.ts +0 -6
  123. package/dist/lib/jednostkaNazwa.d.ts +0 -6
  124. package/dist/lib/jednostkaNazwa.js +0 -9
  125. package/dist/lib/typDokumentuNazwa.d.ts +0 -6
  126. package/dist/lib/typDokumentuNazwa.js +0 -11
  127. package/dist/lib/typ_dokument.d.ts +0 -0
  128. package/dist/lib/typ_dokumentu.d.ts +0 -6
  129. package/dist/lib/unit.d.ts +0 -0
  130. package/dist/src/api/Api.js +0 -316
  131. package/dist/src/api/Endpoint.js +0 -365
  132. package/dist/src/api/createApi.js +0 -50
  133. package/dist/src/api/error.js +0 -15
  134. package/dist/src/api/index.js +0 -5
  135. package/dist/src/api/status.js +0 -3
  136. package/dist/src/api/utils/getAlert.js +0 -63
  137. package/dist/src/api/utils/index.js +0 -1
  138. package/dist/src/app_types.js +0 -72
  139. package/dist/src/components/ApiHostProvider.js +0 -11
  140. package/dist/src/components/StatusTag.js +0 -153
  141. package/dist/src/components/Table/DataTableWrapper.js +0 -115
  142. package/dist/src/components/Table/FloatingActions.js +0 -60
  143. package/dist/src/components/Table/Spinner.js +0 -40
  144. package/dist/src/components/Table/Summary.js +0 -16
  145. package/dist/src/components/Table/Table.js +0 -498
  146. package/dist/src/components/Table/addIndexToObject.js +0 -57
  147. package/dist/src/components/Table/areProvidedColumnsDifferent.js +0 -19
  148. package/dist/src/components/Table/clicked.js +0 -12
  149. package/dist/src/components/Table/displayActions.js +0 -11
  150. package/dist/src/components/Table/hooks/useFetchPage.js +0 -254
  151. package/dist/src/components/Table/hooks/useGetCellRenderer.js +0 -231
  152. package/dist/src/components/Table/hooks/useGetColumnsWithCheckbox.js +0 -33
  153. package/dist/src/components/Table/hooks/useGetDeleteRow.js +0 -181
  154. package/dist/src/components/Table/hooks/useGetResizeColumn.js +0 -72
  155. package/dist/src/components/Table/hooks/useGetRowCheckbox.js +0 -55
  156. package/dist/src/components/Table/hooks/useLoadDataSource.js +0 -16
  157. package/dist/src/components/Table/hooks/usePageSize.js +0 -15
  158. package/dist/src/components/Table/hooks/useRenderRowActions.js +0 -50
  159. package/dist/src/components/Table/hooks/useResizeColumns.js +0 -70
  160. package/dist/src/components/Table/index.js +0 -1
  161. package/dist/src/components/Table/providers/OrderProvider.js +0 -65
  162. package/dist/src/components/Table/styles.js +0 -66
  163. package/dist/src/components/index.js +0 -4
  164. package/dist/src/config.js +0 -6
  165. package/dist/src/db_types.js +0 -1
  166. package/dist/src/hooks/index.js +0 -2
  167. package/dist/src/hooks/useApi.js +0 -84
  168. package/dist/src/hooks/useEndpoint.js +0 -60
  169. package/dist/src/index.js +0 -3
  170. package/dist/src/lib/index.js +0 -2
  171. package/dist/src/lib/jednostkaNazwa.js +0 -6
  172. package/dist/src/lib/typDokumentuNazwa.js +0 -16
  173. package/dist/src/utils/Query.js +0 -73
  174. package/dist/src/utils/getWZNumber.js +0 -4
  175. package/dist/src/utils/getZamowienieDokumentNumber.js +0 -4
  176. package/dist/utils/AlertContext.d.ts +0 -3
  177. package/dist/utils/AlertContext.js +0 -3
  178. package/dist/utils/Query.d.ts +0 -6
  179. package/dist/utils/Query.js +0 -33
  180. package/dist/utils/geNumber.d.ts +0 -2
  181. package/dist/utils/getDocNumber.d.ts +0 -2
  182. package/dist/utils/getWZNumber.js +0 -10
  183. package/dist/utils/getWzNumber.d.ts +0 -2
  184. package/dist/utils/getZamowienieDokumentNumber copy.d.ts +0 -2
  185. package/dist/utils/getZamowienieDokumentNumber.d.ts +0 -2
  186. package/dist/utils/getZamowienieDokumentNumber.js +0 -8
  187. package/dist/utils/index.d.ts +0 -3
  188. package/dist/utils/index.js +0 -12
  189. /package/{dist/api/utils/index.d.ts → src/api/utils/index.ts} +0 -0
  190. /package/{dist/components/index.d.ts → src/components/index.ts} +0 -0
  191. /package/{dist/hooks/index.d.ts → src/hooks/index.ts} +0 -0
  192. /package/{dist/index.d.ts → src/index.ts} +0 -0
  193. /package/{dist/lib/index.d.ts → src/lib/index.ts} +0 -0
@@ -0,0 +1,83 @@
1
+ import React, { FC } from 'react';
2
+ import { Tag as AntTag, TagProps } from 'antd';
3
+
4
+ export const statuses = [
5
+ 'ZAM',
6
+ 'PRZ',
7
+ 'PRO',
8
+ 'WYP',
9
+ 'DWY',
10
+ 'WYB',
11
+ 'PDM',
12
+ 'WZM',
13
+ 'N',
14
+ 'B',
15
+ 'ARC',
16
+ 'WZ',
17
+ 'PW',
18
+ ] as const;
19
+
20
+ export type Status = typeof statuses[number];
21
+
22
+ export const StyledTag: FC<TagProps> = ({
23
+ style,
24
+ ...props
25
+ }) => (
26
+ <AntTag
27
+ style={{
28
+ textAlign: 'center',
29
+ overflow: 'hidden',
30
+ textOverflow: 'ellipsis',
31
+ position: 'absolute',
32
+ top: '50%',
33
+ transform: 'translateY(-50%)',
34
+ right: '0',
35
+ left: '0',
36
+ ...style,
37
+ }}
38
+ {...props}
39
+ />
40
+ );
41
+
42
+
43
+ type Props = {
44
+ status: Status;
45
+ Tag?: FC<TagProps>;
46
+ }
47
+
48
+ const StatusTag: FC<Props> = ({ status, Tag = StyledTag }) => {
49
+ switch (status) {
50
+ case 'ZAM':
51
+ return <Tag color="cyan">Zamówione</Tag>;
52
+ case 'PRZ':
53
+ return <Tag color="blue">Przyjete</Tag>;
54
+ case 'PRO':
55
+ return <Tag color="gold">W produkcji</Tag>;
56
+ case 'WYP':
57
+ return <Tag color="orange">Wyprodukowane</Tag>;
58
+ case 'DWY':
59
+ return <Tag color="green">Do wydania</Tag>;
60
+ case 'WYB':
61
+ return <Tag color="lime">Wybieranie</Tag>;
62
+ case 'PDM':
63
+ return <Tag color="gray">Przyjęte do magazynu</Tag>;
64
+ case 'WZM':
65
+ return <Tag color="green">Wydane z magazynu</Tag>;
66
+ case 'N':
67
+ return <Tag color="gold">Bufor portal</Tag>;
68
+ case 'B':
69
+ return <Tag color="blue">Bufor</Tag>;
70
+ case 'ARC':
71
+ return <Tag color="black">Archiwum</Tag>;
72
+ case 'WZ':
73
+ return <Tag color="blue">Wydanie zewnętrzne</Tag>;
74
+ case 'PW':
75
+ return <Tag color="green">Przychód wewnętrzny</Tag>;
76
+ default:
77
+ // eslint-disable-next-line no-console
78
+ console.log('nieznany: ', status);
79
+ return <Tag color="red">Nieznany</Tag>;
80
+ }
81
+ }
82
+
83
+ export default StatusTag;
@@ -0,0 +1,28 @@
1
+ import React, { ForwardedRef, forwardRef } from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ const Wrapper = styled.div`
5
+ position: relative;
6
+ width: 100%;
7
+ max-height: 100%;
8
+ border-bottom: 1px solid #e8e8e8;
9
+ margin-top: 0;
10
+ `;
11
+
12
+ Wrapper.defaultProps = {
13
+ className: 'data-table-wrapper',
14
+ };
15
+
16
+ function DataTableWrapper(
17
+ { children, ...props }: React.PropsWithChildren<Record<string, unknown>>,
18
+ ref: ForwardedRef<HTMLDivElement>
19
+ ) {
20
+ return (
21
+ <Wrapper className="data-table-wrapper" {...props} ref={ref}>
22
+ {children}
23
+ </Wrapper>
24
+ );
25
+ }
26
+
27
+ export default Wrapper;
28
+ // export default forwardRef(DataTableWrapper);
@@ -0,0 +1,152 @@
1
+ import { Space } from 'antd';
2
+ import React from 'react';
3
+ import { DeleteTwoTone } from '@ant-design/icons';
4
+ import { ActionFunction, Actions, DataRow } from '../../app_types';
5
+ import styled from 'styled-components';
6
+
7
+ const StyledFloatingActions = styled.div`
8
+ & {
9
+ position: absolute;
10
+ left: 100px;
11
+ pointer-events: none;
12
+ transition: width 300ms ease-in-out, padding 300ms ease-in-out;
13
+ box-sizing: content-box;
14
+ overflow: hidden;
15
+ padding-top: 20px;
16
+ z-index: 2;
17
+ }
18
+ &.shown {
19
+ pointer-events: all;
20
+ }
21
+ & > div {
22
+ box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.15);
23
+ height: 58px;
24
+ background: #fff;
25
+ border-radius: 10px;
26
+ margin: 10px;
27
+ }
28
+ & > div > div:first-child {
29
+ margin-left: 27px;
30
+ }
31
+ & > div > div:last-child {
32
+ margin-right: 27px;
33
+ }
34
+ & > div .action {
35
+ width: 24px;
36
+ height: 24px;
37
+ display: flex;
38
+ align-items: center;
39
+ justify-content: center;
40
+ transition: 150ms ease-in-out;
41
+ position: relative;
42
+ }
43
+ & > div .action .action-tooltip {
44
+ position: absolute;
45
+ top: -35px;
46
+ background: #595959;
47
+ color: #fff;
48
+ border-radius: 8px;
49
+ padding: 2px 10px;
50
+ display: none;
51
+ }
52
+ & > div .action .action-tooltip::after {
53
+ content: '';
54
+ position: absolute;
55
+ top: 100%;
56
+ left: calc(50% - 8px);
57
+ display: block;
58
+ width: 0;
59
+ height: 0;
60
+ border-width: 8px;
61
+ border-style: solid;
62
+ border-color: #595959 transparent transparent transparent;
63
+ }
64
+ & > div .action:hover {
65
+ width: 48px;
66
+ height: 48px;
67
+ }
68
+ & > div .action:hover:enabled {
69
+ cursor: pointer;
70
+ }
71
+ & > div .action:hover .action-tooltip {
72
+ display: initial;
73
+ }
74
+ & > div .action:hover span {
75
+ background: rgba(0, 0, 0, 0.1);
76
+ }
77
+ & > div .action:hover span svg {
78
+ font-size: 28px;
79
+ }
80
+ & > div .action span {
81
+ padding: 10px;
82
+ border-radius: 100px;
83
+ transition: 150ms ease-in-out;
84
+ }
85
+ & > div .action span svg {
86
+ transition: 150ms ease-in-out;
87
+ font-size: 24px;
88
+ }
89
+ `
90
+
91
+ export default function FloatingActions<DataType = DataRow>({
92
+ actionsDimensions,
93
+ actionsFor,
94
+ floatingButtons,
95
+ actionHover,
96
+ actionLeave,
97
+ hide,
98
+ actions,
99
+ }: {
100
+ actionsDimensions: { top: number; width: number; transition: string };
101
+ actionsFor: undefined;
102
+ floatingButtons: ActionFunction<DataType>[] | undefined;
103
+ actionHover: () => void;
104
+ actionLeave: () => void;
105
+ hide: (e?: MouseEvent | undefined) => void;
106
+ actions: Actions<DataType>;
107
+ }): JSX.Element {
108
+ return (
109
+ <StyledFloatingActions
110
+ role="button"
111
+ style={actionsDimensions}
112
+ className={`floating-actions ${actionsFor ? 'shown' : ''}`}
113
+ onClick={(e) => {
114
+ e.stopPropagation();
115
+ e.preventDefault();
116
+ }}
117
+ >
118
+ <Space size={28}>
119
+ {floatingButtons?.map((_, i) => (
120
+ <div
121
+ role="button"
122
+ key={i.toString()}
123
+ className="action"
124
+ onMouseEnter={actionHover}
125
+ onMouseLeave={actionLeave}
126
+ onClick={() => hide()}
127
+ >
128
+ {actions.tooltips && actions.tooltips[i] ? (
129
+ <div className="action-tooltip">{actions.tooltips[i]}</div>
130
+ ) : undefined}
131
+ {/* {e(actionsFor)} */}
132
+ </div>
133
+ ))}
134
+ {actions.delete ? (
135
+ <div
136
+ className="action"
137
+ onMouseEnter={actionHover}
138
+ onMouseLeave={actionLeave}
139
+ >
140
+ <div className="action-tooltip">Usuń</div>
141
+ {typeof actionsFor !== 'undefined' && (
142
+ <DeleteTwoTone
143
+ // onClick={() => deleteRow(actionsFor.id)}
144
+ twoToneColor="#F5222D"
145
+ />
146
+ )}
147
+ </div>
148
+ ) : undefined}
149
+ </Space>
150
+ </StyledFloatingActions>
151
+ );
152
+ }
@@ -0,0 +1,35 @@
1
+ import config from '../../config';
2
+ import { Spin } from 'antd';
3
+ import React from 'react';
4
+ import styled from 'styled-components';
5
+
6
+ const { ROW_SIZE } = config;
7
+ const StyledSpinner = styled.div`
8
+ & {
9
+ position: absolute;
10
+ bottom: -34px;
11
+ left: 50%;
12
+ }
13
+
14
+ .ant-spin {
15
+ display: flex;
16
+ justify-content: center;
17
+ margin: 15px 0;
18
+ }
19
+ `
20
+
21
+ export default function Spinner() {
22
+ return (
23
+ <StyledSpinner
24
+ className="spinner-wrapper"
25
+ style={{
26
+ height: ROW_SIZE,
27
+ display: 'flex',
28
+ justifyContent: 'center',
29
+ alignItems: 'center',
30
+ }}
31
+ >
32
+ <Spin style={{ margin: 0 }} />
33
+ </StyledSpinner>
34
+ );
35
+ }
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { TableData } from './styles'
3
+
4
+ export default function Summary({ summary, widths }) {
5
+ return summary ? (
6
+ <div className="tr summary">
7
+ {summary.map((e, i) => (
8
+ <TableData
9
+ key={i}
10
+ style={{ width: `${widths[i]}px` }}
11
+ className={e === undefined ? 'td orphan' : 'td'}
12
+ >
13
+ {e}
14
+ </TableData>
15
+ ))}
16
+ </div>
17
+ ) : null;
18
+ }