asab_webui_components 25.1.1

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.
Files changed (103) hide show
  1. package/CHANGELOG.md +295 -0
  2. package/LICENSE +28 -0
  3. package/README.md +3 -0
  4. package/dist/abc/Module.js +20 -0
  5. package/dist/abc/Renderer.js +67 -0
  6. package/dist/abc/Service.js +24 -0
  7. package/dist/components/AdvancedCard/AdvancedCard.js +38 -0
  8. package/dist/components/AdvancedCard/AdvancedCard.jsx +34 -0
  9. package/dist/components/AttentionRequired/AttentionRequiredBadge.js +22 -0
  10. package/dist/components/AttentionRequired/AttentionRequiredBadge.jsx +17 -0
  11. package/dist/components/Authz/ButtonWithAuthz.js +81 -0
  12. package/dist/components/Authz/ControlledSwitchWithAuthz.js +78 -0
  13. package/dist/components/Authz/Credentials.js +217 -0
  14. package/dist/components/Authz/Credentials.scss +7 -0
  15. package/dist/components/Authz/LinkWithAuthz.js +56 -0
  16. package/dist/components/Authz/UncontrolledSwitchWithAuthz.js +79 -0
  17. package/dist/components/Authz/utils/authz.js +38 -0
  18. package/dist/components/Authz/utils/isAuthorized.js +31 -0
  19. package/dist/components/Console/ConsoleCard.js +98 -0
  20. package/dist/components/Console/ConsoleCard.jsx +70 -0
  21. package/dist/components/Console/ConsoleCard.scss +26 -0
  22. package/dist/components/Console/ConsoleContext.js +14 -0
  23. package/dist/components/Console/ConsoleContext.jsx +5 -0
  24. package/dist/components/Console/components/ConsoleModeButton.js +35 -0
  25. package/dist/components/Console/components/ConsoleModeButton.jsx +30 -0
  26. package/dist/components/ContentLoader.js +57 -0
  27. package/dist/components/Context/PubSubContext.js +51 -0
  28. package/dist/components/ControlledSwitch/index.js +33 -0
  29. package/dist/components/ControlledSwitch/switch.scss +82 -0
  30. package/dist/components/DataTable/ActionButton.js +63 -0
  31. package/dist/components/DataTable/Buttons.js +116 -0
  32. package/dist/components/DataTable/CustomDropdownButton.js +49 -0
  33. package/dist/components/DataTable/DataTable.scss +37 -0
  34. package/dist/components/DataTable/LimitDropdown.js +52 -0
  35. package/dist/components/DataTable/Pagination.js +204 -0
  36. package/dist/components/DataTable/Search.js +29 -0
  37. package/dist/components/DataTable/Sort.js +44 -0
  38. package/dist/components/DataTable/Table.js +310 -0
  39. package/dist/components/DataTable/index.js +180 -0
  40. package/dist/components/DataTable2/DataTable2.js +532 -0
  41. package/dist/components/DataTable2/DataTable2.jsx +446 -0
  42. package/dist/components/DataTable2/DataTable2.scss +38 -0
  43. package/dist/components/DataTable2/DataTableContext.js +401 -0
  44. package/dist/components/DataTable2/DataTableContext.jsx +338 -0
  45. package/dist/components/DataTable2/components/filters/DataTableAdvFilter2.scss +20 -0
  46. package/dist/components/DataTable2/components/filters/DataTableAdvFilterMultiValue2.js +80 -0
  47. package/dist/components/DataTable2/components/filters/DataTableAdvFilterMultiValue2.jsx +64 -0
  48. package/dist/components/DataTable2/components/filters/DataTableAdvFilterSingleValue2.js +61 -0
  49. package/dist/components/DataTable2/components/filters/DataTableAdvFilterSingleValue2.jsx +49 -0
  50. package/dist/components/DataTable2/components/filters/DataTableSimpleFilter2.js +38 -0
  51. package/dist/components/DataTable2/components/filters/DataTableSimpleFilter2.jsx +35 -0
  52. package/dist/components/DataTable2/components/filters/index.js +26 -0
  53. package/dist/components/DataTable2/components/filters/index.jsx +3 -0
  54. package/dist/components/DataTable2/components/utils/updateTableLimit.js +37 -0
  55. package/dist/components/DataTable2/components/utils/updateTableLimit.jsx +22 -0
  56. package/dist/components/DateTime/index.js +44 -0
  57. package/dist/components/DateTime/timeToString.js +88 -0
  58. package/dist/components/DateTime/useDateFNSLocale.js +48 -0
  59. package/dist/components/FullscreenButton.js +35 -0
  60. package/dist/components/FullscreenButton.jsx +26 -0
  61. package/dist/components/Humanize/humanizeToString.js +99 -0
  62. package/dist/components/Humanize/index.js +32 -0
  63. package/dist/components/ResultCard/ResultCard.js +24 -0
  64. package/dist/components/ResultCard/ResultCard.scss +9 -0
  65. package/dist/components/Spinner.js +25 -0
  66. package/dist/components/TreeMenu/TreeMenu.js +78 -0
  67. package/dist/components/TreeMenu/TreeMenu.jsx +63 -0
  68. package/dist/components/TreeMenu/TreeMenu.scss +32 -0
  69. package/dist/components/TreeMenu/TreeMenuCard.js +189 -0
  70. package/dist/components/TreeMenu/TreeMenuItem.js +135 -0
  71. package/dist/components/TreeMenu/index.js +41 -0
  72. package/dist/components/TreeMenu/utils/flattenTree.js +54 -0
  73. package/dist/components/TreeMenu/utils/flattenTree.jsx +44 -0
  74. package/dist/components/TreeMenu/utils/formatIntoLeafFolderTree.js +56 -0
  75. package/dist/components/TreeMenu/utils/formatIntoTree.js +67 -0
  76. package/dist/components/TreeMenu/utils/removeTreeContent.js +97 -0
  77. package/dist/components/UncontrolledSwitch/index.js +60 -0
  78. package/dist/index.js +372 -0
  79. package/dist/styles/components/alert.scss +53 -0
  80. package/dist/styles/components/button.scss +104 -0
  81. package/dist/styles/components/card.scss +174 -0
  82. package/dist/styles/components/form.scss +20 -0
  83. package/dist/styles/components/html.scss +16 -0
  84. package/dist/styles/constants/colors.scss +66 -0
  85. package/dist/styles/constants/index.scss +70 -0
  86. package/dist/styles/constants/theme-dark.scss +55 -0
  87. package/dist/styles/constants/theme-light.scss +46 -0
  88. package/dist/styles/constants/theme-print.scss +198 -0
  89. package/dist/styles/index.scss +15 -0
  90. package/dist/utils/ErrorHandler.js +27 -0
  91. package/dist/utils/deepMerge.js +47 -0
  92. package/dist/utils/deepMerge.jsx +33 -0
  93. package/dist/utils/hexToString.js +27 -0
  94. package/dist/utils/isPrivateIP.js +37 -0
  95. package/dist/utils/isValidIP.js +82 -0
  96. package/dist/utils/itemExtensionHandler.js +24 -0
  97. package/dist/utils/localStorage.js +65 -0
  98. package/dist/utils/lookups/isoCodeCountries.js +264 -0
  99. package/dist/utils/monaco/problemMarkers.js +78 -0
  100. package/dist/utils/monaco/problemMarkers.jsx +57 -0
  101. package/dist/utils/removeFileExtension.js +26 -0
  102. package/dist/utils/validateAccess.js +143 -0
  103. package/package.json +43 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,295 @@
1
+ # CHANGELOG for ASAB WebUI Components
2
+
3
+ ## v24.47
4
+
5
+ ### Releases
6
+
7
+ - v24.47-alpha31
8
+ - v24.47-alpha30
9
+ - v24.47-alpha21
10
+ - v24.47-alpha17
11
+ - v24.47-alpha16
12
+ - v24.47-alpha10
13
+ - v24.47-alpha9
14
+ - v24.47-alpha8
15
+ - v24.47-alpha3
16
+
17
+ ### Refactor
18
+
19
+ - Make message rendering in `problemMarkers` more performant (!493, INDIGO Sprint 241220, v24.47-alpha31)
20
+ - Add fallback on undefined endColumn of problem markers (!471, INDIGO Sprint 241122, v24.47-alpha17)
21
+ - Add possiblity for additional styling by adding a custom class to `CellContentLoader` (!441, INDIGO Sprint 241108, v24.47-alpha8)
22
+
23
+ ### Features
24
+
25
+ - Update default Generic renderer to have a fallback on values which are objects (!475, INDIGO Sprint 241122, v24.47-alpha21)
26
+ - Create reusable `problemMarkers` monaco editor util which returns the list of the problem markers (!467, INDIGO Sprint 241122, v24.47-alpha16)
27
+ - Create `FullscreenButton` that can be added to components to trigger fullscreen mode (!444, INDIGO Sprint 241108, v24.47-alpha9)
28
+ - Modify datatable's advanced filtering, so that title in Dropdown and Badges are aligned and readable for the user (!426, INDIGO Sprint 241108, v24.47-alpha3)
29
+
30
+
31
+ ### Bugfix
32
+
33
+ - Fix on incorrect condition in problem markers util when rendering the end column value (!492, INDIGO Sprint 241220, v24.47-alpha30)
34
+ - Update `@import` to `@use` to eliminate sass-related warning (!443, INDIGO Sprint 241122, v24.47-alpha10)
35
+
36
+ ## v24.43
37
+
38
+ ### Releases
39
+
40
+ - v24.43-alpha7
41
+ - v24.43-alpha4
42
+ - v24.43-alpha1
43
+
44
+ ### Breaking changes
45
+
46
+ - ASAB Config WebUI `v24.43-alpha1` and higher requires LM.io Common Library `v24.40-alpha3` or higher
47
+
48
+ ### Refactor
49
+
50
+ - Refactor Input select of Configuration to be compatible with new schema for default values and selection dropdown values (the selection dropdown values should be added into `enum` part of the schema) (!428, INDIGO Sprint 241004, v24.43-alpha1)
51
+
52
+ ### Features
53
+
54
+ - Add styling for fullscreen card mode (!439, INDIGO Sprint 241030, v24.43-alpha7)
55
+
56
+ ### Bugfix
57
+
58
+ - Refactor `isValidIP` to a function that manually checks the structure of IP addresses instead of using regex expression (!436, INDIGO Sprint 241004, v24.43-alpha4)
59
+
60
+ ## v24.38
61
+
62
+ ### Releases
63
+
64
+ - v24.38-alpha22
65
+ - v24.38-alpha21
66
+ - v24.38-alpha18
67
+ - v24.38-alpha10
68
+ - v24.38-alpha3
69
+ - v24.38-alpha2
70
+
71
+ ### Refactor
72
+
73
+ - Rename `TerminalCard` component to `ConsoleCard` (!430, INDIGO Sprint 241004, v24.38-alpha21)
74
+
75
+ ### Features
76
+
77
+ - Implemented `rowStyle` prop for DataTable2, add info to documentation about new prop (!407, INDIGO Sprint 241004, v24.38-alpha18)
78
+ - Add function `isValidIP` that checks if a given IP address is valid (!403, INDIGO Sprint 240913, v24.38-alpha10)
79
+ - Add Tree menu documentation. Renamed `flatTree` => `flatten` (!406, INDIGO Sprint 240913, v24.38-alpha3)
80
+ - Implement Attention required badge (!390, INDIGO Sprint 240913, v24.38-alpha2)
81
+
82
+ ### Refactor
83
+
84
+ - Update Credentials component, display userName without SeaCatAdminFederationModule (!423, INDIGO Sprint 241004, v24.38-alpha22)
85
+ - Updated `formatIntoTree` function, added sorting nodes (!424, INDIGO Sprint 241004, v24.38-alpha20)
86
+
87
+ ## v24.34
88
+
89
+ ### Releases
90
+
91
+ - v24.34-alpha14
92
+ - v24.34-alpha9
93
+ - v24.34-alpha3
94
+ - v24.34-alpha2
95
+
96
+ ### Feature
97
+
98
+ - Add Tree menu util removeTreeContent that hides folders and files specified in it and new formated data functions `formatIntoTree` and `formatIntoLeafTree` (!392, INDIGO Sprint 240830, v24.34-alpha9)
99
+ - Add Tree menu util and prop which will flatten the Tree menu structure (!358, INDIGO Sprint 240816, v24.34-alpha2)
100
+
101
+ ### Refactor
102
+
103
+ - Change background and font color of the `TerminalCard` (!401, INDIGO Sprint 240913, v24.34-alpha14)
104
+ - Change font color of info alert, button and badge in dark mode to make it more visible (!380, INDIGO Sprint 240802, v24.34-alpha3)
105
+
106
+ ## v24.28
107
+
108
+ ## Releases
109
+
110
+ - v24.28-alpha29
111
+ - v24.28-alpha28
112
+ - v24.28-alpha23
113
+ - v24.28-alpha16
114
+ - v24.28-alpha11
115
+ - v24.28-alpha10
116
+ - v24.28-alpha8
117
+ - v24.28-alpha1
118
+
119
+ ### Refactor
120
+
121
+ - Prevent wrapping of timestamp onto a new line in `DateTime` component (!349, INDIGO Sprint 240621, v24.28-alpha1)
122
+
123
+ ### Features
124
+
125
+ - Add list of country ISO codes with their corresponding full names (!351, INDIGO Sprint 240719, v24.28-alpha29)
126
+ - Implement `removeFileExtension` component for removing extension (!374, INDIGO Sprint 240802, v24.28-alpha28)
127
+ - Implement saving of open nodes in TreeMenu to sessionStorage (!337, INDIGO Sprint 240719, v24.28-alpha23)
128
+ - Add function `isPrivateIP` that checks if a given IP address is private (!350, INDIGO Sprint 240621, v24.28-alpha11)
129
+ - Implement `TerminalCard` component (!276, INDIGO Sprint 240621, v24.28-alpha10)
130
+ - Implement option to specify `disableParams` property to use state to store parameters of DataTable2 instead of usage of searchParams. (!338, INDIGO Sprint 240621, v24.28-alpha8)
131
+ - Implement deepMerge util component. (!338, INDIGO Sprint 240621, v24.28-alpha8)
132
+
133
+ ### Bugfix
134
+
135
+ - Fix deprecation warning in stylesheet regarding nested rules (!366, INDIGO Sprint 240719, v24.28-alpha16)
136
+
137
+ ## v24.19
138
+
139
+ ### Releases
140
+
141
+ - v24.19-alpha29
142
+ - v24.19-alpha28
143
+ - v24.19-alpha22
144
+ - v24.19-alpha18
145
+ - v24.19-alpha12
146
+ - v24.19-alpha10
147
+ - v24.19-alpha8
148
+
149
+ ### Features
150
+
151
+ - Add `hexToString` function that convertes a hexadecimal string into its corresponding ASCII string (!334, INDIGO Sprint 240607, v24.19-alpha29)
152
+ - Set width of the columns based on the content in the DataTable2 (!249, INDIGO Sprint 240607, v24.19-alpha22)
153
+ - Implement `itemExtensionHandler` function (!253, INDIGO Sprint 240607, v24.19-alpha18)
154
+ - Implement `isResourceValid` function. Create utils folder and replace `authz.js`, updated paths for import `authz.js` (!302, INDIGO Sprint 240527, v24.19-alpha8)
155
+
156
+ ### Refactor
157
+
158
+ - Updated pagination callback in `DataTable2` if no count comes. (!330, INDIGO Sprint 240621, v24.19-alpha28)
159
+ - Rename `ErrorMessageHandler` to `ErrorHandler` (!299, INDIGO Sprint 240527, v24.19-alpha12)
160
+ - Rename `isResourceValid` to `isAuthorized` (!317, INDIGO Sprint 240527, v24.19-alpha10)
161
+
162
+ ## v24.08
163
+
164
+ - v24.08-alpha46
165
+ - v24.08-alpha45
166
+ - v24.08-alpha40
167
+ - v24.08-alpha35
168
+ - v24.08-alpha32
169
+ - v24.08-alpha22
170
+ - v24.08-alpha19
171
+ - v24.08-alpha15
172
+ - v24.08-alpha11
173
+ - v24.08-alpha10
174
+ - v24.08-alpha9
175
+ - v24.08-alpha1
176
+
177
+ ### Features
178
+
179
+ - Add application object into the Renderer constructor (!287, INDIGO Sprint 240430, v24.08-alpha45)
180
+ - Implement PubSub messaging, create package.json file to share PubSub messages and functions accross applications (!244, INDIGO Sprint 240411, v24.08-alpha40)
181
+ - Implement print styles for DataTable2 (!245, INDIGO Sprint 240411, v24.08-alpha35)
182
+ - Implement AdvancedCard component (!238, INDIGO Sprint 240315, v24.08-alpha19)
183
+
184
+ ### Refactor
185
+
186
+ - Change card header color to text color so it does not resemble a clickable link (!284, INDIGO Sprint 240430, v24.08-alpha46)
187
+ - Move local styling of the monaco hover from `asab_library_webui` and `lmio_parser_builder_webui` to `asab_webui_components` (!257, INDIGO Sprint 240402, v24.08-alpha32)
188
+ - ErrorMessageHandler moved to asab-component-webui from bs-query-webui (!231, INDIGO Sprint 240315, v24.08-alpha22)
189
+ - Move the access validation with `validateAccess` to be imported from ASAB WebUI instead of handling it locally (!228, INDIGO Sprint 240301, v24.08-alpha15)
190
+ - Change height of ResultCard and remove top margin to prevent scrolling (!122, INDIGO Sprint 240216, v24.08-alpha10)
191
+ - Unify `parseInt` in the DataTable2. Create `parseParam` function. Overflow-x style correction for the DataTableCard2 (!225, INDIGO Sprint 240301, v24.08-alpha9)
192
+ - The obsolete TreeMenu has been completely replaced by the new TreeMenu. TreeMenu2 is renamed to TreeMenu and the old code is removed. Add ability to add custom FolderIcon and FileIcon (!117, INDIGO Sprint 240216, v24.08-alpha1)
193
+
194
+ ### Bugfix
195
+
196
+ - Remove button border of outline buttons in dropdowns (!227, INDIGO Sprint 240301, v24.08-alpha11)
197
+
198
+ ## v24.03
199
+
200
+ ### Releases
201
+
202
+ - v24.03-alpha17
203
+ - v24.03-alpha13
204
+ - v24.03-alpha3
205
+
206
+ ### Features
207
+
208
+ - Update DataTable with alternative approach of retreiving data from loader method using setRows and setCount hooks (!181, INDIGO Sprint 240119, v24.03-alpha17)
209
+
210
+ ### Refactor
211
+
212
+ - Refactor error message to avoid duplication (!199, INDIGO Sprint 240105, v24.03-alpha16)
213
+ - Refactor Humanize component - change naming to "Invalid value", correct validation of value, add non-breaking space before unit (!184, INDIGO Sprint 240119, v24.03-alpha13)
214
+ - Refactor reusable ResultCard so that the redirection will take the user to the present screen (!163, INDIGO Sprint 240105, v24.03-alpha3)
215
+
216
+ ## v23.48
217
+
218
+ ### Releases
219
+
220
+ - v23.48-alpha36
221
+ - v23.48-alpha35
222
+ - v23.48-alpha34
223
+ - v23.48-alpha29
224
+ - v23.48-alpha24
225
+ - v23.48-alpha20
226
+ - v23.48-alpha15
227
+ - v23.48-alpha14
228
+ - v23.48-alpha10
229
+ - v23.48-alpha9
230
+ - v23.48-alpha5
231
+
232
+ ### Features
233
+
234
+ - Implement TreeMenuCard component (!169, INDIGO Sprint 240105, v23.48-alpha34)
235
+ - Add new prop `reload` for updating data in the DataTable2 (!156, INDIGO Sprint 240105, v23.48-alpha29)
236
+ - Implement route replace on DataTable initialization to avoid removal of search parameters when navigating back in browser's history to initial state (!157, INDIGO Sprint 231208, v23.48-alpha20)
237
+ - Implement advanced filtering to DataTable2, refactor serialization of the search parameters in the browser and in REST API request (!96, INDIGO Sprint 231124, v23.48-alpha15)
238
+ - Create resusable ResultCard, to give user information about successful/unsuccessful change (!147, INDIGO Sprint 231124, v23.48-alpha14)
239
+ - Implement option to specify own datetime format in DateTime component (!142, INDIGO Sprint 231124, v23.48-alpha5)
240
+
241
+ ### Refactor
242
+
243
+ - Remove demo part (!126, INDIGO Sprint 231124, v23.48-alpha10)
244
+
245
+ - Refactor x-icons for deleting to trash-icons (!133, INDIGO Sprint 231110, v23.48-alpha9)
246
+
247
+ - Refactor Humanize component to import a new component which will return value as a string (!171, INDIGO Sprint 240105, v23.48-alpha35)
248
+
249
+ ### Bugfix
250
+
251
+ - Implement fallback when URL limit parameter is missing/invalid in DataTable2 (!179, INDIGO Sprint 240105, v23.48-alpha36)
252
+ - Add missing name attribut to inputs (!162, INDIGO Sprint 231208, v23.48-alpha24)
253
+
254
+ ## v23.45
255
+
256
+ ### Releases
257
+
258
+ - v23.45-alpha5
259
+ - v23.45-alpha1
260
+
261
+ ### Breaking changes
262
+
263
+ - After migration from react-router-dom v5 to react-router-dom v6, some of the routing components are not being supported. For more info, please see https://reactrouter.com/en/main/upgrading/v5
264
+
265
+ ### Features
266
+
267
+ - Implement addAlertFromException method to render additional information from exceptions in Alert message (!106, INDIGO Sprint 231110, v23.45-alpha6)
268
+ - Migrate react-router-dom from v5 to v6 (!98, INDIGO Sprint 231027, v23.45-alpha1)
269
+
270
+ ### Refactor
271
+
272
+ - Refactor implementation of bootstrap placeholder and change of its background color (!127, INDIGO Sprint 231110, v23.45-alpha5)
273
+
274
+ ## v23.44
275
+
276
+ ### Releases
277
+
278
+ - v23.44-alpha11
279
+ - v23.44-alpha9
280
+ - v23.44-alpha8
281
+ - v23.44-alpha7
282
+ - v23.44-alpha6
283
+ - v23.44-alpha3
284
+
285
+ ### Refactoring
286
+
287
+ - Refactor ContentLoader to prevent from having negative values in viewBox (!97, INDIGO Sprint 231027, v23.44-alpha3)
288
+
289
+ - Change color of primary button :active state (!113, INDIGO Sprint 231027, v23.44-alpha6)
290
+
291
+ - Refactor disabled button pointer events to show title (!118, INDIGO Sprint 231027, v23.44-alpha7)
292
+
293
+ - Refactor react-content-loader to Bootstrap placeholder (!121, INDIGO Sprint 231027, v23.44-alpha8)
294
+
295
+ - Refactor theme-print styles (!55, INDIGO Sprint 231027, v23.44-alpha9, v23.44-alpha11)
package/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2025, TeskaLabs
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Asab WebUI Components Library
2
+
3
+ Components library of ASAB used in WebUI projects.
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.Module = void 0;
8
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var Module = exports.Module = /*#__PURE__*/function () {
11
+ function Module(app, name) {
12
+ (0, _classCallCheck2["default"])(this, Module);
13
+ this.App = app;
14
+ this.Name = name;
15
+ }
16
+ return (0, _createClass2["default"])(Module, [{
17
+ key: "initialize",
18
+ value: function initialize() {}
19
+ }]);
20
+ }();
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof3 = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.Renderer = void 0;
9
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
15
+ var _react = _interopRequireWildcard(require("react"));
16
+ var _reactJsonView = _interopRequireDefault(require("react-json-view"));
17
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
18
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
19
+ function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
20
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
21
+ var Renderer = exports.Renderer = /*#__PURE__*/function (_Component) {
22
+ // Renderer defaults
23
+ function Renderer(app) {
24
+ var _this;
25
+ (0, _classCallCheck2["default"])(this, Renderer);
26
+ _this = _callSuper(this, Renderer); // Call super() for React component initialization
27
+ _this.App = app;
28
+ return _this;
29
+ }
30
+ (0, _inherits2["default"])(Renderer, _Component);
31
+ return (0, _createClass2["default"])(Renderer, [{
32
+ key: "render",
33
+ value: function render(key, value, schemaField) {
34
+ // Render ReactJson component if value is a object
35
+ if ((0, _typeof2["default"])(value) === 'object') {
36
+ var theme = this.App.Store.getState().theme;
37
+ return /*#__PURE__*/_react["default"].createElement(_reactJsonView["default"], {
38
+ src: value,
39
+ name: false,
40
+ collapsed: false,
41
+ displayDataTypes: false,
42
+ displayArrayKey: false,
43
+ quotesOnKeys: false,
44
+ enableClipboard: false,
45
+ indentWidth: 8,
46
+ theme: theme === 'dark' ? "chalk" : "rjv-default"
47
+ });
48
+ }
49
+ // Render span with value inside as a default
50
+ return /*#__PURE__*/_react["default"].createElement("span", null, value);
51
+ }
52
+ }, {
53
+ key: "plain",
54
+ value: function plain(key, value, schemaField) {
55
+ // Render stringified component if value is a object
56
+ if ((0, _typeof2["default"])(value) === 'object') {
57
+ try {
58
+ return JSON.stringify(value);
59
+ } catch (e) {
60
+ console.warn('Failed to stringify the renderer value:', value, e);
61
+ return value;
62
+ }
63
+ }
64
+ return value;
65
+ }
66
+ }]);
67
+ }(_react.Component);
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.Service = void 0;
8
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var Service = exports.Service = /*#__PURE__*/function () {
11
+ function Service(app, serviceName) {
12
+ (0, _classCallCheck2["default"])(this, Service);
13
+ this.Name = serviceName;
14
+ this.App = app;
15
+ app.registerService(this);
16
+ }
17
+ return (0, _createClass2["default"])(Service, [{
18
+ key: "initialize",
19
+ value: function initialize() {
20
+ // Override this method in your service
21
+ // At this point it is ensured, that Redux Store exists at App.Store
22
+ }
23
+ }]);
24
+ }();
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.AdvancedCard = AdvancedCard;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _reactRedux = require("react-redux");
10
+ var _reactJsonView = _interopRequireDefault(require("react-json-view"));
11
+ var _reactstrap = require("reactstrap");
12
+ // This is a card that displays data on the page in JSON format after hotkeys are pressed `ctrl + shift + 1`
13
+ function AdvancedCard(_ref) {
14
+ var data = _ref.data,
15
+ _ref$cardClassname = _ref.cardClassname,
16
+ cardClassname = _ref$cardClassname === void 0 ? '' : _ref$cardClassname;
17
+ var theme = (0, _reactRedux.useSelector)(function (state) {
18
+ return state.theme;
19
+ });
20
+ var advmode = (0, _reactRedux.useSelector)(function (state) {
21
+ var _state$advmode;
22
+ return (_state$advmode = state.advmode) === null || _state$advmode === void 0 ? void 0 : _state$advmode.enabled;
23
+ });
24
+ return advmode ? /*#__PURE__*/_react["default"].createElement(_reactstrap.Card, {
25
+ className: "".concat(cardClassname)
26
+ }, /*#__PURE__*/_react["default"].createElement(_reactstrap.CardHeader, {
27
+ className: "card-header-flex"
28
+ }, /*#__PURE__*/_react["default"].createElement("div", {
29
+ className: "flex-fill"
30
+ }, /*#__PURE__*/_react["default"].createElement("h3", null, /*#__PURE__*/_react["default"].createElement("i", {
31
+ className: "bi bi-code-slash pe-2"
32
+ }), "JSON"))), /*#__PURE__*/_react["default"].createElement(_reactstrap.CardBody, null, /*#__PURE__*/_react["default"].createElement(_reactJsonView["default"], {
33
+ src: data,
34
+ theme: theme === 'dark' ? 'chalk' : 'rjv-default',
35
+ name: false,
36
+ collapsed: false
37
+ }))) : null;
38
+ }
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { useSelector } from 'react-redux';
3
+ import ReactJson from 'react-json-view';
4
+ import { Card, CardHeader, CardBody } from 'reactstrap';
5
+
6
+ // This is a card that displays data on the page in JSON format after hotkeys are pressed `ctrl + shift + 1`
7
+ export function AdvancedCard ({ data, cardClassname='' }) {
8
+ const theme = useSelector(state => state.theme);
9
+ const advmode = useSelector(state => state.advmode?.enabled);
10
+
11
+ return (
12
+ advmode ?
13
+ <Card className={`${cardClassname}`}>
14
+ <CardHeader className='card-header-flex'>
15
+ <div className='flex-fill'>
16
+ <h3>
17
+ <i className='bi bi-code-slash pe-2' />
18
+ JSON
19
+ </h3>
20
+ </div>
21
+ </CardHeader>
22
+ <CardBody>
23
+ <ReactJson
24
+ src={data}
25
+ theme={(theme === 'dark') ? 'chalk' : 'rjv-default'}
26
+ name={false}
27
+ collapsed={false}
28
+ />
29
+ </CardBody>
30
+ </Card>
31
+ :
32
+ null
33
+ )
34
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.AttentionBadge = AttentionBadge;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
+ var _react = _interopRequireDefault(require("react"));
11
+ var _reactstrap = require("reactstrap");
12
+ var _excluded = ["content"];
13
+ // Component for Attention badge rendereing
14
+ function AttentionBadge(_ref) {
15
+ var content = _ref.content,
16
+ props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
17
+ var level = (content === null || content === void 0 ? void 0 : content.level) || 'danger';
18
+ return /*#__PURE__*/_react["default"].createElement(_reactstrap.Badge, (0, _extends2["default"])({
19
+ className: "attention-required-badge",
20
+ color: level
21
+ }, props), content === null || content === void 0 ? void 0 : content.count);
22
+ }
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { Badge } from 'reactstrap';
3
+
4
+ // Component for Attention badge rendereing
5
+ export function AttentionBadge({ content, ...props }) {
6
+ const level = content?.level || 'danger';
7
+
8
+ return(
9
+ <Badge
10
+ className='attention-required-badge'
11
+ color={level}
12
+ {...props} // Spread the additional props like onClick, etc.
13
+ >
14
+ {content?.count}
15
+ </Badge>
16
+ )
17
+ }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ButtonWithAuthz = ButtonWithAuthz;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+ var _react = _interopRequireWildcard(require("react"));
12
+ var _reactstrap = require("reactstrap");
13
+ var _authz = require("./utils/authz");
14
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
15
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
16
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
+ 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) { (0, _defineProperty2["default"])(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; }
18
+ /*
19
+ ButtonWithAutz component emulates the functionality of reactstrap <Button/> component
20
+ and extend it by disable feature based on resources.
21
+
22
+ * resource
23
+ * the resource to distinguish access rights, e.g. yourproduct:yourcomponent:write
24
+
25
+ * resources
26
+ * the list of resources from the userinfo
27
+
28
+ * hideOnUnauthorizedAccess
29
+ * the option to hide the button completely instead of disabling it, default is false
30
+
31
+ * Language localisations for generic `unauthorized message` can be added to the translation.json files of
32
+ public/locales/en & public/locales/cs of the product where component ButtonWithAuthz is used. The default
33
+ message is `You do not have rights` and it can be re-set in locales as e.g.
34
+
35
+ {
36
+ "You do not have access rights to perform this action": "You do not have access rights to perform this action"
37
+ }
38
+
39
+ ---
40
+
41
+ Example:
42
+
43
+ import { ButtonWithAuthz } from 'asab_webui_components';
44
+ import { useSelector } from 'react-redux';
45
+
46
+ ...
47
+
48
+ const resources = useSelector(state => state.auth?.resources);
49
+
50
+ ...
51
+
52
+ return(
53
+ ...
54
+ <ButtonWithAuthz
55
+ title={t('MyApp|Delete')}
56
+ color="danger"
57
+ size="sm"
58
+ onClick={() => { deleteApp() }}
59
+ resource="myapp:mylist:write"
60
+ resources={resources}
61
+ hideOnUnauthorizedAccess={true}
62
+ >
63
+ <span className="bi bi-code-slash pe-2" />
64
+ {t('MyApp|Delete')}
65
+ </ButtonWithAuthz>
66
+ ...
67
+ )
68
+
69
+ */
70
+
71
+ function ButtonWithAuthz(props) {
72
+ var childProps = _objectSpread({}, props); // Create a new child component to have option to remove props
73
+ var authzObj = (0, _authz.authz)(childProps);
74
+ var disabled = authzObj.disabled;
75
+ var hide = authzObj.hide;
76
+ var title = authzObj.title;
77
+ return hide && disabled ? null : /*#__PURE__*/_react["default"].createElement(_reactstrap.Button, (0, _extends2["default"])({}, childProps, {
78
+ title: title,
79
+ disabled: disabled
80
+ }), childProps.children);
81
+ }