@ceed/cds 0.0.32 → 0.0.82

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 (102) hide show
  1. package/dist/components/Autocomplete/Autocomplete.d.ts +11 -0
  2. package/dist/components/Autocomplete/index.d.ts +3 -0
  3. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +21 -0
  4. package/dist/components/Breadcrumbs/index.d.ts +3 -0
  5. package/dist/components/Button/Button.d.ts +1 -1
  6. package/dist/components/Calendar/Calendar.d.ts +7 -0
  7. package/dist/components/Calendar/hooks/use-calendar-props.d.ts +35 -0
  8. package/dist/components/Calendar/hooks/use-calendar.d.ts +35 -0
  9. package/dist/components/Calendar/index.d.ts +3 -0
  10. package/dist/components/Calendar/types.d.ts +24 -0
  11. package/dist/components/Calendar/utils/index.d.ts +12 -0
  12. package/dist/components/DataTable/DataTable.d.ts +25 -5
  13. package/dist/components/DatePicker/DatePicker.d.ts +22 -0
  14. package/dist/components/DatePicker/index.d.ts +3 -0
  15. package/dist/components/DateRangePicker/DateRangePicker.d.ts +22 -0
  16. package/dist/components/DateRangePicker/index.d.ts +3 -0
  17. package/dist/components/DialogActions/DialogActions.d.ts +2 -2
  18. package/dist/components/DialogContent/DialogContent.d.ts +2 -2
  19. package/dist/components/DialogTitle/DialogTitle.d.ts +2 -2
  20. package/dist/components/FormControl/FormControl.d.ts +1 -1
  21. package/dist/components/Input/Input.d.ts +21 -3
  22. package/dist/components/Modal/Modal.d.ts +4 -4
  23. package/dist/components/MonthRangePicker/MonthRangePicker.d.ts +22 -0
  24. package/dist/components/MonthRangePicker/index.d.ts +3 -0
  25. package/dist/components/Radio/Radio.d.ts +2 -2
  26. package/dist/components/Select/Select.d.ts +11 -13
  27. package/dist/components/Stack/Stack.d.ts +1 -1
  28. package/dist/components/Tabs/Tabs.d.ts +2 -2
  29. package/dist/components/Textarea/Textarea.d.ts +19 -1
  30. package/dist/components/ThemeProvider/ThemeProvider.d.ts +10 -0
  31. package/dist/components/index.d.ts +8 -2
  32. package/dist/index.d.ts +2 -2
  33. package/dist/index.js +2842 -6
  34. package/framer/index.js +29510 -18631
  35. package/package.json +17 -8
  36. package/dist/components/Accordions/Accordions.js +0 -66
  37. package/dist/components/Accordions/index.js +0 -3
  38. package/dist/components/Box/Box.js +0 -6
  39. package/dist/components/Box/index.js +0 -3
  40. package/dist/components/Button/Button.js +0 -28
  41. package/dist/components/Button/index.js +0 -3
  42. package/dist/components/Checkbox/Checkbox.js +0 -28
  43. package/dist/components/Checkbox/index.js +0 -3
  44. package/dist/components/Container/Container.js +0 -51
  45. package/dist/components/Container/index.js +0 -3
  46. package/dist/components/DataTable/DataTable.js +0 -268
  47. package/dist/components/DataTable/index.js +0 -3
  48. package/dist/components/DialogActions/DialogActions.js +0 -6
  49. package/dist/components/DialogActions/index.js +0 -3
  50. package/dist/components/DialogContent/DialogContent.js +0 -6
  51. package/dist/components/DialogContent/index.js +0 -3
  52. package/dist/components/DialogFrame/DialogFrame.js +0 -44
  53. package/dist/components/DialogFrame/index.js +0 -3
  54. package/dist/components/DialogTitle/DialogTitle.js +0 -6
  55. package/dist/components/DialogTitle/index.js +0 -3
  56. package/dist/components/Divider/Divider.js +0 -28
  57. package/dist/components/Divider/index.js +0 -3
  58. package/dist/components/Dropdown/Dropdown.js +0 -6
  59. package/dist/components/Dropdown/index.js +0 -3
  60. package/dist/components/FormControl/FormControl.js +0 -6
  61. package/dist/components/FormControl/index.js +0 -3
  62. package/dist/components/FormHelperText/FormHelperText.js +0 -6
  63. package/dist/components/FormHelperText/index.js +0 -3
  64. package/dist/components/FormLabel/FormLabel.js +0 -6
  65. package/dist/components/FormLabel/index.js +0 -3
  66. package/dist/components/Grid/Grid.js +0 -6
  67. package/dist/components/Grid/index.js +0 -3
  68. package/dist/components/IconButton/IconButton.js +0 -28
  69. package/dist/components/IconButton/index.js +0 -3
  70. package/dist/components/Input/Input.js +0 -28
  71. package/dist/components/Input/index.js +0 -3
  72. package/dist/components/InsetDrawer/InsetDrawer.js +0 -45
  73. package/dist/components/InsetDrawer/index.js +0 -3
  74. package/dist/components/Menu/Menu.js +0 -56
  75. package/dist/components/Menu/index.js +0 -3
  76. package/dist/components/Modal/Modal.js +0 -60
  77. package/dist/components/Modal/index.js +0 -3
  78. package/dist/components/Radio/Radio.js +0 -10
  79. package/dist/components/Radio/index.js +0 -3
  80. package/dist/components/RadioList/RadioList.js +0 -38
  81. package/dist/components/RadioList/index.js +0 -3
  82. package/dist/components/Select/Select.js +0 -12
  83. package/dist/components/Select/index.js +0 -3
  84. package/dist/components/Sheet/Sheet.js +0 -6
  85. package/dist/components/Sheet/index.js +0 -3
  86. package/dist/components/Stack/Stack.js +0 -6
  87. package/dist/components/Stack/index.js +0 -3
  88. package/dist/components/Switch/Switch.js +0 -54
  89. package/dist/components/Switch/index.js +0 -3
  90. package/dist/components/Table/Table.js +0 -89
  91. package/dist/components/Table/index.js +0 -3
  92. package/dist/components/Tabs/Tabs.js +0 -18
  93. package/dist/components/Tabs/index.js +0 -3
  94. package/dist/components/Textarea/Textarea.js +0 -28
  95. package/dist/components/Textarea/index.js +0 -3
  96. package/dist/components/ThemeProvider/ThemeProvider.js +0 -54
  97. package/dist/components/ThemeProvider/index.js +0 -3
  98. package/dist/components/Tooltip/Tooltip.js +0 -28
  99. package/dist/components/Tooltip/index.js +0 -3
  100. package/dist/components/Typography/Typography.js +0 -28
  101. package/dist/components/Typography/index.js +0 -3
  102. package/dist/components/index.js +0 -33
package/package.json CHANGED
@@ -1,19 +1,27 @@
1
1
  {
2
2
  "name": "@ceed/cds",
3
- "version": "0.0.32",
3
+ "version": "0.0.82",
4
4
  "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
5
6
  "type": "module",
6
7
  "description": "UI tool for Ecube Labs front-end developers",
7
8
  "scripts": {
8
9
  "storybook": "storybook dev -p 6006",
9
10
  "build-storybook": "storybook build",
10
- "build": "yarn build-for-framer && rm -rf ./dist && tsc --p tsconfig.build.json",
11
- "build-for-framer": "yarn dlx esbuild src/framer-entrypoint.ts --bundle --outfile='framer/index.js' --format=esm '--external:react' '--external:react/jsx-runtime' '--external:react-dom' '--external:framer' '--external:framer-motion'"
11
+ "build": "yarn build-for-framer && rm -rf ./dist && tsc --emitDeclarationOnly -p tsconfig.build.json && yarn dlx esbuild src/index.ts --bundle --outfile='dist/index.js' --format=esm '--packages=external' --tsconfig=tsconfig.build.json",
12
+ "build-for-framer": "yarn dlx esbuild src/framer-entrypoint.ts --bundle --outfile='framer/index.js' --format=esm '--external:react' '--external:react/jsx-runtime' '--external:react-dom' '--external:framer' '--external:framer-motion' --main-fields=module,main --target=chrome58",
13
+ "prepack": "yarn build"
12
14
  },
13
15
  "files": [
14
16
  "dist",
15
17
  "framer"
16
18
  ],
19
+ "exports": {
20
+ ".": {
21
+ "import": "./dist/index.js",
22
+ "require": "./dist/index.js"
23
+ }
24
+ },
17
25
  "author": "Ecube Labs",
18
26
  "sideEffects": false,
19
27
  "license": "MIT",
@@ -22,20 +30,21 @@
22
30
  "react-dom": "^17.0.0 || ^18.0.0"
23
31
  },
24
32
  "dependencies": {
25
- "@emotion/react": "^11.11.3",
33
+ "@emotion/react": "^11.11.0",
26
34
  "@emotion/styled": "^11.11.0",
27
- "@mui/joy": "^5.0.0-beta.26",
28
- "framer-motion": "^11.0.3"
35
+ "@mui/base": "5.0.0-beta.40",
36
+ "@mui/icons-material": "^5.0.0",
37
+ "@mui/joy": "^5.0.0-beta.32",
38
+ "framer-motion": "^11.0.3",
39
+ "react-imask": "^7.5.0"
29
40
  },
30
41
  "devDependencies": {
31
42
  "@ecubelabs/tsconfig": "^1.0.0",
32
- "@mui/icons-material": "^5.15.10",
33
43
  "@mui/material": "^5.15.10",
34
44
  "@storybook/addon-a11y": "^7.6.13",
35
45
  "@storybook/addon-essentials": "^7.6.13",
36
46
  "@storybook/addon-interactions": "^7.6.13",
37
47
  "@storybook/addon-links": "^7.6.13",
38
- "@storybook/addon-onboarding": "^1.0.11",
39
48
  "@storybook/blocks": "^7.6.13",
40
49
  "@storybook/manager-api": "^7.6.13",
41
50
  "@storybook/react": "^7.6.13",
@@ -1,66 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
- import React from "react";
24
- import { AccordionGroup as JoyAccordionGroup, Accordion as JoyAccordion, AccordionSummary as JoyAccordionSummary, AccordionDetails as JoyAccordionDetails, } from "@mui/joy";
25
- import { motion } from "framer-motion";
26
- var MotionAccordionSummary = motion(JoyAccordionSummary);
27
- var AccordionSummary = MotionAccordionSummary;
28
- export { AccordionSummary };
29
- AccordionSummary.displayName = "AccordionSummary";
30
- var MotionAccordionDetails = motion(JoyAccordionDetails);
31
- var AccordionDetails = MotionAccordionDetails;
32
- export { AccordionDetails };
33
- AccordionDetails.displayName = "AccordionDetails";
34
- var MotionAccordion = motion(JoyAccordion);
35
- function Accordion(props) {
36
- // prop destruction
37
- var summary = props.summary, details = props.details, variant = props.variant, color = props.color, innerProps = __rest(props, ["summary", "details", "variant", "color"]);
38
- // lib hooks
39
- // state, ref, querystring hooks
40
- // form hooks
41
- // query hooks
42
- // calculated values
43
- var inheritedVariant = variant === "solid" ? "solid" : undefined;
44
- // effects
45
- // handlers
46
- return (React.createElement(MotionAccordion, __assign({ variant: inheritedVariant, color: color }, innerProps),
47
- React.createElement(AccordionSummary, { variant: inheritedVariant, color: color }, summary),
48
- React.createElement(AccordionDetails, { variant: inheritedVariant, color: color }, details)));
49
- }
50
- export { Accordion };
51
- Accordion.displayName = "Accordion";
52
- var MotionAccordions = motion(JoyAccordionGroup);
53
- function Accordions(props) {
54
- // prop destruction
55
- var variant = props.variant, color = props.color, items = props.items, innerProps = __rest(props, ["variant", "color", "items"]);
56
- // lib hooks
57
- // state, ref, querystring hooks
58
- // form hooks
59
- // query hooks
60
- // calculated values
61
- // effects
62
- // handlers
63
- return (React.createElement(MotionAccordions, __assign({ variant: variant, color: color }, innerProps), items.map(function (item, index) { return (React.createElement(Accordion, { summary: item.summary, details: item.details, index: index, variant: variant, color: color })); })));
64
- }
65
- export { Accordions };
66
- Accordions.displayName = "Accordions";
@@ -1,3 +0,0 @@
1
- import { Accordions } from "./Accordions";
2
- export * from "./Accordions";
3
- export default Accordions;
@@ -1,6 +0,0 @@
1
- import { Box as JoyBox } from "@mui/joy";
2
- import { motion } from "framer-motion";
3
- var MotionBox = motion(JoyBox);
4
- var Box = MotionBox;
5
- export { Box };
6
- Box.displayName = "Box";
@@ -1,3 +0,0 @@
1
- import { Box } from "./Box";
2
- export * from "./Box";
3
- export default Box;
@@ -1,28 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import React, { forwardRef } from "react";
13
- import { Button as JoyButton } from "@mui/joy";
14
- import { motion } from "framer-motion";
15
- var MotionButton = motion(JoyButton);
16
- var Button = forwardRef(function (props, ref) {
17
- // prop destruction
18
- // lib hooks
19
- // state, ref, querystring hooks
20
- // form hooks
21
- // query hooks
22
- // calculated values
23
- // effects
24
- // handlers
25
- return (React.createElement(MotionButton, __assign({ ref: ref }, props)));
26
- });
27
- export { Button };
28
- Button.displayName = "Button";
@@ -1,3 +0,0 @@
1
- import { Button } from "./Button";
2
- export * from "./Button";
3
- export default Button;
@@ -1,28 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import React from "react";
13
- import { Checkbox as JoyCheckbox } from "@mui/joy";
14
- import { motion } from "framer-motion";
15
- var MotionCheckbox = motion(JoyCheckbox);
16
- var Checkbox = function (props) {
17
- // prop destruction
18
- // lib hooks
19
- // state, ref, querystring hooks
20
- // form hooks
21
- // query hooks
22
- // calculated values
23
- // effects
24
- // handlers
25
- return React.createElement(MotionCheckbox, __assign({}, props));
26
- };
27
- export { Checkbox };
28
- Checkbox.displayName = "Checkbox";
@@ -1,3 +0,0 @@
1
- import { Checkbox } from "./Checkbox";
2
- export * from "./Checkbox";
3
- export default Checkbox;
@@ -1,51 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import { styled } from "@mui/joy";
13
- import React, { forwardRef } from "react";
14
- var ContainerRoot = styled("div", {
15
- name: "Container",
16
- slot: "root",
17
- shouldForwardProp: function (prop) { return prop !== "maxWidth"; },
18
- })(function (_a) {
19
- var _b, _c, _d, _e;
20
- var theme = _a.theme, _f = _a.maxWidth, maxWidth = _f === void 0 ? "lg" : _f;
21
- return (__assign(__assign(__assign(__assign({ width: "100%", marginLeft: "auto", boxSizing: "border-box", marginRight: "auto", display: "block", paddingLeft: theme.spacing(2), paddingRight: theme.spacing(2) }, (maxWidth === "sm" && (_b = {},
22
- _b[theme.breakpoints.up("xs")] = {
23
- maxWidth: theme.breakpoints.values.sm,
24
- },
25
- _b))), (maxWidth === "md" && (_c = {},
26
- _c[theme.breakpoints.up("sm")] = {
27
- maxWidth: theme.breakpoints.values.md,
28
- },
29
- _c))), (maxWidth === "lg" && (_d = {},
30
- _d[theme.breakpoints.up("md")] = {
31
- maxWidth: theme.breakpoints.values.lg,
32
- },
33
- _d))), (maxWidth === "xl" && (_e = {},
34
- _e[theme.breakpoints.up("lg")] = {
35
- maxWidth: theme.breakpoints.values.xl,
36
- },
37
- _e))));
38
- });
39
- var Container = forwardRef(function Container(props, ref) {
40
- // prop destruction
41
- // lib hooks
42
- // state, ref, querystring hooks
43
- // form hooks
44
- // query hooks
45
- // calculated values
46
- // effects
47
- // handlers
48
- return React.createElement(ContainerRoot, __assign({ ref: ref }, props));
49
- });
50
- export { Container };
51
- Container.displayName = "Container";
@@ -1,3 +0,0 @@
1
- import { Container } from "./Container";
2
- export * from "./Container";
3
- export default Container;
@@ -1,268 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
24
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
25
- if (ar || !(i in from)) {
26
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
27
- ar[i] = from[i];
28
- }
29
- }
30
- return to.concat(ar || Array.prototype.slice.call(from));
31
- };
32
- import React, { useCallback, useEffect, useMemo, useRef, useState, } from "react";
33
- import Sheet from "../Sheet";
34
- import { Table } from "../Table";
35
- import Checkbox from "../Checkbox";
36
- import Box from "../Box";
37
- import Stack from "../Stack";
38
- import Typography from "../Typography";
39
- import Button from "../Button";
40
- var numberFormatter = function (value) {
41
- return "Intl" in window ? new Intl.NumberFormat().format(value) : value;
42
- };
43
- function TablePagination(props) {
44
- // prop destruction
45
- var _a = props.paginationModel, page = _a.page, pageSize = _a.pageSize, rowCount = props.rowCount, onPageChange = props.onPageChange;
46
- // lib hooks
47
- // state, ref, querystring hooks
48
- // form hooks
49
- // query hooks
50
- // calculated values
51
- var firstPage = 1;
52
- var lastPage = Math.ceil(rowCount / pageSize);
53
- var beforePages = [page - 2, page - 1].filter(function (p) { return p > 1; });
54
- var afterPages = [page + 1, page + 2].filter(function (p) { return p <= lastPage - 1; });
55
- var isMoreAfterPages = lastPage > 1 && page < lastPage - 3;
56
- var isMoreBeforePages = lastPage > 1 && page > 4;
57
- // effects
58
- // handlers
59
- return (React.createElement(Stack, { direction: "row", spacing: 1, sx: {
60
- pt: 1,
61
- pb: 1,
62
- }, justifyContent: "end", alignItems: "center" },
63
- React.createElement(Stack, { direction: "row", spacing: 0.5, alignItems: "center" },
64
- React.createElement(Button, { size: "sm", variant: "plain", color: "neutral", onClick: function () { return onPageChange(page - 1); }, disabled: page === firstPage, "aria-label": "Previous page" }, "<"),
65
- page !== firstPage && (React.createElement(Button, { size: "sm", variant: "plain", color: "neutral", onClick: function () { return onPageChange(firstPage); } }, firstPage)),
66
- isMoreBeforePages && (React.createElement(Button, { size: "sm", variant: "plain", color: "neutral", onClick: function () { return onPageChange(page - 3); } }, "...")),
67
- beforePages.map(function (p) { return (React.createElement(Button, { key: p, size: "sm", variant: "plain", color: "neutral", onClick: function () { return onPageChange(p); } }, p)); }),
68
- React.createElement(Button, { variant: "soft", size: "sm" }, page),
69
- afterPages.map(function (p) { return (React.createElement(Button, { key: p, size: "sm", variant: "plain", color: "neutral", onClick: function () { return onPageChange(p); } }, p)); }),
70
- isMoreAfterPages && (React.createElement(Button, { size: "sm", variant: "plain", color: "neutral", onClick: function () { return onPageChange(page + 3); } }, "...")),
71
- page !== lastPage && (React.createElement(Button, { size: "sm", variant: "plain", color: "neutral", onClick: function () { return onPageChange(lastPage); } }, lastPage)),
72
- React.createElement(Button, { size: "sm", variant: "plain", color: "neutral", onClick: function () { return onPageChange(page + 1); }, disabled: page === lastPage, "aria-label": "Next page" }, ">"))));
73
- }
74
- var Resizer = function (ref) { return (React.createElement(Box, { sx: {
75
- position: "absolute",
76
- top: 0,
77
- right: 0,
78
- bottom: 0,
79
- width: "4px",
80
- cursor: "col-resize",
81
- }, onMouseDown: function (e) {
82
- var _a;
83
- var initialX = e.clientX;
84
- var initialWidth = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width;
85
- var onMouseMove = function (e) {
86
- if (initialWidth && initialX) {
87
- ref.current.style.width = "".concat(initialWidth + (e.clientX - initialX), "px");
88
- }
89
- };
90
- var onMouseUp = function () {
91
- document.removeEventListener("mousemove", onMouseMove);
92
- document.removeEventListener("mouseup", onMouseUp);
93
- };
94
- document.addEventListener("mousemove", onMouseMove);
95
- document.addEventListener("mouseup", onMouseUp);
96
- } })); };
97
- var HeadCell = function (props) {
98
- var _a, _b, _c;
99
- var ref = useRef(null);
100
- var style = {
101
- width: props.width,
102
- minWidth: (_a = props.minWidth) !== null && _a !== void 0 ? _a : "50px",
103
- maxWidth: props.maxWidth,
104
- textAlign: props.type === "number" ? "end" : "start",
105
- position: props.stickyHeader ? undefined : "relative",
106
- };
107
- var resizer = ((_b = props.resizable) !== null && _b !== void 0 ? _b : true) ? Resizer(ref) : null;
108
- return (React.createElement("th", { ref: ref, key: props.field, style: style }, (_c = props.headerName) !== null && _c !== void 0 ? _c : props.field,
109
- resizer));
110
- };
111
- function useDataTableRenderer(_a) {
112
- var rows = _a.rows, columns = _a.columns, totalRowsProp = _a.rowCount, paginationModel = _a.paginationModel, onPaginationModelChange = _a.onPaginationModelChange, _b = _a.selectionModel, selectionModel = _b === void 0 ? [] : _b, onSelectionModelChange = _a.onSelectionModelChange, stickyHeader = _a.stickyHeader;
113
- var _c = useState((paginationModel === null || paginationModel === void 0 ? void 0 : paginationModel.page) || 1), page = _c[0], setPage = _c[1];
114
- var pageSize = (paginationModel === null || paginationModel === void 0 ? void 0 : paginationModel.pageSize) || 20;
115
- var selectedModelSet = useMemo(function () { return new Set(selectionModel); }, [selectionModel]);
116
- var dataInPage = useMemo(function () { return rows.slice((page - 1) * pageSize, (page - 1) * pageSize + pageSize); }, [rows, page, pageSize]);
117
- var isAllSelected = useMemo(function () {
118
- return dataInPage.length > 0 &&
119
- dataInPage.every(function (_, i) {
120
- return selectedModelSet.has("".concat(i + (page - 1) * pageSize));
121
- });
122
- }, [dataInPage, selectedModelSet, page, pageSize]);
123
- var rowCount = totalRowsProp || rows.length;
124
- var isTotalSelected = useMemo(function () { return rowCount > 0 && selectionModel.length === rowCount; }, [selectionModel, rowCount]);
125
- var handlePageChange = useCallback(function (newPage) {
126
- setPage(newPage);
127
- onPaginationModelChange === null || onPaginationModelChange === void 0 ? void 0 : onPaginationModelChange({ page: newPage, pageSize: pageSize });
128
- }, [onPaginationModelChange]);
129
- useEffect(function () {
130
- handlePageChange(1);
131
- }, [rowCount]);
132
- useEffect(function () {
133
- if (page > Math.ceil(rowCount / pageSize)) {
134
- handlePageChange(Math.ceil(rowCount / pageSize));
135
- }
136
- }, [rowCount, pageSize]);
137
- useEffect(function () {
138
- onSelectionModelChange === null || onSelectionModelChange === void 0 ? void 0 : onSelectionModelChange([]);
139
- }, [page]);
140
- return {
141
- rowCount: rowCount,
142
- page: page,
143
- pageSize: pageSize,
144
- onPaginationModelChange: handlePageChange,
145
- HeadCell: HeadCell,
146
- // HeadCell: useCallback(
147
- // (column: Column<any>) => {
148
- // const ref = useRef<HTMLTableCellElement>(null);
149
- // const style = {
150
- // width: column.width,
151
- // minWidth: column.minWidth ?? "50px",
152
- // maxWidth: column.maxWidth,
153
- // textAlign: column.type === "number" ? "end" : "start",
154
- // position: stickyHeader ? undefined : "relative",
155
- // } as React.CSSProperties;
156
- // const resizer = column.resizable ?? true ? Resizer(ref) : null;
157
- // return (
158
- // <th ref={ref} key={column.field as string} style={style}>
159
- // {column.headerName ?? (column.field as string)}
160
- // {resizer}
161
- // </th>
162
- // );
163
- // },
164
- // [stickyHeader, columns]
165
- // ),
166
- dataInPage: dataInPage,
167
- isAllSelected: isAllSelected, // all rows are selected on this page
168
- isTotalSelected: isTotalSelected,
169
- isSelectedRow: useCallback(function (model) { return selectedModelSet.has(model); }, [selectedModelSet]),
170
- onAllCheckboxChange: useCallback(function () {
171
- onSelectionModelChange === null || onSelectionModelChange === void 0 ? void 0 : onSelectionModelChange(isAllSelected
172
- ? []
173
- : dataInPage.map(function (_, i) { return "".concat(i + (page - 1) * pageSize); }));
174
- }, [isAllSelected, dataInPage, onSelectionModelChange]),
175
- onCheckboxChange: useCallback(function (event, selectedModel) {
176
- if (selectedModelSet.has(selectedModel)) {
177
- var newSelectionModel = selectionModel.filter(function (model) { return model !== selectedModel; });
178
- onSelectionModelChange === null || onSelectionModelChange === void 0 ? void 0 : onSelectionModelChange(newSelectionModel);
179
- }
180
- else {
181
- var newSelectionModel = __spreadArray(__spreadArray([], selectionModel, true), [selectedModel], false);
182
- onSelectionModelChange === null || onSelectionModelChange === void 0 ? void 0 : onSelectionModelChange(newSelectionModel);
183
- }
184
- }, [selectionModel, onSelectionModelChange]),
185
- columns: useMemo(function () {
186
- return columns ||
187
- // fallback
188
- Object.keys(rows[0] || {}).map(function (key) { return ({
189
- field: key,
190
- }); });
191
- }, [rows, columns]),
192
- onTotalSelect: useCallback(function () {
193
- onSelectionModelChange === null || onSelectionModelChange === void 0 ? void 0 : onSelectionModelChange(isTotalSelected ? [] : rows.map(function (_, i) { return "".concat(i); }));
194
- }, [isTotalSelected, rows, onSelectionModelChange]),
195
- };
196
- }
197
- function DataTable(props) {
198
- // prop destruction
199
- var rows = props.rows, checkboxSelection = props.checkboxSelection, selectionModel = props.selectionModel, onSelectionModelChange = props.onSelectionModelChange, _ = props.rowCount, // rowCount is used in useDataTableRenderer
200
- __ = props.columns, // columns is used in useDataTableRenderer
201
- ___ = props.onPaginationModelChange, // onPaginationModelChange is used in useDataTableRenderer
202
- paginationModel = props.paginationModel, _a = props.slots, _b = _a === void 0 ? {} : _a, _c = _b.checkbox, RenderCheckbox = _c === void 0 ? Checkbox : _c, Toolbar = _b.toolbar, Footer = _b.footer, _d = props.slotProps, _e = _d === void 0 ? {} : _d, _f = _e.checkbox, checkboxProps = _f === void 0 ? {} : _f, toolbarProps = _e.toolbar, _g = _e.background, backgroundProps = _g === void 0 ? {} : _g, innerProps = __rest(props, ["rows", "checkboxSelection", "selectionModel", "onSelectionModelChange", "rowCount", "columns", "onPaginationModelChange", "paginationModel", "slots", "slotProps"]);
203
- // lib hooks
204
- var _h = useDataTableRenderer(props), columns = _h.columns, isAllSelected = _h.isAllSelected, isSelectedRow = _h.isSelectedRow, onAllCheckboxChange = _h.onAllCheckboxChange, onCheckboxChange = _h.onCheckboxChange, rowCount = _h.rowCount, page = _h.page, pageSize = _h.pageSize, onPaginationModelChange = _h.onPaginationModelChange, dataInPage = _h.dataInPage, isTotalSelected = _h.isTotalSelected, onTotalSelect = _h.onTotalSelect, HeadCell = _h.HeadCell;
205
- // state, ref, querystring hooks
206
- // form hooks
207
- // query hooks
208
- // calculated values
209
- // effects
210
- // handlers
211
- return (React.createElement(Box, null,
212
- React.createElement(Stack, { direction: "row", sx: {
213
- pt: 1,
214
- pb: 1,
215
- }, justifyContent: "space-between", alignItems: "center" },
216
- React.createElement(Stack, { direction: "row", spacing: 1 },
217
- !isAllSelected && (React.createElement(Typography, { level: "body-xs" },
218
- numberFormatter((selectionModel === null || selectionModel === void 0 ? void 0 : selectionModel.length) || 0),
219
- " items selected")),
220
- isAllSelected && !isTotalSelected && (React.createElement(Stack, { direction: "row", spacing: 1, alignItems: "center" },
221
- React.createElement(Typography, { level: "body-xs" },
222
- "All ",
223
- numberFormatter((selectionModel === null || selectionModel === void 0 ? void 0 : selectionModel.length) || 0),
224
- " items on this page are selected."),
225
- React.createElement(Button, { size: "sm", variant: "plain", onClick: onTotalSelect },
226
- "Select all ",
227
- numberFormatter(rows.length),
228
- " items"))),
229
- isTotalSelected && (React.createElement(Stack, { direction: "row", spacing: 1, alignItems: "center" },
230
- React.createElement(Typography, { level: "body-xs" },
231
- "All ",
232
- numberFormatter(rows.length),
233
- " items are selected."),
234
- React.createElement(Button, { size: "sm", variant: "plain", color: "danger", onClick: onTotalSelect }, "Cancel")))),
235
- Toolbar && React.createElement(Toolbar, __assign({}, (toolbarProps || {})))),
236
- React.createElement(Sheet, __assign({ variant: "outlined", sx: {
237
- overflow: "auto",
238
- width: "100%",
239
- boxShadow: "sm",
240
- borderRadius: "sm",
241
- } }, backgroundProps),
242
- React.createElement(Table, __assign({}, innerProps),
243
- React.createElement("thead", null,
244
- React.createElement("tr", null,
245
- checkboxSelection && (React.createElement("th", { style: {
246
- width: "40px",
247
- textAlign: "center",
248
- } },
249
- React.createElement(RenderCheckbox, __assign({ onChange: onAllCheckboxChange, checked: isAllSelected, indeterminate: (selectionModel || []).length > 0 && !isAllSelected }, checkboxProps)))),
250
- columns.map(function (c) { return (React.createElement(HeadCell, __assign({ key: c.field, stickyHeader: props.stickyHeader }, c))); }))),
251
- React.createElement("tbody", null, dataInPage.map(function (row, rowIndex) {
252
- var rowId = "".concat(rowIndex + (page - 1) * pageSize);
253
- return (React.createElement("tr", { key: rowId, role: checkboxSelection ? "checkbox" : undefined, tabIndex: checkboxSelection ? -1 : undefined, onClick: checkboxSelection
254
- ? function (e) { return onCheckboxChange(e, rowId); }
255
- : undefined, "aria-checked": checkboxSelection ? isSelectedRow(rowId) : undefined },
256
- checkboxSelection && (React.createElement("th", { scope: "row", style: {
257
- textAlign: "center",
258
- } },
259
- React.createElement(RenderCheckbox, __assign({ onChange: function (e) { return onCheckboxChange(e, rowId); }, checked: isSelectedRow(rowId) }, checkboxProps)))),
260
- columns.map(function (column) { return (React.createElement("td", { key: column.field, style: {
261
- textAlign: column.type === "number" ? "end" : "start",
262
- } }, row[column.field])); })));
263
- })),
264
- Footer && React.createElement(Footer, null))),
265
- React.createElement(TablePagination, { paginationModel: { page: page, pageSize: pageSize }, rowCount: rowCount, onPageChange: onPaginationModelChange, onRowsPerPageChange: function () { } })));
266
- }
267
- export { DataTable };
268
- DataTable.displayName = "DataTable";
@@ -1,3 +0,0 @@
1
- import { DataTable } from "./DataTable";
2
- export * from "./DataTable";
3
- export default DataTable;
@@ -1,6 +0,0 @@
1
- import { DialogActions as JoyDialogActions } from "@mui/joy";
2
- import { motion } from "framer-motion";
3
- var MotionDialogActions = motion(JoyDialogActions);
4
- var DialogActions = MotionDialogActions;
5
- export { DialogActions };
6
- DialogActions.displayName = "DialogActions";
@@ -1,3 +0,0 @@
1
- import { DialogActions } from "./DialogActions";
2
- export * from "./DialogActions";
3
- export default DialogActions;
@@ -1,6 +0,0 @@
1
- import { DialogContent as JoyDialogContent } from "@mui/joy";
2
- import { motion } from "framer-motion";
3
- var MotionDialogContent = motion(JoyDialogContent);
4
- var DialogContent = MotionDialogContent;
5
- export { DialogContent };
6
- DialogContent.displayName = "DialogContent";
@@ -1,3 +0,0 @@
1
- import { DialogContent } from "./DialogContent";
2
- export * from "./DialogContent";
3
- export default DialogContent;
@@ -1,44 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
- import React from "react";
24
- import DialogTitle from "../DialogTitle";
25
- import DialogContent from "../DialogContent";
26
- import { ModalDialog } from "../Modal";
27
- import DialogActions from "../DialogActions";
28
- function DialogFrame(props) {
29
- // prop destruction
30
- var title = props.title, children = props.children, actions = props.actions, innerProps = __rest(props, ["title", "children", "actions"]);
31
- // lib hooks
32
- // state, ref, querystring hooks
33
- // form hooks
34
- // query hooks
35
- // calculated values
36
- // effects
37
- // handlers
38
- return (React.createElement(ModalDialog, __assign({}, innerProps),
39
- React.createElement(DialogTitle, null, title),
40
- React.createElement(DialogContent, null, children),
41
- React.createElement(DialogActions, null, actions)));
42
- }
43
- export { DialogFrame };
44
- DialogFrame.displayName = "DialogFrame";
@@ -1,3 +0,0 @@
1
- import { DialogFrame } from "./DialogFrame";
2
- export * from "./DialogFrame";
3
- export default DialogFrame;
@@ -1,6 +0,0 @@
1
- import { DialogTitle as JoyDialogTitle } from "@mui/joy";
2
- import { motion } from "framer-motion";
3
- var MotionDialogTitle = motion(JoyDialogTitle);
4
- var DialogTitle = MotionDialogTitle;
5
- export { DialogTitle };
6
- DialogTitle.displayName = "DialogTitle";
@@ -1,3 +0,0 @@
1
- import { DialogTitle } from "./DialogTitle";
2
- export * from "./DialogTitle";
3
- export default DialogTitle;