@ceed/ads 0.0.23 → 0.0.24

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,61 @@ 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
+ return ({
113
+ width: column.width,
114
+ minWidth: column.minWidth,
115
+ maxWidth: column.maxWidth,
116
+ textAlign: column.type === "number" ? "end" : "start",
117
+ position: stickyHeader ? undefined : "relative",
118
+ });
119
+ }, [column, stickyHeader]);
120
+ useEffect(function () {
121
+ if (column.resizable && ref.current) {
122
+ var resizeObserver_1 = new ResizeObserver(function (entries) {
123
+ for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
124
+ var entry = entries_1[_i];
125
+ var width = entry.contentRect.width;
126
+ if (width && ref.current) {
127
+ ref.current.style.width = "".concat(width, "px");
128
+ }
129
+ }
130
+ });
131
+ resizeObserver_1.observe(ref.current);
132
+ return function () {
133
+ resizeObserver_1.disconnect();
134
+ };
135
+ }
136
+ }, [column.resizable, ref.current]);
137
+ var resizer = ((_a = column.resizable) !== null && _a !== void 0 ? _a : true) ? (React.createElement(Box, { sx: {
138
+ position: "absolute",
139
+ top: 0,
140
+ right: 0,
141
+ bottom: 0,
142
+ width: "4px",
143
+ cursor: "col-resize",
144
+ }, onMouseDown: function (e) {
145
+ var _a;
146
+ var initialX = e.clientX;
147
+ var initialWidth = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width;
148
+ var onMouseMove = function (e) {
149
+ if (initialWidth && initialX) {
150
+ ref.current.style.width = "".concat(initialWidth + (e.clientX - initialX), "px");
151
+ }
152
+ };
153
+ var onMouseUp = function () {
154
+ document.removeEventListener("mousemove", onMouseMove);
155
+ document.removeEventListener("mouseup", onMouseUp);
156
+ };
157
+ document.addEventListener("mousemove", onMouseMove);
158
+ document.addEventListener("mouseup", onMouseUp);
159
+ } })) : null;
160
+ return (React.createElement("th", { ref: ref, key: column.field, style: style }, (_b = column.headerName) !== null && _b !== void 0 ? _b : column.field,
161
+ resizer));
162
+ }, [stickyHeader, columns]),
108
163
  dataInPage: dataInPage,
109
164
  isAllSelected: isAllSelected, // all rows are selected on this page
110
165
  isTotalSelected: isTotalSelected,
@@ -139,9 +194,11 @@ function useDataTableRenderer(_a) {
139
194
  function DataTable(props) {
140
195
  // prop destruction
141
196
  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"]);
197
+ __ = props.columns, // columns is used in useDataTableRenderer
198
+ ___ = props.onPaginationModelChange, // onPaginationModelChange is used in useDataTableRenderer
199
+ 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
200
  // 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;
201
+ 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
202
  // state, ref, querystring hooks
146
203
  // form hooks
147
204
  // query hooks
@@ -194,15 +251,7 @@ function DataTable(props) {
194
251
  textAlign: "center",
195
252
  } },
196
253
  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
- }))),
254
+ columns.map(getColumnHeader))),
206
255
  React.createElement("tbody", null, dataInPage.map(function (row, rowIndex) {
207
256
  var rowId = "".concat(rowIndex + (page - 1) * pageSize);
208
257
  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,70 @@ 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,
32280
+ maxWidth: column2.maxWidth,
32281
+ textAlign: column2.type === "number" ? "end" : "start",
32282
+ position: stickyHeader ? void 0 : "relative"
32283
+ }),
32284
+ [column2, stickyHeader]
32285
+ );
32286
+ useEffect33(() => {
32287
+ if (column2.resizable && ref.current) {
32288
+ const resizeObserver = new ResizeObserver((entries) => {
32289
+ for (const entry of entries) {
32290
+ const { width: width2 } = entry.contentRect;
32291
+ if (width2 && ref.current) {
32292
+ ref.current.style.width = `${width2}px`;
32293
+ }
32294
+ }
32295
+ });
32296
+ resizeObserver.observe(ref.current);
32297
+ return () => {
32298
+ resizeObserver.disconnect();
32299
+ };
32300
+ }
32301
+ }, [column2.resizable, ref.current]);
32302
+ const resizer = column2.resizable ?? true ? /* @__PURE__ */ jsx2(
32303
+ Box_default2,
32304
+ {
32305
+ sx: {
32306
+ position: "absolute",
32307
+ top: 0,
32308
+ right: 0,
32309
+ bottom: 0,
32310
+ width: "4px",
32311
+ cursor: "col-resize"
32312
+ },
32313
+ onMouseDown: (e) => {
32314
+ const initialX = e.clientX;
32315
+ const initialWidth = ref.current?.getBoundingClientRect().width;
32316
+ const onMouseMove = (e2) => {
32317
+ if (initialWidth && initialX) {
32318
+ ref.current.style.width = `${initialWidth + (e2.clientX - initialX)}px`;
32319
+ }
32320
+ };
32321
+ const onMouseUp = () => {
32322
+ document.removeEventListener("mousemove", onMouseMove);
32323
+ document.removeEventListener("mouseup", onMouseUp);
32324
+ };
32325
+ document.addEventListener("mousemove", onMouseMove);
32326
+ document.addEventListener("mouseup", onMouseUp);
32327
+ }
32328
+ }
32329
+ ) : null;
32330
+ return /* @__PURE__ */ jsxs2("th", { ref, style: style4, children: [
32331
+ column2.headerName ?? column2.field,
32332
+ resizer
32333
+ ] }, column2.field);
32334
+ },
32335
+ [stickyHeader, columns]
32336
+ ),
32268
32337
  dataInPage,
32269
32338
  isAllSelected,
32270
32339
  // all rows are selected on this page
@@ -32314,6 +32383,10 @@ function DataTable(props) {
32314
32383
  onSelectionModelChange,
32315
32384
  rowCount: _4,
32316
32385
  // rowCount is used in useDataTableRenderer
32386
+ columns: __,
32387
+ // columns is used in useDataTableRenderer
32388
+ onPaginationModelChange: ___,
32389
+ // onPaginationModelChange is used in useDataTableRenderer
32317
32390
  paginationModel,
32318
32391
  slots: {
32319
32392
  checkbox: RenderCheckbox = Checkbox_default2,
@@ -32339,7 +32412,8 @@ function DataTable(props) {
32339
32412
  onPaginationModelChange,
32340
32413
  dataInPage,
32341
32414
  isTotalSelected,
32342
- onTotalSelect
32415
+ onTotalSelect,
32416
+ getColumnHeader
32343
32417
  } = useDataTableRenderer(props);
32344
32418
  return /* @__PURE__ */ jsxs2(Box_default2, { children: [
32345
32419
  /* @__PURE__ */ jsxs2(
@@ -32433,19 +32507,7 @@ function DataTable(props) {
32433
32507
  )
32434
32508
  }
32435
32509
  ),
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
- ))
32510
+ columns.map(getColumnHeader)
32449
32511
  ] }) }),
32450
32512
  /* @__PURE__ */ jsx2("tbody", { children: dataInPage.map((row, rowIndex) => {
32451
32513
  const rowId = `${rowIndex + (page - 1) * pageSize}`;
@@ -32767,14 +32829,6 @@ Textarea3.displayName = "Textarea";
32767
32829
  // src/components/ThemeProvider/ThemeProvider.tsx
32768
32830
  var defaultTheme4 = extendTheme({
32769
32831
  cssVarPrefix: "ceed",
32770
- breakpoints: {
32771
- values: {
32772
- mobile: 0,
32773
- tablet: 768,
32774
- laptop: 1024,
32775
- desktop: 1280
32776
- }
32777
- },
32778
32832
  components: {
32779
32833
  JoyTable: {
32780
32834
  defaultProps: {
@@ -33089,11 +33143,16 @@ var dataTablePropertyControls = {
33089
33143
  },
33090
33144
  width: {
33091
33145
  type: ControlType7.String
33146
+ },
33147
+ type: {
33148
+ type: ControlType7.Enum,
33149
+ defaultValue: "string",
33150
+ options: ["string", "number"]
33151
+ },
33152
+ resizable: {
33153
+ type: ControlType7.Boolean,
33154
+ defaultValue: true
33092
33155
  }
33093
- // numeric: {
33094
- // type: ControlType.Boolean,
33095
- // defaultValue: false,
33096
- // },
33097
33156
  }
33098
33157
  },
33099
33158
  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.24",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "description": "UI tool for Ecube Labs front-end developers",