@assembly-js/design-system 3.1.8 → 3.1.10
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/dist/esm/components/Checkbox/Checkbox.js +1 -1
- package/dist/esm/components/Chip/Chip.js +2 -8
- package/dist/esm/components/Icon.js +2 -10
- package/dist/esm/components/IconPicker/IconPicker.js +12 -7
- package/dist/esm/components/IconPicker/index.js +1 -0
- package/dist/esm/components/TextLink/TextLink.js +1 -1
- package/dist/esm/components/Typography/Base.js +1 -1
- package/dist/esm/components/__tests__/Icon.test.js +82 -0
- package/dist/esm/components/iconType.js +21 -0
- package/dist/esm/types/components/Icon.d.ts +2 -3
- package/dist/esm/types/components/IconPicker/IconPicker.d.ts +3 -0
- package/dist/esm/types/components/IconPicker/IconPicker.stories.d.ts +1 -0
- package/dist/esm/types/components/IconPicker/index.d.ts +2 -0
- package/dist/esm/types/components/__tests__/Icon.test.d.ts +1 -0
- package/dist/esm/types/components/iconType.d.ts +5 -0
- package/dist/esm/types/tsconfig.tsbuildinfo +1 -1
- package/dist/styles/main.css +1 -1
- package/dist/types/components/Icon.d.ts +2 -3
- package/dist/types/components/IconPicker/IconPicker.d.ts +3 -0
- package/dist/types/components/IconPicker/IconPicker.stories.d.ts +1 -0
- package/dist/types/components/IconPicker/index.d.ts +2 -0
- package/dist/types/components/__tests__/Icon.test.d.ts +1 -0
- package/dist/types/components/iconType.d.ts +5 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/umd/components/Checkbox/Checkbox.js +1 -1
- package/dist/umd/components/Chip/Chip.js +5 -12
- package/dist/umd/components/Icon.js +11 -15
- package/dist/umd/components/IconPicker/IconPicker.js +12 -7
- package/dist/umd/components/IconPicker/index.js +10 -4
- package/dist/umd/components/TextLink/TextLink.js +1 -1
- package/dist/umd/components/Typography/Base.js +1 -1
- package/dist/umd/components/__tests__/Icon.test.js +98 -0
- package/dist/umd/components/iconType.js +43 -0
- package/dist/umd/types/components/Icon.d.ts +2 -3
- package/dist/umd/types/components/IconPicker/IconPicker.d.ts +3 -0
- package/dist/umd/types/components/IconPicker/IconPicker.stories.d.ts +1 -0
- package/dist/umd/types/components/IconPicker/index.d.ts +2 -0
- package/dist/umd/types/components/__tests__/Icon.test.d.ts +1 -0
- package/dist/umd/types/components/iconType.d.ts +5 -0
- package/dist/umd/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
return CheckboxSize;
|
|
36
36
|
}({});
|
|
37
37
|
var checkboxContainerStyles = (0, _cva.cva)({
|
|
38
|
-
base: 'cop-box-border cop-flex cop-cursor-pointer cop-rounded-[3px] cop-border cop-border-solid cop-p-0 cop-outline-none
|
|
38
|
+
base: 'cop-box-border cop-flex cop-cursor-pointer cop-rounded-[3px] cop-border cop-border-solid cop-p-0 cop-outline-none peer-focus-visible:cop-outline-2 peer-focus-visible:cop-outline-[#0071E3] cop-justify-center cop-items-center',
|
|
39
39
|
variants: {
|
|
40
40
|
size: _defineProperty(_defineProperty({}, CheckboxSize.DEFAULT, 'cop-h-4 cop-w-4'), CheckboxSize.LARGE, 'cop-h-[18px] cop-w-[18px]'),
|
|
41
41
|
checked: {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// This file is generated by a script. Do not edit this file directly.
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
if (typeof define === "function" && define.amd) {
|
|
4
|
-
define(["exports", "cva", "react", "../Typography", "../../common/utils", "../Icon", "
|
|
4
|
+
define(["exports", "cva", "react", "../Typography", "../../common/utils", "../Icon", "./ChipColorDisplay"], factory);
|
|
5
5
|
} else if (typeof exports !== "undefined") {
|
|
6
|
-
factory(exports, require("cva"), require("react"), require("../Typography"), require("../../common/utils"), require("../Icon"), require("
|
|
6
|
+
factory(exports, require("cva"), require("react"), require("../Typography"), require("../../common/utils"), require("../Icon"), require("./ChipColorDisplay"));
|
|
7
7
|
} else {
|
|
8
8
|
var mod = {
|
|
9
9
|
exports: {}
|
|
10
10
|
};
|
|
11
|
-
factory(mod.exports, global.cva, global.react, global.Typography, global.utils, global.Icon, global.
|
|
11
|
+
factory(mod.exports, global.cva, global.react, global.Typography, global.utils, global.Icon, global.ChipColorDisplay);
|
|
12
12
|
global.Chip = mod.exports;
|
|
13
13
|
}
|
|
14
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _cva, _react, _Typography, _utils, _Icon,
|
|
14
|
+
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _cva, _react, _Typography, _utils, _Icon, _ChipColorDisplay) {
|
|
15
15
|
"use strict";
|
|
16
16
|
|
|
17
17
|
Object.defineProperty(_exports, "__esModule", {
|
|
@@ -19,9 +19,6 @@
|
|
|
19
19
|
});
|
|
20
20
|
_exports.Chip = void 0;
|
|
21
21
|
_react = _interopRequireDefault(_react);
|
|
22
|
-
icons = _interopRequireWildcard(icons);
|
|
23
|
-
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); }
|
|
24
|
-
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; }
|
|
25
22
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
26
23
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
27
24
|
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; }
|
|
@@ -29,10 +26,6 @@
|
|
|
29
26
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
30
27
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
31
28
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
32
|
-
// Type guard function to validate IconType
|
|
33
|
-
var isIconType = function isIconType(icon) {
|
|
34
|
-
return typeof icon === 'string' && Object.keys(icons).includes(icon);
|
|
35
|
-
};
|
|
36
29
|
var chipStyles = (0, _cva.cva)({
|
|
37
30
|
base: 'cop-inline-flex cop-items-center cop-justify-center cop-gap-1.5 cop-rounded-[4px] cop-border cop-border-solid cop-box-border',
|
|
38
31
|
variants: {
|
|
@@ -91,7 +84,7 @@
|
|
|
91
84
|
if (!icon) {
|
|
92
85
|
return null;
|
|
93
86
|
}
|
|
94
|
-
if (
|
|
87
|
+
if ((0, _Icon.isValidIconType)(icon)) {
|
|
95
88
|
return /*#__PURE__*/_react["default"].createElement(_Icon.Icon, {
|
|
96
89
|
icon: icon,
|
|
97
90
|
className: className
|
|
@@ -2,23 +2,29 @@
|
|
|
2
2
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
if (typeof define === "function" && define.amd) {
|
|
5
|
-
define(["exports", "react", "../icons", "
|
|
5
|
+
define(["exports", "react", "../icons", "../constants/iconToFaMap", "./iconType"], factory);
|
|
6
6
|
} else if (typeof exports !== "undefined") {
|
|
7
|
-
factory(exports, require("react"), require("../icons"), require("
|
|
7
|
+
factory(exports, require("react"), require("../icons"), require("../constants/iconToFaMap"), require("./iconType"));
|
|
8
8
|
} else {
|
|
9
9
|
var mod = {
|
|
10
10
|
exports: {}
|
|
11
11
|
};
|
|
12
|
-
factory(mod.exports, global.react, global.icons, global.
|
|
12
|
+
factory(mod.exports, global.react, global.icons, global.iconToFaMap, global.iconType);
|
|
13
13
|
global.Icon = mod.exports;
|
|
14
14
|
}
|
|
15
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _react, icons,
|
|
15
|
+
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _react, icons, _iconToFaMap, _iconType) {
|
|
16
16
|
"use strict";
|
|
17
17
|
|
|
18
18
|
Object.defineProperty(_exports, "__esModule", {
|
|
19
19
|
value: true
|
|
20
20
|
});
|
|
21
21
|
_exports.Icon = void 0;
|
|
22
|
+
Object.defineProperty(_exports, "isValidIconType", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function get() {
|
|
25
|
+
return _iconType.isValidIconType;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
22
28
|
_react = _interopRequireDefault(_react);
|
|
23
29
|
icons = _interopRequireWildcard(icons);
|
|
24
30
|
var _excluded = ["icon"];
|
|
@@ -28,16 +34,6 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
28
34
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
29
35
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
30
36
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
|
|
31
|
-
var faIconMap;
|
|
32
|
-
function getFAIconMap() {
|
|
33
|
-
if (!faIconMap) {
|
|
34
|
-
faIconMap = new Map(_icons2.icons.map(function (i) {
|
|
35
|
-
return [i.name, i];
|
|
36
|
-
}));
|
|
37
|
-
}
|
|
38
|
-
return faIconMap;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
37
|
/**
|
|
42
38
|
* Icon component that renders either a Font Awesome icon or a Design System icon.
|
|
43
39
|
* it checks if the icon name is in the Font Awesome icon set and renders the corresponding icon.
|
|
@@ -52,7 +48,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
52
48
|
var mappedFaIcon = _iconToFaMap.iconToFaMap[icon];
|
|
53
49
|
|
|
54
50
|
// if the icon name has a mapped fa icon, render the mapped fa icon, otherwise render the fa icon
|
|
55
|
-
var faIcon = mappedFaIcon ? getFAIconMap().get(mappedFaIcon) : getFAIconMap().get(icon);
|
|
51
|
+
var faIcon = mappedFaIcon ? (0, _iconType.getFAIconMap)().get(mappedFaIcon) : (0, _iconType.getFAIconMap)().get(icon);
|
|
56
52
|
if (faIcon) {
|
|
57
53
|
return /*#__PURE__*/_react["default"].createElement("svg", _extends({
|
|
58
54
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -39,7 +39,8 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
39
39
|
placeholder = _ref$placeholder === void 0 ? 'Select an icon' : _ref$placeholder,
|
|
40
40
|
className = _ref.className,
|
|
41
41
|
_ref$disabled = _ref.disabled,
|
|
42
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled
|
|
42
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
43
|
+
inlineAction = _ref.inlineAction;
|
|
43
44
|
var isControlled = value !== undefined;
|
|
44
45
|
var _React$useState = React.useState(defaultValue),
|
|
45
46
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
@@ -190,12 +191,15 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
190
191
|
return document.removeEventListener('keydown', handleKeyDown);
|
|
191
192
|
};
|
|
192
193
|
}, [open]);
|
|
194
|
+
var closeAndReset = React.useCallback(function () {
|
|
195
|
+
setOpen(false);
|
|
196
|
+
setSearch('');
|
|
197
|
+
}, []);
|
|
193
198
|
var handleSelect = React.useCallback(function (icon) {
|
|
194
199
|
if (!isControlled) setInternalValue(icon.name);
|
|
195
200
|
onChange === null || onChange === void 0 || onChange(icon.name);
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}, [isControlled, onChange]);
|
|
201
|
+
closeAndReset();
|
|
202
|
+
}, [isControlled, onChange, closeAndReset]);
|
|
199
203
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
200
204
|
ref: triggerRef,
|
|
201
205
|
className: "cop-inline-flex"
|
|
@@ -232,8 +236,9 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
232
236
|
},
|
|
233
237
|
className: "cop-fixed cop-z-1500 cop-w-[330px] cop-overflow-clip cop-rounded cop-border cop-border-solid cop-border-[#eff1f4] cop-bg-white cop-shadow-[0px_6px_20px_0px_rgba(0,0,0,0.07)]"
|
|
234
238
|
}, /*#__PURE__*/React.createElement("div", {
|
|
235
|
-
className: "cop-px-3 cop-pt-3"
|
|
239
|
+
className: "cop-flex cop-items-center cop-gap-2 cop-px-3 cop-pt-3"
|
|
236
240
|
}, /*#__PURE__*/React.createElement(_Input.Input, {
|
|
241
|
+
containerClassName: "cop-flex-1 cop-min-w-0",
|
|
237
242
|
ref: searchInputRef,
|
|
238
243
|
placeholder: "Search icons",
|
|
239
244
|
value: search,
|
|
@@ -251,8 +256,8 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
251
256
|
(_gridRef$current2 = gridRef.current) === null || _gridRef$current2 === void 0 || _gridRef$current2.focusFirst();
|
|
252
257
|
}
|
|
253
258
|
},
|
|
254
|
-
className: "focus-visible
|
|
255
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
259
|
+
className: "cop-h-8 !cop-border-input-gray focus-visible:!cop-border-[#1a1a1a] focus-visible:cop-ring-0 focus-visible:cop-ring-offset-0"
|
|
260
|
+
}), inlineAction === null || inlineAction === void 0 ? void 0 : inlineAction(closeAndReset)), /*#__PURE__*/React.createElement("div", {
|
|
256
261
|
className: "cop-py-3 cop-pl-3 cop-pr-0"
|
|
257
262
|
}, /*#__PURE__*/React.createElement(_IconGrid.IconGrid, {
|
|
258
263
|
ref: gridRef,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// This file is generated by a script. Do not edit this file directly.
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
if (typeof define === "function" && define.amd) {
|
|
4
|
-
define(["exports", "react", "./IconPicker"], factory);
|
|
4
|
+
define(["exports", "react", "./IconPicker", "./pickerIcons"], factory);
|
|
5
5
|
} else if (typeof exports !== "undefined") {
|
|
6
|
-
factory(exports, require("react"), require("./IconPicker"));
|
|
6
|
+
factory(exports, require("react"), require("./IconPicker"), require("./pickerIcons"));
|
|
7
7
|
} else {
|
|
8
8
|
var mod = {
|
|
9
9
|
exports: {}
|
|
10
10
|
};
|
|
11
|
-
factory(mod.exports, global.react, global.IconPicker);
|
|
11
|
+
factory(mod.exports, global.react, global.IconPicker, global.pickerIcons);
|
|
12
12
|
global.index = mod.exports;
|
|
13
13
|
}
|
|
14
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _react, _IconPicker) {
|
|
14
|
+
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _react, _IconPicker, _pickerIcons) {
|
|
15
15
|
"use strict";
|
|
16
16
|
|
|
17
17
|
Object.defineProperty(_exports, "__esModule", {
|
|
@@ -23,6 +23,12 @@
|
|
|
23
23
|
return _IconPicker.IconPicker;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
+
Object.defineProperty(_exports, "pickerIcons", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function get() {
|
|
29
|
+
return _pickerIcons.pickerIcons;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
26
32
|
_react = _interopRequireDefault(_react);
|
|
27
33
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
28
34
|
});
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
26
26
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
|
|
27
27
|
var textLinkClasses = (0, _cva.cva)({
|
|
28
|
-
base: 'cop-flex cop-items-center cop-gap-1.5 outline-none cop-outline-solid cop-outline-link cop-outline-offset-[3px] cop-w-fit cop-underline-offset-[3px] cursor-pointer',
|
|
28
|
+
base: 'cop-flex cop-items-center cop-gap-1.5 cop-outline-none cop-outline-solid cop-outline-link cop-outline-offset-[3px] cop-w-fit cop-underline-offset-[3px] cop-cursor-pointer',
|
|
29
29
|
variants: {
|
|
30
30
|
variant: {
|
|
31
31
|
"default": 'cop-text-link cop-no-underline hover:cop-text-link-hover active:cop-text-link-active',
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// This file is generated by a script. Do not edit this file directly.
|
|
2
|
+
(function (global, factory) {
|
|
3
|
+
if (typeof define === "function" && define.amd) {
|
|
4
|
+
define([], factory);
|
|
5
|
+
} else if (typeof exports !== "undefined") {
|
|
6
|
+
factory();
|
|
7
|
+
} else {
|
|
8
|
+
var mod = {
|
|
9
|
+
exports: {}
|
|
10
|
+
};
|
|
11
|
+
factory();
|
|
12
|
+
global.IconTest = mod.exports;
|
|
13
|
+
}
|
|
14
|
+
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function () {
|
|
15
|
+
"use strict";
|
|
16
|
+
|
|
17
|
+
var loadIconTypeModule = function loadIconTypeModule() {
|
|
18
|
+
var module;
|
|
19
|
+
jest.isolateModules(function () {
|
|
20
|
+
jest.doMock("../../icons", function () {
|
|
21
|
+
return {
|
|
22
|
+
Close: function Close() {
|
|
23
|
+
return null;
|
|
24
|
+
},
|
|
25
|
+
Search: function Search() {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
jest.doMock("../IconPicker/icons.generated", function () {
|
|
31
|
+
return {
|
|
32
|
+
icons: [{
|
|
33
|
+
name: 'address-book',
|
|
34
|
+
viewBox: '0 0 1 1',
|
|
35
|
+
path: 'M0 0'
|
|
36
|
+
}]
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
module = require("../iconType");
|
|
40
|
+
});
|
|
41
|
+
if (!module) {
|
|
42
|
+
throw new Error('Failed to load iconType module for tests');
|
|
43
|
+
}
|
|
44
|
+
return module;
|
|
45
|
+
};
|
|
46
|
+
describe('isValidIconType', function () {
|
|
47
|
+
it('returns true for a design-system icon name', function () {
|
|
48
|
+
var _loadIconTypeModule = loadIconTypeModule(),
|
|
49
|
+
isValidIconType = _loadIconTypeModule.isValidIconType;
|
|
50
|
+
expect(isValidIconType('Close')).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
it('returns true for a font-awesome icon name', function () {
|
|
53
|
+
var _loadIconTypeModule2 = loadIconTypeModule(),
|
|
54
|
+
isValidIconType = _loadIconTypeModule2.isValidIconType;
|
|
55
|
+
expect(isValidIconType('address-book')).toBe(true);
|
|
56
|
+
});
|
|
57
|
+
it('returns false for unknown icon strings', function () {
|
|
58
|
+
var _loadIconTypeModule3 = loadIconTypeModule(),
|
|
59
|
+
isValidIconType = _loadIconTypeModule3.isValidIconType;
|
|
60
|
+
expect(isValidIconType('definitely-not-a-valid-icon')).toBe(false);
|
|
61
|
+
});
|
|
62
|
+
it('returns false for inherited prototype property names', function () {
|
|
63
|
+
var _loadIconTypeModule4 = loadIconTypeModule(),
|
|
64
|
+
isValidIconType = _loadIconTypeModule4.isValidIconType;
|
|
65
|
+
expect(isValidIconType('constructor')).toBe(false);
|
|
66
|
+
});
|
|
67
|
+
it('returns false for non-string values', function () {
|
|
68
|
+
var _loadIconTypeModule5 = loadIconTypeModule(),
|
|
69
|
+
isValidIconType = _loadIconTypeModule5.isValidIconType;
|
|
70
|
+
expect(isValidIconType(undefined)).toBe(false);
|
|
71
|
+
expect(isValidIconType(null)).toBe(false);
|
|
72
|
+
expect(isValidIconType(42)).toBe(false);
|
|
73
|
+
expect(isValidIconType({
|
|
74
|
+
icon: 'Close'
|
|
75
|
+
})).toBe(false);
|
|
76
|
+
});
|
|
77
|
+
it('builds FA icon maps from the provided source', function () {
|
|
78
|
+
var _loadIconTypeModule6 = loadIconTypeModule(),
|
|
79
|
+
getFAIconMap = _loadIconTypeModule6.getFAIconMap;
|
|
80
|
+
var initialSource = [{
|
|
81
|
+
name: 'first',
|
|
82
|
+
viewBox: '0 0 1 1',
|
|
83
|
+
path: 'M0 0'
|
|
84
|
+
}];
|
|
85
|
+
var newSource = [{
|
|
86
|
+
name: 'second',
|
|
87
|
+
viewBox: '0 0 1 1',
|
|
88
|
+
path: 'M0 0'
|
|
89
|
+
}];
|
|
90
|
+
var firstMap = getFAIconMap(initialSource);
|
|
91
|
+
expect(firstMap.has('first')).toBe(true);
|
|
92
|
+
expect(firstMap.has('second')).toBe(false);
|
|
93
|
+
var secondMap = getFAIconMap(newSource);
|
|
94
|
+
expect(secondMap.has('first')).toBe(false);
|
|
95
|
+
expect(secondMap.has('second')).toBe(true);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// This file is generated by a script. Do not edit this file directly.
|
|
2
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
|
+
(function (global, factory) {
|
|
4
|
+
if (typeof define === "function" && define.amd) {
|
|
5
|
+
define(["exports", "../icons", "./IconPicker/icons.generated"], factory);
|
|
6
|
+
} else if (typeof exports !== "undefined") {
|
|
7
|
+
factory(exports, require("../icons"), require("./IconPicker/icons.generated"));
|
|
8
|
+
} else {
|
|
9
|
+
var mod = {
|
|
10
|
+
exports: {}
|
|
11
|
+
};
|
|
12
|
+
factory(mod.exports, global.icons, global.icons);
|
|
13
|
+
global.iconType = mod.exports;
|
|
14
|
+
}
|
|
15
|
+
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, icons, _icons2) {
|
|
16
|
+
"use strict";
|
|
17
|
+
|
|
18
|
+
Object.defineProperty(_exports, "__esModule", {
|
|
19
|
+
value: true
|
|
20
|
+
});
|
|
21
|
+
_exports.isValidIconType = _exports.getFAIconMap = void 0;
|
|
22
|
+
icons = _interopRequireWildcard(icons);
|
|
23
|
+
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); }
|
|
24
|
+
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; }
|
|
25
|
+
var defaultFAIconMap = new Map(_icons2.icons.map(function (icon) {
|
|
26
|
+
return [icon.name, icon];
|
|
27
|
+
}));
|
|
28
|
+
var getFAIconMap = _exports.getFAIconMap = function getFAIconMap() {
|
|
29
|
+
var source = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _icons2.icons;
|
|
30
|
+
if (source === _icons2.icons) {
|
|
31
|
+
return defaultFAIconMap;
|
|
32
|
+
}
|
|
33
|
+
return new Map(source.map(function (icon) {
|
|
34
|
+
return [icon.name, icon];
|
|
35
|
+
}));
|
|
36
|
+
};
|
|
37
|
+
var isValidIconType = _exports.isValidIconType = function isValidIconType(arg) {
|
|
38
|
+
if (typeof arg !== 'string') {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
return Object.prototype.hasOwnProperty.call(icons, arg) || getFAIconMap().has(arg);
|
|
42
|
+
};
|
|
43
|
+
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { SVGProps } from 'react';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
export type IconType = keyof typeof icons | FAIconName;
|
|
2
|
+
import type { IconType } from './iconType';
|
|
3
|
+
export { type IconType, isValidIconType } from './iconType';
|
|
5
4
|
/**
|
|
6
5
|
* Icon component that renders either a Font Awesome icon or a Design System icon.
|
|
7
6
|
* it checks if the icon name is in the Font Awesome icon set and renders the corresponding icon.
|
|
@@ -10,6 +10,9 @@ export interface IconPickerProps {
|
|
|
10
10
|
placeholder?: string;
|
|
11
11
|
className?: string;
|
|
12
12
|
disabled?: boolean;
|
|
13
|
+
/** Optional render prop for an inline action next to the search input.
|
|
14
|
+
* Receives a `closePopover` callback to dismiss the picker. */
|
|
15
|
+
inlineAction?: (closePopover: () => void) => React.ReactNode;
|
|
13
16
|
}
|
|
14
17
|
declare const IconPicker: React.ForwardRefExoticComponent<IconPickerProps & React.RefAttributes<HTMLDivElement>>;
|
|
15
18
|
export { IconPicker };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as icons from '../icons';
|
|
2
|
+
import { type FAIcon, type FAIconName } from './IconPicker/icons.generated';
|
|
3
|
+
export type IconType = keyof typeof icons | FAIconName;
|
|
4
|
+
export declare const getFAIconMap: (source?: ReadonlyArray<FAIcon>) => Map<string, FAIcon>;
|
|
5
|
+
export declare const isValidIconType: (arg: unknown) => arg is IconType;
|