@pingux/astro 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.js +8 -2
- package/lib/cjs/components/AccordionGridItem/AccordionGridItemBody.js +5 -2
- package/lib/cjs/components/AccordionGridItem/AccordionGridItemHeader.js +8 -3
- package/lib/cjs/components/ArrayField/ArrayField.js +213 -0
- package/lib/cjs/components/ArrayField/ArrayField.stories.js +223 -0
- package/lib/cjs/components/ArrayField/ArrayField.test.js +208 -0
- package/lib/cjs/components/ArrayField/ArrayFieldDeleteButton.js +61 -0
- package/lib/cjs/components/ArrayField/index.js +27 -0
- package/lib/cjs/components/CodeView/CodeView.js +3 -3
- package/lib/cjs/components/ListView/ListView.stories.js +3 -0
- package/lib/cjs/components/Loader/Loader.stories.js +3 -3
- package/lib/cjs/components/Modal/Modal.js +3 -0
- package/lib/cjs/components/Modal/Modal.stories.js +11 -66
- package/lib/cjs/components/NavBar/NavBar.js +30 -4
- package/lib/cjs/components/NavBar/NavBar.stories.js +70 -463
- package/lib/cjs/components/NavBar/NavBar.test.js +51 -1
- package/lib/cjs/components/NavBarSection/NavBarItem.js +137 -0
- package/lib/cjs/components/NavBarSection/NavBarItemButton.js +96 -0
- package/lib/cjs/components/NavBarSection/NavBarItemHeader.js +1 -1
- package/lib/cjs/components/NavBarSection/NavBarItemLink.js +98 -0
- package/lib/cjs/components/NavBarSection/NavBarSection.js +10 -8
- package/lib/cjs/components/NavBarSection/index.js +28 -1
- package/lib/cjs/components/SelectFieldBase/SelectFieldBase.js +8 -1
- package/lib/cjs/context/NavBarContext/index.js +20 -0
- package/lib/cjs/hooks/index.js +9 -0
- package/lib/cjs/hooks/useNavBarPress/index.js +18 -0
- package/lib/cjs/hooks/useNavBarPress/useNavBarPress.js +38 -0
- package/lib/cjs/hooks/useNavBarPress/useNavBarPress.test.js +42 -0
- package/lib/cjs/index.js +80 -58
- package/lib/cjs/styles/variants/accordion.js +39 -7
- package/lib/cjs/styles/variants/boxes.js +1 -24
- package/lib/cjs/styles/variants/buttons.js +7 -1
- package/lib/cjs/styles/variants/codeView.js +91 -0
- package/lib/cjs/styles/variants/navBar.js +68 -0
- package/lib/cjs/styles/variants/separator.js +2 -1
- package/lib/cjs/styles/variants/text.js +3 -1
- package/lib/cjs/styles/variants/variants.js +3 -0
- package/lib/components/AccordionGridGroup/AccordionGridGroup.js +7 -2
- package/lib/components/AccordionGridItem/AccordionGridItemBody.js +4 -2
- package/lib/components/AccordionGridItem/AccordionGridItemHeader.js +9 -4
- package/lib/components/ArrayField/ArrayField.js +179 -0
- package/lib/components/ArrayField/ArrayField.stories.js +196 -0
- package/lib/components/ArrayField/ArrayField.test.js +185 -0
- package/lib/components/ArrayField/ArrayFieldDeleteButton.js +43 -0
- package/lib/components/ArrayField/index.js +2 -0
- package/lib/components/CodeView/CodeView.js +2 -2
- package/lib/components/ListView/ListView.stories.js +3 -0
- package/lib/components/Loader/Loader.stories.js +1 -1
- package/lib/components/Modal/Modal.js +4 -1
- package/lib/components/Modal/Modal.stories.js +10 -59
- package/lib/components/NavBar/NavBar.js +25 -4
- package/lib/components/NavBar/NavBar.stories.js +71 -462
- package/lib/components/NavBar/NavBar.test.js +39 -2
- package/lib/components/NavBarSection/NavBarItem.js +111 -0
- package/lib/components/NavBarSection/NavBarItemButton.js +69 -0
- package/lib/components/NavBarSection/NavBarItemHeader.js +1 -1
- package/lib/components/NavBarSection/NavBarItemLink.js +71 -0
- package/lib/components/NavBarSection/NavBarSection.js +9 -8
- package/lib/components/NavBarSection/index.js +4 -1
- package/lib/components/SelectFieldBase/SelectFieldBase.js +8 -1
- package/lib/context/NavBarContext/index.js +5 -0
- package/lib/hooks/index.js +1 -0
- package/lib/hooks/useNavBarPress/index.js +1 -0
- package/lib/hooks/useNavBarPress/useNavBarPress.js +27 -0
- package/lib/hooks/useNavBarPress/useNavBarPress.test.js +36 -0
- package/lib/index.js +2 -0
- package/lib/styles/variants/accordion.js +26 -5
- package/lib/styles/variants/boxes.js +1 -24
- package/lib/styles/variants/buttons.js +7 -1
- package/lib/styles/variants/codeView.js +91 -0
- package/lib/styles/variants/navBar.js +46 -0
- package/lib/styles/variants/separator.js +2 -1
- package/lib/styles/variants/text.js +3 -1
- package/lib/styles/variants/variants.js +2 -0
- package/package.json +3 -1
- package/lib/cjs/recipes/ArrayField.stories.js +0 -169
- package/lib/recipes/ArrayField.stories.js +0 -134
@@ -1,3 +1,93 @@
|
|
1
|
+
var theme = {
|
2
|
+
plain: {
|
3
|
+
color: '#545454',
|
4
|
+
background: 'none',
|
5
|
+
lineHeight: 1.5,
|
6
|
+
tabSize: 4
|
7
|
+
},
|
8
|
+
styles: [{
|
9
|
+
types: ['prolog', 'constant', 'builtin'],
|
10
|
+
style: {
|
11
|
+
color: 'rgb(189, 147, 249)'
|
12
|
+
}
|
13
|
+
}, {
|
14
|
+
types: ['inserted', 'function'],
|
15
|
+
style: {
|
16
|
+
color: 'rgb(80, 250, 123)'
|
17
|
+
}
|
18
|
+
}, {
|
19
|
+
types: ['deleted'],
|
20
|
+
style: {
|
21
|
+
color: 'rgb(255, 85, 85)'
|
22
|
+
}
|
23
|
+
}, {
|
24
|
+
types: ['changed'],
|
25
|
+
style: {
|
26
|
+
color: 'rgb(255, 184, 108)'
|
27
|
+
}
|
28
|
+
}, {
|
29
|
+
types: ['punctuation', 'symbol'],
|
30
|
+
style: {
|
31
|
+
color: 'rgb(248, 248, 242)'
|
32
|
+
}
|
33
|
+
}, {
|
34
|
+
types: ['string', 'char', 'tag', 'selector'],
|
35
|
+
style: {
|
36
|
+
color: 'rgb(255, 121, 198)'
|
37
|
+
}
|
38
|
+
}, {
|
39
|
+
types: ['keyword', 'variable'],
|
40
|
+
style: {
|
41
|
+
color: 'rgb(189, 147, 249)',
|
42
|
+
fontStyle: 'italic'
|
43
|
+
}
|
44
|
+
}, {
|
45
|
+
types: ['comment'],
|
46
|
+
style: {
|
47
|
+
color: 'rgb(98, 114, 164)'
|
48
|
+
}
|
49
|
+
}, {
|
50
|
+
types: ['attr-name'],
|
51
|
+
style: {
|
52
|
+
color: 'rgb(241, 250, 140)'
|
53
|
+
}
|
54
|
+
}, {
|
55
|
+
types: ['comment', 'prolog', 'doctype', 'cdata'],
|
56
|
+
style: {
|
57
|
+
color: '#696969'
|
58
|
+
}
|
59
|
+
}, {
|
60
|
+
types: ['punctuation'],
|
61
|
+
style: {
|
62
|
+
color: '#545454'
|
63
|
+
}
|
64
|
+
}, {
|
65
|
+
types: ['property', 'tag', 'constant', 'symbol', 'deleted'],
|
66
|
+
style: {
|
67
|
+
color: '#007299'
|
68
|
+
}
|
69
|
+
}, {
|
70
|
+
types: ['boolean', 'number', 'operator', 'entity', 'url', 'variable'],
|
71
|
+
style: {
|
72
|
+
color: '#008000'
|
73
|
+
}
|
74
|
+
}, {
|
75
|
+
types: ['selector', 'attr-name', 'char', 'builtin', 'inserted', 'atrule', 'attr-value', 'function', 'string'],
|
76
|
+
style: {
|
77
|
+
color: '#aa5d00'
|
78
|
+
}
|
79
|
+
}, {
|
80
|
+
types: ['keyword', 'regex', 'important'],
|
81
|
+
style: {
|
82
|
+
color: '#d91e18'
|
83
|
+
}
|
84
|
+
}, {
|
85
|
+
types: ['keyword'],
|
86
|
+
style: {
|
87
|
+
fontStyle: 'normal'
|
88
|
+
}
|
89
|
+
}]
|
90
|
+
};
|
1
91
|
var wrapper = {
|
2
92
|
bg: 'accent.99',
|
3
93
|
border: '1px solid',
|
@@ -62,6 +152,7 @@ var lineNo = {
|
|
62
152
|
color: 'white'
|
63
153
|
};
|
64
154
|
export default {
|
155
|
+
theme: theme,
|
65
156
|
wrapper: wrapper,
|
66
157
|
lineNo: lineNo
|
67
158
|
};
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
2
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
3
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
4
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
5
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
6
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
7
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
8
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
9
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
|
+
|
11
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
12
|
+
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty(_context = ownKeys(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context2; _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
14
|
+
|
15
|
+
import accordion from './accordion';
|
16
|
+
var container = {
|
17
|
+
height: '100%',
|
18
|
+
width: '230px',
|
19
|
+
position: 'absolute',
|
20
|
+
zIndex: '1',
|
21
|
+
top: '0',
|
22
|
+
left: '0',
|
23
|
+
backgroundColor: 'accent.20',
|
24
|
+
overflowY: 'hidden'
|
25
|
+
};
|
26
|
+
var itemHeaderContainer = {
|
27
|
+
flexGrow: 1,
|
28
|
+
alignItems: 'center',
|
29
|
+
maxWidth: '180px'
|
30
|
+
};
|
31
|
+
var sectionContainer = {
|
32
|
+
height: '100%',
|
33
|
+
maxHeight: '100%',
|
34
|
+
overflowY: 'overlay !important'
|
35
|
+
};
|
36
|
+
|
37
|
+
var sectionBody = _objectSpread(_objectSpread({}, accordion.accordionGridBody), {}, {
|
38
|
+
pl: '0'
|
39
|
+
});
|
40
|
+
|
41
|
+
export default {
|
42
|
+
container: container,
|
43
|
+
itemHeaderContainer: itemHeaderContainer,
|
44
|
+
sectionContainer: sectionContainer,
|
45
|
+
sectionBody: sectionBody
|
46
|
+
};
|
@@ -30,9 +30,10 @@ var navBarSeparator = _objectSpread(_objectSpread({}, base), {}, {
|
|
30
30
|
});
|
31
31
|
|
32
32
|
var navBarSubtitleSeparator = _objectSpread(_objectSpread({}, base), {}, {
|
33
|
+
mt: 'sm',
|
34
|
+
mb: '20px',
|
33
35
|
ml: '45px',
|
34
36
|
width: 'calc(100% - 75px)',
|
35
|
-
mb: '15px',
|
36
37
|
backgroundColor: 'neutral.60'
|
37
38
|
});
|
38
39
|
|
@@ -28,7 +28,7 @@ var wordWrap = {
|
|
28
28
|
};
|
29
29
|
|
30
30
|
var tabLabel = _objectSpread(_objectSpread(_objectSpread({}, base), wordWrap), {}, {
|
31
|
-
fontSize: '
|
31
|
+
fontSize: 'sm',
|
32
32
|
fontWeight: 1,
|
33
33
|
mb: 6,
|
34
34
|
color: 'neutral.40',
|
@@ -128,6 +128,8 @@ var environmentBreadcrumb = _objectSpread(_objectSpread({}, base), {}, {
|
|
128
128
|
});
|
129
129
|
|
130
130
|
var navBarSubtitle = {
|
131
|
+
my: 'md',
|
132
|
+
ml: 'md',
|
131
133
|
fontWeight: 3,
|
132
134
|
fontSize: '11px',
|
133
135
|
color: 'accent.80'
|
@@ -24,6 +24,7 @@ import modal from './modal';
|
|
24
24
|
import menu from './menu';
|
25
25
|
import menuItem from './menuItem';
|
26
26
|
import messages from './messages';
|
27
|
+
import navBar from './navBar';
|
27
28
|
import numberField from './numberField';
|
28
29
|
import overlayPanel from './overlayPanel';
|
29
30
|
import popoverMenu from './popoverMenu';
|
@@ -46,6 +47,7 @@ export default _objectSpread(_objectSpread({
|
|
46
47
|
menuItem: menuItem,
|
47
48
|
messages: messages,
|
48
49
|
modal: modal,
|
50
|
+
navBar: navBar,
|
49
51
|
numberField: numberField,
|
50
52
|
overlayPanel: overlayPanel,
|
51
53
|
popoverMenu: popoverMenu,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pingux/astro",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.3.0",
|
4
4
|
"description": "PingUX themeable React component library",
|
5
5
|
"author": "ux-development@pingidentity.com",
|
6
6
|
"license": "Apache-2.0",
|
@@ -38,9 +38,11 @@
|
|
38
38
|
"@emotion/eslint-plugin": "^11.2.0",
|
39
39
|
"@storybook/addon-a11y": "^6.1.16",
|
40
40
|
"@storybook/addon-actions": "^6.1.16",
|
41
|
+
"@storybook/addon-console": "^1.2.3",
|
41
42
|
"@storybook/addon-docs": "^6.1.16",
|
42
43
|
"@storybook/addon-essentials": "^6.1.16",
|
43
44
|
"@storybook/addon-links": "^6.1.16",
|
45
|
+
"@storybook/addon-storysource": "^6.4.14",
|
44
46
|
"@storybook/addons": "^6.1.16",
|
45
47
|
"@storybook/react": "^6.1.16",
|
46
48
|
"@storybook/theming": "^6.1.16",
|
@@ -1,169 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard");
|
4
|
-
|
5
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
6
|
-
|
7
|
-
var _Object$defineProperty2 = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
8
|
-
|
9
|
-
_Object$defineProperty2(exports, "__esModule", {
|
10
|
-
value: true
|
11
|
-
});
|
12
|
-
|
13
|
-
exports.Default = exports["default"] = void 0;
|
14
|
-
|
15
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-property"));
|
16
|
-
|
17
|
-
var _defineProperties = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-properties"));
|
18
|
-
|
19
|
-
var _getOwnPropertyDescriptors = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors"));
|
20
|
-
|
21
|
-
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
22
|
-
|
23
|
-
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor"));
|
24
|
-
|
25
|
-
var _getOwnPropertySymbols = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols"));
|
26
|
-
|
27
|
-
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
28
|
-
|
29
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
30
|
-
|
31
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
32
|
-
|
33
|
-
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
34
|
-
|
35
|
-
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
|
36
|
-
|
37
|
-
var _defineProperty3 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
38
|
-
|
39
|
-
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
40
|
-
|
41
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
42
|
-
|
43
|
-
var _react = _interopRequireWildcard(require("react"));
|
44
|
-
|
45
|
-
var _TrashIcon = _interopRequireDefault(require("mdi-react/TrashIcon"));
|
46
|
-
|
47
|
-
var _uuid = require("uuid");
|
48
|
-
|
49
|
-
var _index = require("../index");
|
50
|
-
|
51
|
-
var _react2 = require("@emotion/react");
|
52
|
-
|
53
|
-
function ownKeys(object, enumerableOnly) { var keys = (0, _keys["default"])(object); if (_getOwnPropertySymbols["default"]) { var symbols = (0, _getOwnPropertySymbols["default"])(object); if (enumerableOnly) symbols = (0, _filter["default"])(symbols).call(symbols, function (sym) { return (0, _getOwnPropertyDescriptor["default"])(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
54
|
-
|
55
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context2; (0, _forEach["default"])(_context2 = ownKeys(Object(source), true)).call(_context2, function (key) { (0, _defineProperty3["default"])(target, key, source[key]); }); } else if (_getOwnPropertyDescriptors["default"]) { (0, _defineProperties["default"])(target, (0, _getOwnPropertyDescriptors["default"])(source)); } else { var _context3; (0, _forEach["default"])(_context3 = ownKeys(Object(source))).call(_context3, function (key) { (0, _defineProperty2["default"])(target, key, (0, _getOwnPropertyDescriptor["default"])(source, key)); }); } } return target; }
|
56
|
-
|
57
|
-
var _default = {
|
58
|
-
title: 'Recipes/ArrayField'
|
59
|
-
};
|
60
|
-
exports["default"] = _default;
|
61
|
-
|
62
|
-
var Default = function Default() {
|
63
|
-
var createEmptyField = (0, _react.useCallback)(function () {
|
64
|
-
return {
|
65
|
-
id: (0, _uuid.v4)(),
|
66
|
-
value: '',
|
67
|
-
'aria-label': 'array field input'
|
68
|
-
};
|
69
|
-
}, []);
|
70
|
-
|
71
|
-
var _useState = (0, _react.useState)([createEmptyField()]),
|
72
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
73
|
-
fieldValues = _useState2[0],
|
74
|
-
setFieldValues = _useState2[1];
|
75
|
-
|
76
|
-
var mapArrayFieldWithNewValue = (0, _react.useCallback)(function (arrValues, newValue, fieldId) {
|
77
|
-
return (0, _map["default"])(arrValues).call(arrValues, function (fieldValue) {
|
78
|
-
if (fieldValue.id === fieldId) {
|
79
|
-
return _objectSpread(_objectSpread({}, fieldValue), {}, {
|
80
|
-
value: newValue
|
81
|
-
});
|
82
|
-
}
|
83
|
-
|
84
|
-
return fieldValue;
|
85
|
-
});
|
86
|
-
}, []);
|
87
|
-
var onFieldValueChange = (0, _react.useCallback)(function (_ref, fieldId) {
|
88
|
-
var newValue = _ref.target.value;
|
89
|
-
setFieldValues(function (oldValues) {
|
90
|
-
return mapArrayFieldWithNewValue(oldValues, newValue, fieldId);
|
91
|
-
});
|
92
|
-
}, []);
|
93
|
-
var onFieldDelete = (0, _react.useCallback)(function (fieldId) {
|
94
|
-
setFieldValues(function (oldValues) {
|
95
|
-
return (0, _filter["default"])(oldValues).call(oldValues, function (_ref2) {
|
96
|
-
var id = _ref2.id;
|
97
|
-
return id !== fieldId;
|
98
|
-
});
|
99
|
-
});
|
100
|
-
}, []);
|
101
|
-
var onFieldAdd = (0, _react.useCallback)(function () {
|
102
|
-
setFieldValues(function (oldValues) {
|
103
|
-
var _context;
|
104
|
-
|
105
|
-
return (0, _concat["default"])(_context = []).call(_context, oldValues, [createEmptyField()]);
|
106
|
-
});
|
107
|
-
}, []);
|
108
|
-
|
109
|
-
var DeleteButton = function DeleteButton(_ref3) {
|
110
|
-
var id = _ref3.id;
|
111
|
-
return (0, _react2.jsx)(_index.IconButton, {
|
112
|
-
onPress: function onPress() {
|
113
|
-
return onFieldDelete(id);
|
114
|
-
},
|
115
|
-
isDisabled: fieldValues.length === 1,
|
116
|
-
sx: {
|
117
|
-
position: 'absolute',
|
118
|
-
right: -30,
|
119
|
-
top: 5,
|
120
|
-
width: 'auto'
|
121
|
-
},
|
122
|
-
type: "delete",
|
123
|
-
title: "Delete Field"
|
124
|
-
}, (0, _react2.jsx)(_index.Icon, {
|
125
|
-
icon: _TrashIcon["default"],
|
126
|
-
size: 20,
|
127
|
-
color: "black"
|
128
|
-
}));
|
129
|
-
};
|
130
|
-
|
131
|
-
return (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Text, {
|
132
|
-
variant: "label"
|
133
|
-
}, "Redirected URIs"), (0, _map["default"])(fieldValues).call(fieldValues, function (_ref4) {
|
134
|
-
var id = _ref4.id,
|
135
|
-
value = _ref4.value,
|
136
|
-
otherFieldProps = (0, _objectWithoutProperties2["default"])(_ref4, ["id", "value"]);
|
137
|
-
return (0, _react2.jsx)(_index.Box, {
|
138
|
-
isRow: true,
|
139
|
-
mb: "sm",
|
140
|
-
alignItems: "center",
|
141
|
-
key: id
|
142
|
-
}, (0, _react2.jsx)(_index.TextField, (0, _extends2["default"])({
|
143
|
-
value: value,
|
144
|
-
onChange: function onChange(e) {
|
145
|
-
return onFieldValueChange(e, id);
|
146
|
-
},
|
147
|
-
mr: "xs",
|
148
|
-
slots: {
|
149
|
-
inContainer: (0, _react2.jsx)(DeleteButton, {
|
150
|
-
id: id
|
151
|
-
})
|
152
|
-
},
|
153
|
-
title: "Text Field"
|
154
|
-
}, otherFieldProps)));
|
155
|
-
}), (0, _react2.jsx)(_index.Button, {
|
156
|
-
variant: "link",
|
157
|
-
onPress: onFieldAdd,
|
158
|
-
role: "button",
|
159
|
-
title: "Add Field Button",
|
160
|
-
sx: {
|
161
|
-
width: 'fit-content'
|
162
|
-
}
|
163
|
-
}, (0, _react2.jsx)(_index.Text, {
|
164
|
-
variant: "label",
|
165
|
-
color: "active"
|
166
|
-
}, "+ Add")));
|
167
|
-
};
|
168
|
-
|
169
|
-
exports.Default = Default;
|
@@ -1,134 +0,0 @@
|
|
1
|
-
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
2
|
-
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
3
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
4
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
5
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
6
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
7
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
8
|
-
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
9
|
-
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
10
|
-
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
11
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
12
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
13
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
14
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
15
|
-
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
17
|
-
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context2; _forEachInstanceProperty(_context2 = ownKeys(Object(source), true)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context3; _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
19
|
-
|
20
|
-
import React, { useCallback, useState } from 'react';
|
21
|
-
import TrashIcon from 'mdi-react/TrashIcon';
|
22
|
-
import { v4 as uuid } from 'uuid';
|
23
|
-
import { Box, Button, Icon, Text, TextField, IconButton } from '../index';
|
24
|
-
import { jsx as ___EmotionJSX } from "@emotion/react";
|
25
|
-
export default {
|
26
|
-
title: 'Recipes/ArrayField'
|
27
|
-
};
|
28
|
-
export var Default = function Default() {
|
29
|
-
var createEmptyField = useCallback(function () {
|
30
|
-
return {
|
31
|
-
id: uuid(),
|
32
|
-
value: '',
|
33
|
-
'aria-label': 'array field input'
|
34
|
-
};
|
35
|
-
}, []);
|
36
|
-
|
37
|
-
var _useState = useState([createEmptyField()]),
|
38
|
-
_useState2 = _slicedToArray(_useState, 2),
|
39
|
-
fieldValues = _useState2[0],
|
40
|
-
setFieldValues = _useState2[1];
|
41
|
-
|
42
|
-
var mapArrayFieldWithNewValue = useCallback(function (arrValues, newValue, fieldId) {
|
43
|
-
return _mapInstanceProperty(arrValues).call(arrValues, function (fieldValue) {
|
44
|
-
if (fieldValue.id === fieldId) {
|
45
|
-
return _objectSpread(_objectSpread({}, fieldValue), {}, {
|
46
|
-
value: newValue
|
47
|
-
});
|
48
|
-
}
|
49
|
-
|
50
|
-
return fieldValue;
|
51
|
-
});
|
52
|
-
}, []);
|
53
|
-
var onFieldValueChange = useCallback(function (_ref, fieldId) {
|
54
|
-
var newValue = _ref.target.value;
|
55
|
-
setFieldValues(function (oldValues) {
|
56
|
-
return mapArrayFieldWithNewValue(oldValues, newValue, fieldId);
|
57
|
-
});
|
58
|
-
}, []);
|
59
|
-
var onFieldDelete = useCallback(function (fieldId) {
|
60
|
-
setFieldValues(function (oldValues) {
|
61
|
-
return _filterInstanceProperty(oldValues).call(oldValues, function (_ref2) {
|
62
|
-
var id = _ref2.id;
|
63
|
-
return id !== fieldId;
|
64
|
-
});
|
65
|
-
});
|
66
|
-
}, []);
|
67
|
-
var onFieldAdd = useCallback(function () {
|
68
|
-
setFieldValues(function (oldValues) {
|
69
|
-
var _context;
|
70
|
-
|
71
|
-
return _concatInstanceProperty(_context = []).call(_context, oldValues, [createEmptyField()]);
|
72
|
-
});
|
73
|
-
}, []);
|
74
|
-
|
75
|
-
var DeleteButton = function DeleteButton(_ref3) {
|
76
|
-
var id = _ref3.id;
|
77
|
-
return ___EmotionJSX(IconButton, {
|
78
|
-
onPress: function onPress() {
|
79
|
-
return onFieldDelete(id);
|
80
|
-
},
|
81
|
-
isDisabled: fieldValues.length === 1,
|
82
|
-
sx: {
|
83
|
-
position: 'absolute',
|
84
|
-
right: -30,
|
85
|
-
top: 5,
|
86
|
-
width: 'auto'
|
87
|
-
},
|
88
|
-
type: "delete",
|
89
|
-
title: "Delete Field"
|
90
|
-
}, ___EmotionJSX(Icon, {
|
91
|
-
icon: TrashIcon,
|
92
|
-
size: 20,
|
93
|
-
color: "black"
|
94
|
-
}));
|
95
|
-
};
|
96
|
-
|
97
|
-
return ___EmotionJSX(Box, null, ___EmotionJSX(Text, {
|
98
|
-
variant: "label"
|
99
|
-
}, "Redirected URIs"), _mapInstanceProperty(fieldValues).call(fieldValues, function (_ref4) {
|
100
|
-
var id = _ref4.id,
|
101
|
-
value = _ref4.value,
|
102
|
-
otherFieldProps = _objectWithoutProperties(_ref4, ["id", "value"]);
|
103
|
-
|
104
|
-
return ___EmotionJSX(Box, {
|
105
|
-
isRow: true,
|
106
|
-
mb: "sm",
|
107
|
-
alignItems: "center",
|
108
|
-
key: id
|
109
|
-
}, ___EmotionJSX(TextField, _extends({
|
110
|
-
value: value,
|
111
|
-
onChange: function onChange(e) {
|
112
|
-
return onFieldValueChange(e, id);
|
113
|
-
},
|
114
|
-
mr: "xs",
|
115
|
-
slots: {
|
116
|
-
inContainer: ___EmotionJSX(DeleteButton, {
|
117
|
-
id: id
|
118
|
-
})
|
119
|
-
},
|
120
|
-
title: "Text Field"
|
121
|
-
}, otherFieldProps)));
|
122
|
-
}), ___EmotionJSX(Button, {
|
123
|
-
variant: "link",
|
124
|
-
onPress: onFieldAdd,
|
125
|
-
role: "button",
|
126
|
-
title: "Add Field Button",
|
127
|
-
sx: {
|
128
|
-
width: 'fit-content'
|
129
|
-
}
|
130
|
-
}, ___EmotionJSX(Text, {
|
131
|
-
variant: "label",
|
132
|
-
color: "active"
|
133
|
-
}, "+ Add")));
|
134
|
-
};
|