@ceed/ads 0.0.29 → 0.0.31

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";
@@ -71,6 +71,43 @@ function TablePagination(props) {
71
71
  page !== lastPage && (React.createElement(Button, { size: "sm", variant: "plain", color: "neutral", onClick: function () { return onPageChange(lastPage); } }, lastPage)),
72
72
  React.createElement(Button, { size: "sm", variant: "plain", color: "neutral", onClick: function () { return onPageChange(page + 1); }, disabled: page === lastPage, "aria-label": "Next page" }, ">"))));
73
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
+ };
74
111
  function useDataTableRenderer(_a) {
75
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;
76
113
  var _c = useState((paginationModel === null || paginationModel === void 0 ? void 0 : paginationModel.page) || 1), page = _c[0], setPage = _c[1];
@@ -105,45 +142,27 @@ function useDataTableRenderer(_a) {
105
142
  page: page,
106
143
  pageSize: pageSize,
107
144
  onPaginationModelChange: handlePageChange,
108
- getColumnHeader: useCallback(function (column) {
109
- var _a, _b;
110
- var ref = useRef(null);
111
- var style = useMemo(function () {
112
- var _a;
113
- return ({
114
- width: column.width,
115
- minWidth: (_a = column.minWidth) !== null && _a !== void 0 ? _a : "50px",
116
- maxWidth: column.maxWidth,
117
- textAlign: column.type === "number" ? "end" : "start",
118
- position: stickyHeader ? undefined : "relative",
119
- });
120
- }, [column, stickyHeader]);
121
- var resizer = ((_a = column.resizable) !== null && _a !== void 0 ? _a : true) ? (React.createElement(Box, { sx: {
122
- position: "absolute",
123
- top: 0,
124
- right: 0,
125
- bottom: 0,
126
- width: "4px",
127
- cursor: "col-resize",
128
- }, onMouseDown: function (e) {
129
- var _a;
130
- var initialX = e.clientX;
131
- var initialWidth = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width;
132
- var onMouseMove = function (e) {
133
- if (initialWidth && initialX) {
134
- ref.current.style.width = "".concat(initialWidth + (e.clientX - initialX), "px");
135
- }
136
- };
137
- var onMouseUp = function () {
138
- document.removeEventListener("mousemove", onMouseMove);
139
- document.removeEventListener("mouseup", onMouseUp);
140
- };
141
- document.addEventListener("mousemove", onMouseMove);
142
- document.addEventListener("mouseup", onMouseUp);
143
- } })) : null;
144
- return (React.createElement("th", { ref: ref, key: column.field, style: style }, (_b = column.headerName) !== null && _b !== void 0 ? _b : column.field,
145
- resizer));
146
- }, [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
+ // ),
147
166
  dataInPage: dataInPage,
148
167
  isAllSelected: isAllSelected, // all rows are selected on this page
149
168
  isTotalSelected: isTotalSelected,
@@ -182,7 +201,7 @@ function DataTable(props) {
182
201
  ___ = props.onPaginationModelChange, // onPaginationModelChange is used in useDataTableRenderer
183
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"]);
184
203
  // lib hooks
185
- 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;
186
205
  // state, ref, querystring hooks
187
206
  // form hooks
188
207
  // query hooks
@@ -235,7 +254,7 @@ function DataTable(props) {
235
254
  textAlign: "center",
236
255
  } },
237
256
  React.createElement(RenderCheckbox, __assign({ onChange: onAllCheckboxChange, checked: isAllSelected, indeterminate: (selectionModel || []).length > 0 && !isAllSelected }, checkboxProps)))),
238
- columns.map(getColumnHeader))),
257
+ columns.map(function (c) { return (React.createElement(HeadCell, __assign({ key: c.field, stickyHeader: props.stickyHeader }, c))); }))),
239
258
  React.createElement("tbody", null, dataInPage.map(function (row, rowIndex) {
240
259
  var rowId = "".concat(rowIndex + (page - 1) * pageSize);
241
260
  return (React.createElement("tr", { key: rowId, role: checkboxSelection ? "checkbox" : undefined, tabIndex: checkboxSelection ? -1 : undefined, onClick: checkboxSelection
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
@@ -32216,6 +32219,49 @@ function TablePagination(props) {
32216
32219
  }
32217
32220
  );
32218
32221
  }
32222
+ var Resizer = (ref) => /* @__PURE__ */ jsx2(
32223
+ Box_default2,
32224
+ {
32225
+ sx: {
32226
+ position: "absolute",
32227
+ top: 0,
32228
+ right: 0,
32229
+ bottom: 0,
32230
+ width: "4px",
32231
+ cursor: "col-resize"
32232
+ },
32233
+ onMouseDown: (e) => {
32234
+ const initialX = e.clientX;
32235
+ const initialWidth = ref.current?.getBoundingClientRect().width;
32236
+ const onMouseMove = (e2) => {
32237
+ if (initialWidth && initialX) {
32238
+ ref.current.style.width = `${initialWidth + (e2.clientX - initialX)}px`;
32239
+ }
32240
+ };
32241
+ const onMouseUp = () => {
32242
+ document.removeEventListener("mousemove", onMouseMove);
32243
+ document.removeEventListener("mouseup", onMouseUp);
32244
+ };
32245
+ document.addEventListener("mousemove", onMouseMove);
32246
+ document.addEventListener("mouseup", onMouseUp);
32247
+ }
32248
+ }
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
+ };
32219
32265
  function useDataTableRenderer({
32220
32266
  rows,
32221
32267
  columns,
@@ -32270,54 +32316,27 @@ function useDataTableRenderer({
32270
32316
  page,
32271
32317
  pageSize,
32272
32318
  onPaginationModelChange: handlePageChange,
32273
- getColumnHeader: useCallback23(
32274
- (column2) => {
32275
- const ref = useRef40(null);
32276
- const style4 = useMemo32(
32277
- () => ({
32278
- width: column2.width,
32279
- minWidth: column2.minWidth ?? "50px",
32280
- maxWidth: column2.maxWidth,
32281
- textAlign: column2.type === "number" ? "end" : "start",
32282
- position: stickyHeader ? void 0 : "relative"
32283
- }),
32284
- [column2, stickyHeader]
32285
- );
32286
- const resizer = column2.resizable ?? true ? /* @__PURE__ */ jsx2(
32287
- Box_default2,
32288
- {
32289
- sx: {
32290
- position: "absolute",
32291
- top: 0,
32292
- right: 0,
32293
- bottom: 0,
32294
- width: "4px",
32295
- cursor: "col-resize"
32296
- },
32297
- onMouseDown: (e) => {
32298
- const initialX = e.clientX;
32299
- const initialWidth = ref.current?.getBoundingClientRect().width;
32300
- const onMouseMove = (e2) => {
32301
- if (initialWidth && initialX) {
32302
- ref.current.style.width = `${initialWidth + (e2.clientX - initialX)}px`;
32303
- }
32304
- };
32305
- const onMouseUp = () => {
32306
- document.removeEventListener("mousemove", onMouseMove);
32307
- document.removeEventListener("mouseup", onMouseUp);
32308
- };
32309
- document.addEventListener("mousemove", onMouseMove);
32310
- document.addEventListener("mouseup", onMouseUp);
32311
- }
32312
- }
32313
- ) : null;
32314
- return /* @__PURE__ */ jsxs2("th", { ref, style: style4, children: [
32315
- column2.headerName ?? column2.field,
32316
- resizer
32317
- ] }, column2.field);
32318
- },
32319
- [stickyHeader, columns]
32320
- ),
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
+ // ),
32321
32340
  dataInPage,
32322
32341
  isAllSelected,
32323
32342
  // all rows are selected on this page
@@ -32397,7 +32416,7 @@ function DataTable(props) {
32397
32416
  dataInPage,
32398
32417
  isTotalSelected,
32399
32418
  onTotalSelect,
32400
- getColumnHeader
32419
+ HeadCell: HeadCell2
32401
32420
  } = useDataTableRenderer(props);
32402
32421
  return /* @__PURE__ */ jsxs2(Box_default2, { children: [
32403
32422
  /* @__PURE__ */ jsxs2(
@@ -32491,7 +32510,14 @@ function DataTable(props) {
32491
32510
  )
32492
32511
  }
32493
32512
  ),
32494
- columns.map(getColumnHeader)
32513
+ columns.map((c) => /* @__PURE__ */ jsx2(
32514
+ HeadCell2,
32515
+ {
32516
+ stickyHeader: props.stickyHeader,
32517
+ ...c
32518
+ },
32519
+ c.field
32520
+ ))
32495
32521
  ] }) }),
32496
32522
  /* @__PURE__ */ jsx2("tbody", { children: dataInPage.map((row, rowIndex) => {
32497
32523
  const rowId = `${rowIndex + (page - 1) * pageSize}`;
@@ -33141,10 +33167,10 @@ var dataTablePropertyControls = {
33141
33167
  },
33142
33168
  defaultValue: []
33143
33169
  },
33144
- pageSize: {
33145
- type: ControlType7.Number,
33146
- defaultValue: 20
33147
- },
33170
+ // pageSize: {
33171
+ // type: ControlType.Number,
33172
+ // defaultValue: 20,
33173
+ // },
33148
33174
  stickyHeader: {
33149
33175
  type: ControlType7.Boolean,
33150
33176
  defaultValue: false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ceed/ads",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "description": "UI tool for Ecube Labs front-end developers",