@portnet/ui 0.1.53 → 0.1.55

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.
@@ -30,26 +30,8 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
30
30
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
31
31
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
32
32
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
33
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // Container for search form and actions
34
- const PuiStandardSearchPageContainer = _ref => {
35
- let {
36
- actions,
37
- children
38
- } = _ref;
39
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PuiGrid.default, {
40
- container: true,
41
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
42
- item: true,
43
- xs: 12,
44
- children: children
45
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
46
- item: true,
47
- xs: 12,
48
- children: actions
49
- })]
50
- });
51
- };
52
- const PuiSearchPage = _ref2 => {
33
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
34
+ const PuiSearchPage = _ref => {
53
35
  let {
54
36
  formik,
55
37
  formikProps,
@@ -65,14 +47,21 @@ const PuiSearchPage = _ref2 => {
65
47
  onRetour,
66
48
  onReset,
67
49
  onSubmit,
68
- children: _children,
69
50
  additionalActions,
70
51
  collapsibleSearchSection = true // Collapsible by default
71
- } = _ref2;
52
+ } = _ref;
72
53
  const [isSearchSectionExpanded, setSearchSectionExpanded] = (0, _react.useState)(false);
73
54
  const toggleSearchSection = () => {
74
55
  setSearchSectionExpanded(prev => !prev);
75
56
  };
57
+
58
+ // Extract columns from tableProps
59
+ const {
60
+ columns
61
+ } = tableProps || [];
62
+ const alwaysVisibleFields = columns.slice(0, 3); // First row fields
63
+ const expandableFields = columns.slice(3); // Second row fields
64
+
76
65
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PuiDefaultPage.default, {
77
66
  title: title,
78
67
  titleIcon: titleIcon,
@@ -93,7 +82,7 @@ const PuiSearchPage = _ref2 => {
93
82
  },
94
83
  children: [collapsibleSearchSection && (isSearchSectionExpanded ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandLess.default, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandMore.default, {})), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
95
84
  style: {
96
- marginLeft: collapsibleSearchSection ? "8px" : "0px"
85
+ marginLeft: "8px"
97
86
  },
98
87
  children: "Param\xE8tres de recherche"
99
88
  })]
@@ -101,95 +90,76 @@ const PuiSearchPage = _ref2 => {
101
90
  sx: {
102
91
  marginBottom: 2
103
92
  },
104
- children: isSearchSectionExpanded && (formik ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_formik.Formik, _objectSpread(_objectSpread({
105
- initialValues: {}
93
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_formik.Formik, _objectSpread(_objectSpread({
94
+ initialValues: formikProps.initialValues
106
95
  }, formikProps), {}, {
107
- children: _ref3 => {
96
+ children: _ref2 => {
108
97
  let {
109
98
  resetForm,
110
99
  submitForm
111
- } = _ref3;
112
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiFormikForm.default, {
113
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(PuiStandardSearchPageContainer, {
114
- actions: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PuiGrid.default, {
115
- container: true,
116
- justifyContent: "end",
117
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
118
- item: true,
119
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
120
- startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIcon.default, {
121
- type: "effacer",
122
- size: "small"
123
- }),
124
- onClick: resetForm,
125
- color: "tertiary",
126
- children: "Effacer"
127
- })
128
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
129
- item: true,
130
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
131
- startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIcon.default, {
132
- type: "rechercher",
133
- size: "small"
134
- }),
135
- onClick: submitForm,
136
- loadingPosition: "start",
137
- children: "Rechercher"
138
- })
139
- }), additionalActions && additionalActions.map((actionItem, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
140
- item: true,
141
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
142
- startIcon: actionItem.icon,
143
- onClick: actionItem.action,
144
- children: actionItem.name
145
- })
146
- }, index))]
147
- }),
148
- children: _children
149
- })
100
+ } = _ref2;
101
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PuiFormikForm.default, {
102
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_PuiGrid.default, {
103
+ container: true,
104
+ spacing: 2,
105
+ children: [alwaysVisibleFields.map((column, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
106
+ item: true,
107
+ xs: 12,
108
+ sm: 4,
109
+ children: column.renderCell ? column.renderCell({
110
+ row: {}
111
+ }) // Render fields
112
+ : column.headerName
113
+ }, index)), isSearchSectionExpanded && expandableFields.map((column, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
114
+ item: true,
115
+ xs: 12,
116
+ sm: 4,
117
+ children: column.renderCell ? column.renderCell({
118
+ row: {}
119
+ }) : column.headerName
120
+ }, index))]
121
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PuiGrid.default, {
122
+ container: true,
123
+ justifyContent: "end",
124
+ spacing: 2,
125
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
126
+ item: true,
127
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
128
+ startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIcon.default, {
129
+ type: "effacer",
130
+ size: "small"
131
+ }),
132
+ onClick: resetForm,
133
+ color: "tertiary",
134
+ children: "Effacer"
135
+ })
136
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
137
+ item: true,
138
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
139
+ startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIcon.default, {
140
+ type: "rechercher",
141
+ size: "small"
142
+ }),
143
+ onClick: submitForm,
144
+ loadingPosition: "start",
145
+ children: "Rechercher"
146
+ })
147
+ }), additionalActions && additionalActions.map((actionItem, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
148
+ item: true,
149
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
150
+ startIcon: actionItem.icon,
151
+ onClick: actionItem.action,
152
+ children: actionItem.name
153
+ })
154
+ }, index))]
155
+ })]
150
156
  });
151
157
  }
152
- })) : /*#__PURE__*/(0, _jsxRuntime.jsx)(PuiStandardSearchPageContainer, {
153
- actions: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PuiGrid.default, {
154
- container: true,
155
- justifyContent: "end",
156
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
157
- item: true,
158
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
159
- startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIcon.default, {
160
- type: "effacer",
161
- size: "small"
162
- }),
163
- onClick: onReset,
164
- color: "tertiary",
165
- children: "Effacer"
166
- })
167
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
168
- item: true,
169
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
170
- startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIcon.default, {
171
- type: "rechercher",
172
- size: "small"
173
- }),
174
- onClick: onSubmit,
175
- loadingPosition: "start",
176
- children: "Rechercher"
177
- })
178
- }), additionalActions && additionalActions.map((actionItem, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
179
- item: true,
180
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
181
- startIcon: actionItem.icon,
182
- onClick: actionItem.action,
183
- children: actionItem.name
184
- })
185
- }, index))]
186
- }),
187
- children: _children
188
158
  }))
189
159
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiTable.default, _objectSpread(_objectSpread({
190
160
  paginationMode: "server"
191
161
  }, tableProps), {}, {
192
- pinnedColumns: tableProps.pinnedColumns // Added pinnedColumns
162
+ pinnedColumns: tableProps.pinnedColumns
193
163
  }))]
194
164
  });
195
165
  };
@@ -197,14 +167,19 @@ PuiSearchPage.propTypes = {
197
167
  formik: _propTypes.default.bool,
198
168
  formikProps: _propTypes.default.object,
199
169
  title: _propTypes.default.string.isRequired,
200
- titleIcon: _propTypes.default.element.isRequired,
170
+ titleIcon: _propTypes.default.element,
201
171
  trace: _propTypes.default.arrayOf(_propTypes.default.string),
202
172
  navActions: _propTypes.default.element,
203
173
  topNav: _propTypes.default.bool,
204
174
  bottomNav: _propTypes.default.bool,
205
175
  loading: _propTypes.default.bool,
206
176
  tableProps: _propTypes.default.shape({
207
- pinnedColumns: _propTypes.default.object // Added pinnedColumns prop type
177
+ columns: _propTypes.default.arrayOf(_propTypes.default.shape({
178
+ field: _propTypes.default.string.isRequired,
179
+ headerName: _propTypes.default.string.isRequired,
180
+ renderCell: _propTypes.default.func
181
+ })).isRequired,
182
+ pinnedColumns: _propTypes.default.object
208
183
  }),
209
184
  retour: _propTypes.default.bool,
210
185
  onRetour: _propTypes.default.func,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portnet/ui",
3
- "version": "0.1.53",
3
+ "version": "0.1.55",
4
4
  "description": "Portnet UI",
5
5
  "keywords": [
6
6
  "react",