@vincentgraul/react-components 1.0.1 → 1.0.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/build/bundle.js CHANGED
@@ -1,230 +1,6 @@
1
- var __importDefault = (this && this.__importDefault) || function (mod) {
2
- return (mod && mod.__esModule) ? mod : { "default": mod };
3
- };
4
- define("match-device/useMatchDevice", ["require", "exports", "react", "ua-parser-js"], function (require, exports, react_1, ua_parser_js_1) {
5
- "use strict";
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- ua_parser_js_1 = __importDefault(ua_parser_js_1);
8
- /**
9
- * React hook to detect the device (mobile, tablet or desktop) based on the user agent.
10
- * @public
11
- * @param UA - The user agent.
12
- * @returns An object with multiple properties (isMobile, isTablet...) used to detect the device.
13
- */
14
- function useMatchDevice(UA) {
15
- const isClientSide = typeof window !== "undefined";
16
- const compute = () => {
17
- const parser = new ua_parser_js_1.default.UAParser(UA);
18
- const { type } = parser.getDevice();
19
- const device = {
20
- isMobile: type === "mobile",
21
- isTablet: type === "tablet",
22
- isMobileOrTablet: false,
23
- isDesktop: !type,
24
- };
25
- device.isMobileOrTablet = device.isMobile || device.isTablet;
26
- return device;
27
- };
28
- if (!isClientSide) {
29
- return compute();
30
- }
31
- const [device, setDevice] = (0, react_1.useState)(compute());
32
- (0, react_1.useEffect)(() => {
33
- setDevice(compute());
34
- }, [UA]);
35
- return device;
36
- }
37
- exports.default = useMatchDevice;
38
- });
39
- define("match-resolution/useMatchResolution", ["require", "exports", "react", "match-device/useMatchDevice"], function (require, exports, react_2, useMatchDevice_1) {
40
- "use strict";
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.defaultBreakpoints = void 0;
43
- useMatchDevice_1 = __importDefault(useMatchDevice_1);
44
- exports.defaultBreakpoints = {
45
- desktop: "(min-width: 1281px)",
46
- laptop: "(min-width: 1025px) and (max-width: 1280px)",
47
- laptopOrUpper: "(min-width: 1025px)",
48
- laptopOrLower: "(max-width: 1280px)",
49
- tablet: "(min-width: 768px) and (max-width: 1024px)",
50
- tabletOrUpper: "(min-width: 768px)",
51
- tabletOrLower: "(max-width: 1024px)",
52
- largeMobile: "(min-width: 481px) and (max-width: 767px)",
53
- largeMobileOrUpper: "(min-width: 481px)",
54
- largeMobileOrLower: "(max-width: 767px)",
55
- mobile: "(min-width: 320px) and (max-width: 480px)",
56
- portrait: "(orientation: portrait)",
57
- landscape: "(orientation: landscape)",
58
- };
59
- /**
60
- * React hook to detect the resolution (desktop, laptop, tablet, mobile...).
61
- * @public
62
- * @param breakpoints - List of breakpoints (used for determine when a resolution is a "desktop", a "laptop" etc.).
63
- * @param UA - The user agent (used for determine the resolution in case of SSR).
64
- * @returns An object with three properties:
65
- * - resolution: object with multiple properties (isDesktop, isLaptop...) used for know the current resolution
66
- * - breakpoints: the breakpoints passed as parameters
67
- * - match: function used to detect the current resolution with a custom breakpoint
68
- */
69
- function useMatchResolution(breakpoints = exports.defaultBreakpoints, UA = "") {
70
- const isClientSide = typeof window !== "undefined";
71
- const { isDesktop, isMobile } = (0, useMatchDevice_1.default)(UA);
72
- const match = (query) => isClientSide && window.matchMedia(query).matches;
73
- const compute = () => ({
74
- isDesktop: isClientSide ? match(breakpoints.desktop) : isDesktop,
75
- isLaptop: isClientSide ? match(breakpoints.laptop) : isDesktop,
76
- isLaptopOrUpper: isClientSide ? match(breakpoints.laptopOrUpper) : isDesktop,
77
- isLaptopOrLower: isClientSide ? match(breakpoints.laptopOrLower) : false,
78
- isTablet: isClientSide ? match(breakpoints.tablet) : isMobile,
79
- isTabletOrUpper: isClientSide ? match(breakpoints.tabletOrUpper) : false,
80
- isTabletOrLower: isClientSide ? match(breakpoints.tabletOrLower) : isMobile,
81
- isLargeMobile: isClientSide ? match(breakpoints.largeMobile) : isMobile,
82
- isLargeMobileOrUpper: isClientSide ? match(breakpoints.largeMobileOrUpper) : false,
83
- isLargeMobileOrLower: isClientSide ? match(breakpoints.largeMobileOrLower) : isMobile,
84
- isMobile: isClientSide ? match(breakpoints.mobile) : isMobile,
85
- isPortrait: isClientSide ? match(breakpoints.portrait) : false,
86
- isLandscape: isClientSide ? match(breakpoints.landscape) : false,
87
- });
88
- const [resolution, setResolution] = (0, react_2.useState)(compute());
89
- (0, react_2.useEffect)(() => {
90
- const onResize = () => setResolution(compute());
91
- window.addEventListener("resize", onResize);
92
- return () => {
93
- window.removeEventListener("resize", onResize);
94
- };
95
- }, []);
96
- (0, react_2.useEffect)(() => {
97
- setResolution(compute());
98
- }, [breakpoints]);
99
- return { resolution, breakpoints, match };
100
- }
101
- exports.default = useMatchResolution;
102
- });
103
- define("mount-react-hook/mountReactHook", ["require", "exports", "react", "@testing-library/react"], function (require, exports, react_3, react_4) {
104
- "use strict";
105
- Object.defineProperty(exports, "__esModule", { value: true });
106
- react_3 = __importDefault(react_3);
107
- /**
108
- * React hook to mount a hook in an unit test.
109
- * @public
110
- * @param Component - The component to be tested.
111
- * @param props - Props passed to the component.
112
- * @returns The component, the value it returns and a function to unmount the component.
113
- */
114
- function mountReactHook(Component, props = {}) {
115
- let value = null;
116
- const { container, unmount } = (0, react_4.render)(react_3.default.createElement(Component, Object.assign({}, props), (hookValue) => {
117
- value = hookValue;
118
- return null;
119
- }));
120
- return { container, unmount, value };
121
- }
122
- exports.default = mountReactHook;
123
- });
124
- define("pagination/usePagination", ["require", "exports", "react"], function (require, exports, react_5) {
125
- "use strict";
126
- Object.defineProperty(exports, "__esModule", { value: true });
127
- /**
128
- * React hook to manage pagination.
129
- * @public
130
- * @param props - An object which multiple properties:
131
- * - page: the current page
132
- * - totalRecords: the total number of records
133
- * - maxRecordsPerPage: the maximum number of records displayed per page
134
- * - itemNeighbours: the maximum number of items (page indicator) beside the current item
135
- * - minItems: the minimum of items (page indicator)
136
- * @returns An object with multiples properties:
137
- * - page: the current page
138
- * - total: the total number of pages
139
- * - items: an array of numbers (represents the page indicators)
140
- * - maxRecordsPerPage: the maximum number of records displayed per page
141
- * - some functions to change the page (goToPage, goToFirst...)
142
- */
143
- function usePagination(props) {
144
- const { totalRecords, itemNeighbours = 2, minItems = 5, maxRecordsPerPage = 10 } = props;
145
- const [page, setPage] = (0, react_5.useState)(props.page);
146
- const [total, setTotal] = (0, react_5.useState)(0);
147
- const [items, setItems] = (0, react_5.useState)([]);
148
- const generateItems = () => {
149
- const items = [];
150
- const from = Math.max(1, Math.min(page - itemNeighbours, total + 1 - minItems));
151
- const to = Math.min(total, Math.max(minItems, page + itemNeighbours));
152
- for (let i = from; i <= to; i++) {
153
- items.push(i);
154
- }
155
- return items;
156
- };
157
- (0, react_5.useEffect)(() => {
158
- setTotal(Math.ceil(totalRecords / maxRecordsPerPage));
159
- }, [totalRecords, maxRecordsPerPage]);
160
- (0, react_5.useEffect)(() => {
161
- setItems(generateItems());
162
- }, [page, total, itemNeighbours, minItems]);
163
- const goToPage = (page) => {
164
- const currentPage = Math.max(1, Math.min(page, total));
165
- setPage(currentPage);
166
- };
167
- const goToFirst = () => {
168
- goToPage(1);
169
- };
170
- const goToLeft = () => {
171
- goToPage(page - 1);
172
- };
173
- const goToRight = () => {
174
- goToPage(page + 1);
175
- };
176
- const goToLast = () => {
177
- goToPage(total);
178
- };
179
- return {
180
- page,
181
- total,
182
- items,
183
- maxRecordsPerPage,
184
- goToPage,
185
- goToFirst,
186
- goToLeft,
187
- goToRight,
188
- goToLast,
189
- };
190
- }
191
- exports.default = usePagination;
192
- });
193
- define("numbered-pagination/NumberedPagination", ["require", "exports", "react", "styled-components"], function (require, exports, react_6, styled_components_1) {
194
- "use strict";
195
- Object.defineProperty(exports, "__esModule", { value: true });
196
- exports.ArrowPosition = void 0;
197
- react_6 = __importDefault(react_6);
198
- styled_components_1 = __importDefault(styled_components_1);
199
- var ArrowPosition;
200
- (function (ArrowPosition) {
201
- ArrowPosition[ArrowPosition["LEFT"] = 0] = "LEFT";
202
- ArrowPosition[ArrowPosition["RIGHT"] = 1] = "RIGHT";
203
- })(ArrowPosition = exports.ArrowPosition || (exports.ArrowPosition = {}));
204
- /**
205
- * React component used to display a pagination (with numbers).
206
- * @public
207
- * @param props - An object which contains:
208
- * - properties inherited from the Pagination interface in usePagination hook
209
- * - some properties to customise the rendering
210
- * @returns A React component.
211
- */
212
- function NumberedPagination(props) {
213
- const { page, total, items, goToFirst, goToLeft, goToRight, goToLast, goToPage, renderSingleArrow, renderDoubleArrow, className = "", } = props;
214
- return (react_6.default.createElement(Container, { className: `${className} pagination` },
215
- page > 1 && (react_6.default.createElement(react_6.default.Fragment, null,
216
- renderDoubleArrow && (react_6.default.createElement(Item, { className: "pagination-item pagination-item-arrow pagination-item-double-arrow", onClick: () => goToFirst() }, renderDoubleArrow(ArrowPosition.LEFT))),
217
- renderSingleArrow && (react_6.default.createElement(Item, { className: "pagination-item pagination-item-arrow pagination-item-single-arrow", onClick: () => goToLeft() }, renderSingleArrow(ArrowPosition.LEFT))))),
218
- items.map((page, index) => (react_6.default.createElement(Item, { className: `pagination-item pagination-item-number ${page === props.page ? "selected" : ""}`, key: index, onClick: () => goToPage(page) }, page))),
219
- page < total && (react_6.default.createElement(react_6.default.Fragment, null,
220
- renderSingleArrow && (react_6.default.createElement(Item, { className: "pagination-item pagination-item-arrow pagination-item-single-arrow", onClick: () => goToRight() }, renderSingleArrow(ArrowPosition.RIGHT))),
221
- renderDoubleArrow && (react_6.default.createElement(Item, { className: "pagination-item pagination-item-arrow pagination-item-double-arrow", onClick: () => goToLast() }, renderDoubleArrow(ArrowPosition.RIGHT)))))));
222
- }
223
- exports.default = NumberedPagination;
224
- const Container = styled_components_1.default.div `
1
+ var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};define("match-device/useMatchDevice",["require","exports","react","ua-parser-js"],function(e,t,i,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),n=__importDefault(n),t.default=function(a){var e="undefined"!=typeof window;const t=()=>{const e=new n.default.UAParser(a);var t=e.getDevice()["type"];const r={isMobile:"mobile"===t,isTablet:"tablet"===t,isMobileOrTablet:!1,isDesktop:!t};return r.isMobileOrTablet=r.isMobile||r.isTablet,r};if(!e)return t();const[r,o]=(0,i.useState)(t());return(0,i.useEffect)(()=>{o(t())},[a]),r}}),define("match-resolution/useMatchResolution",["require","exports","react","match-device/useMatchDevice"],function(e,u,d,c){"use strict";Object.defineProperty(u,"__esModule",{value:!0}),u.defaultBreakpoints=void 0,c=__importDefault(c),u.defaultBreakpoints={desktop:"(min-width: 1281px)",laptop:"(min-width: 1025px) and (max-width: 1280px)",laptopOrUpper:"(min-width: 1025px)",laptopOrLower:"(max-width: 1280px)",tablet:"(min-width: 768px) and (max-width: 1024px)",tabletOrUpper:"(min-width: 768px)",tabletOrLower:"(max-width: 1024px)",largeMobile:"(min-width: 481px) and (max-width: 767px)",largeMobileOrUpper:"(min-width: 481px)",largeMobileOrLower:"(max-width: 767px)",mobile:"(min-width: 320px) and (max-width: 480px)",portrait:"(orientation: portrait)",landscape:"(orientation: landscape)"},u.default=function(e=u.defaultBreakpoints,t=""){const r="undefined"!=typeof window,{isDesktop:a,isMobile:o}=(0,c.default)(t),i=e=>r&&window.matchMedia(e).matches,n=()=>({isDesktop:r?i(e.desktop):a,isLaptop:r?i(e.laptop):a,isLaptopOrUpper:r?i(e.laptopOrUpper):a,isLaptopOrLower:!!r&&i(e.laptopOrLower),isTablet:r?i(e.tablet):o,isTabletOrUpper:!!r&&i(e.tabletOrUpper),isTabletOrLower:r?i(e.tabletOrLower):o,isLargeMobile:r?i(e.largeMobile):o,isLargeMobileOrUpper:!!r&&i(e.largeMobileOrUpper),isLargeMobileOrLower:r?i(e.largeMobileOrLower):o,isMobile:r?i(e.mobile):o,isPortrait:!!r&&i(e.portrait),isLandscape:!!r&&i(e.landscape)}),[l,s]=(0,d.useState)(n());return(0,d.useEffect)(()=>{const e=()=>s(n());return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[]),(0,d.useEffect)(()=>{s(n())},[e]),{resolution:l,breakpoints:e,match:i}}}),define("mount-react-hook/mountReactHook",["require","exports","react","@testing-library/react"],function(e,t,a,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),a=__importDefault(a),t.default=function(e,t={}){let r=null;var{container:e,unmount:t}=(0,o.render)(a.default.createElement(e,Object.assign({},t),e=>(r=e,null)));return{container:e,unmount:t,value:r}}}),define("pagination/usePagination",["require","exports","react"],function(e,t,p){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){const{totalRecords:t,itemNeighbours:o=2,minItems:i=5,maxRecordsPerPage:r=10}=e,[n,a]=(0,p.useState)(e.page),[l,s]=(0,p.useState)(0),[u,d]=(0,p.useState)([]),c=((0,p.useEffect)(()=>{s(Math.ceil(t/r))},[t,r]),(0,p.useEffect)(()=>{d((()=>{const t=[];var r=Math.max(1,Math.min(n-o,l+1-i)),a=Math.min(l,Math.max(i,n+o));for(let e=r;e<=a;e++)t.push(e);return t})())},[n,l,o,i]),e=>{e=Math.max(1,Math.min(e,l));a(e)});return{page:n,total:l,items:u,maxRecordsPerPage:r,goToPage:c,goToFirst:()=>{c(1)},goToLeft:()=>{c(n-1)},goToRight:()=>{c(n+1)},goToLast:()=>{c(l)}}}}),define("numbered-pagination/NumberedPagination",["require","exports","react","styled-components"],function(e,t,p,r){"use strict";var m,a;Object.defineProperty(t,"__esModule",{value:!0}),t.ArrowPosition=void 0,p=__importDefault(p),r=__importDefault(r),(a=m=t.ArrowPosition||(t.ArrowPosition={}))[a.LEFT=0]="LEFT",a[a.RIGHT=1]="RIGHT",t.default=function(r){const{page:e,total:t,items:a,goToFirst:o,goToLeft:i,goToRight:n,goToLast:l,goToPage:s,renderSingleArrow:u,renderDoubleArrow:d,className:c=""}=r;return p.default.createElement(f,{className:c+" pagination"},1<e&&p.default.createElement(p.default.Fragment,null,d&&p.default.createElement(b,{className:"pagination-item pagination-item-arrow pagination-item-double-arrow",onClick:()=>o()},d(m.LEFT)),u&&p.default.createElement(b,{className:"pagination-item pagination-item-arrow pagination-item-single-arrow",onClick:()=>i()},u(m.LEFT))),a.map((e,t)=>p.default.createElement(b,{className:"pagination-item pagination-item-number "+(e===r.page?"selected":""),key:t,onClick:()=>s(e)},e)),e<t&&p.default.createElement(p.default.Fragment,null,u&&p.default.createElement(b,{className:"pagination-item pagination-item-arrow pagination-item-single-arrow",onClick:()=>n()},u(m.RIGHT)),d&&p.default.createElement(b,{className:"pagination-item pagination-item-arrow pagination-item-double-arrow",onClick:()=>l()},d(m.RIGHT))))};const f=r.default.div`
225
2
  display: flex;
226
- `;
227
- const Item = styled_components_1.default.div `
3
+ `,b=r.default.div`
228
4
  &:first-child {
229
5
  border-width: 1px 1px 1px 1px;
230
6
  }
@@ -235,123 +11,27 @@ define("numbered-pagination/NumberedPagination", ["require", "exports", "react",
235
11
  display: flex;
236
12
  align-items: center;
237
13
  cursor: pointer;
238
- `;
239
- });
240
- define("scroll-to/useScrollTo", ["require", "exports"], function (require, exports) {
241
- "use strict";
242
- Object.defineProperty(exports, "__esModule", { value: true });
243
- /**
244
- * React hook to scroll to an element.
245
- * @public
246
- * @param target - The target where we want to scroll.
247
- * @returns An object which contains:
248
- * - scrollToTop: function used to scroll to the top of the element
249
- */
250
- function useScrollTo(target) {
251
- const isClientSide = typeof window !== "undefined";
252
- if (!isClientSide) {
253
- return { scrollToTop: () => null };
254
- }
255
- const scrollToTop = () => {
256
- if (target.current) {
257
- window.scrollTo(0, target.current.offsetTop);
258
- }
259
- };
260
- return { scrollToTop };
261
- }
262
- exports.default = useScrollTo;
263
- });
264
- define("table/Table", ["require", "exports", "react", "styled-components"], function (require, exports, react_7, styled_components_2) {
265
- "use strict";
266
- Object.defineProperty(exports, "__esModule", { value: true });
267
- exports.Td = exports.Tr = exports.Th = void 0;
268
- react_7 = __importDefault(react_7);
269
- styled_components_2 = __importDefault(styled_components_2);
270
- /**
271
- * React component used to display a data table.
272
- * @public
273
- * @param props - An Object which contains:
274
- * - columns: the table columns
275
- * - records: the table records
276
- * - some properties to customise the rendering
277
- * @returns A React component.
278
- */
279
- function Table(props) {
280
- const { columns, records, renderHeader = () => null, renderFooter = () => null, renderColumnsRow = (columns) => (react_7.default.createElement("tr", { className: "table-main-columns-row" }, columns)), renderColumnsCell = (column, key) => (react_7.default.createElement(exports.Th, { className: "table-main-columns-cell", key: key }, column.name)), renderRecordsRow = (cells, key) => (react_7.default.createElement(exports.Tr, { className: "table-main-records-row", key: key }, cells)), renderRecordsCell = (cell, key) => (react_7.default.createElement(exports.Td, { className: "table-main-records-cell", key: key }, cell)), renderRecordsEmptyCell = (key) => (react_7.default.createElement(exports.Td, { className: "table-main-records-cell", key: key }, "X")), renderNoRecords = () => null, className = "", } = props;
281
- const displayColumns = () => renderColumnsRow(columns.map((column, index) => renderColumnsCell(column, `column-${index}`)));
282
- const displayRows = () => {
283
- const columnNames = columns.map((column) => column.name);
284
- return records.map((record, rowIndex) => {
285
- const cells = columnNames.map((name) => record[name]);
286
- return renderRecordsRow(cells.map((cell, cellIndex) => cell
287
- ? renderRecordsCell(cell, `cell-${cellIndex}`)
288
- : renderRecordsEmptyCell(`cell-${cellIndex}`)), `row-${rowIndex}`);
289
- });
290
- };
291
- return (react_7.default.createElement(Container, { className: `table ${className}` },
292
- renderHeader(),
293
- records.length === 0 ? (renderNoRecords()) : (react_7.default.createElement(react_7.default.Fragment, null,
294
- react_7.default.createElement(Main, { className: "table-main" },
295
- react_7.default.createElement("thead", { className: "table-main-columns" }, displayColumns()),
296
- react_7.default.createElement(TBody, { className: "table-main-records" }, displayRows())))),
297
- renderFooter()));
298
- }
299
- exports.default = Table;
300
- const Container = styled_components_2.default.div `
301
- display: flex;
302
- flex-flow: column;
303
- `;
304
- const Main = styled_components_2.default.table `
305
- width: 100%;
306
- table-layout: fixed;
307
- border-collapse: collapse;
308
- `;
309
- const TBody = styled_components_2.default.tbody `
310
- user-select: text;
311
- tr:last-child {
312
- border: none;
313
- }
314
- `;
315
- exports.Th = styled_components_2.default.th `
316
- padding: 2rem 1rem 1rem 0;
317
- word-wrap: break-word;
318
- white-space: nowrap;
319
- `;
320
- exports.Tr = styled_components_2.default.tr `
321
- text-align: center;
322
- border-bottom: 2px solid black;
323
- `;
324
- exports.Td = styled_components_2.default.td `
325
- padding: 2rem 1rem 1rem 0;
326
- word-wrap: break-word;
327
- `;
328
- });
329
- define("visible/useVisible", ["require", "exports", "react"], function (require, exports, react_8) {
330
- "use strict";
331
- Object.defineProperty(exports, "__esModule", { value: true });
332
- /**
333
- * React hook to know if an element is visible.
334
- * @public
335
- * @param target - The target where you want to identify its visibility.
336
- * @returns The visibility of the target.
337
- */
338
- function useVisible(target) {
339
- const [isVisible, setVisibility] = (0, react_8.useState)(false);
340
- const handleObserver = (entry) => {
341
- setVisibility(entry.isIntersecting);
342
- };
343
- (0, react_8.useEffect)(() => {
344
- const observer = new IntersectionObserver(([entry]) => handleObserver(entry));
345
- if (target && target.current) {
346
- observer.observe(target.current);
347
- }
348
- return () => {
349
- if (target && target.current) {
350
- observer.unobserve(target.current);
351
- }
352
- };
353
- }, [target]);
354
- return isVisible;
355
- }
356
- exports.default = useVisible;
357
- });
14
+ `}),define("scroll-to/useScrollTo",["require","exports"],function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return"undefined"!=typeof window?{scrollToTop:()=>{e.current&&window.scrollTo(0,e.current.offsetTop)}}:{scrollToTop:()=>null}}}),define("table/Table",["require","exports","react","styled-components"],function(e,p,m,t){"use strict";Object.defineProperty(p,"__esModule",{value:!0}),p.Td=p.Tr=p.Th=void 0,m=__importDefault(m),t=__importDefault(t),p.default=function(e){const{columns:t,records:r,renderHeader:a=()=>null,renderFooter:o=()=>null,renderColumnsRow:i=e=>m.default.createElement("tr",{className:"table-main-columns-row"},e),renderColumnsCell:n=(e,t)=>m.default.createElement(p.Th,{className:"table-main-columns-cell",key:t},e.name),renderRecordsRow:l=(e,t)=>m.default.createElement(p.Tr,{className:"table-main-records-row",key:t},e),renderRecordsCell:s=(e,t)=>m.default.createElement(p.Td,{className:"table-main-records-cell",key:t},e),renderRecordsEmptyCell:u=e=>m.default.createElement(p.Td,{className:"table-main-records-cell",key:e},"X"),renderNoRecords:d=()=>null,className:c=""}=e;return m.default.createElement(f,{className:"table "+c},a(),0===r.length?d():m.default.createElement(m.default.Fragment,null,m.default.createElement(b,{className:"table-main"},m.default.createElement("thead",{className:"table-main-columns"},i(t.map((e,t)=>n(e,"column-"+t)))),m.default.createElement(w,{className:"table-main-records"},(()=>{const a=t.map(e=>e.name);return r.map((t,e)=>{const r=a.map(e=>t[e]);return l(r.map((e,t)=>e?s(e,"cell-"+t):u("cell-"+t)),"row-"+e)})})()))),o())};const f=t.default.div`
15
+ display: flex;
16
+ flex-flow: column;
17
+ `,b=t.default.table`
18
+ width: 100%;
19
+ table-layout: fixed;
20
+ border-collapse: collapse;
21
+ `,w=t.default.tbody`
22
+ user-select: text;
23
+ tr:last-child {
24
+ border: none;
25
+ }
26
+ `;p.Th=t.default.th`
27
+ padding: 2rem 1rem 1rem 0;
28
+ word-wrap: break-word;
29
+ white-space: nowrap;
30
+ `,p.Tr=t.default.tr`
31
+ text-align: center;
32
+ border-bottom: 2px solid black;
33
+ `,p.Td=t.default.td`
34
+ padding: 2rem 1rem 1rem 0;
35
+ word-wrap: break-word;
36
+ `}),define("visible/useVisible",["require","exports","react"],function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(t){const[e,r]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{const e=new IntersectionObserver(([e])=>{r(e.isIntersecting)});return t&&t.current&&e.observe(t.current),()=>{t&&t.current&&e.unobserve(t.current)}},[t]),e}});
37
+ //# sourceMappingURL=build/bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build/bundle.js","sources":["build/bundle.js"],"names":["__importDefault","this","mod","__esModule","default","define","require","exports","react_1","ua_parser_js_1","Object","defineProperty","value","UA","isClientSide","window","compute","parser","UAParser","type","getDevice","device","isMobile","isTablet","isMobileOrTablet","isDesktop","setDevice","useState","useEffect","react_2","useMatchDevice_1","defaultBreakpoints","desktop","laptop","laptopOrUpper","laptopOrLower","tablet","tabletOrUpper","tabletOrLower","largeMobile","largeMobileOrUpper","largeMobileOrLower","mobile","portrait","landscape","breakpoints","match","matchMedia","query","matches","isLaptop","isLaptopOrUpper","isLaptopOrLower","isTabletOrUpper","isTabletOrLower","isLargeMobile","isLargeMobileOrUpper","isLargeMobileOrLower","isPortrait","isLandscape","resolution","setResolution","onResize","addEventListener","removeEventListener","react_3","react_4","Component","props","let","container","unmount","render","createElement","assign","hookValue","react_5","totalRecords","itemNeighbours","minItems","maxRecordsPerPage","page","setPage","total","setTotal","items","setItems","goToPage","Math","ceil","from","max","min","to","i","push","generateItems","currentPage","goToFirst","goToLeft","goToRight","goToLast","react_6","styled_components_1","ArrowPosition","renderSingleArrow","renderDoubleArrow","className","Container","Fragment","Item","onClick","LEFT","map","index","key","RIGHT","div","target","scrollToTop","current","scrollTo","offsetTop","react_7","styled_components_2","Td","Tr","Th","columns","records","renderHeader","renderFooter","renderColumnsRow","renderColumnsCell","column","name","renderRecordsRow","cells","renderRecordsCell","cell","renderRecordsEmptyCell","renderNoRecords","length","Main","TBody","columnNames","record","rowIndex","cellIndex","displayRows","table","tbody","th","tr","td","react_8","isVisible","setVisibility","observer","IntersectionObserver","entry","isIntersecting","observe","unobserve"],"mappings":"AAAA,IAAIA,gBAAmBC,MAAQA,KAAKD,iBAAoB,SAAUE,GAC9D,OAAQA,GAAOA,EAAIC,WAAcD,EAAM,CAAEE,QAAWF,IAExDG,OAAO,8BAA+B,CAAC,UAAW,UAAW,QAAS,gBAAiB,SAAUC,EAASC,EAASC,EAASC,gBAExHC,OAAOC,eAAeJ,EAAS,aAAc,CAAEK,OAAO,IACtDH,EAAiBT,gBAAgBS,GA8BjCF,EAAQH,QAvBR,SAAwBS,GACpB,IAAMC,EAAiC,oBAAXC,OAC5B,MAAMC,EAAU,KACZ,MAAMC,EAAS,IAAIR,EAAeL,QAAQc,SAASL,GACnD,IAAQM,EAASF,EAAOG,YA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CAAA,CAAEC,MAH5CH,EAAcG,EAAMC,kBAOpB,OAHI3C,GAAUA,EAAOE,SACjBsC,EAASI,QAAQ5C,EAAOE,SAErB,KACCF,GAAUA,EAAOE,SACjBsC,EAASK,UAAU7C,EAAOE,WAGnC,CAACF,IACGsC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vincentgraul/react-components",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "main": "./build/bundle.js",
5
5
  "license": "GNU GPLV3",
6
6
  "repository": "https://github.com/vincentgraul/react-components.git",
@@ -20,12 +20,12 @@
20
20
  }
21
21
  ],
22
22
  "scripts": {
23
- "build": "tsc && npm run build-storybook",
24
- "storybook": "start-storybook -p 6006",
25
- "build-storybook": "build-storybook",
23
+ "build": "tsc && npm run compress",
24
+ "storybook": "build-storybook && start-storybook -p 6006",
26
25
  "test": "jest",
27
26
  "doc": "typedoc",
28
- "lint": "eslint './src/**/*.ts'"
27
+ "lint": "eslint src",
28
+ "compress": "uglifyjs build/bundle.js -o build/bundle.js --config-file uglifyrc.json"
29
29
  },
30
30
  "dependencies": {
31
31
  "@testing-library/react": "13.3.0",
@@ -49,13 +49,14 @@
49
49
  "@types/jest": "28.1.6",
50
50
  "@typescript-eslint/eslint-plugin": "5.31.0",
51
51
  "@typescript-eslint/parser": "5.31.0",
52
+ "babel-loader": "8.2.5",
52
53
  "eslint": "8.20.0",
53
54
  "eslint-config-prettier": "8.5.0",
54
55
  "eslint-plugin-prettier": "4.2.1",
55
- "babel-loader": "8.2.5",
56
56
  "jest": "28.1.3",
57
57
  "ts-jest": "28.0.7",
58
58
  "typedoc": "0.23.9",
59
- "typescript": "4.7.4"
59
+ "typescript": "4.7.4",
60
+ "uglify-js": "^3.16.3"
60
61
  }
61
62
  }