@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.
Files changed (41) hide show
  1. package/dist/esm/components/Checkbox/Checkbox.js +1 -1
  2. package/dist/esm/components/Chip/Chip.js +2 -8
  3. package/dist/esm/components/Icon.js +2 -10
  4. package/dist/esm/components/IconPicker/IconPicker.js +12 -7
  5. package/dist/esm/components/IconPicker/index.js +1 -0
  6. package/dist/esm/components/TextLink/TextLink.js +1 -1
  7. package/dist/esm/components/Typography/Base.js +1 -1
  8. package/dist/esm/components/__tests__/Icon.test.js +82 -0
  9. package/dist/esm/components/iconType.js +21 -0
  10. package/dist/esm/types/components/Icon.d.ts +2 -3
  11. package/dist/esm/types/components/IconPicker/IconPicker.d.ts +3 -0
  12. package/dist/esm/types/components/IconPicker/IconPicker.stories.d.ts +1 -0
  13. package/dist/esm/types/components/IconPicker/index.d.ts +2 -0
  14. package/dist/esm/types/components/__tests__/Icon.test.d.ts +1 -0
  15. package/dist/esm/types/components/iconType.d.ts +5 -0
  16. package/dist/esm/types/tsconfig.tsbuildinfo +1 -1
  17. package/dist/styles/main.css +1 -1
  18. package/dist/types/components/Icon.d.ts +2 -3
  19. package/dist/types/components/IconPicker/IconPicker.d.ts +3 -0
  20. package/dist/types/components/IconPicker/IconPicker.stories.d.ts +1 -0
  21. package/dist/types/components/IconPicker/index.d.ts +2 -0
  22. package/dist/types/components/__tests__/Icon.test.d.ts +1 -0
  23. package/dist/types/components/iconType.d.ts +5 -0
  24. package/dist/types/tsconfig.tsbuildinfo +1 -1
  25. package/dist/umd/components/Checkbox/Checkbox.js +1 -1
  26. package/dist/umd/components/Chip/Chip.js +5 -12
  27. package/dist/umd/components/Icon.js +11 -15
  28. package/dist/umd/components/IconPicker/IconPicker.js +12 -7
  29. package/dist/umd/components/IconPicker/index.js +10 -4
  30. package/dist/umd/components/TextLink/TextLink.js +1 -1
  31. package/dist/umd/components/Typography/Base.js +1 -1
  32. package/dist/umd/components/__tests__/Icon.test.js +98 -0
  33. package/dist/umd/components/iconType.js +43 -0
  34. package/dist/umd/types/components/Icon.d.ts +2 -3
  35. package/dist/umd/types/components/IconPicker/IconPicker.d.ts +3 -0
  36. package/dist/umd/types/components/IconPicker/IconPicker.stories.d.ts +1 -0
  37. package/dist/umd/types/components/IconPicker/index.d.ts +2 -0
  38. package/dist/umd/types/components/__tests__/Icon.test.d.ts +1 -0
  39. package/dist/umd/types/components/iconType.d.ts +5 -0
  40. package/dist/umd/types/tsconfig.tsbuildinfo +1 -1
  41. package/package.json +1 -1
@@ -20,7 +20,7 @@ export var CheckboxSize = /*#__PURE__*/function (CheckboxSize) {
20
20
  return CheckboxSize;
21
21
  }({});
22
22
  var checkboxContainerStyles = cva({
23
- 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] flex cop-justify-center cop-items-center',
23
+ 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',
24
24
  variants: {
25
25
  size: _defineProperty(_defineProperty({}, CheckboxSize.DEFAULT, 'cop-h-4 cop-w-4'), CheckboxSize.LARGE, 'cop-h-[18px] cop-w-[18px]'),
26
26
  checked: {
@@ -9,14 +9,8 @@ import { cva } from 'cva';
9
9
  import React from 'react';
10
10
  import { Body } from "../Typography";
11
11
  import { cn } from "../../common/utils";
12
- import { Icon } from "../Icon";
13
- import * as icons from "../../icons";
12
+ import { Icon, isValidIconType } from "../Icon";
14
13
  import { ChipColorDisplay } from "./ChipColorDisplay";
15
-
16
- // Type guard function to validate IconType
17
- var isIconType = function isIconType(icon) {
18
- return typeof icon === 'string' && Object.keys(icons).includes(icon);
19
- };
20
14
  var chipStyles = cva({
21
15
  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',
22
16
  variants: {
@@ -75,7 +69,7 @@ var RenderIcon = function RenderIcon(_ref) {
75
69
  if (!icon) {
76
70
  return null;
77
71
  }
78
- if (typeof icon === 'string' && isIconType(icon)) {
72
+ if (isValidIconType(icon)) {
79
73
  return /*#__PURE__*/React.createElement(Icon, {
80
74
  icon: icon,
81
75
  className: className
@@ -5,17 +5,9 @@ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i
5
5
  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; }
6
6
  import React from "react";
7
7
  import * as icons from "../icons";
8
- import { icons as faIcons } from "./IconPicker/icons.generated";
9
8
  import { iconToFaMap } from "../constants/iconToFaMap";
10
- var faIconMap;
11
- function getFAIconMap() {
12
- if (!faIconMap) {
13
- faIconMap = new Map(faIcons.map(function (i) {
14
- return [i.name, i];
15
- }));
16
- }
17
- return faIconMap;
18
- }
9
+ import { getFAIconMap } from "./iconType";
10
+ export { isValidIconType } from "./iconType";
19
11
 
20
12
  /**
21
13
  * Icon component that renders either a Font Awesome icon or a Design System icon.
@@ -24,7 +24,8 @@ var IconPicker = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
24
24
  placeholder = _ref$placeholder === void 0 ? 'Select an icon' : _ref$placeholder,
25
25
  className = _ref.className,
26
26
  _ref$disabled = _ref.disabled,
27
- disabled = _ref$disabled === void 0 ? false : _ref$disabled;
27
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
28
+ inlineAction = _ref.inlineAction;
28
29
  var isControlled = value !== undefined;
29
30
  var _React$useState = React.useState(defaultValue),
30
31
  _React$useState2 = _slicedToArray(_React$useState, 2),
@@ -175,12 +176,15 @@ var IconPicker = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
175
176
  return document.removeEventListener('keydown', handleKeyDown);
176
177
  };
177
178
  }, [open]);
179
+ var closeAndReset = React.useCallback(function () {
180
+ setOpen(false);
181
+ setSearch('');
182
+ }, []);
178
183
  var handleSelect = React.useCallback(function (icon) {
179
184
  if (!isControlled) setInternalValue(icon.name);
180
185
  onChange === null || onChange === void 0 || onChange(icon.name);
181
- setOpen(false);
182
- setSearch('');
183
- }, [isControlled, onChange]);
186
+ closeAndReset();
187
+ }, [isControlled, onChange, closeAndReset]);
184
188
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
185
189
  ref: triggerRef,
186
190
  className: "cop-inline-flex"
@@ -217,8 +221,9 @@ var IconPicker = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
217
221
  },
218
222
  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)]"
219
223
  }, /*#__PURE__*/React.createElement("div", {
220
- className: "cop-px-3 cop-pt-3"
224
+ className: "cop-flex cop-items-center cop-gap-2 cop-px-3 cop-pt-3"
221
225
  }, /*#__PURE__*/React.createElement(Input, {
226
+ containerClassName: "cop-flex-1 cop-min-w-0",
222
227
  ref: searchInputRef,
223
228
  placeholder: "Search icons",
224
229
  value: search,
@@ -236,8 +241,8 @@ var IconPicker = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
236
241
  (_gridRef$current2 = gridRef.current) === null || _gridRef$current2 === void 0 || _gridRef$current2.focusFirst();
237
242
  }
238
243
  },
239
- className: "focus-visible:cop-border-[#1a1a1a] focus-visible:cop-ring-0 focus-visible:cop-ring-offset-0"
240
- })), /*#__PURE__*/React.createElement("div", {
244
+ className: "cop-h-8 !cop-border-input-gray focus-visible:!cop-border-[#1a1a1a] focus-visible:cop-ring-0 focus-visible:cop-ring-offset-0"
245
+ }), inlineAction === null || inlineAction === void 0 ? void 0 : inlineAction(closeAndReset)), /*#__PURE__*/React.createElement("div", {
241
246
  className: "cop-py-3 cop-pl-3 cop-pr-0"
242
247
  }, /*#__PURE__*/React.createElement(IconGrid, {
243
248
  ref: gridRef,
@@ -1,3 +1,4 @@
1
1
  // This file is generated by a script. Do not edit this file directly.
2
2
  import React from "react";
3
3
  export { IconPicker } from "./IconPicker";
4
+ export { pickerIcons } from "./pickerIcons";
@@ -6,7 +6,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
6
6
  import React from 'react';
7
7
  import { cva } from 'cva';
8
8
  var textLinkClasses = cva({
9
- 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',
9
+ 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',
10
10
  variants: {
11
11
  variant: {
12
12
  "default": 'cop-text-link cop-no-underline hover:cop-text-link-hover active:cop-text-link-active',
@@ -46,7 +46,7 @@ var WEIGHT_CLASSNAMES = {
46
46
  bold: 'cop-font-bold',
47
47
  semibold: 'cop-font-semibold',
48
48
  medium: 'cop-font-medium',
49
- regular: 'cop-font-regular',
49
+ regular: '',
50
50
  light: 'cop-font-light'
51
51
  };
52
52
  export var Base = function Base(_ref) {
@@ -0,0 +1,82 @@
1
+ // This file is generated by a script. Do not edit this file directly.
2
+ var loadIconTypeModule = function loadIconTypeModule() {
3
+ var module;
4
+ jest.isolateModules(function () {
5
+ jest.doMock("../../icons", function () {
6
+ return {
7
+ Close: function Close() {
8
+ return null;
9
+ },
10
+ Search: function Search() {
11
+ return null;
12
+ }
13
+ };
14
+ });
15
+ jest.doMock("../IconPicker/icons.generated", function () {
16
+ return {
17
+ icons: [{
18
+ name: 'address-book',
19
+ viewBox: '0 0 1 1',
20
+ path: 'M0 0'
21
+ }]
22
+ };
23
+ });
24
+ module = require("../iconType");
25
+ });
26
+ if (!module) {
27
+ throw new Error('Failed to load iconType module for tests');
28
+ }
29
+ return module;
30
+ };
31
+ describe('isValidIconType', function () {
32
+ it('returns true for a design-system icon name', function () {
33
+ var _loadIconTypeModule = loadIconTypeModule(),
34
+ isValidIconType = _loadIconTypeModule.isValidIconType;
35
+ expect(isValidIconType('Close')).toBe(true);
36
+ });
37
+ it('returns true for a font-awesome icon name', function () {
38
+ var _loadIconTypeModule2 = loadIconTypeModule(),
39
+ isValidIconType = _loadIconTypeModule2.isValidIconType;
40
+ expect(isValidIconType('address-book')).toBe(true);
41
+ });
42
+ it('returns false for unknown icon strings', function () {
43
+ var _loadIconTypeModule3 = loadIconTypeModule(),
44
+ isValidIconType = _loadIconTypeModule3.isValidIconType;
45
+ expect(isValidIconType('definitely-not-a-valid-icon')).toBe(false);
46
+ });
47
+ it('returns false for inherited prototype property names', function () {
48
+ var _loadIconTypeModule4 = loadIconTypeModule(),
49
+ isValidIconType = _loadIconTypeModule4.isValidIconType;
50
+ expect(isValidIconType('constructor')).toBe(false);
51
+ });
52
+ it('returns false for non-string values', function () {
53
+ var _loadIconTypeModule5 = loadIconTypeModule(),
54
+ isValidIconType = _loadIconTypeModule5.isValidIconType;
55
+ expect(isValidIconType(undefined)).toBe(false);
56
+ expect(isValidIconType(null)).toBe(false);
57
+ expect(isValidIconType(42)).toBe(false);
58
+ expect(isValidIconType({
59
+ icon: 'Close'
60
+ })).toBe(false);
61
+ });
62
+ it('builds FA icon maps from the provided source', function () {
63
+ var _loadIconTypeModule6 = loadIconTypeModule(),
64
+ getFAIconMap = _loadIconTypeModule6.getFAIconMap;
65
+ var initialSource = [{
66
+ name: 'first',
67
+ viewBox: '0 0 1 1',
68
+ path: 'M0 0'
69
+ }];
70
+ var newSource = [{
71
+ name: 'second',
72
+ viewBox: '0 0 1 1',
73
+ path: 'M0 0'
74
+ }];
75
+ var firstMap = getFAIconMap(initialSource);
76
+ expect(firstMap.has('first')).toBe(true);
77
+ expect(firstMap.has('second')).toBe(false);
78
+ var secondMap = getFAIconMap(newSource);
79
+ expect(secondMap.has('first')).toBe(false);
80
+ expect(secondMap.has('second')).toBe(true);
81
+ });
82
+ });
@@ -0,0 +1,21 @@
1
+ // This file is generated by a script. Do not edit this file directly.
2
+ import * as icons from "../icons";
3
+ import { icons as faIcons } from "./IconPicker/icons.generated";
4
+ var defaultFAIconMap = new Map(faIcons.map(function (icon) {
5
+ return [icon.name, icon];
6
+ }));
7
+ export var getFAIconMap = function getFAIconMap() {
8
+ var source = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : faIcons;
9
+ if (source === faIcons) {
10
+ return defaultFAIconMap;
11
+ }
12
+ return new Map(source.map(function (icon) {
13
+ return [icon.name, icon];
14
+ }));
15
+ };
16
+ export var isValidIconType = function isValidIconType(arg) {
17
+ if (typeof arg !== 'string') {
18
+ return false;
19
+ }
20
+ return Object.prototype.hasOwnProperty.call(icons, arg) || getFAIconMap().has(arg);
21
+ };
@@ -1,7 +1,6 @@
1
1
  import type { SVGProps } from 'react';
2
- import * as icons from '../icons';
3
- import { type FAIconName } from './IconPicker/icons.generated';
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 };
@@ -6,3 +6,4 @@ export default meta;
6
6
  type Story = StoryObj<typeof meta>;
7
7
  export declare const Default: Story;
8
8
  export declare const WithValue: Story;
9
+ export declare const WithInlineAction: Story;
@@ -1,3 +1,5 @@
1
1
  export { IconPicker } from './IconPicker';
2
2
  export type { IconPickerProps } from './IconPicker';
3
3
  export type { FAIcon } from './icons.generated';
4
+ export { pickerIcons } from './pickerIcons';
5
+ export type { PickerIcon } from './pickerIcons';
@@ -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;