@ceed/ads 0.0.23 → 0.0.25

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.
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
2
  declare const Container: React.ForwardRefExoticComponent<Omit<import("@mui/system").MUIStyledCommonProps<import("@mui/joy").Theme> & {
3
- maxWidth?: "tablet" | "laptop" | "desktop" | undefined;
3
+ maxWidth?: "sm" | "md" | "lg" | "xl" | undefined;
4
4
  } & React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
5
5
  export { Container };
@@ -16,21 +16,25 @@ var ContainerRoot = styled("div", {
16
16
  slot: "root",
17
17
  shouldForwardProp: function (prop) { return prop !== "maxWidth"; },
18
18
  })(function (_a) {
19
- var _b, _c, _d;
20
- var theme = _a.theme, _e = _a.maxWidth, maxWidth = _e === void 0 ? "desktop" : _e;
21
- return (__assign(__assign(__assign({ width: "100%", marginLeft: "auto", boxSizing: "border-box", marginRight: "auto", display: "block", paddingLeft: theme.spacing(2), paddingRight: theme.spacing(2) }, (maxWidth === "tablet" && (_b = {},
22
- _b[theme.breakpoints.up("mobile")] = {
23
- maxWidth: theme.breakpoints.values.tablet,
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
24
  },
25
- _b))), (maxWidth === "laptop" && (_c = {},
26
- _c[theme.breakpoints.up("tablet")] = {
27
- maxWidth: theme.breakpoints.values.laptop,
25
+ _b))), (maxWidth === "md" && (_c = {},
26
+ _c[theme.breakpoints.up("sm")] = {
27
+ maxWidth: theme.breakpoints.values.md,
28
28
  },
29
- _c))), (maxWidth === "desktop" && (_d = {},
30
- _d[theme.breakpoints.up("laptop")] = {
31
- maxWidth: theme.breakpoints.values.desktop,
29
+ _c))), (maxWidth === "lg" && (_d = {},
30
+ _d[theme.breakpoints.up("md")] = {
31
+ maxWidth: theme.breakpoints.values.lg,
32
32
  },
33
- _d))));
33
+ _d))), (maxWidth === "xl" && (_e = {},
34
+ _e[theme.breakpoints.up("lg")] = {
35
+ maxWidth: theme.breakpoints.values.xl,
36
+ },
37
+ _e))));
34
38
  });
35
39
  var Container = forwardRef(function Container(props, ref) {
36
40
  // prop destruction
@@ -1,16 +1,18 @@
1
1
  import React, { ComponentProps } from "react";
2
2
  import { Table } from "../Table";
3
+ type Column<T extends Record<string, unknown>> = {
4
+ type?: "number" | "string";
5
+ field: keyof T;
6
+ headerName?: string;
7
+ width?: string;
8
+ minWidth?: string;
9
+ maxWidth?: string;
10
+ resizable?: boolean;
11
+ };
3
12
  type DataTableProps<T extends Record<string, unknown>> = {
4
13
  rows: T[];
5
14
  checkboxSelection?: boolean;
6
- columns: {
7
- type?: "number" | "string";
8
- field: keyof T;
9
- headerName?: string;
10
- width?: string;
11
- minWidth?: string;
12
- maxWidth?: string;
13
- }[];
15
+ columns: Column<T>[];
14
16
  /**
15
17
  * 체크박스가 있는 경우, 체크박스를 클릭했을 때 선택된 row의 index를 지정한다.
16
18
  */
@@ -29,7 +29,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
29
29
  }
30
30
  return to.concat(ar || Array.prototype.slice.call(from));
31
31
  };
32
- import React, { useCallback, useEffect, useMemo, useState, } from "react";
32
+ import React, { useCallback, useEffect, useMemo, useRef, useState, } from "react";
33
33
  import Sheet from "../Sheet";
34
34
  import { Table } from "../Table";
35
35
  import Checkbox from "../Checkbox";
@@ -72,7 +72,7 @@ function TablePagination(props) {
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
74
  function useDataTableRenderer(_a) {
75
- 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;
75
+ 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
76
  var _c = useState((paginationModel === null || paginationModel === void 0 ? void 0 : paginationModel.page) || 1), page = _c[0], setPage = _c[1];
77
77
  var pageSize = (paginationModel === null || paginationModel === void 0 ? void 0 : paginationModel.pageSize) || 20;
78
78
  var selectedModelSet = useMemo(function () { return new Set(selectionModel); }, [selectionModel]);
@@ -105,6 +105,45 @@ function useDataTableRenderer(_a) {
105
105
  page: page,
106
106
  pageSize: pageSize,
107
107
  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]),
108
147
  dataInPage: dataInPage,
109
148
  isAllSelected: isAllSelected, // all rows are selected on this page
110
149
  isTotalSelected: isTotalSelected,
@@ -139,9 +178,11 @@ function useDataTableRenderer(_a) {
139
178
  function DataTable(props) {
140
179
  // prop destruction
141
180
  var rows = props.rows, checkboxSelection = props.checkboxSelection, selectionModel = props.selectionModel, onSelectionModelChange = props.onSelectionModelChange, _ = props.rowCount, // rowCount is used in useDataTableRenderer
142
- 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", "paginationModel", "slots", "slotProps"]);
181
+ __ = props.columns, // columns is used in useDataTableRenderer
182
+ ___ = props.onPaginationModelChange, // onPaginationModelChange is used in useDataTableRenderer
183
+ 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"]);
143
184
  // lib hooks
144
- 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;
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;
145
186
  // state, ref, querystring hooks
146
187
  // form hooks
147
188
  // query hooks
@@ -194,15 +235,7 @@ function DataTable(props) {
194
235
  textAlign: "center",
195
236
  } },
196
237
  React.createElement(RenderCheckbox, __assign({ onChange: onAllCheckboxChange, checked: isAllSelected, indeterminate: (selectionModel || []).length > 0 && !isAllSelected }, checkboxProps)))),
197
- columns.map(function (column) {
198
- var _a;
199
- return (React.createElement("th", { key: column.field, style: {
200
- width: column.width,
201
- minWidth: column.minWidth,
202
- maxWidth: column.maxWidth,
203
- textAlign: column.type === "number" ? "end" : "start",
204
- } }, (_a = column.headerName) !== null && _a !== void 0 ? _a : column.field));
205
- }))),
238
+ columns.map(getColumnHeader))),
206
239
  React.createElement("tbody", null, dataInPage.map(function (row, rowIndex) {
207
240
  var rowId = "".concat(rowIndex + (page - 1) * pageSize);
208
241
  return (React.createElement("tr", { key: rowId, role: checkboxSelection ? "checkbox" : undefined, tabIndex: checkboxSelection ? -1 : undefined, onClick: checkboxSelection
@@ -1,17 +1,4 @@
1
1
  import React from "react";
2
- declare module "@mui/joy/styles" {
3
- interface BreakpointOverrides {
4
- xs: false;
5
- sm: false;
6
- md: false;
7
- lg: false;
8
- xl: false;
9
- mobile: true;
10
- tablet: true;
11
- laptop: true;
12
- desktop: true;
13
- }
14
- }
15
2
  declare function ThemeProvider(props: {
16
3
  children?: React.ReactNode;
17
4
  }): React.JSX.Element;
@@ -2,14 +2,6 @@ import React from "react";
2
2
  import { CssBaseline, CssVarsProvider, checkboxClasses, extendTheme, } from "@mui/joy";
3
3
  var defaultTheme = extendTheme({
4
4
  cssVarPrefix: "ceed",
5
- breakpoints: {
6
- values: {
7
- mobile: 0,
8
- tablet: 768,
9
- laptop: 1024,
10
- desktop: 1280,
11
- },
12
- },
13
5
  components: {
14
6
  JoyTable: {
15
7
  defaultProps: {
package/framer/index.js CHANGED
@@ -31945,33 +31945,36 @@ var ContainerRoot = styled_default2("div", {
31945
31945
  name: "Container",
31946
31946
  slot: "root",
31947
31947
  shouldForwardProp: (prop) => prop !== "maxWidth"
31948
- })(
31949
- ({ theme, maxWidth: maxWidth2 = "desktop" }) => ({
31950
- width: "100%",
31951
- marginLeft: "auto",
31952
- boxSizing: "border-box",
31953
- marginRight: "auto",
31954
- display: "block",
31955
- // Fix IE11 layout when used with main.
31956
- paddingLeft: theme.spacing(2),
31957
- paddingRight: theme.spacing(2),
31958
- ...maxWidth2 === "tablet" && {
31959
- [theme.breakpoints.up("mobile")]: {
31960
- maxWidth: theme.breakpoints.values.tablet
31961
- }
31962
- },
31963
- ...maxWidth2 === "laptop" && {
31964
- [theme.breakpoints.up("tablet")]: {
31965
- maxWidth: theme.breakpoints.values.laptop
31966
- }
31967
- },
31968
- ...maxWidth2 === "desktop" && {
31969
- [theme.breakpoints.up("laptop")]: {
31970
- maxWidth: theme.breakpoints.values.desktop
31971
- }
31948
+ })(({ theme, maxWidth: maxWidth2 = "lg" }) => ({
31949
+ width: "100%",
31950
+ marginLeft: "auto",
31951
+ boxSizing: "border-box",
31952
+ marginRight: "auto",
31953
+ display: "block",
31954
+ // Fix IE11 layout when used with main.
31955
+ paddingLeft: theme.spacing(2),
31956
+ paddingRight: theme.spacing(2),
31957
+ ...maxWidth2 === "sm" && {
31958
+ [theme.breakpoints.up("xs")]: {
31959
+ maxWidth: theme.breakpoints.values.sm
31972
31960
  }
31973
- })
31974
- );
31961
+ },
31962
+ ...maxWidth2 === "md" && {
31963
+ [theme.breakpoints.up("sm")]: {
31964
+ maxWidth: theme.breakpoints.values.md
31965
+ }
31966
+ },
31967
+ ...maxWidth2 === "lg" && {
31968
+ [theme.breakpoints.up("md")]: {
31969
+ maxWidth: theme.breakpoints.values.lg
31970
+ }
31971
+ },
31972
+ ...maxWidth2 === "xl" && {
31973
+ [theme.breakpoints.up("lg")]: {
31974
+ maxWidth: theme.breakpoints.values.xl
31975
+ }
31976
+ }
31977
+ }));
31975
31978
  var Container = forwardRef76(function Container2(props, ref) {
31976
31979
  return /* @__PURE__ */ jsx2(ContainerRoot, { ref, ...props });
31977
31980
  });
@@ -31982,6 +31985,7 @@ import {
31982
31985
  useCallback as useCallback23,
31983
31986
  useEffect as useEffect33,
31984
31987
  useMemo as useMemo32,
31988
+ useRef as useRef40,
31985
31989
  useState as useState21
31986
31990
  } from "react";
31987
31991
 
@@ -32219,7 +32223,8 @@ function useDataTableRenderer({
32219
32223
  paginationModel,
32220
32224
  onPaginationModelChange,
32221
32225
  selectionModel = [],
32222
- onSelectionModelChange
32226
+ onSelectionModelChange,
32227
+ stickyHeader
32223
32228
  }) {
32224
32229
  const [page, setPage] = useState21(paginationModel?.page || 1);
32225
32230
  const pageSize = paginationModel?.pageSize || 20;
@@ -32265,6 +32270,54 @@ function useDataTableRenderer({
32265
32270
  page,
32266
32271
  pageSize,
32267
32272
  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
+ ),
32268
32321
  dataInPage,
32269
32322
  isAllSelected,
32270
32323
  // all rows are selected on this page
@@ -32314,6 +32367,10 @@ function DataTable(props) {
32314
32367
  onSelectionModelChange,
32315
32368
  rowCount: _4,
32316
32369
  // rowCount is used in useDataTableRenderer
32370
+ columns: __,
32371
+ // columns is used in useDataTableRenderer
32372
+ onPaginationModelChange: ___,
32373
+ // onPaginationModelChange is used in useDataTableRenderer
32317
32374
  paginationModel,
32318
32375
  slots: {
32319
32376
  checkbox: RenderCheckbox = Checkbox_default2,
@@ -32339,7 +32396,8 @@ function DataTable(props) {
32339
32396
  onPaginationModelChange,
32340
32397
  dataInPage,
32341
32398
  isTotalSelected,
32342
- onTotalSelect
32399
+ onTotalSelect,
32400
+ getColumnHeader
32343
32401
  } = useDataTableRenderer(props);
32344
32402
  return /* @__PURE__ */ jsxs2(Box_default2, { children: [
32345
32403
  /* @__PURE__ */ jsxs2(
@@ -32433,19 +32491,7 @@ function DataTable(props) {
32433
32491
  )
32434
32492
  }
32435
32493
  ),
32436
- columns.map((column2) => /* @__PURE__ */ jsx2(
32437
- "th",
32438
- {
32439
- style: {
32440
- width: column2.width,
32441
- minWidth: column2.minWidth,
32442
- maxWidth: column2.maxWidth,
32443
- textAlign: column2.type === "number" ? "end" : "start"
32444
- },
32445
- children: column2.headerName ?? column2.field
32446
- },
32447
- column2.field
32448
- ))
32494
+ columns.map(getColumnHeader)
32449
32495
  ] }) }),
32450
32496
  /* @__PURE__ */ jsx2("tbody", { children: dataInPage.map((row, rowIndex) => {
32451
32497
  const rowId = `${rowIndex + (page - 1) * pageSize}`;
@@ -32767,14 +32813,6 @@ Textarea3.displayName = "Textarea";
32767
32813
  // src/components/ThemeProvider/ThemeProvider.tsx
32768
32814
  var defaultTheme4 = extendTheme({
32769
32815
  cssVarPrefix: "ceed",
32770
- breakpoints: {
32771
- values: {
32772
- mobile: 0,
32773
- tablet: 768,
32774
- laptop: 1024,
32775
- desktop: 1280
32776
- }
32777
- },
32778
32816
  components: {
32779
32817
  JoyTable: {
32780
32818
  defaultProps: {
@@ -33089,11 +33127,16 @@ var dataTablePropertyControls = {
33089
33127
  },
33090
33128
  width: {
33091
33129
  type: ControlType7.String
33130
+ },
33131
+ type: {
33132
+ type: ControlType7.Enum,
33133
+ defaultValue: "string",
33134
+ options: ["string", "number"]
33135
+ },
33136
+ resizable: {
33137
+ type: ControlType7.Boolean,
33138
+ defaultValue: true
33092
33139
  }
33093
- // numeric: {
33094
- // type: ControlType.Boolean,
33095
- // defaultValue: false,
33096
- // },
33097
33140
  }
33098
33141
  },
33099
33142
  defaultValue: []
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ceed/ads",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "description": "UI tool for Ecube Labs front-end developers",