@pareto-engineering/design-system 4.0.0-alpha.70 → 4.0.0-alpha.72

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 (125) hide show
  1. package/dist/cjs/{c/ContentSlides/common/Slide/Slide.js → a/LexicalPreview/LexicalPreview.js} +43 -28
  2. package/dist/cjs/{c/ContentSlides/common/Sidebar → a/LexicalPreview}/index.js +3 -3
  3. package/dist/cjs/a/LexicalPreview/styles.scss +46 -0
  4. package/dist/cjs/a/People/common/Person/Person.js +7 -2
  5. package/dist/cjs/a/ProgressBar/ProgressBar.js +3 -2
  6. package/dist/cjs/a/ProgressBar/styles.scss +11 -1
  7. package/dist/cjs/a/XMLEditor/XMLEditor.js +14 -6
  8. package/dist/cjs/a/index.js +8 -1
  9. package/dist/cjs/b/ExpandableLexicalPreview/ExpandableLexicalPreview.js +125 -0
  10. package/dist/cjs/b/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.js +112 -0
  11. package/dist/cjs/{c/ContentSlides/common/Navigator → b/ExpandableLexicalPreview/common/ExpandButton}/index.js +3 -3
  12. package/dist/cjs/b/ExpandableLexicalPreview/common/index.js +12 -0
  13. package/dist/cjs/b/ExpandableLexicalPreview/index.js +13 -0
  14. package/dist/cjs/b/ExpandableLexicalPreview/styles.scss +84 -0
  15. package/dist/cjs/b/index.js +8 -1
  16. package/dist/cjs/c/index.js +0 -13
  17. package/dist/cjs/f/fields/EditorInput/EditorInput.js +14 -3
  18. package/dist/cjs/f/fields/EditorInput/common/StopPropagationPlugin.js +30 -0
  19. package/dist/cjs/f/fields/EditorInput/common/index.js +7 -0
  20. package/dist/cjs/index.js +0 -11
  21. package/dist/es/a/LexicalPreview/LexicalPreview.js +80 -0
  22. package/dist/es/a/LexicalPreview/index.js +2 -0
  23. package/dist/es/a/LexicalPreview/styles.scss +46 -0
  24. package/dist/es/a/People/common/Person/Person.js +22 -15
  25. package/dist/es/a/ProgressBar/ProgressBar.js +3 -2
  26. package/dist/es/a/ProgressBar/styles.scss +11 -1
  27. package/dist/es/a/XMLEditor/XMLEditor.js +16 -10
  28. package/dist/es/a/index.js +2 -1
  29. package/dist/es/b/ExpandableLexicalPreview/ExpandableLexicalPreview.js +115 -0
  30. package/dist/es/b/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.js +102 -0
  31. package/dist/es/b/ExpandableLexicalPreview/common/ExpandButton/index.js +1 -0
  32. package/dist/es/b/ExpandableLexicalPreview/common/index.js +1 -0
  33. package/dist/es/b/ExpandableLexicalPreview/index.js +2 -0
  34. package/dist/es/b/ExpandableLexicalPreview/styles.scss +84 -0
  35. package/dist/es/b/index.js +2 -1
  36. package/dist/es/c/index.js +0 -1
  37. package/dist/es/f/fields/EditorInput/EditorInput.js +15 -4
  38. package/dist/es/f/fields/EditorInput/common/StopPropagationPlugin.js +23 -0
  39. package/dist/es/f/fields/EditorInput/common/index.js +2 -1
  40. package/dist/es/index.js +0 -1
  41. package/package.json +5 -5
  42. package/src/stories/a/LexicalPreview.stories.jsx +28 -0
  43. package/src/stories/a/ProgressBar.stories.jsx +1 -1
  44. package/src/stories/b/ExpandableLexicalPreview.stories.jsx +29 -0
  45. package/src/stories/colors.js +4 -0
  46. package/src/ui/a/LexicalPreview/LexicalPreview.jsx +109 -0
  47. package/src/ui/a/LexicalPreview/index.js +2 -0
  48. package/src/ui/a/LexicalPreview/styles.scss +46 -0
  49. package/src/ui/a/People/common/Person/Person.jsx +31 -19
  50. package/src/ui/a/ProgressBar/ProgressBar.jsx +2 -0
  51. package/src/ui/a/ProgressBar/styles.scss +11 -1
  52. package/src/ui/a/XMLEditor/XMLEditor.jsx +16 -5
  53. package/src/ui/a/index.js +1 -0
  54. package/src/ui/b/ExpandableLexicalPreview/ExpandableLexicalPreview.jsx +157 -0
  55. package/src/ui/b/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.jsx +123 -0
  56. package/src/ui/b/ExpandableLexicalPreview/common/ExpandButton/index.js +1 -0
  57. package/src/ui/b/ExpandableLexicalPreview/common/index.js +1 -0
  58. package/src/ui/b/ExpandableLexicalPreview/index.js +2 -0
  59. package/src/ui/b/ExpandableLexicalPreview/styles.scss +84 -0
  60. package/src/ui/b/index.js +1 -0
  61. package/src/ui/c/index.js +0 -1
  62. package/src/ui/f/fields/EditorInput/EditorInput.jsx +16 -2
  63. package/src/ui/f/fields/EditorInput/common/StopPropagationPlugin.jsx +29 -0
  64. package/src/ui/f/fields/EditorInput/common/index.jsx +1 -0
  65. package/src/ui/index.js +0 -1
  66. package/tests/__snapshots__/Storyshots.test.js.snap +1249 -641
  67. package/dist/cjs/c/ContentSlides/ContentSlides.js +0 -172
  68. package/dist/cjs/c/ContentSlides/Context.js +0 -10
  69. package/dist/cjs/c/ContentSlides/common/HorizontalMenu/HorizontalMenu.js +0 -126
  70. package/dist/cjs/c/ContentSlides/common/HorizontalMenu/index.js +0 -13
  71. package/dist/cjs/c/ContentSlides/common/Navigator/Navigator.js +0 -128
  72. package/dist/cjs/c/ContentSlides/common/Sidebar/Sidebar.js +0 -94
  73. package/dist/cjs/c/ContentSlides/common/Slide/index.js +0 -13
  74. package/dist/cjs/c/ContentSlides/common/index.js +0 -33
  75. package/dist/cjs/c/ContentSlides/index.js +0 -27
  76. package/dist/cjs/c/ContentSlides/styles.scss +0 -312
  77. package/dist/cjs/c/ContentSlides/useContentSlides.js +0 -11
  78. package/dist/cjs/r/SwitchRouteMap/SwitchRouteMap.js +0 -58
  79. package/dist/cjs/r/SwitchRouteMap/index.js +0 -13
  80. package/dist/cjs/r/common/PrivateRoute/PrivateRoute.js +0 -74
  81. package/dist/cjs/r/common/PrivateRoute/index.js +0 -13
  82. package/dist/cjs/r/common/index.js +0 -12
  83. package/dist/cjs/r/index.js +0 -27
  84. package/dist/es/c/ContentSlides/ContentSlides.js +0 -160
  85. package/dist/es/c/ContentSlides/Context.js +0 -2
  86. package/dist/es/c/ContentSlides/common/HorizontalMenu/HorizontalMenu.js +0 -116
  87. package/dist/es/c/ContentSlides/common/HorizontalMenu/index.js +0 -2
  88. package/dist/es/c/ContentSlides/common/Navigator/Navigator.js +0 -118
  89. package/dist/es/c/ContentSlides/common/Navigator/index.js +0 -2
  90. package/dist/es/c/ContentSlides/common/Sidebar/Sidebar.js +0 -84
  91. package/dist/es/c/ContentSlides/common/Sidebar/index.js +0 -2
  92. package/dist/es/c/ContentSlides/common/Slide/Slide.js +0 -65
  93. package/dist/es/c/ContentSlides/common/Slide/index.js +0 -2
  94. package/dist/es/c/ContentSlides/common/index.js +0 -4
  95. package/dist/es/c/ContentSlides/index.js +0 -4
  96. package/dist/es/c/ContentSlides/styles.scss +0 -312
  97. package/dist/es/c/ContentSlides/useContentSlides.js +0 -3
  98. package/dist/es/r/SwitchRouteMap/SwitchRouteMap.js +0 -45
  99. package/dist/es/r/SwitchRouteMap/index.js +0 -2
  100. package/dist/es/r/common/PrivateRoute/PrivateRoute.js +0 -66
  101. package/dist/es/r/common/PrivateRoute/index.js +0 -2
  102. package/dist/es/r/common/index.js +0 -1
  103. package/dist/es/r/index.js +0 -2
  104. package/src/stories/c/ContentSlides.stories.jsx +0 -214
  105. package/src/ui/c/ContentSlides/ContentSlides.jsx +0 -214
  106. package/src/ui/c/ContentSlides/Context.js +0 -3
  107. package/src/ui/c/ContentSlides/common/HorizontalMenu/HorizontalMenu.jsx +0 -145
  108. package/src/ui/c/ContentSlides/common/HorizontalMenu/index.js +0 -2
  109. package/src/ui/c/ContentSlides/common/Navigator/Navigator.jsx +0 -150
  110. package/src/ui/c/ContentSlides/common/Navigator/index.js +0 -2
  111. package/src/ui/c/ContentSlides/common/Sidebar/Sidebar.jsx +0 -135
  112. package/src/ui/c/ContentSlides/common/Sidebar/index.js +0 -2
  113. package/src/ui/c/ContentSlides/common/Slide/Slide.jsx +0 -87
  114. package/src/ui/c/ContentSlides/common/Slide/index.js +0 -2
  115. package/src/ui/c/ContentSlides/common/index.js +0 -4
  116. package/src/ui/c/ContentSlides/index.js +0 -4
  117. package/src/ui/c/ContentSlides/styles.scss +0 -312
  118. package/src/ui/c/ContentSlides/useContentSlides.js +0 -4
  119. package/src/ui/r/SwitchRouteMap/SwitchRouteMap.jsx +0 -64
  120. package/src/ui/r/SwitchRouteMap/index.js +0 -2
  121. package/src/ui/r/common/PrivateRoute/PrivateRoute.jsx +0 -73
  122. package/src/ui/r/common/PrivateRoute/index.js +0 -2
  123. package/src/ui/r/common/index.js +0 -1
  124. package/src/ui/r/index.js +0 -2
  125. /package/src/stories/a/{CodeEditor.stories.jsx → XMLEditor.stories.jsx} +0 -0
@@ -1,312 +0,0 @@
1
- /* @pareto-engineering/generator-front 1.0.12 */
2
- /* stylelint-disable selector-max-compound-selectors -- Required here */
3
- /* stylelint-disable max-nesting-depth -- Required here */
4
-
5
- @use "@pareto-engineering/bem";
6
- @use "@pareto-engineering/styles/src/mixins";
7
- @use "@pareto-engineering/styles/src/globals" as *;
8
-
9
- $class-sidebar:sidebar;
10
- $class-horizontal-menu:horizontal-menu;
11
- $class-slide:slide;
12
- $class-navigator:navigator;
13
-
14
- //$class-main-container:main;
15
-
16
- $default-sidebar-width:minmax(250px, 330px);
17
- $default-border:none;//2px solid var(--grid);
18
- $default-border-radius:var(--theme-border-radius);
19
- $default-content-background: var(--background-far);
20
- $default-padding:var(--theme-default-padding);
21
-
22
- $mobile-content-margin:6em;
23
-
24
- .#{bem.$base}.content-slides {
25
- height: 100%;
26
-
27
- .#{$class-sidebar} {
28
- background: $default-content-background;
29
- border-right: $default-border;
30
- display: flex;
31
- flex-direction: column;
32
- height: 100%;
33
- justify-content: space-between;
34
- overflow: auto;
35
-
36
- header,
37
- .#{bem.$element-content},
38
- footer {
39
- padding: $default-padding;
40
- }
41
-
42
- header {
43
- border-bottom: $default-border;
44
- }
45
-
46
- footer {
47
- border-top: $default-border;
48
- }
49
-
50
- .#{bem.$element-content} {
51
- .icon-list {
52
- .#{bem.$element-item} {
53
- &:not(:last-child) {
54
- margin-bottom: 1em;
55
- }
56
- }
57
- }
58
- }
59
- }
60
-
61
-
62
- //.#{$class-main-container} {
63
- main {
64
- overflow: hidden;
65
- position: relative;
66
-
67
- .#{$class-slide} {
68
- height: 100%;
69
- left: 0;
70
- position: absolute;
71
- right: 0;
72
- top: 0;
73
- transition: opacity .3s;
74
-
75
- .wrapper {
76
- padding: var(--u);
77
-
78
- .#{bem.$element-content} {
79
- background: $default-content-background;
80
-
81
- border: var(--theme-border);
82
- border-radius: $default-border-radius;
83
- max-width: 600px;
84
- padding: $default-padding;
85
- position: relative;
86
- width: 90%;
87
- //z-index: 1;
88
-
89
- .#{$class-navigator} {
90
- display: flex;
91
- margin-top: $default-padding;
92
- }
93
- }
94
- }
95
-
96
-
97
- &:not(.#{bem.$modifier-active}) {
98
- opacity: .5;
99
- z-index: -1;
100
- }
101
-
102
- &.#{bem.$modifier-active} {
103
- opacity: 1;
104
- }
105
- }
106
- }
107
-
108
- .#{$class-horizontal-menu} {
109
- background: $default-content-background;
110
- border-bottom: var(--theme-border);
111
- color: var(--heading);
112
- z-index: 1;
113
-
114
- .#{bem.$element-content} {
115
- display: grid;
116
- grid-template-columns: 1fr [title] 6fr 1fr;
117
- padding: $default-padding;
118
-
119
- .title {
120
- grid-column: title/span 1;
121
- text-align: center;
122
- //font-weight:600;
123
- }
124
-
125
- .left {
126
- text-align: left;
127
-
128
- .prev-button {
129
- font-family: var(--theme-default-paragraph);
130
- font-size: calc(var(--s2) * 1em);
131
- }
132
- }
133
-
134
- .right {
135
- text-align: right;
136
- }
137
- }
138
- //
139
- }
140
-
141
- @include mixins.media($to:$sm-md) {
142
- display: flex;
143
- flex-direction: column;
144
-
145
- .#{$class-sidebar} {
146
- display: none;
147
- }
148
-
149
- //.#{$class-main-container} {
150
-
151
- main {
152
- flex-grow: 1;
153
-
154
- .#{$class-slide} {
155
- display: flex;
156
- flex-direction: column;
157
- justify-content: safe center;
158
- overflow: auto;
159
-
160
- /*
161
- > img {
162
- height: 100%;
163
- object-fit: cover;
164
- position: absolute;
165
- top: 0;
166
- transition: opacity .3s;
167
- width: 100%;
168
- } */
169
-
170
- /* stylelint-disable scss/media-feature-value-dollar-variable -- For orientation mq */
171
- .wrapper {
172
- display: flex;
173
- flex-direction: column;
174
- height: 100%;
175
- //justify-content: safe center;
176
- overflow: auto;
177
-
178
- -ms-overflow-style: none;
179
- padding-bottom: 0;
180
- padding-top: 0;
181
- //padding-bottom: $mobile-content-margin;
182
- //padding-top: $mobile-content-margin;
183
- scrollbar-width: none;
184
-
185
- &::-webkit-scrollbar {
186
- display: none;
187
- }
188
-
189
- &::after,
190
- &::before {
191
- //background: red;
192
- content: " ";
193
- flex-grow: 1;
194
- white-space: pre;
195
- //z-index: 20;
196
- @media (orientation: portrait) {
197
- min-height: calc(#{$mobile-content-margin} + var(--u));
198
- }
199
- }
200
- @media (orientation: landscape) {
201
- &::before {
202
- min-height: var(--u);
203
- }
204
- }
205
-
206
- .#{bem.$element-content} {
207
- margin: 0 auto;
208
-
209
- .#{$class-navigator} {
210
- .prev {
211
- display: none;
212
- }
213
-
214
- .next {
215
- flex-grow: 1;
216
- justify-content: flex-end;
217
- }
218
- }
219
- }
220
- }
221
- /* stylelint-enable */
222
-
223
- /*
224
- &:not(.#{bem.$modifier-active}) {
225
- }
226
-
227
- &.#{bem.$modifier-active} {
228
- } */
229
- }
230
- }
231
- }
232
-
233
- @include mixins.media($from:$sm-md) {
234
- display: grid;
235
- grid-template-columns: $default-sidebar-width 1fr;
236
-
237
- .#{$class-horizontal-menu} {
238
- display: none;
239
- }
240
-
241
- &.simple {
242
- grid-template-columns: 1fr;
243
- grid-template-rows: auto 1fr;
244
-
245
- .#{$class-horizontal-menu} {
246
- display: block;
247
-
248
- .#{bem.$element-content} {
249
- padding: .5em;
250
- }
251
-
252
- .left,
253
- .right {
254
- display: none;
255
- }
256
- }
257
- }
258
-
259
-
260
-
261
- main {
262
- .#{$class-slide} {
263
- //display: flex;
264
- //flex-direction: column;
265
- overflow: auto;
266
- -ms-overflow-style: none;
267
- scrollbar-width: none;
268
-
269
- &::-webkit-scrollbar {
270
- background: transparent; /* Optional: just make scrollbar invisible */
271
- width: 0; /* Remove scrollbar space */
272
- }
273
-
274
- /*
275
- > img {
276
- height: 100%;
277
- object-fit: cover;
278
- position: absolute;
279
- top: 0;
280
- transition: opacity .3s;
281
- width: 100%;
282
- } */
283
-
284
- .wrapper {
285
- display: flex;
286
- //flex-direction: column;
287
- height: 100%;
288
- justify-content: center;
289
- //overflow: auto;
290
- .#{bem.$element-content} {
291
- height: min-content;
292
- margin: auto 0;
293
-
294
- .#{$class-navigator} {
295
- justify-content: space-between;
296
- }
297
- }
298
- }
299
-
300
-
301
- /*
302
- &:not(.#{bem.$modifier-active}) {
303
- }
304
-
305
- &.#{bem.$modifier-active} {
306
- } */
307
- }
308
- }
309
- }
310
- }
311
-
312
-
@@ -1,11 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = require("react");
8
- var _Context = _interopRequireDefault(require("./Context"));
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- var _default = () => (0, _react.useContext)(_Context.default);
11
- exports.default = _default;
@@ -1,58 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var React = _interopRequireWildcard(require("react"));
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _reactRouterDom = require("react-router-dom");
10
- var _common = require("../common");
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
- 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 && Object.prototype.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; }
14
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } /* @pareto-engineering/generator-front 0.2.2 */
15
- /* eslint-disable react/no-children-prop */
16
- /**
17
- * **Dependencies : `react-router-dom.Router`,**
18
- * **`SessionContextProvider` in case you're using PrivateRoutes. **
19
- * `SwitchRouteMap` generates a routing `Switch` from an array of route Props
20
- */
21
- const SwitchRouteMap = _ref => {
22
- let {
23
- routes,
24
- NotFound
25
- } = _ref;
26
- return /*#__PURE__*/React.createElement(_reactRouterDom.Switch, {
27
- children: [...routes.map(_ref2 => {
28
- let {
29
- isPrivate,
30
- ...routeProps
31
- } = _ref2;
32
- return isPrivate ? /*#__PURE__*/React.createElement(_common.PrivateRoute, _extends({
33
- key: routeProps.path
34
- }, routeProps)) : /*#__PURE__*/React.createElement(_reactRouterDom.Route, _extends({
35
- key: routeProps.path
36
- }, routeProps));
37
- }), ...(NotFound ? [/*#__PURE__*/React.createElement(_reactRouterDom.Route, {
38
- component: NotFound
39
- })] : [])]
40
- });
41
- };
42
- SwitchRouteMap.propTypes = {
43
- /**
44
- * The routes to render
45
- */
46
- routes: _propTypes.default.arrayOf(_propTypes.default.shape({
47
- path: _propTypes.default.string.isRequired
48
- // title:PropTypes.string.isRequired,
49
- // state:PropTypes.string.isRequired,
50
- })).isRequired,
51
- /**
52
- * A component to display in case no route was found.
53
- * In case you're doing SSR, you might want to use
54
- * a component that returns a 404 code.
55
- */
56
- NotFound: _propTypes.default.node
57
- };
58
- var _default = exports.default = SwitchRouteMap;
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "SwitchRouteMap", {
7
- enumerable: true,
8
- get: function () {
9
- return _SwitchRouteMap.default;
10
- }
11
- });
12
- var _SwitchRouteMap = _interopRequireDefault(require("./SwitchRouteMap"));
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,74 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var React = _react;
9
- var _propTypes = _interopRequireDefault(require("prop-types"));
10
- var _reactRouterDom = require("react-router-dom");
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
- 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 && Object.prototype.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; }
14
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } /* @pareto-engineering/generator-front 0.2.1 */
15
- // import { SessionContext } from '..'
16
- const SessionContext = /*#__PURE__*/React.createContext({});
17
-
18
- // Package-level Imports
19
- // import styleNames from 'style_names.scss'
20
-
21
- // Component-level imports
22
-
23
- /**
24
- * **Dependencies : `SessionContext.loginPath` **
25
- * `PrivateRoute` subclasses `react-router-dom` `Route`.
26
- * `PrivateRoute` checks whether a user matches a specified test before allowing him to the resource
27
- * In case the user is not allowed, he is redirected to `SessionContext.loginPath`.
28
- * Please remember this is a front-end test, and is not equivalent to back-end permission checks.
29
- * This component is meant to be used alongside back-end checks.
30
- */
31
- const PrivateRoute = _ref => {
32
- let {
33
- component: Component,
34
- render,
35
- test,
36
- ...rest
37
- } = _ref;
38
- const {
39
- currentUserData: currentUser,
40
- loginPath
41
- } = (0, _react.useContext)(SessionContext);
42
- const location = (0, _reactRouterDom.useLocation)();
43
- // console.log(me)
44
-
45
- const isUserAllowed = currentUser && test(currentUser);
46
- return /*#__PURE__*/React.createElement(_reactRouterDom.Route, _extends({}, rest, {
47
- render: props => isUserAllowed ? render?.(props) || /*#__PURE__*/React.createElement(Component, props) : /*#__PURE__*/React.createElement(_reactRouterDom.Redirect, {
48
- to: {
49
- pathname: loginPath,
50
- state: {
51
- from: location
52
- } // TODO to implement
53
- }
54
- })
55
- }));
56
- };
57
- PrivateRoute.propTypes = {
58
- /**
59
- * A function that takes the user and returns a boolean.
60
- */
61
- test: _propTypes.default.func,
62
- /**
63
- * Provide a custom rendering function in the "Render Props" pattern
64
- */
65
- render: _propTypes.default.func,
66
- /**
67
- * Which javascript component to render
68
- */
69
- component: _propTypes.default.node
70
- };
71
- PrivateRoute.defaultProps = {
72
- test: user => user.id
73
- };
74
- var _default = exports.default = PrivateRoute;
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "PrivateRoute", {
7
- enumerable: true,
8
- get: function () {
9
- return _PrivateRoute.default;
10
- }
11
- });
12
- var _PrivateRoute = _interopRequireDefault(require("./PrivateRoute"));
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "PrivateRoute", {
7
- enumerable: true,
8
- get: function () {
9
- return _PrivateRoute.PrivateRoute;
10
- }
11
- });
12
- var _PrivateRoute = require("./PrivateRoute");
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {
7
- SwitchRouteMap: true
8
- };
9
- Object.defineProperty(exports, "SwitchRouteMap", {
10
- enumerable: true,
11
- get: function () {
12
- return _SwitchRouteMap.SwitchRouteMap;
13
- }
14
- });
15
- var _common = require("./common");
16
- Object.keys(_common).forEach(function (key) {
17
- if (key === "default" || key === "__esModule") return;
18
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
19
- if (key in exports && exports[key] === _common[key]) return;
20
- Object.defineProperty(exports, key, {
21
- enumerable: true,
22
- get: function () {
23
- return _common[key];
24
- }
25
- });
26
- });
27
- var _SwitchRouteMap = require("./SwitchRouteMap");
@@ -1,160 +0,0 @@
1
- /* @pareto-engineering/generator-front 1.0.12 */
2
- import * as React from 'react';
3
- import { useInsertionEffect, useReducer } from 'react';
4
- import PropTypes from 'prop-types';
5
- import { useHistory } from 'react-router-dom';
6
- import styleNames from '@pareto-engineering/bem/exports';
7
- import ContentSlidesContext from "./Context";
8
- import { Slide, HorizontalMenu, Sidebar, Navigator } from "./common";
9
- import "./styles.scss";
10
-
11
- // Local Definitions
12
-
13
- const baseClassName = styleNames.base;
14
- const componentClassName = 'content-slides';
15
- const reducer = (state, action) => {
16
- switch (action.type) {
17
- case 'SET_STEP_INDEX':
18
- return {
19
- ...state,
20
- currentStepIndex: action.payload
21
- };
22
- case 'SET_CURRENT_STEP':
23
- return {
24
- ...state,
25
- ...action.payload
26
- };
27
- case 'SET_EXTRA_CONTEXT':
28
- return {
29
- ...state,
30
- ...action.payload
31
- };
32
- default:
33
- return state;
34
- }
35
- };
36
-
37
- /**
38
- * This is the component description.
39
- * Colors :
40
- * `y` : the background of the content
41
- */
42
- const ContentSlides = ({
43
- id,
44
- className: userClassName,
45
- style,
46
- children,
47
- steps,
48
- simple,
49
- isDebug
50
- // ...otherProps
51
- }) => {
52
- const history = useHistory();
53
- const [state, dispatch] = useReducer(reducer, {
54
- currentStepIndex: 0
55
- });
56
- const {
57
- // currentSlide,
58
- currentStepIndex,
59
- isFirstStep,
60
- isLastStep
61
- } = state;
62
- const setNextStepIndex = (step = 1) => {
63
- if (!isLastStep) {
64
- dispatch({
65
- type: 'SET_STEP_INDEX',
66
- payload: currentStepIndex + step
67
- });
68
- }
69
- };
70
- const setPrevStepIndex = (step = 1) => {
71
- if (!isFirstStep) {
72
- dispatch({
73
- type: 'SET_STEP_INDEX',
74
- payload: currentStepIndex - step
75
- });
76
- }
77
- };
78
- const setStepIndex = index => {
79
- dispatch({
80
- type: 'SET_STEP_INDEX',
81
- payload: index
82
- });
83
- };
84
- const setCurrentStep = index => {
85
- const newStep = steps[index];
86
- if (newStep.location) {
87
- history.push(newStep.location);
88
- }
89
- dispatch({
90
- type: 'SET_CURRENT_STEP',
91
- payload: {
92
- currentStep: steps[index],
93
- isFirstStep: index === 0,
94
- isLastStep: index === steps.length - 1
95
- }
96
- });
97
- };
98
- useInsertionEffect(() => {
99
- setCurrentStep(currentStepIndex);
100
- }, [currentStepIndex]);
101
- return /*#__PURE__*/React.createElement(ContentSlidesContext.Provider, {
102
- value: {
103
- steps,
104
- setNextStepIndex,
105
- setPrevStepIndex,
106
- setStepIndex,
107
- dispatch,
108
- isDebug,
109
- ...state
110
- }
111
- }, /*#__PURE__*/React.createElement("div", {
112
- id: id,
113
- className: [baseClassName, componentClassName, userClassName, simple && 'simple', 'u1 md-u2'].filter(e => e).join(' '),
114
- style: style
115
- }, children));
116
- };
117
- ContentSlides.propTypes = {
118
- /**
119
- * The HTML id for this element
120
- */
121
- id: PropTypes.string,
122
- /**
123
- * The HTML class names for this element
124
- */
125
- className: PropTypes.string,
126
- /**
127
- * The React-written, css properties for this element.
128
- */
129
- style: PropTypes.objectOf(PropTypes.string),
130
- /**
131
- * The children JSX
132
- */
133
- children: PropTypes.node,
134
- /**
135
- * The slides properties
136
- */
137
- steps: PropTypes.arrayOf(PropTypes.shape({
138
- id: PropTypes.string.isRequired,
139
- title: PropTypes.string.isRequired,
140
- progress: PropTypes.number.isRequired,
141
- location: PropTypes.string.isRequired
142
- })),
143
- /**
144
- * Whether this shouldn't use a sidebar on desktop
145
- */
146
- simple: PropTypes.bool,
147
- /**
148
- * Whether the debug mode is enabled
149
- */
150
- isDebug: PropTypes.bool
151
- };
152
- ContentSlides.defaultProps = {
153
- simple: false,
154
- isDebug: false
155
- };
156
- ContentSlides.Sidebar = Sidebar;
157
- ContentSlides.HorizontalMenu = HorizontalMenu;
158
- ContentSlides.Slide = Slide;
159
- ContentSlides.Navigator = Navigator;
160
- export default ContentSlides;
@@ -1,2 +0,0 @@
1
- import * as React from 'react';
2
- export default /*#__PURE__*/React.createContext({});