cloudmr-ux 1.0.5 → 1.0.6

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.
package/dist/index.css CHANGED
@@ -141,6 +141,11 @@
141
141
  background-color: #dcbfea !important;
142
142
  }
143
143
 
144
+ /* src/CmrComponents/collapse/Collapse.css */
145
+ .collapse-bar {
146
+ margin-bottom: 4px;
147
+ }
148
+
144
149
  /* src/CmrTable/CmrTable.css */
145
150
  .css-1lymaxv-MuiDataGrid-root .MuiDataGrid-columnHeader:focus-within,
146
151
  .css-1lymaxv-MuiDataGrid-root .MuiDataGrid-cell:focus-within {
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ButtonProps } from '@mui/material';
3
- import React, { ChangeEvent, CSSProperties, FC } from 'react';
3
+ import React, { ChangeEvent, ReactNode, CSSProperties, FC } from 'react';
4
4
  import { SizeType } from 'antd/lib/config-provider/SizeContext';
5
+ import { CollapsibleType } from 'antd/es/collapse/CollapsePanel';
6
+ import { ExpandIconPosition } from 'antd/es/collapse/Collapse';
5
7
  import { DataGridProps } from '@mui/x-data-grid';
6
8
 
7
9
  declare const CmrButton: (props: ButtonProps) => react_jsx_runtime.JSX.Element;
@@ -56,6 +58,31 @@ interface CmrSelectProps {
56
58
  }
57
59
  declare const CmrSelect: React.FC<CmrSelectProps>;
58
60
 
61
+ interface CmrCollapseProps {
62
+ accordion?: boolean;
63
+ activeKey?: Array<string | number> | number;
64
+ bordered?: boolean;
65
+ collapsible?: CollapsibleType;
66
+ defaultActiveKey?: Array<string | number>;
67
+ destroyInactivePanel?: boolean;
68
+ expandIconPosition?: ExpandIconPosition;
69
+ ghost?: boolean;
70
+ onChange?: (key: Array<string | number> | number) => void;
71
+ children?: JSX.Element[] | JSX.Element;
72
+ }
73
+ declare const CmrCollapse: (props: CmrCollapseProps) => react_jsx_runtime.JSX.Element;
74
+
75
+ interface CmrPanelProps extends React.HTMLAttributes<HTMLDivElement> {
76
+ activeKey?: string | string[];
77
+ header: string | undefined;
78
+ children: ReactNode;
79
+ panelKey?: number;
80
+ onToggle?: (key: number | undefined) => void;
81
+ expanded?: boolean;
82
+ cardProps?: React.HTMLAttributes<HTMLDivElement>;
83
+ }
84
+ declare const CmrPanel: (props: CmrPanelProps) => react_jsx_runtime.JSX.Element;
85
+
59
86
  interface CmrTableProps extends Omit<DataGridProps, 'rows'> {
60
87
  dataSource: any[];
61
88
  idAlias?: string;
@@ -66,4 +93,4 @@ interface CmrTableProps extends Omit<DataGridProps, 'rows'> {
66
93
 
67
94
  declare const CmrTable: FC<CmrTableProps>;
68
95
 
69
- export { CmrButton, CmrCheckbox, CmrInput, CmrRadioGroup, CmrSelect, CmrTable, CmrTableProps };
96
+ export { CmrButton, CmrCheckbox, CmrCollapse, CmrInput, CmrPanel, CmrRadioGroup, CmrSelect, CmrTable, CmrTableProps };
package/dist/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
@@ -22,7 +32,9 @@ var src_exports = {};
22
32
  __export(src_exports, {
23
33
  CmrButton: () => CmrButton,
24
34
  CmrCheckbox: () => CmrCheckbox,
35
+ CmrCollapse: () => Collapse_default,
25
36
  CmrInput: () => CmrInput,
37
+ CmrPanel: () => Panel_default,
26
38
  CmrRadioGroup: () => CmrRadioGroup_default,
27
39
  CmrSelect: () => CmrSelect_default,
28
40
  CmrTable: () => CmrTable2
@@ -174,9 +186,113 @@ var CmrSelect = ({ options, label, disabled }) => {
174
186
  };
175
187
  var CmrSelect_default = CmrSelect;
176
188
 
189
+ // src/CmrComponents/collapse/Collapse.tsx
190
+ var import_react3 = __toESM(require("react"));
191
+ var import_jsx_runtime6 = require("react/jsx-runtime");
192
+ var CmrCollapse = (props) => {
193
+ let { activeKey, defaultActiveKey, onChange, children } = props;
194
+ defaultActiveKey = defaultActiveKey || [];
195
+ const [activeKeys, setActiveKeys] = import_react3.default.useState(defaultActiveKey);
196
+ import_react3.default.useEffect(() => {
197
+ if (activeKey !== void 0 && activeKey !== activeKeys) {
198
+ if (Array.isArray(activeKey)) {
199
+ setActiveKeys(activeKey);
200
+ } else {
201
+ setActiveKeys([activeKey]);
202
+ }
203
+ }
204
+ }, [activeKey]);
205
+ const onToggle = (key) => {
206
+ const newKeys = [...activeKeys];
207
+ const keyIndex = newKeys.indexOf(key);
208
+ if (keyIndex === -1) {
209
+ newKeys.push(key);
210
+ } else {
211
+ newKeys.splice(keyIndex, 1);
212
+ }
213
+ setActiveKeys(newKeys);
214
+ if (onChange)
215
+ onChange(newKeys);
216
+ };
217
+ const renderChildren = () => {
218
+ if (!children)
219
+ return null;
220
+ if (Array.isArray(children)) {
221
+ return children.map((child, index) => {
222
+ const panelKey = index;
223
+ const expanded = activeKeys.includes(panelKey);
224
+ const header = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { onClick: () => onToggle(panelKey), style: { cursor: "pointer" }, children: child.props.header });
225
+ return (0, import_react3.cloneElement)(child, {
226
+ expanded,
227
+ panelKey,
228
+ onToggle,
229
+ header
230
+ // Override header with clickable version
231
+ });
232
+ });
233
+ } else {
234
+ const panelKey = 0;
235
+ const expanded = activeKeys.includes(panelKey);
236
+ const header = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { onClick: () => onToggle(panelKey), style: { cursor: "pointer" }, children: children.props.header });
237
+ return (0, import_react3.cloneElement)(children, {
238
+ expanded,
239
+ panelKey,
240
+ onToggle,
241
+ header
242
+ // Override header with clickable version
243
+ });
244
+ }
245
+ };
246
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "cmr-collapse", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { children: renderChildren() }) });
247
+ };
248
+ var Collapse_default = CmrCollapse;
249
+
250
+ // src/CmrComponents/panel/Panel.tsx
251
+ var import_ArrowDropUp = __toESM(require("@mui/icons-material/ArrowDropUp"));
252
+ var import_ArrowDropDown = __toESM(require("@mui/icons-material/ArrowDropDown"));
253
+ var import_jsx_runtime7 = require("react/jsx-runtime");
254
+ var CmrPanel = function(props) {
255
+ var _a, _b;
256
+ let { expanded, onToggle } = props;
257
+ const toggle = () => {
258
+ if (onToggle)
259
+ onToggle(props.panelKey);
260
+ };
261
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: `card ${props.className}`, children: [
262
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "card-header", style: { background: "white", display: props.header == void 0 ? "none" : void 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "row align-items-center", children: [
263
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "col", children: props.header }),
264
+ onToggle && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "col text-end", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
265
+ "span",
266
+ {
267
+ className: "react-collapse float-end btn",
268
+ onClick: (e) => {
269
+ toggle();
270
+ },
271
+ children: !expanded ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ArrowDropDown.default, {}) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ArrowDropUp.default, {})
272
+ }
273
+ ) })
274
+ ] }) }),
275
+ !expanded ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: `card-body m-0 ${(_a = props.cardProps) == null ? void 0 : _a.className}`, style: {
276
+ maxHeight: "0",
277
+ padding: 0,
278
+ opacity: "0",
279
+ overflow: "hidden",
280
+ visibility: "collapse",
281
+ transition: "all 0.5s"
282
+ }, children: props.children }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: `card-body m-4 ${(_b = props.cardProps) == null ? void 0 : _b.className}`, style: {
283
+ maxHeight: void 0,
284
+ padding: 0,
285
+ opacity: "1",
286
+ visibility: "visible",
287
+ transition: "all 0.5s"
288
+ }, children: props.children })
289
+ ] });
290
+ };
291
+ var Panel_default = CmrPanel;
292
+
177
293
  // src/CmrTable/CmrTable.tsx
178
294
  var import_x_data_grid = require("@mui/x-data-grid");
179
- var import_jsx_runtime6 = require("react/jsx-runtime");
295
+ var import_jsx_runtime8 = require("react/jsx-runtime");
180
296
  var CmrTable = (props) => {
181
297
  const {
182
298
  dataSource,
@@ -188,7 +304,7 @@ var CmrTable = (props) => {
188
304
  showCheckbox = true,
189
305
  ...rest
190
306
  } = props;
191
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: style ?? { height: "400px", width: "100%" }, className: className ?? "", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
307
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: style ?? { height: "400px", width: "100%" }, className: className ?? "", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
192
308
  import_x_data_grid.DataGrid,
193
309
  {
194
310
  rows: dataSource ? dataSource.map((row) => ({
@@ -216,7 +332,9 @@ var CmrTable2 = CmrTable_default;
216
332
  0 && (module.exports = {
217
333
  CmrButton,
218
334
  CmrCheckbox,
335
+ CmrCollapse,
219
336
  CmrInput,
337
+ CmrPanel,
220
338
  CmrRadioGroup,
221
339
  CmrSelect,
222
340
  CmrTable
package/dist/index.mjs CHANGED
@@ -149,9 +149,113 @@ var CmrSelect = ({ options, label, disabled }) => {
149
149
  };
150
150
  var CmrSelect_default = CmrSelect;
151
151
 
152
+ // src/CmrComponents/collapse/Collapse.tsx
153
+ import React3, { cloneElement } from "react";
154
+ import { jsx as jsx6 } from "react/jsx-runtime";
155
+ var CmrCollapse = (props) => {
156
+ let { activeKey, defaultActiveKey, onChange, children } = props;
157
+ defaultActiveKey = defaultActiveKey || [];
158
+ const [activeKeys, setActiveKeys] = React3.useState(defaultActiveKey);
159
+ React3.useEffect(() => {
160
+ if (activeKey !== void 0 && activeKey !== activeKeys) {
161
+ if (Array.isArray(activeKey)) {
162
+ setActiveKeys(activeKey);
163
+ } else {
164
+ setActiveKeys([activeKey]);
165
+ }
166
+ }
167
+ }, [activeKey]);
168
+ const onToggle = (key) => {
169
+ const newKeys = [...activeKeys];
170
+ const keyIndex = newKeys.indexOf(key);
171
+ if (keyIndex === -1) {
172
+ newKeys.push(key);
173
+ } else {
174
+ newKeys.splice(keyIndex, 1);
175
+ }
176
+ setActiveKeys(newKeys);
177
+ if (onChange)
178
+ onChange(newKeys);
179
+ };
180
+ const renderChildren = () => {
181
+ if (!children)
182
+ return null;
183
+ if (Array.isArray(children)) {
184
+ return children.map((child, index) => {
185
+ const panelKey = index;
186
+ const expanded = activeKeys.includes(panelKey);
187
+ const header = /* @__PURE__ */ jsx6("div", { onClick: () => onToggle(panelKey), style: { cursor: "pointer" }, children: child.props.header });
188
+ return cloneElement(child, {
189
+ expanded,
190
+ panelKey,
191
+ onToggle,
192
+ header
193
+ // Override header with clickable version
194
+ });
195
+ });
196
+ } else {
197
+ const panelKey = 0;
198
+ const expanded = activeKeys.includes(panelKey);
199
+ const header = /* @__PURE__ */ jsx6("div", { onClick: () => onToggle(panelKey), style: { cursor: "pointer" }, children: children.props.header });
200
+ return cloneElement(children, {
201
+ expanded,
202
+ panelKey,
203
+ onToggle,
204
+ header
205
+ // Override header with clickable version
206
+ });
207
+ }
208
+ };
209
+ return /* @__PURE__ */ jsx6("div", { className: "cmr-collapse", children: /* @__PURE__ */ jsx6("div", { children: renderChildren() }) });
210
+ };
211
+ var Collapse_default = CmrCollapse;
212
+
213
+ // src/CmrComponents/panel/Panel.tsx
214
+ import ArrowDropUpIcon from "@mui/icons-material/ArrowDropUp";
215
+ import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown";
216
+ import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
217
+ var CmrPanel = function(props) {
218
+ var _a, _b;
219
+ let { expanded, onToggle } = props;
220
+ const toggle = () => {
221
+ if (onToggle)
222
+ onToggle(props.panelKey);
223
+ };
224
+ return /* @__PURE__ */ jsxs3("div", { className: `card ${props.className}`, children: [
225
+ /* @__PURE__ */ jsx7("div", { className: "card-header", style: { background: "white", display: props.header == void 0 ? "none" : void 0 }, children: /* @__PURE__ */ jsxs3("div", { className: "row align-items-center", children: [
226
+ /* @__PURE__ */ jsx7("div", { className: "col", children: props.header }),
227
+ onToggle && /* @__PURE__ */ jsx7("div", { className: "col text-end", children: /* @__PURE__ */ jsx7(
228
+ "span",
229
+ {
230
+ className: "react-collapse float-end btn",
231
+ onClick: (e) => {
232
+ toggle();
233
+ },
234
+ children: !expanded ? /* @__PURE__ */ jsx7(ArrowDropDownIcon, {}) : /* @__PURE__ */ jsx7(ArrowDropUpIcon, {})
235
+ }
236
+ ) })
237
+ ] }) }),
238
+ !expanded ? /* @__PURE__ */ jsx7("div", { className: `card-body m-0 ${(_a = props.cardProps) == null ? void 0 : _a.className}`, style: {
239
+ maxHeight: "0",
240
+ padding: 0,
241
+ opacity: "0",
242
+ overflow: "hidden",
243
+ visibility: "collapse",
244
+ transition: "all 0.5s"
245
+ }, children: props.children }) : /* @__PURE__ */ jsx7("div", { className: `card-body m-4 ${(_b = props.cardProps) == null ? void 0 : _b.className}`, style: {
246
+ maxHeight: void 0,
247
+ padding: 0,
248
+ opacity: "1",
249
+ visibility: "visible",
250
+ transition: "all 0.5s"
251
+ }, children: props.children })
252
+ ] });
253
+ };
254
+ var Panel_default = CmrPanel;
255
+
152
256
  // src/CmrTable/CmrTable.tsx
153
257
  import { DataGrid } from "@mui/x-data-grid";
154
- import { jsx as jsx6 } from "react/jsx-runtime";
258
+ import { jsx as jsx8 } from "react/jsx-runtime";
155
259
  var CmrTable = (props) => {
156
260
  const {
157
261
  dataSource,
@@ -163,7 +267,7 @@ var CmrTable = (props) => {
163
267
  showCheckbox = true,
164
268
  ...rest
165
269
  } = props;
166
- return /* @__PURE__ */ jsx6("div", { style: style ?? { height: "400px", width: "100%" }, className: className ?? "", children: /* @__PURE__ */ jsx6(
270
+ return /* @__PURE__ */ jsx8("div", { style: style ?? { height: "400px", width: "100%" }, className: className ?? "", children: /* @__PURE__ */ jsx8(
167
271
  DataGrid,
168
272
  {
169
273
  rows: dataSource ? dataSource.map((row) => ({
@@ -190,7 +294,9 @@ var CmrTable2 = CmrTable_default;
190
294
  export {
191
295
  CmrButton,
192
296
  CmrCheckbox,
297
+ Collapse_default as CmrCollapse,
193
298
  CmrInput,
299
+ Panel_default as CmrPanel,
194
300
  CmrRadioGroup_default as CmrRadioGroup,
195
301
  CmrSelect_default as CmrSelect,
196
302
  CmrTable2 as CmrTable
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudmr-ux",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "author": "erosmontin@gmail.com",
5
5
  "license": "MIT",
6
6
  "repository": "erosmontin/cloudmr-ux",