@ceed/ads 0.0.30 → 0.0.32

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.
@@ -21,5 +21,5 @@ declare const Button: React.ForwardRefExoticComponent<Omit<{
21
21
  loadingPosition?: "center" | "end" | "start" | undefined;
22
22
  } & Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
23
23
  ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
24
- }, "color" | "tabIndex" | "variant" | "sx" | "disabled" | "size" | "component" | keyof import("@mui/joy").ButtonSlotsAndSlotProps | "action" | "endDecorator" | "focusVisibleClassName" | "fullWidth" | "startDecorator" | "loading" | "loadingIndicator" | "loadingPosition"> & MotionProps, "ref"> & React.RefAttributes<unknown>>;
24
+ }, "color" | "tabIndex" | "variant" | "sx" | "disabled" | "size" | "component" | keyof import("@mui/joy").ButtonSlotsAndSlotProps | "action" | "endDecorator" | "focusVisibleClassName" | "fullWidth" | "startDecorator" | "loading" | "loadingIndicator" | "loadingPosition"> & MotionProps, "ref"> & React.RefAttributes<HTMLElement>>;
25
25
  export { Button };
@@ -13,7 +13,7 @@ import React, { forwardRef } from "react";
13
13
  import { Button as JoyButton } from "@mui/joy";
14
14
  import { motion } from "framer-motion";
15
15
  var MotionButton = motion(JoyButton);
16
- var Button = forwardRef(function (props) {
16
+ var Button = forwardRef(function (props, ref) {
17
17
  // prop destruction
18
18
  // lib hooks
19
19
  // state, ref, querystring hooks
@@ -22,7 +22,7 @@ var Button = forwardRef(function (props) {
22
22
  // calculated values
23
23
  // effects
24
24
  // handlers
25
- return (React.createElement(MotionButton, __assign({}, props)));
25
+ return (React.createElement(MotionButton, __assign({ ref: ref }, props)));
26
26
  });
27
27
  export { Button };
28
28
  Button.displayName = "Button";
@@ -94,6 +94,20 @@ var Resizer = function (ref) { return (React.createElement(Box, { sx: {
94
94
  document.addEventListener("mousemove", onMouseMove);
95
95
  document.addEventListener("mouseup", onMouseUp);
96
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
+ };
97
111
  function useDataTableRenderer(_a) {
98
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;
99
113
  var _c = useState((paginationModel === null || paginationModel === void 0 ? void 0 : paginationModel.page) || 1), page = _c[0], setPage = _c[1];
@@ -128,20 +142,27 @@ function useDataTableRenderer(_a) {
128
142
  page: page,
129
143
  pageSize: pageSize,
130
144
  onPaginationModelChange: handlePageChange,
131
- getColumnHeader: useCallback(function (column) {
132
- var _a, _b, _c;
133
- var ref = useRef(null);
134
- var style = {
135
- width: column.width,
136
- minWidth: (_a = column.minWidth) !== null && _a !== void 0 ? _a : "50px",
137
- maxWidth: column.maxWidth,
138
- textAlign: column.type === "number" ? "end" : "start",
139
- position: stickyHeader ? undefined : "relative",
140
- };
141
- var resizer = ((_b = column.resizable) !== null && _b !== void 0 ? _b : true) ? Resizer(ref) : null;
142
- return (React.createElement("th", { ref: ref, key: column.field, style: style }, (_c = column.headerName) !== null && _c !== void 0 ? _c : column.field,
143
- resizer));
144
- }, [stickyHeader, columns]),
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
+ // ),
145
166
  dataInPage: dataInPage,
146
167
  isAllSelected: isAllSelected, // all rows are selected on this page
147
168
  isTotalSelected: isTotalSelected,
@@ -180,7 +201,7 @@ function DataTable(props) {
180
201
  ___ = props.onPaginationModelChange, // onPaginationModelChange is used in useDataTableRenderer
181
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"]);
182
203
  // lib hooks
183
- 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, getColumnHeader = _h.getColumnHeader;
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;
184
205
  // state, ref, querystring hooks
185
206
  // form hooks
186
207
  // query hooks
@@ -218,14 +239,7 @@ function DataTable(props) {
218
239
  boxShadow: "sm",
219
240
  borderRadius: "sm",
220
241
  } }, backgroundProps),
221
- React.createElement(Table, __assign({ sx: [
222
- {
223
- // "--TableCell-headBackground": "transparent",
224
- "--TableCell-selectedBackground": function (theme) {
225
- return theme.vars.palette.neutral.plainActiveBg;
226
- },
227
- },
228
- ] }, innerProps),
242
+ React.createElement(Table, __assign({}, innerProps),
229
243
  React.createElement("thead", null,
230
244
  React.createElement("tr", null,
231
245
  checkboxSelection && (React.createElement("th", { style: {
@@ -233,19 +247,12 @@ function DataTable(props) {
233
247
  textAlign: "center",
234
248
  } },
235
249
  React.createElement(RenderCheckbox, __assign({ onChange: onAllCheckboxChange, checked: isAllSelected, indeterminate: (selectionModel || []).length > 0 && !isAllSelected }, checkboxProps)))),
236
- columns.map(getColumnHeader))),
250
+ columns.map(function (c) { return (React.createElement(HeadCell, __assign({ key: c.field, stickyHeader: props.stickyHeader }, c))); }))),
237
251
  React.createElement("tbody", null, dataInPage.map(function (row, rowIndex) {
238
252
  var rowId = "".concat(rowIndex + (page - 1) * pageSize);
239
253
  return (React.createElement("tr", { key: rowId, role: checkboxSelection ? "checkbox" : undefined, tabIndex: checkboxSelection ? -1 : undefined, onClick: checkboxSelection
240
254
  ? function (e) { return onCheckboxChange(e, rowId); }
241
- : undefined, "aria-checked": checkboxSelection ? isSelectedRow(rowId) : undefined, style: checkboxSelection && isSelectedRow(rowId)
242
- ? {
243
- "--TableCell-dataBackground": "var(--TableCell-selectedBackground)",
244
- "--TableCell-headBackground": "var(--TableCell-selectedBackground)",
245
- }
246
- : {
247
- "--TableCell-headBackground": "transparent",
248
- } },
255
+ : undefined, "aria-checked": checkboxSelection ? isSelectedRow(rowId) : undefined },
249
256
  checkboxSelection && (React.createElement("th", { scope: "row", style: {
250
257
  textAlign: "center",
251
258
  } },
@@ -12,8 +12,23 @@ var defaultTheme = extendTheme({
12
12
  root: function (_a) {
13
13
  var _b;
14
14
  var theme = _a.theme;
15
- return (_b = {},
16
- // "--TableRow-hoverBackground": theme.palette.primary.outlinedHoverBg,
15
+ return (_b = {
16
+ "--TableRow-stripeBackground": theme.palette.background.level1,
17
+ "--TableCell-selectedBackground": theme.palette.background.level2,
18
+ "--TableRow-hoverBackground": theme.palette.background.level3,
19
+ "& tbody tr[aria-checked=false] th": {
20
+ "--TableCell-headBackground": "transparent",
21
+ },
22
+ "& tbody tr[aria-checked=true]:hover th": {
23
+ "--TableCell-headBackground": "var(--TableRow-hoverBackground)",
24
+ }
25
+ },
26
+ _b["& tbody tr[aria-checked=true]:not(:hover) th"] = {
27
+ "--TableCell-headBackground": "var(--TableCell-selectedBackground)",
28
+ },
29
+ _b["& tbody tr[aria-checked=true]:not(:hover) td"] = {
30
+ "--TableCell-dataBackground": "var(--TableCell-selectedBackground)",
31
+ },
17
32
  _b["& .".concat(checkboxClasses.root)] = {
18
33
  verticalAlign: "middle",
19
34
  },
package/framer/index.js CHANGED
@@ -31915,14 +31915,17 @@ var Box_default2 = Box2;
31915
31915
  import { forwardRef as forwardRef75 } from "react";
31916
31916
  import { motion as motion3 } from "framer-motion";
31917
31917
  var MotionButton = motion3(Button_default);
31918
- var Button3 = forwardRef75((props) => {
31919
- return /* @__PURE__ */ jsx2(
31920
- MotionButton,
31921
- {
31922
- ...props
31923
- }
31924
- );
31925
- });
31918
+ var Button3 = forwardRef75(
31919
+ (props, ref) => {
31920
+ return /* @__PURE__ */ jsx2(
31921
+ MotionButton,
31922
+ {
31923
+ ref,
31924
+ ...props
31925
+ }
31926
+ );
31927
+ }
31928
+ );
31926
31929
  Button3.displayName = "Button";
31927
31930
 
31928
31931
  // src/components/Button/index.ts
@@ -32244,6 +32247,21 @@ var Resizer = (ref) => /* @__PURE__ */ jsx2(
32244
32247
  }
32245
32248
  }
32246
32249
  );
32250
+ var HeadCell = (props) => {
32251
+ const ref = useRef40(null);
32252
+ const style4 = {
32253
+ width: props.width,
32254
+ minWidth: props.minWidth ?? "50px",
32255
+ maxWidth: props.maxWidth,
32256
+ textAlign: props.type === "number" ? "end" : "start",
32257
+ position: props.stickyHeader ? void 0 : "relative"
32258
+ };
32259
+ const resizer = props.resizable ?? true ? Resizer(ref) : null;
32260
+ return /* @__PURE__ */ jsxs2("th", { ref, style: style4, children: [
32261
+ props.headerName ?? props.field,
32262
+ resizer
32263
+ ] }, props.field);
32264
+ };
32247
32265
  function useDataTableRenderer({
32248
32266
  rows,
32249
32267
  columns,
@@ -32298,24 +32316,27 @@ function useDataTableRenderer({
32298
32316
  page,
32299
32317
  pageSize,
32300
32318
  onPaginationModelChange: handlePageChange,
32301
- getColumnHeader: useCallback23(
32302
- (column2) => {
32303
- const ref = useRef40(null);
32304
- const style4 = {
32305
- width: column2.width,
32306
- minWidth: column2.minWidth ?? "50px",
32307
- maxWidth: column2.maxWidth,
32308
- textAlign: column2.type === "number" ? "end" : "start",
32309
- position: stickyHeader ? void 0 : "relative"
32310
- };
32311
- const resizer = column2.resizable ?? true ? Resizer(ref) : null;
32312
- return /* @__PURE__ */ jsxs2("th", { ref, style: style4, children: [
32313
- column2.headerName ?? column2.field,
32314
- resizer
32315
- ] }, column2.field);
32316
- },
32317
- [stickyHeader, columns]
32318
- ),
32319
+ HeadCell,
32320
+ // HeadCell: useCallback(
32321
+ // (column: Column<any>) => {
32322
+ // const ref = useRef<HTMLTableCellElement>(null);
32323
+ // const style = {
32324
+ // width: column.width,
32325
+ // minWidth: column.minWidth ?? "50px",
32326
+ // maxWidth: column.maxWidth,
32327
+ // textAlign: column.type === "number" ? "end" : "start",
32328
+ // position: stickyHeader ? undefined : "relative",
32329
+ // } as React.CSSProperties;
32330
+ // const resizer = column.resizable ?? true ? Resizer(ref) : null;
32331
+ // return (
32332
+ // <th ref={ref} key={column.field as string} style={style}>
32333
+ // {column.headerName ?? (column.field as string)}
32334
+ // {resizer}
32335
+ // </th>
32336
+ // );
32337
+ // },
32338
+ // [stickyHeader, columns]
32339
+ // ),
32319
32340
  dataInPage,
32320
32341
  isAllSelected,
32321
32342
  // all rows are selected on this page
@@ -32395,7 +32416,7 @@ function DataTable(props) {
32395
32416
  dataInPage,
32396
32417
  isTotalSelected,
32397
32418
  onTotalSelect,
32398
- getColumnHeader
32419
+ HeadCell: HeadCell2
32399
32420
  } = useDataTableRenderer(props);
32400
32421
  return /* @__PURE__ */ jsxs2(Box_default2, { children: [
32401
32422
  /* @__PURE__ */ jsxs2(
@@ -32459,90 +32480,79 @@ function DataTable(props) {
32459
32480
  borderRadius: "sm"
32460
32481
  },
32461
32482
  ...backgroundProps,
32462
- children: /* @__PURE__ */ jsxs2(
32463
- Table3,
32464
- {
32465
- sx: [
32483
+ children: /* @__PURE__ */ jsxs2(Table3, { ...innerProps, children: [
32484
+ /* @__PURE__ */ jsx2("thead", { children: /* @__PURE__ */ jsxs2("tr", { children: [
32485
+ checkboxSelection && /* @__PURE__ */ jsx2(
32486
+ "th",
32466
32487
  {
32467
- // "--TableCell-headBackground": "transparent",
32468
- "--TableCell-selectedBackground": (theme) => theme.vars.palette.neutral.plainActiveBg
32469
- }
32470
- ],
32471
- ...innerProps,
32472
- children: [
32473
- /* @__PURE__ */ jsx2("thead", { children: /* @__PURE__ */ jsxs2("tr", { children: [
32474
- checkboxSelection && /* @__PURE__ */ jsx2(
32475
- "th",
32488
+ style: {
32489
+ width: "40px",
32490
+ textAlign: "center"
32491
+ },
32492
+ children: /* @__PURE__ */ jsx2(
32493
+ RenderCheckbox,
32476
32494
  {
32477
- style: {
32478
- width: "40px",
32479
- textAlign: "center"
32480
- },
32481
- children: /* @__PURE__ */ jsx2(
32482
- RenderCheckbox,
32483
- {
32484
- onChange: onAllCheckboxChange,
32485
- checked: isAllSelected,
32486
- indeterminate: (selectionModel || []).length > 0 && !isAllSelected,
32487
- ...checkboxProps
32488
- }
32489
- )
32495
+ onChange: onAllCheckboxChange,
32496
+ checked: isAllSelected,
32497
+ indeterminate: (selectionModel || []).length > 0 && !isAllSelected,
32498
+ ...checkboxProps
32490
32499
  }
32491
- ),
32492
- columns.map(getColumnHeader)
32493
- ] }) }),
32494
- /* @__PURE__ */ jsx2("tbody", { children: dataInPage.map((row, rowIndex) => {
32495
- const rowId = `${rowIndex + (page - 1) * pageSize}`;
32496
- return /* @__PURE__ */ jsxs2(
32497
- "tr",
32498
- {
32499
- role: checkboxSelection ? "checkbox" : void 0,
32500
- tabIndex: checkboxSelection ? -1 : void 0,
32501
- onClick: checkboxSelection ? (e) => onCheckboxChange(e, rowId) : void 0,
32502
- "aria-checked": checkboxSelection ? isSelectedRow(rowId) : void 0,
32503
- style: checkboxSelection && isSelectedRow(rowId) ? {
32504
- "--TableCell-dataBackground": "var(--TableCell-selectedBackground)",
32505
- "--TableCell-headBackground": "var(--TableCell-selectedBackground)"
32506
- } : {
32507
- "--TableCell-headBackground": "transparent"
32508
- },
32509
- children: [
32510
- checkboxSelection && /* @__PURE__ */ jsx2(
32511
- "th",
32500
+ )
32501
+ }
32502
+ ),
32503
+ columns.map((c) => /* @__PURE__ */ jsx2(
32504
+ HeadCell2,
32505
+ {
32506
+ stickyHeader: props.stickyHeader,
32507
+ ...c
32508
+ },
32509
+ c.field
32510
+ ))
32511
+ ] }) }),
32512
+ /* @__PURE__ */ jsx2("tbody", { children: dataInPage.map((row, rowIndex) => {
32513
+ const rowId = `${rowIndex + (page - 1) * pageSize}`;
32514
+ return /* @__PURE__ */ jsxs2(
32515
+ "tr",
32516
+ {
32517
+ role: checkboxSelection ? "checkbox" : void 0,
32518
+ tabIndex: checkboxSelection ? -1 : void 0,
32519
+ onClick: checkboxSelection ? (e) => onCheckboxChange(e, rowId) : void 0,
32520
+ "aria-checked": checkboxSelection ? isSelectedRow(rowId) : void 0,
32521
+ children: [
32522
+ checkboxSelection && /* @__PURE__ */ jsx2(
32523
+ "th",
32524
+ {
32525
+ scope: "row",
32526
+ style: {
32527
+ textAlign: "center"
32528
+ },
32529
+ children: /* @__PURE__ */ jsx2(
32530
+ RenderCheckbox,
32512
32531
  {
32513
- scope: "row",
32514
- style: {
32515
- textAlign: "center"
32516
- },
32517
- children: /* @__PURE__ */ jsx2(
32518
- RenderCheckbox,
32519
- {
32520
- onChange: (e) => onCheckboxChange(e, rowId),
32521
- checked: isSelectedRow(rowId),
32522
- ...checkboxProps
32523
- }
32524
- )
32532
+ onChange: (e) => onCheckboxChange(e, rowId),
32533
+ checked: isSelectedRow(rowId),
32534
+ ...checkboxProps
32525
32535
  }
32526
- ),
32527
- columns.map((column2) => /* @__PURE__ */ jsx2(
32528
- "td",
32529
- {
32530
- style: {
32531
- textAlign: column2.type === "number" ? "end" : "start"
32532
- },
32533
- children: row[column2.field]
32534
- },
32535
- column2.field
32536
- ))
32537
- ]
32538
- },
32539
- rowId
32540
- );
32541
- }) }),
32542
- Footer && /* @__PURE__ */ jsx2(Footer, {})
32543
- ]
32544
- }
32545
- )
32536
+ )
32537
+ }
32538
+ ),
32539
+ columns.map((column2) => /* @__PURE__ */ jsx2(
32540
+ "td",
32541
+ {
32542
+ style: {
32543
+ textAlign: column2.type === "number" ? "end" : "start"
32544
+ },
32545
+ children: row[column2.field]
32546
+ },
32547
+ column2.field
32548
+ ))
32549
+ ]
32550
+ },
32551
+ rowId
32552
+ );
32553
+ }) }),
32554
+ Footer && /* @__PURE__ */ jsx2(Footer, {})
32555
+ ] })
32546
32556
  }
32547
32557
  ),
32548
32558
  /* @__PURE__ */ jsx2(
@@ -32819,7 +32829,21 @@ var defaultTheme4 = extendTheme({
32819
32829
  },
32820
32830
  styleOverrides: {
32821
32831
  root: ({ theme }) => ({
32822
- // "--TableRow-hoverBackground": theme.palette.primary.outlinedHoverBg,
32832
+ "--TableRow-stripeBackground": theme.palette.background.level1,
32833
+ "--TableCell-selectedBackground": theme.palette.background.level2,
32834
+ "--TableRow-hoverBackground": theme.palette.background.level3,
32835
+ "& tbody tr[aria-checked=false] th": {
32836
+ "--TableCell-headBackground": "transparent"
32837
+ },
32838
+ "& tbody tr[aria-checked=true]:hover th": {
32839
+ "--TableCell-headBackground": "var(--TableRow-hoverBackground)"
32840
+ },
32841
+ [`& tbody tr[aria-checked=true]:not(:hover) th`]: {
32842
+ "--TableCell-headBackground": "var(--TableCell-selectedBackground)"
32843
+ },
32844
+ [`& tbody tr[aria-checked=true]:not(:hover) td`]: {
32845
+ "--TableCell-dataBackground": "var(--TableCell-selectedBackground)"
32846
+ },
32823
32847
  [`& .${checkboxClasses_default.root}`]: {
32824
32848
  verticalAlign: "middle"
32825
32849
  }
@@ -33139,10 +33163,10 @@ var dataTablePropertyControls = {
33139
33163
  },
33140
33164
  defaultValue: []
33141
33165
  },
33142
- pageSize: {
33143
- type: ControlType7.Number,
33144
- defaultValue: 20
33145
- },
33166
+ // pageSize: {
33167
+ // type: ControlType.Number,
33168
+ // defaultValue: 20,
33169
+ // },
33146
33170
  stickyHeader: {
33147
33171
  type: ControlType7.Boolean,
33148
33172
  defaultValue: false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ceed/ads",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "description": "UI tool for Ecube Labs front-end developers",