@pingux/astro 1.31.0-alpha.7 → 1.31.0-alpha.9

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.
@@ -85,7 +85,8 @@ exports["default"] = _default;
85
85
  var items = [{
86
86
  key: 'Aardvark',
87
87
  name: 'Aardvark',
88
- id: '1'
88
+ id: '1',
89
+ hasSeparator: false
89
90
  }, {
90
91
  key: 'Kangaroo',
91
92
  name: 'Kangaroo',
@@ -49,6 +49,7 @@ var ListViewItem = function ListViewItem(props) {
49
49
  rowProps = _props$item$props.rowProps,
50
50
  _props$item$props$has = _props$item$props.hasSeparator,
51
51
  hasSeparator = _props$item$props$has === void 0 ? true : _props$item$props$has,
52
+ hasInsetSeparator = _props$item$props.hasInsetSeparator,
52
53
  className = props.className;
53
54
  var dataId = item.props['data-id'];
54
55
 
@@ -88,7 +89,8 @@ var ListViewItem = function ListViewItem(props) {
88
89
  isHovered: isSelectable && isHovered,
89
90
  isSelected: isSelected,
90
91
  isFocused: isDisabled ? false : isFocusVisible || isFocusVisibleWithin,
91
- hasSeparator: hasSeparator
92
+ hasSeparator: hasSeparator,
93
+ hasInsetSeparator: hasInsetSeparator
92
94
  }),
93
95
  classNames = _useStatusClasses.classNames;
94
96
 
@@ -120,7 +122,8 @@ ListViewItem.propTypes = {
120
122
  'data-id': _propTypes["default"].string,
121
123
  listItemProps: _propTypes["default"].shape({}),
122
124
  rowProps: _propTypes["default"].shape({}),
123
- hasSeparator: _propTypes["default"].bool
125
+ hasSeparator: _propTypes["default"].bool,
126
+ hasInsetSeparator: _propTypes["default"].bool
124
127
  })
125
128
  })
126
129
  };
@@ -0,0 +1,424 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
5
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
6
+
7
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
8
+
9
+ var _typeof = require("@babel/runtime-corejs3/helpers/typeof");
10
+
11
+ var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
12
+
13
+ _Object$defineProperty(exports, "__esModule", {
14
+ value: true
15
+ });
16
+
17
+ exports["default"] = exports.Default = void 0;
18
+
19
+ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
20
+
21
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
22
+
23
+ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
24
+
25
+ var _splice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/splice"));
26
+
27
+ var _findIndex = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find-index"));
28
+
29
+ var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
30
+
31
+ var _react = _interopRequireWildcard(require("react"));
32
+
33
+ var _collections = require("@react-stately/collections");
34
+
35
+ var _DotsVerticalIcon = _interopRequireDefault(require("mdi-react/DotsVerticalIcon"));
36
+
37
+ var _index = require("../index");
38
+
39
+ var _react2 = require("@emotion/react");
40
+
41
+ function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
42
+
43
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
44
+
45
+ var _default = {
46
+ title: 'Recipes/LinkedListView',
47
+ argTypes: {
48
+ loadingState: {
49
+ control: {
50
+ type: 'select'
51
+ }
52
+ },
53
+ disabledKeys: {
54
+ defaultValue: []
55
+ },
56
+ items: {
57
+ control: {
58
+ type: 'none'
59
+ }
60
+ },
61
+ onSelectionChange: {
62
+ control: 'none',
63
+ // eslint-disable-next-line no-console
64
+ defaultValue: console.log
65
+ }
66
+ }
67
+ };
68
+ exports["default"] = _default;
69
+ var testData = [{
70
+ key: 'Default Risk Policy',
71
+ name: 'Default Risk Policy',
72
+ policyId: 'sdfasdfasdf-124123asdf',
73
+ id: '1',
74
+ hasSeparator: false,
75
+ hasInsetSeparator: true,
76
+ chipText: 'default',
77
+ expirationText: 'Expiring On: 2022-12-08',
78
+ childrenObjects: [{
79
+ key: 'Staging Policy',
80
+ name: 'Staging Policy',
81
+ policyId: '23423sdfsdf-124123asdf',
82
+ id: '4',
83
+ expirationText: 'Expiring On: 2022-12-08',
84
+ hasSeparator: true
85
+ }]
86
+ }, {
87
+ key: 'Policy4',
88
+ name: 'Policy4',
89
+ policyId: '9234890324k-124123asdf',
90
+ chipText: 'default',
91
+ id: '2',
92
+ hasSeparator: true
93
+ }, {
94
+ key: 'Policy5',
95
+ name: 'Policy5',
96
+ policyId: 'asdf23zaa-124123asdf',
97
+ id: '3'
98
+ }]; // IMPORTANT PLEASE READ
99
+ // in order for the list portion of this recipe to function correctly,
100
+ // the array of objects that will be used to create
101
+ // the production and staging rows, will need to be flat and sorted.
102
+ // I.e. the staging rows will need to immediately follow the prod row that they correspond to.
103
+ // This flat, sorted array will then be passed into the listview component as the items prop.
104
+ // You may not need these functions if you are able to change the data shape on the back end
105
+ // (which is reccomended for performance reasons)
106
+
107
+ var flattenArray = function flattenArray(array) {
108
+ var newArray = array;
109
+ (0, _forEach["default"])(newArray).call(newArray, function (item) {
110
+ if (item.childrenObjects) {
111
+ var _context;
112
+
113
+ (0, _forEach["default"])(_context = item.childrenObjects).call(_context, function (obj) {
114
+ var newObj = obj;
115
+ newObj.parentId = item.id;
116
+ newArray.push(newObj);
117
+ });
118
+ }
119
+ });
120
+ return newArray;
121
+ };
122
+
123
+ var testSort = function testSort(array) {
124
+ var newArray = array;
125
+ (0, _forEach["default"])(newArray).call(newArray, function (item, i) {
126
+ if (item.parentId) {
127
+ var thisindex = (0, _findIndex["default"])(newArray).call(newArray, function (object) {
128
+ return object.id === item.parentId;
129
+ });
130
+ var element = (0, _splice["default"])(newArray).call(newArray, i, 1)[0];
131
+ (0, _splice["default"])(newArray).call(newArray, thisindex + 1, 0, element);
132
+ }
133
+ });
134
+ return newArray;
135
+ };
136
+
137
+ var unsorted = flattenArray(testData);
138
+ var sorted = testSort(unsorted);
139
+
140
+ var Default = function Default(_ref) {
141
+ var _context2;
142
+
143
+ var args = (0, _extends2["default"])({}, _ref);
144
+
145
+ var _useState = (0, _react.useState)((0, _concat["default"])(_context2 = []).call(_context2, sorted)),
146
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 1),
147
+ theseItems = _useState2[0]; // svg of the bottom portion of the bracket, the portion with the L shaped hook.
148
+
149
+
150
+ var BottomBracket = function BottomBracket() {
151
+ var color = '#CACED3';
152
+ return (0, _react2.jsx)(_index.Box, {
153
+ sx: {
154
+ width: '20px',
155
+ position: 'relative'
156
+ }
157
+ }, (0, _react2.jsx)(_index.Box, {
158
+ flexBasis: "50%"
159
+ }, (0, _react2.jsx)("svg", {
160
+ xmlns: "http://www.w3.org/2000/svg",
161
+ version: "1.1",
162
+ preserveAspectRatio: "none",
163
+ viewBox: "0 0 10 10",
164
+ style: {
165
+ flexGrow: 1
166
+ }
167
+ }, (0, _react2.jsx)("title", null, "bracket-fill"), (0, _react2.jsx)("g", null, (0, _react2.jsx)("title", null, "Layer 1"), (0, _react2.jsx)("line", {
168
+ strokeLinecap: "undefined",
169
+ strokeLinejoin: "undefined",
170
+ y2: "0",
171
+ x2: "0",
172
+ y1: "15",
173
+ x1: "0",
174
+ stroke: color,
175
+ fill: "none"
176
+ }))), (0, _react2.jsx)("svg", {
177
+ width: "17",
178
+ height: "9",
179
+ viewBox: "0 0 17 9",
180
+ fill: "none",
181
+ xmlns: "http://www.w3.org/2000/svg"
182
+ }, (0, _react2.jsx)("g", {
183
+ clipPath: "url(#clip0_1900_8817)"
184
+ }, (0, _react2.jsx)("g", {
185
+ mask: "url(#mask0_1900_8817)"
186
+ }, (0, _react2.jsx)("rect", {
187
+ x: "0.5",
188
+ y: "-54.5",
189
+ width: "20",
190
+ height: "63",
191
+ rx: "4.5",
192
+ stroke: "#CACED3"
193
+ }))), (0, _react2.jsx)("defs", null, (0, _react2.jsx)("clipPath", {
194
+ id: "clip0_1900_8817"
195
+ }, (0, _react2.jsx)("rect", {
196
+ width: "1600",
197
+ height: "917",
198
+ fill: "white",
199
+ transform: "translate(-280 -419)"
200
+ }))))));
201
+ }; // the top portion of the bracket svg, this is basically just a straight vertical line.
202
+
203
+
204
+ var TopBracket = function TopBracket() {
205
+ var color = '#CACED3';
206
+ return (0, _react2.jsx)(_index.Box, {
207
+ width: 15,
208
+ sx: {
209
+ position: 'absolute',
210
+ bottom: 0,
211
+ left: 12,
212
+ top: 55
213
+ }
214
+ }, (0, _react2.jsx)("svg", {
215
+ xmlns: "http://www.w3.org/2000/svg",
216
+ version: "1.1",
217
+ preserveAspectRatio: "none",
218
+ viewBox: "0 0 10 10",
219
+ style: {
220
+ flexGrow: 1
221
+ },
222
+ "data-testid": "isLastLayer"
223
+ }, (0, _react2.jsx)("title", null, "bracket-fill"), (0, _react2.jsx)("g", null, (0, _react2.jsx)("title", null, "Layer 3"), (0, _react2.jsx)("line", {
224
+ strokeLinecap: "undefined",
225
+ strokeLinejoin: "undefined",
226
+ y2: "0",
227
+ x2: "0",
228
+ y1: "10",
229
+ x1: "0",
230
+ stroke: color,
231
+ fill: "none"
232
+ }))));
233
+ }; // the vector shield and key icon.
234
+
235
+
236
+ var ShieldVector = function ShieldVector(props) {
237
+ return (0, _react2.jsx)("svg", (0, _extends2["default"])({
238
+ width: "19",
239
+ height: "23",
240
+ viewBox: "0 0 19 23",
241
+ xmlns: "http://www.w3.org/2000/svg"
242
+ }, props), (0, _react2.jsx)("path", {
243
+ d: "M9.5 7.33342C9.77627 7.33342 10.0412 7.44316 10.2366 7.63851C10.4319 7.83386 10.5417 8.09881 10.5417 8.37508C10.5417 8.65135 10.4319 8.9163 10.2366 9.11165C10.0412 9.307 9.77627 9.41675 9.5 9.41675C9.22373 9.41675 8.95878 9.307 8.76343 9.11165C8.56808 8.9163 8.45833 8.65135 8.45833 8.37508C8.45833 8.09881 8.56808 7.83386 8.76343 7.63851C8.95878 7.44316 9.22373 7.33342 9.5 7.33342ZM18.875 10.4584C18.875 16.2397 14.875 21.6459 9.5 22.9584C4.125 21.6459 0.125 16.2397 0.125 10.4584V4.20842L9.5 0.041748L18.875 4.20842V10.4584ZM9.5 5.25008C8.6712 5.25008 7.87634 5.57932 7.29029 6.16537C6.70424 6.75142 6.375 7.54628 6.375 8.37508C6.375 9.73967 7.23958 10.8959 8.45833 11.323V17.7501H10.5417V15.6667H12.625V13.5834H10.5417V11.323C11.7604 10.8959 12.625 9.73967 12.625 8.37508C12.625 7.54628 12.2958 6.75142 11.7097 6.16537C11.1237 5.57932 10.3288 5.25008 9.5 5.25008Z"
244
+ }));
245
+ }; // reusable piece of code that handles the iconbutton and popover on the right side of the rows
246
+
247
+
248
+ var IconWithPopover = function IconWithPopover() {
249
+ return (0, _react2.jsx)(_index.PopoverMenu, {
250
+ direction: "left"
251
+ }, (0, _react2.jsx)(_index.Box, {
252
+ alignItems: "center",
253
+ alignSelf: "center"
254
+ }, (0, _react2.jsx)(_index.IconButton, {
255
+ "aria-label": "Menu Button"
256
+ }, (0, _react2.jsx)(_index.Icon, {
257
+ icon: _DotsVerticalIcon["default"],
258
+ size: 16,
259
+ color: "Neutral.40",
260
+ m: "0.61px"
261
+ }))), (0, _react2.jsx)(_index.Menu, {
262
+ direction: "left",
263
+ sx: {
264
+ minWidth: '155px',
265
+ minHeight: '144px'
266
+ }
267
+ }, (0, _react2.jsx)(_collections.Item, {
268
+ key: "view"
269
+ }, "View"), (0, _react2.jsx)(_collections.Item, {
270
+ key: "edit"
271
+ }, "Edit"), (0, _react2.jsx)(_collections.Item, {
272
+ key: "rename"
273
+ }, "Rename"), (0, _react2.jsx)(_collections.Item, {
274
+ key: "delete",
275
+ textValue: "delete"
276
+ }, (0, _react2.jsx)(_index.Text, {
277
+ color: "critical.bright"
278
+ }, "Delete"))));
279
+ }; // made these separate components because staging and production both use them.
280
+
281
+
282
+ var DefaultChip = function DefaultChip() {
283
+ return (0, _react2.jsx)(_index.Chip, {
284
+ label: "Default",
285
+ bg: "active",
286
+ sx: {
287
+ marginLeft: '25px',
288
+ alignSelf: 'center',
289
+ alignItems: 'center',
290
+ padding: '3px 5px 2px 5px'
291
+ }
292
+ });
293
+ };
294
+
295
+ var ExprirationChip = function ExprirationChip(props) {
296
+ var expirationText = props.expirationText,
297
+ chipText = props.chipText;
298
+ return (0, _react2.jsx)(_index.Box, {
299
+ sx: !chipText && {
300
+ paddingLeft: '72px'
301
+ },
302
+ flexGrow: 1,
303
+ alignItems: "center",
304
+ alignSelf: "center"
305
+ }, (0, _react2.jsx)(_index.Chip, {
306
+ bg: "white",
307
+ sx: {
308
+ border: 'solid 1px',
309
+ borderColor: 'neutral.80',
310
+ alignSelf: 'center',
311
+ alignItems: 'center',
312
+ padding: '3px 5px 2px 5px'
313
+ },
314
+ textColor: "text.primary",
315
+ textProps: {
316
+ fontSize: 'xs'
317
+ },
318
+ label: expirationText
319
+ }));
320
+ }; // jsx of the production row
321
+
322
+
323
+ var Production = function Production(props) {
324
+ var chipText = props.chipText,
325
+ hasStaging = props.hasStaging,
326
+ policyId = props.policyId,
327
+ name = props.name;
328
+ return (0, _react2.jsx)(_index.Box, {
329
+ isRow: true,
330
+ height: "75px"
331
+ }, (0, _react2.jsx)(_index.Box, {
332
+ alignItems: "center",
333
+ justifyContent: "center",
334
+ sx: {
335
+ position: 'relative'
336
+ }
337
+ }, (0, _react2.jsx)(_index.Icon, {
338
+ icon: ShieldVector,
339
+ color: hasStaging ? 'decorative.7' : 'accent.40',
340
+ size: 24,
341
+ isLinked: hasStaging
342
+ }), hasStaging && (0, _react2.jsx)(TopBracket, null)), (0, _react2.jsx)(_index.Box, {
343
+ isRow: true,
344
+ mr: "auto",
345
+ alignSelf: "center",
346
+ justifyContent: "center",
347
+ ml: "18px",
348
+ alignItems: "center"
349
+ }, (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Text, {
350
+ sx: {
351
+ fontWeight: 1,
352
+ color: 'text.primary',
353
+ fontSize: 'md'
354
+ }
355
+ }, name), (0, _react2.jsx)(_index.Text, {
356
+ sx: {
357
+ fontWeight: 0,
358
+ color: 'text.secondary',
359
+ fontSize: 'sm'
360
+ }
361
+ }, "Policy Id: ", policyId)), chipText && (0, _react2.jsx)(DefaultChip, null)), (0, _react2.jsx)(IconWithPopover, null));
362
+ }; // jsx of the staging row.
363
+
364
+
365
+ var Staging = function Staging(props) {
366
+ var chipText = props.chipText,
367
+ expirationText = props.expirationText,
368
+ policyId = props.policyId,
369
+ name = props.name;
370
+ return (0, _react2.jsx)(_index.Box, {
371
+ isRow: true,
372
+ height: "75px",
373
+ marginLeft: "12px"
374
+ }, (0, _react2.jsx)(BottomBracket, null), (0, _react2.jsx)(_index.Box, {
375
+ isRow: true,
376
+ alignItems: "center",
377
+ justifyContent: "center"
378
+ }, (0, _react2.jsx)(_index.Box, {
379
+ pl: "0px",
380
+ height: "30px",
381
+ flexDirection: "row",
382
+ alignItems: "center"
383
+ }, (0, _react2.jsx)(_index.Separator, {
384
+ orientation: "vertical",
385
+ sx: {
386
+ width: '2px !important',
387
+ backgroundColor: 'decorative.7',
388
+ marginLeft: '2px !important'
389
+ }
390
+ })), (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Text, {
391
+ sx: {
392
+ fontWeight: 1,
393
+ color: 'text.primary',
394
+ fontSize: 'md'
395
+ }
396
+ }, name), (0, _react2.jsx)(_index.Text, {
397
+ sx: {
398
+ fontWeight: 0,
399
+ color: 'text.secondary',
400
+ fontSize: 'sm'
401
+ }
402
+ }, "Policy Id: ", policyId))), chipText && (0, _react2.jsx)(DefaultChip, null), expirationText && (0, _react2.jsx)(ExprirationChip, {
403
+ expirationText: expirationText
404
+ }), (0, _react2.jsx)(IconWithPopover, null));
405
+ };
406
+
407
+ return (0, _react2.jsx)(_index.OverlayProvider, null, (0, _react2.jsx)(_index.ListView, (0, _extends2["default"])({}, args, {
408
+ items: theseItems
409
+ }), function (item) {
410
+ return (0, _react2.jsx)(_collections.Item, (0, _extends2["default"])({}, item, {
411
+ textValue: item.name,
412
+ "data-id": item.key,
413
+ listItemProps: {
414
+ variant: 'boxes.linkedListViewItem'
415
+ }
416
+ }), item.parentId ? (0, _react2.jsx)(Staging, (0, _extends2["default"])({}, item, {
417
+ hasInsetSeparator: true
418
+ })) : (0, _react2.jsx)(Production, (0, _extends2["default"])({
419
+ hasStaging: item.childrenObjects
420
+ }, item)));
421
+ }));
422
+ };
423
+
424
+ exports.Default = Default;
@@ -100,6 +100,21 @@ var listViewItem = _objectSpread(_objectSpread({}, base), {}, {
100
100
  }
101
101
  });
102
102
 
103
+ var linkedListViewItem = _objectSpread(_objectSpread({}, listViewItem), {}, {
104
+ minHeight: '75px',
105
+ '&.has-inset-separator': {
106
+ '&:after': {
107
+ content: '""',
108
+ position: 'absolute',
109
+ width: 'calc(100% - 43px)',
110
+ right: 0,
111
+ bottom: 0,
112
+ borderBottom: '1px solid',
113
+ borderBottomColor: 'line.hairline'
114
+ }
115
+ }
116
+ });
117
+
103
118
  var listBoxSectionTitle = {
104
119
  fontSize: 'sm',
105
120
  fontWeight: '3',
@@ -381,6 +396,7 @@ var _default = {
381
396
  listItem: listItem,
382
397
  listBoxSectionTitle: listBoxSectionTitle,
383
398
  listViewItem: listViewItem,
399
+ linkedListViewItem: linkedListViewItem,
384
400
  radioCheckedContent: radioCheckedContent,
385
401
  radioContainer: radioContainer,
386
402
  scrollbox: scrollbox,
@@ -49,7 +49,8 @@ export default {
49
49
  var items = [{
50
50
  key: 'Aardvark',
51
51
  name: 'Aardvark',
52
- id: '1'
52
+ id: '1',
53
+ hasSeparator: false
53
54
  }, {
54
55
  key: 'Kangaroo',
55
56
  name: 'Kangaroo',
@@ -17,6 +17,7 @@ var ListViewItem = function ListViewItem(props) {
17
17
  rowProps = _props$item$props.rowProps,
18
18
  _props$item$props$has = _props$item$props.hasSeparator,
19
19
  hasSeparator = _props$item$props$has === void 0 ? true : _props$item$props$has,
20
+ hasInsetSeparator = _props$item$props.hasInsetSeparator,
20
21
  className = props.className;
21
22
  var dataId = item.props['data-id'];
22
23
 
@@ -56,7 +57,8 @@ var ListViewItem = function ListViewItem(props) {
56
57
  isHovered: isSelectable && isHovered,
57
58
  isSelected: isSelected,
58
59
  isFocused: isDisabled ? false : isFocusVisible || isFocusVisibleWithin,
59
- hasSeparator: hasSeparator
60
+ hasSeparator: hasSeparator,
61
+ hasInsetSeparator: hasInsetSeparator
60
62
  }),
61
63
  classNames = _useStatusClasses.classNames;
62
64
 
@@ -88,7 +90,8 @@ ListViewItem.propTypes = {
88
90
  'data-id': PropTypes.string,
89
91
  listItemProps: PropTypes.shape({}),
90
92
  rowProps: PropTypes.shape({}),
91
- hasSeparator: PropTypes.bool
93
+ hasSeparator: PropTypes.bool,
94
+ hasInsetSeparator: PropTypes.bool
92
95
  })
93
96
  })
94
97
  };
@@ -0,0 +1,393 @@
1
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
2
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
3
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
4
+ import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/splice";
5
+ import _findIndexInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find-index";
6
+ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
7
+ import React, { useState } from 'react';
8
+ import { Item } from '@react-stately/collections';
9
+ import DotsVerticalIcon from 'mdi-react/DotsVerticalIcon';
10
+ import { ListView, Text, Box, Icon, IconButton, Chip, Separator, OverlayProvider, PopoverMenu, Menu } from '../index';
11
+ import { jsx as ___EmotionJSX } from "@emotion/react";
12
+ export default {
13
+ title: 'Recipes/LinkedListView',
14
+ argTypes: {
15
+ loadingState: {
16
+ control: {
17
+ type: 'select'
18
+ }
19
+ },
20
+ disabledKeys: {
21
+ defaultValue: []
22
+ },
23
+ items: {
24
+ control: {
25
+ type: 'none'
26
+ }
27
+ },
28
+ onSelectionChange: {
29
+ control: 'none',
30
+ // eslint-disable-next-line no-console
31
+ defaultValue: console.log
32
+ }
33
+ }
34
+ };
35
+ var testData = [{
36
+ key: 'Default Risk Policy',
37
+ name: 'Default Risk Policy',
38
+ policyId: 'sdfasdfasdf-124123asdf',
39
+ id: '1',
40
+ hasSeparator: false,
41
+ hasInsetSeparator: true,
42
+ chipText: 'default',
43
+ expirationText: 'Expiring On: 2022-12-08',
44
+ childrenObjects: [{
45
+ key: 'Staging Policy',
46
+ name: 'Staging Policy',
47
+ policyId: '23423sdfsdf-124123asdf',
48
+ id: '4',
49
+ expirationText: 'Expiring On: 2022-12-08',
50
+ hasSeparator: true
51
+ }]
52
+ }, {
53
+ key: 'Policy4',
54
+ name: 'Policy4',
55
+ policyId: '9234890324k-124123asdf',
56
+ chipText: 'default',
57
+ id: '2',
58
+ hasSeparator: true
59
+ }, {
60
+ key: 'Policy5',
61
+ name: 'Policy5',
62
+ policyId: 'asdf23zaa-124123asdf',
63
+ id: '3'
64
+ }]; // IMPORTANT PLEASE READ
65
+ // in order for the list portion of this recipe to function correctly,
66
+ // the array of objects that will be used to create
67
+ // the production and staging rows, will need to be flat and sorted.
68
+ // I.e. the staging rows will need to immediately follow the prod row that they correspond to.
69
+ // This flat, sorted array will then be passed into the listview component as the items prop.
70
+ // You may not need these functions if you are able to change the data shape on the back end
71
+ // (which is reccomended for performance reasons)
72
+
73
+ var flattenArray = function flattenArray(array) {
74
+ var newArray = array;
75
+
76
+ _forEachInstanceProperty(newArray).call(newArray, function (item) {
77
+ if (item.childrenObjects) {
78
+ var _context;
79
+
80
+ _forEachInstanceProperty(_context = item.childrenObjects).call(_context, function (obj) {
81
+ var newObj = obj;
82
+ newObj.parentId = item.id;
83
+ newArray.push(newObj);
84
+ });
85
+ }
86
+ });
87
+
88
+ return newArray;
89
+ };
90
+
91
+ var testSort = function testSort(array) {
92
+ var newArray = array;
93
+
94
+ _forEachInstanceProperty(newArray).call(newArray, function (item, i) {
95
+ if (item.parentId) {
96
+ var thisindex = _findIndexInstanceProperty(newArray).call(newArray, function (object) {
97
+ return object.id === item.parentId;
98
+ });
99
+
100
+ var element = _spliceInstanceProperty(newArray).call(newArray, i, 1)[0];
101
+
102
+ _spliceInstanceProperty(newArray).call(newArray, thisindex + 1, 0, element);
103
+ }
104
+ });
105
+
106
+ return newArray;
107
+ };
108
+
109
+ var unsorted = flattenArray(testData);
110
+ var sorted = testSort(unsorted);
111
+ export var Default = function Default(_ref) {
112
+ var _context2;
113
+
114
+ var args = _extends({}, _ref);
115
+
116
+ var _useState = useState(_concatInstanceProperty(_context2 = []).call(_context2, sorted)),
117
+ _useState2 = _slicedToArray(_useState, 1),
118
+ theseItems = _useState2[0]; // svg of the bottom portion of the bracket, the portion with the L shaped hook.
119
+
120
+
121
+ var BottomBracket = function BottomBracket() {
122
+ var color = '#CACED3';
123
+ return ___EmotionJSX(Box, {
124
+ sx: {
125
+ width: '20px',
126
+ position: 'relative'
127
+ }
128
+ }, ___EmotionJSX(Box, {
129
+ flexBasis: "50%"
130
+ }, ___EmotionJSX("svg", {
131
+ xmlns: "http://www.w3.org/2000/svg",
132
+ version: "1.1",
133
+ preserveAspectRatio: "none",
134
+ viewBox: "0 0 10 10",
135
+ style: {
136
+ flexGrow: 1
137
+ }
138
+ }, ___EmotionJSX("title", null, "bracket-fill"), ___EmotionJSX("g", null, ___EmotionJSX("title", null, "Layer 1"), ___EmotionJSX("line", {
139
+ strokeLinecap: "undefined",
140
+ strokeLinejoin: "undefined",
141
+ y2: "0",
142
+ x2: "0",
143
+ y1: "15",
144
+ x1: "0",
145
+ stroke: color,
146
+ fill: "none"
147
+ }))), ___EmotionJSX("svg", {
148
+ width: "17",
149
+ height: "9",
150
+ viewBox: "0 0 17 9",
151
+ fill: "none",
152
+ xmlns: "http://www.w3.org/2000/svg"
153
+ }, ___EmotionJSX("g", {
154
+ clipPath: "url(#clip0_1900_8817)"
155
+ }, ___EmotionJSX("g", {
156
+ mask: "url(#mask0_1900_8817)"
157
+ }, ___EmotionJSX("rect", {
158
+ x: "0.5",
159
+ y: "-54.5",
160
+ width: "20",
161
+ height: "63",
162
+ rx: "4.5",
163
+ stroke: "#CACED3"
164
+ }))), ___EmotionJSX("defs", null, ___EmotionJSX("clipPath", {
165
+ id: "clip0_1900_8817"
166
+ }, ___EmotionJSX("rect", {
167
+ width: "1600",
168
+ height: "917",
169
+ fill: "white",
170
+ transform: "translate(-280 -419)"
171
+ }))))));
172
+ }; // the top portion of the bracket svg, this is basically just a straight vertical line.
173
+
174
+
175
+ var TopBracket = function TopBracket() {
176
+ var color = '#CACED3';
177
+ return ___EmotionJSX(Box, {
178
+ width: 15,
179
+ sx: {
180
+ position: 'absolute',
181
+ bottom: 0,
182
+ left: 12,
183
+ top: 55
184
+ }
185
+ }, ___EmotionJSX("svg", {
186
+ xmlns: "http://www.w3.org/2000/svg",
187
+ version: "1.1",
188
+ preserveAspectRatio: "none",
189
+ viewBox: "0 0 10 10",
190
+ style: {
191
+ flexGrow: 1
192
+ },
193
+ "data-testid": "isLastLayer"
194
+ }, ___EmotionJSX("title", null, "bracket-fill"), ___EmotionJSX("g", null, ___EmotionJSX("title", null, "Layer 3"), ___EmotionJSX("line", {
195
+ strokeLinecap: "undefined",
196
+ strokeLinejoin: "undefined",
197
+ y2: "0",
198
+ x2: "0",
199
+ y1: "10",
200
+ x1: "0",
201
+ stroke: color,
202
+ fill: "none"
203
+ }))));
204
+ }; // the vector shield and key icon.
205
+
206
+
207
+ var ShieldVector = function ShieldVector(props) {
208
+ return ___EmotionJSX("svg", _extends({
209
+ width: "19",
210
+ height: "23",
211
+ viewBox: "0 0 19 23",
212
+ xmlns: "http://www.w3.org/2000/svg"
213
+ }, props), ___EmotionJSX("path", {
214
+ d: "M9.5 7.33342C9.77627 7.33342 10.0412 7.44316 10.2366 7.63851C10.4319 7.83386 10.5417 8.09881 10.5417 8.37508C10.5417 8.65135 10.4319 8.9163 10.2366 9.11165C10.0412 9.307 9.77627 9.41675 9.5 9.41675C9.22373 9.41675 8.95878 9.307 8.76343 9.11165C8.56808 8.9163 8.45833 8.65135 8.45833 8.37508C8.45833 8.09881 8.56808 7.83386 8.76343 7.63851C8.95878 7.44316 9.22373 7.33342 9.5 7.33342ZM18.875 10.4584C18.875 16.2397 14.875 21.6459 9.5 22.9584C4.125 21.6459 0.125 16.2397 0.125 10.4584V4.20842L9.5 0.041748L18.875 4.20842V10.4584ZM9.5 5.25008C8.6712 5.25008 7.87634 5.57932 7.29029 6.16537C6.70424 6.75142 6.375 7.54628 6.375 8.37508C6.375 9.73967 7.23958 10.8959 8.45833 11.323V17.7501H10.5417V15.6667H12.625V13.5834H10.5417V11.323C11.7604 10.8959 12.625 9.73967 12.625 8.37508C12.625 7.54628 12.2958 6.75142 11.7097 6.16537C11.1237 5.57932 10.3288 5.25008 9.5 5.25008Z"
215
+ }));
216
+ }; // reusable piece of code that handles the iconbutton and popover on the right side of the rows
217
+
218
+
219
+ var IconWithPopover = function IconWithPopover() {
220
+ return ___EmotionJSX(PopoverMenu, {
221
+ direction: "left"
222
+ }, ___EmotionJSX(Box, {
223
+ alignItems: "center",
224
+ alignSelf: "center"
225
+ }, ___EmotionJSX(IconButton, {
226
+ "aria-label": "Menu Button"
227
+ }, ___EmotionJSX(Icon, {
228
+ icon: DotsVerticalIcon,
229
+ size: 16,
230
+ color: "Neutral.40",
231
+ m: "0.61px"
232
+ }))), ___EmotionJSX(Menu, {
233
+ direction: "left",
234
+ sx: {
235
+ minWidth: '155px',
236
+ minHeight: '144px'
237
+ }
238
+ }, ___EmotionJSX(Item, {
239
+ key: "view"
240
+ }, "View"), ___EmotionJSX(Item, {
241
+ key: "edit"
242
+ }, "Edit"), ___EmotionJSX(Item, {
243
+ key: "rename"
244
+ }, "Rename"), ___EmotionJSX(Item, {
245
+ key: "delete",
246
+ textValue: "delete"
247
+ }, ___EmotionJSX(Text, {
248
+ color: "critical.bright"
249
+ }, "Delete"))));
250
+ }; // made these separate components because staging and production both use them.
251
+
252
+
253
+ var DefaultChip = function DefaultChip() {
254
+ return ___EmotionJSX(Chip, {
255
+ label: "Default",
256
+ bg: "active",
257
+ sx: {
258
+ marginLeft: '25px',
259
+ alignSelf: 'center',
260
+ alignItems: 'center',
261
+ padding: '3px 5px 2px 5px'
262
+ }
263
+ });
264
+ };
265
+
266
+ var ExprirationChip = function ExprirationChip(props) {
267
+ var expirationText = props.expirationText,
268
+ chipText = props.chipText;
269
+ return ___EmotionJSX(Box, {
270
+ sx: !chipText && {
271
+ paddingLeft: '72px'
272
+ },
273
+ flexGrow: 1,
274
+ alignItems: "center",
275
+ alignSelf: "center"
276
+ }, ___EmotionJSX(Chip, {
277
+ bg: "white",
278
+ sx: {
279
+ border: 'solid 1px',
280
+ borderColor: 'neutral.80',
281
+ alignSelf: 'center',
282
+ alignItems: 'center',
283
+ padding: '3px 5px 2px 5px'
284
+ },
285
+ textColor: "text.primary",
286
+ textProps: {
287
+ fontSize: 'xs'
288
+ },
289
+ label: expirationText
290
+ }));
291
+ }; // jsx of the production row
292
+
293
+
294
+ var Production = function Production(props) {
295
+ var chipText = props.chipText,
296
+ hasStaging = props.hasStaging,
297
+ policyId = props.policyId,
298
+ name = props.name;
299
+ return ___EmotionJSX(Box, {
300
+ isRow: true,
301
+ height: "75px"
302
+ }, ___EmotionJSX(Box, {
303
+ alignItems: "center",
304
+ justifyContent: "center",
305
+ sx: {
306
+ position: 'relative'
307
+ }
308
+ }, ___EmotionJSX(Icon, {
309
+ icon: ShieldVector,
310
+ color: hasStaging ? 'decorative.7' : 'accent.40',
311
+ size: 24,
312
+ isLinked: hasStaging
313
+ }), hasStaging && ___EmotionJSX(TopBracket, null)), ___EmotionJSX(Box, {
314
+ isRow: true,
315
+ mr: "auto",
316
+ alignSelf: "center",
317
+ justifyContent: "center",
318
+ ml: "18px",
319
+ alignItems: "center"
320
+ }, ___EmotionJSX(Box, null, ___EmotionJSX(Text, {
321
+ sx: {
322
+ fontWeight: 1,
323
+ color: 'text.primary',
324
+ fontSize: 'md'
325
+ }
326
+ }, name), ___EmotionJSX(Text, {
327
+ sx: {
328
+ fontWeight: 0,
329
+ color: 'text.secondary',
330
+ fontSize: 'sm'
331
+ }
332
+ }, "Policy Id: ", policyId)), chipText && ___EmotionJSX(DefaultChip, null)), ___EmotionJSX(IconWithPopover, null));
333
+ }; // jsx of the staging row.
334
+
335
+
336
+ var Staging = function Staging(props) {
337
+ var chipText = props.chipText,
338
+ expirationText = props.expirationText,
339
+ policyId = props.policyId,
340
+ name = props.name;
341
+ return ___EmotionJSX(Box, {
342
+ isRow: true,
343
+ height: "75px",
344
+ marginLeft: "12px"
345
+ }, ___EmotionJSX(BottomBracket, null), ___EmotionJSX(Box, {
346
+ isRow: true,
347
+ alignItems: "center",
348
+ justifyContent: "center"
349
+ }, ___EmotionJSX(Box, {
350
+ pl: "0px",
351
+ height: "30px",
352
+ flexDirection: "row",
353
+ alignItems: "center"
354
+ }, ___EmotionJSX(Separator, {
355
+ orientation: "vertical",
356
+ sx: {
357
+ width: '2px !important',
358
+ backgroundColor: 'decorative.7',
359
+ marginLeft: '2px !important'
360
+ }
361
+ })), ___EmotionJSX(Box, null, ___EmotionJSX(Text, {
362
+ sx: {
363
+ fontWeight: 1,
364
+ color: 'text.primary',
365
+ fontSize: 'md'
366
+ }
367
+ }, name), ___EmotionJSX(Text, {
368
+ sx: {
369
+ fontWeight: 0,
370
+ color: 'text.secondary',
371
+ fontSize: 'sm'
372
+ }
373
+ }, "Policy Id: ", policyId))), chipText && ___EmotionJSX(DefaultChip, null), expirationText && ___EmotionJSX(ExprirationChip, {
374
+ expirationText: expirationText
375
+ }), ___EmotionJSX(IconWithPopover, null));
376
+ };
377
+
378
+ return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(ListView, _extends({}, args, {
379
+ items: theseItems
380
+ }), function (item) {
381
+ return ___EmotionJSX(Item, _extends({}, item, {
382
+ textValue: item.name,
383
+ "data-id": item.key,
384
+ listItemProps: {
385
+ variant: 'boxes.linkedListViewItem'
386
+ }
387
+ }), item.parentId ? ___EmotionJSX(Staging, _extends({}, item, {
388
+ hasInsetSeparator: true
389
+ })) : ___EmotionJSX(Production, _extends({
390
+ hasStaging: item.childrenObjects
391
+ }, item)));
392
+ }));
393
+ };
@@ -81,6 +81,21 @@ var listViewItem = _objectSpread(_objectSpread({}, base), {}, {
81
81
  }
82
82
  });
83
83
 
84
+ var linkedListViewItem = _objectSpread(_objectSpread({}, listViewItem), {}, {
85
+ minHeight: '75px',
86
+ '&.has-inset-separator': {
87
+ '&:after': {
88
+ content: '""',
89
+ position: 'absolute',
90
+ width: 'calc(100% - 43px)',
91
+ right: 0,
92
+ bottom: 0,
93
+ borderBottom: '1px solid',
94
+ borderBottomColor: 'line.hairline'
95
+ }
96
+ }
97
+ });
98
+
84
99
  var listBoxSectionTitle = {
85
100
  fontSize: 'sm',
86
101
  fontWeight: '3',
@@ -361,6 +376,7 @@ export default {
361
376
  listItem: listItem,
362
377
  listBoxSectionTitle: listBoxSectionTitle,
363
378
  listViewItem: listViewItem,
379
+ linkedListViewItem: linkedListViewItem,
364
380
  radioCheckedContent: radioCheckedContent,
365
381
  radioContainer: radioContainer,
366
382
  scrollbox: scrollbox,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "1.31.0-alpha.7",
3
+ "version": "1.31.0-alpha.9",
4
4
  "description": "PingUX themeable React component library",
5
5
  "repository": {
6
6
  "type": "git",