@dscout/particle 1.0.0-alpha.44 → 1.0.0-alpha.45
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/lib/cjs/components/callout.d.ts +3 -1
- package/lib/cjs/components/callout.js +10 -9
- package/lib/cjs/components/callout.js.map +1 -1
- package/lib/cjs/components/chip.d.ts +77 -6
- package/lib/cjs/components/chip.js +158 -12
- package/lib/cjs/components/chip.js.map +1 -1
- package/lib/cjs/components/filter_chip.d.ts +76 -0
- package/lib/cjs/components/filter_chip.js +91 -0
- package/lib/cjs/components/filter_chip.js.map +1 -0
- package/lib/cjs/icons/express/index.d.ts +4 -0
- package/lib/cjs/icons/express/index.js +4 -0
- package/lib/cjs/icons/express/index.js.map +1 -1
- package/lib/cjs/icons/express/lightbulb_filled.d.ts +7 -0
- package/lib/cjs/icons/express/lightbulb_filled.js +41 -0
- package/lib/cjs/icons/express/lightbulb_filled.js.map +1 -0
- package/lib/cjs/icons/express/triangle_exclamation_filled.d.ts +7 -0
- package/lib/cjs/icons/express/triangle_exclamation_filled.js +40 -0
- package/lib/cjs/icons/express/triangle_exclamation_filled.js.map +1 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +7 -5
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/components/callout.d.ts +3 -1
- package/lib/esm/components/callout.js +10 -9
- package/lib/esm/components/callout.js.map +1 -1
- package/lib/esm/components/chip.d.ts +77 -6
- package/lib/esm/components/chip.js +135 -12
- package/lib/esm/components/chip.js.map +1 -1
- package/lib/esm/components/filter_chip.d.ts +76 -0
- package/lib/esm/components/filter_chip.js +61 -0
- package/lib/esm/components/filter_chip.js.map +1 -0
- package/lib/esm/icons/express/index.d.ts +4 -0
- package/lib/esm/icons/express/index.js +4 -0
- package/lib/esm/icons/express/index.js.map +1 -1
- package/lib/esm/icons/express/lightbulb_filled.d.ts +7 -0
- package/lib/esm/icons/express/lightbulb_filled.js +34 -0
- package/lib/esm/icons/express/lightbulb_filled.js.map +1 -0
- package/lib/esm/icons/express/triangle_exclamation_filled.d.ts +7 -0
- package/lib/esm/icons/express/triangle_exclamation_filled.js +33 -0
- package/lib/esm/icons/express/triangle_exclamation_filled.js.map +1 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/stylesheets/particle.css +68 -20
- package/lib/stylesheets/particle.css.map +1 -1
- package/lib/stylesheets/particle.min.css +1 -1
- package/lib/stylesheets/particle.min.css.gz +0 -0
- package/package.json +1 -1
- package/styles/components/callout/_base.scss +0 -4
- package/styles/components/callout/themes/_theme_builder.scss +4 -8
- package/styles/components/chip/_base.scss +20 -7
- package/styles/components/chip/themes/_theme_builder.scss +2 -0
- package/styles/components/filter_chip/_base.scss +33 -0
- package/styles/components/filter_chip/themes/_bandit.scss +2 -0
- package/styles/components/filter_chip/themes/_default.scss +6 -0
- package/styles/components/filter_chip/themes/_theme_builder.scss +38 -0
- package/styles/particle.scss +1 -0
|
@@ -8,12 +8,14 @@ interface Props extends CommonComponentProps, MarginModifierProp, ModifierClassP
|
|
|
8
8
|
title: ReactNode;
|
|
9
9
|
variant?: 'error' | 'info' | 'tip' | 'warning';
|
|
10
10
|
width?: Dimensions;
|
|
11
|
+
withIcon?: boolean;
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
14
|
* Renders a Callout styled component in one of four variants: 'error', 'info', 'tip', or 'warning'.
|
|
14
15
|
* Optionally can include accordion/collapsible details content via the `detailsContent` and `detailsButtonLabel` props
|
|
15
16
|
* Or can provide a clickable action button via the `actionLabel` and `onActionClick` props.
|
|
16
17
|
* If a `detailsContent` prop is present without a `detailsButtonLabel` prop, details will appear in a fixed, open state.
|
|
18
|
+
* If `withIcon` (default `true`) is provided as false, the callout will render without a decorative icon
|
|
17
19
|
*/
|
|
18
|
-
export declare function Callout({ _modifierClass, actionLabel, margin, detailsContent, detailsButtonLabel, onActionClick, title, variant, width, ...rest }: Props): React.JSX.Element;
|
|
20
|
+
export declare function Callout({ _modifierClass, actionLabel, margin, detailsContent, detailsButtonLabel, onActionClick, title, variant, width, withIcon, ...rest }: Props): React.JSX.Element;
|
|
19
21
|
export default Callout;
|
|
@@ -57,18 +57,18 @@ var data_attributes_1 = __importDefault(require("../utils/data_attributes"));
|
|
|
57
57
|
var button_plain_1 = require("./button_plain");
|
|
58
58
|
var collapsible_content_1 = require("./collapsible_content");
|
|
59
59
|
var button_1 = require("./button");
|
|
60
|
-
var IconChevronDown = express_1.ExpressIcons.IconChevronDown,
|
|
60
|
+
var IconChevronDown = express_1.ExpressIcons.IconChevronDown, IconCircleInfoAltFilled = express_1.ExpressIcons.IconCircleInfoAltFilled, IconLightbulbFilled = express_1.ExpressIcons.IconLightbulbFilled, IconTriangleExclamationFilled = express_1.ExpressIcons.IconTriangleExclamationFilled;
|
|
61
61
|
var getVariantIcon = function (variant) {
|
|
62
62
|
switch (variant) {
|
|
63
63
|
case 'error':
|
|
64
|
-
return react_1.default.createElement(
|
|
64
|
+
return react_1.default.createElement(IconTriangleExclamationFilled, { base: "16", "aria-hidden": true });
|
|
65
65
|
case 'info':
|
|
66
|
-
return react_1.default.createElement(
|
|
66
|
+
return react_1.default.createElement(IconCircleInfoAltFilled, { base: "16", "aria-hidden": true });
|
|
67
67
|
case 'warning':
|
|
68
|
-
return react_1.default.createElement(
|
|
68
|
+
return react_1.default.createElement(IconTriangleExclamationFilled, { base: "16", "aria-hidden": true });
|
|
69
69
|
case 'tip':
|
|
70
70
|
default:
|
|
71
|
-
return react_1.default.createElement(
|
|
71
|
+
return react_1.default.createElement(IconLightbulbFilled, { base: "16", "aria-hidden": true });
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
74
|
/**
|
|
@@ -76,17 +76,18 @@ var getVariantIcon = function (variant) {
|
|
|
76
76
|
* Optionally can include accordion/collapsible details content via the `detailsContent` and `detailsButtonLabel` props
|
|
77
77
|
* Or can provide a clickable action button via the `actionLabel` and `onActionClick` props.
|
|
78
78
|
* If a `detailsContent` prop is present without a `detailsButtonLabel` prop, details will appear in a fixed, open state.
|
|
79
|
+
* If `withIcon` (default `true`) is provided as false, the callout will render without a decorative icon
|
|
79
80
|
*/
|
|
80
81
|
function Callout(_a) {
|
|
81
|
-
var _modifierClass = _a._modifierClass, actionLabel = _a.actionLabel, margin = _a.margin, detailsContent = _a.detailsContent, detailsButtonLabel = _a.detailsButtonLabel, onActionClick = _a.onActionClick, title = _a.title, _b = _a.variant, variant = _b === void 0 ? 'info' : _b, _c = _a.width, width = _c === void 0 ? '100%' : _c, rest = __rest(_a, ["_modifierClass", "actionLabel", "margin", "detailsContent", "detailsButtonLabel", "onActionClick", "title", "variant", "width"]);
|
|
82
|
-
var
|
|
83
|
-
var icon = getVariantIcon(variant);
|
|
82
|
+
var _modifierClass = _a._modifierClass, actionLabel = _a.actionLabel, margin = _a.margin, detailsContent = _a.detailsContent, detailsButtonLabel = _a.detailsButtonLabel, onActionClick = _a.onActionClick, title = _a.title, _b = _a.variant, variant = _b === void 0 ? 'info' : _b, _c = _a.width, width = _c === void 0 ? '100%' : _c, _d = _a.withIcon, withIcon = _d === void 0 ? true : _d, rest = __rest(_a, ["_modifierClass", "actionLabel", "margin", "detailsContent", "detailsButtonLabel", "onActionClick", "title", "variant", "width", "withIcon"]);
|
|
83
|
+
var _e = (0, react_1.useState)(true), hideDetails = _e[0], setHideDetails = _e[1];
|
|
84
|
+
var icon = withIcon && getVariantIcon(variant);
|
|
84
85
|
var renderWithDetailsAccordion = !!detailsContent && !!detailsButtonLabel;
|
|
85
86
|
var renderWithActionButton = !!actionLabel && !!onActionClick;
|
|
86
87
|
var containerClassnames = (0, class_names_1.default)('Callout flex direction--column rounded--med align-items--stretch', "Callout--".concat(variant), _modifierClass, (0, modifier_classes_1.getDimensionClass)('width', width), (0, modifier_classes_1.getMarginClass)(margin));
|
|
87
88
|
return (react_1.default.createElement("div", __assign({ className: containerClassnames }, (0, data_attributes_1.default)(rest)),
|
|
88
89
|
react_1.default.createElement("div", { className: "Callout__Title-Container flex" },
|
|
89
|
-
react_1.default.createElement("div", { className: "Callout__Icon-Container
|
|
90
|
+
!!icon && (react_1.default.createElement("div", { className: "Callout__Icon-Container padding--0.25 flex-shrink--0 flex-grow--0 margin-r--0.75 flex justify--center align-self--start" }, icon)),
|
|
90
91
|
react_1.default.createElement("div", { className: (0, class_names_1.default)('flex-grow--1', {
|
|
91
92
|
'padding-r--1': renderWithDetailsAccordion || renderWithActionButton
|
|
92
93
|
}) },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callout.js","sourceRoot":"","sources":["../../../src/components/callout.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAwD;AAExD,qEAA8C;AAC9C,4CAAgD;AAQhD,8DAA8E;AAC9E,6EAAyD;AACzD,+CAA6C;AAC7C,6DAA2D;AAC3D,mCAAkC;AAGhC,IAAA,eAAe,GAIb,sBAAY,gBAJC,EACf,
|
|
1
|
+
{"version":3,"file":"callout.js","sourceRoot":"","sources":["../../../src/components/callout.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAwD;AAExD,qEAA8C;AAC9C,4CAAgD;AAQhD,8DAA8E;AAC9E,6EAAyD;AACzD,+CAA6C;AAC7C,6DAA2D;AAC3D,mCAAkC;AAGhC,IAAA,eAAe,GAIb,sBAAY,gBAJC,EACf,uBAAuB,GAGrB,sBAAY,wBAHS,EACvB,mBAAmB,GAEjB,sBAAY,oBAFK,EACnB,6BAA6B,GAC3B,sBAAY,8BADe,CACd;AAgBjB,IAAM,cAAc,GAAG,UAAC,OAAsC;IAC5D,QAAQ,OAAO,EAAE;QACf,KAAK,OAAO;YACV,OAAO,8BAAC,6BAA6B,IAAC,IAAI,EAAC,IAAI,wBAAe,CAAC;QACjE,KAAK,MAAM;YACT,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6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Colors, CommonComponentProps, MarginModifierProp, ModifierClassProp } from '../types';
|
|
3
3
|
import type { GetRef } from '../utils/refs';
|
|
4
|
+
import type { BuiltInTooltipConfig } from './tooltip/types';
|
|
4
5
|
interface ChipProps extends CommonComponentProps, MarginModifierProp, ModifierClassProp {
|
|
5
6
|
children?: React.ReactNode;
|
|
6
7
|
color?: Colors;
|
|
@@ -9,30 +10,100 @@ interface ChipProps extends CommonComponentProps, MarginModifierProp, ModifierCl
|
|
|
9
10
|
outline?: boolean;
|
|
10
11
|
textColor?: Colors;
|
|
11
12
|
title?: string;
|
|
13
|
+
tooltipConfig?: Partial<Omit<BuiltInTooltipConfig, 'tooltipContent'>>;
|
|
12
14
|
variant?: 'legacy' | 'modern';
|
|
13
15
|
/**
|
|
14
16
|
* For modern variant only
|
|
15
17
|
*/
|
|
16
18
|
bgColor?: Colors;
|
|
17
19
|
icon?: React.ReactNode;
|
|
20
|
+
maxCharacters?: number;
|
|
21
|
+
actionConfig?: {
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
onClick: React.MouseEventHandler<HTMLSpanElement>;
|
|
24
|
+
hoverBgColor: Colors;
|
|
25
|
+
activeBgColor: Colors;
|
|
26
|
+
icon: React.ReactNode;
|
|
27
|
+
};
|
|
18
28
|
}
|
|
19
29
|
/**
|
|
30
|
+
* A versatile component for displaying attributes in a compact form. Supports both
|
|
31
|
+
* static display and interactive button functionality with optional text truncation.
|
|
32
|
+
*
|
|
33
|
+
* ## Variants
|
|
34
|
+
*
|
|
35
|
+
* - **Legacy**: Traditional uppercase styling with medium radius
|
|
36
|
+
* - **Modern**: Contemporary styling with smaller text and radius (recommended)
|
|
37
|
+
*
|
|
38
|
+
* ## Color Behavior
|
|
39
|
+
*
|
|
20
40
|
* With no color specified, the `<Chip />` bases its colors off of the text
|
|
21
41
|
* color inherited by CSS. However, there's a slight difference between the
|
|
22
|
-
* default and the `outline` variants
|
|
42
|
+
* default and the `outline` variants:
|
|
23
43
|
*
|
|
24
|
-
*
|
|
44
|
+
* **Default**: With no color specified, the background color will match the
|
|
25
45
|
* inherited text color and the text color will default to `invert`. If the
|
|
26
|
-
* default text color is not suitable for legibility
|
|
46
|
+
* default text color is not suitable for legibility or accessibility purposes, an
|
|
27
47
|
* explicit text color will need to be set with the `textColor` prop. For
|
|
28
48
|
* example, if you're placing a `<Chip />` in an element with white text (such
|
|
29
49
|
* as `<Button color="dscout" />`) you'll need to specify a text color
|
|
30
50
|
* or else it won't be visible.
|
|
31
51
|
*
|
|
32
|
-
*
|
|
33
|
-
* __Outline__: With no color specified, the outline color _and_ the text color
|
|
52
|
+
* **Outline**: With no color specified, the outline color _and_ the text color
|
|
34
53
|
* will match the inherited text color. If desired, the text color can be set
|
|
35
54
|
* explicitly with `textColor` prop, but that's an unlikely use case.
|
|
55
|
+
*
|
|
56
|
+
* ## Interactive Functionality
|
|
57
|
+
*
|
|
58
|
+
* The `actionConfig` prop transforms the chip into a semantic `button` element
|
|
59
|
+
* with hover and active states. When provided, it must include:
|
|
60
|
+
* - `onClick`: Click handler function
|
|
61
|
+
* - `hoverBgColor`: Background color on hover
|
|
62
|
+
* - `activeBgColor`: Background color when pressed
|
|
63
|
+
* - `icon`: Icon to display (typically a close or action icon)
|
|
64
|
+
* - `disabled` (optional): Disables interaction when true
|
|
65
|
+
*
|
|
66
|
+
* ## Text Truncation
|
|
67
|
+
*
|
|
68
|
+
* The `maxCharacters` prop enables automatic text truncation with tooltip support.
|
|
69
|
+
* When the chip's text content exceeds the specified character limit, it will be
|
|
70
|
+
* truncated with "..." and a tooltip will show the full content on hover.
|
|
71
|
+
*
|
|
72
|
+
* - Only works with string `children` content
|
|
73
|
+
* - Use `tooltipConfig` to customize tooltip placement, z-index, etc.
|
|
74
|
+
* - When truncation is active, the `getRef` prop cannot be used as the ref is
|
|
75
|
+
* managed by the tooltip container
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```tsx
|
|
79
|
+
* // Basic chip
|
|
80
|
+
* <Chip variant="modern" bgColor="blue-100" textColor="blue-700">
|
|
81
|
+
* Tag Label
|
|
82
|
+
* </Chip>
|
|
83
|
+
*
|
|
84
|
+
* // Interactive chip
|
|
85
|
+
* <Chip
|
|
86
|
+
* variant="modern"
|
|
87
|
+
* bgColor="gray-100"
|
|
88
|
+
* actionConfig={{
|
|
89
|
+
* onClick: handleRemove,
|
|
90
|
+
* hoverBgColor: "gray-200",
|
|
91
|
+
* activeBgColor: "gray-300",
|
|
92
|
+
* icon: <CloseIcon />
|
|
93
|
+
* }}
|
|
94
|
+
* >
|
|
95
|
+
* Removable Tag
|
|
96
|
+
* </Chip>
|
|
97
|
+
*
|
|
98
|
+
* // Truncated chip
|
|
99
|
+
* <Chip
|
|
100
|
+
* variant="modern"
|
|
101
|
+
* maxCharacters={20}
|
|
102
|
+
* tooltipConfig={{ placement: "top" }}
|
|
103
|
+
* >
|
|
104
|
+
* Very long chip label that will be truncated
|
|
105
|
+
* </Chip>
|
|
106
|
+
* ```
|
|
36
107
|
*/
|
|
37
|
-
export declare function Chip({ _modifierClass, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, 'aria-describedby': ariaDescribedby, children, color, bgColor, getRef, icon, id, margin, outline, textColor, title, variant, ...rest }: ChipProps): React.JSX.Element;
|
|
108
|
+
export declare function Chip({ _modifierClass, actionConfig, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, 'aria-describedby': ariaDescribedby, children, color, bgColor, getRef, icon, id, margin, maxCharacters, outline, textColor, tooltipConfig, title, variant, ...rest }: ChipProps): React.JSX.Element;
|
|
38
109
|
export {};
|
|
@@ -10,6 +10,29 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
13
36
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
37
|
var t = {};
|
|
15
38
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -26,32 +49,95 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
49
|
};
|
|
27
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
51
|
exports.Chip = void 0;
|
|
29
|
-
var react_1 =
|
|
52
|
+
var react_1 = __importStar(require("react"));
|
|
30
53
|
var class_names_1 = __importDefault(require("../utils/class_names"));
|
|
31
54
|
var data_attributes_1 = __importDefault(require("../utils/data_attributes"));
|
|
32
55
|
var modifier_classes_1 = require("../utils/modifier_classes");
|
|
56
|
+
var tooltip_container_1 = require("./tooltip/tooltip_container");
|
|
33
57
|
var DEFAULT_TEXT_COLOR = 'invert';
|
|
34
58
|
/**
|
|
59
|
+
* A versatile component for displaying attributes in a compact form. Supports both
|
|
60
|
+
* static display and interactive button functionality with optional text truncation.
|
|
61
|
+
*
|
|
62
|
+
* ## Variants
|
|
63
|
+
*
|
|
64
|
+
* - **Legacy**: Traditional uppercase styling with medium radius
|
|
65
|
+
* - **Modern**: Contemporary styling with smaller text and radius (recommended)
|
|
66
|
+
*
|
|
67
|
+
* ## Color Behavior
|
|
68
|
+
*
|
|
35
69
|
* With no color specified, the `<Chip />` bases its colors off of the text
|
|
36
70
|
* color inherited by CSS. However, there's a slight difference between the
|
|
37
|
-
* default and the `outline` variants
|
|
71
|
+
* default and the `outline` variants:
|
|
38
72
|
*
|
|
39
|
-
*
|
|
73
|
+
* **Default**: With no color specified, the background color will match the
|
|
40
74
|
* inherited text color and the text color will default to `invert`. If the
|
|
41
|
-
* default text color is not suitable for legibility
|
|
75
|
+
* default text color is not suitable for legibility or accessibility purposes, an
|
|
42
76
|
* explicit text color will need to be set with the `textColor` prop. For
|
|
43
77
|
* example, if you're placing a `<Chip />` in an element with white text (such
|
|
44
78
|
* as `<Button color="dscout" />`) you'll need to specify a text color
|
|
45
79
|
* or else it won't be visible.
|
|
46
80
|
*
|
|
47
|
-
*
|
|
48
|
-
* __Outline__: With no color specified, the outline color _and_ the text color
|
|
81
|
+
* **Outline**: With no color specified, the outline color _and_ the text color
|
|
49
82
|
* will match the inherited text color. If desired, the text color can be set
|
|
50
83
|
* explicitly with `textColor` prop, but that's an unlikely use case.
|
|
84
|
+
*
|
|
85
|
+
* ## Interactive Functionality
|
|
86
|
+
*
|
|
87
|
+
* The `actionConfig` prop transforms the chip into a semantic `button` element
|
|
88
|
+
* with hover and active states. When provided, it must include:
|
|
89
|
+
* - `onClick`: Click handler function
|
|
90
|
+
* - `hoverBgColor`: Background color on hover
|
|
91
|
+
* - `activeBgColor`: Background color when pressed
|
|
92
|
+
* - `icon`: Icon to display (typically a close or action icon)
|
|
93
|
+
* - `disabled` (optional): Disables interaction when true
|
|
94
|
+
*
|
|
95
|
+
* ## Text Truncation
|
|
96
|
+
*
|
|
97
|
+
* The `maxCharacters` prop enables automatic text truncation with tooltip support.
|
|
98
|
+
* When the chip's text content exceeds the specified character limit, it will be
|
|
99
|
+
* truncated with "..." and a tooltip will show the full content on hover.
|
|
100
|
+
*
|
|
101
|
+
* - Only works with string `children` content
|
|
102
|
+
* - Use `tooltipConfig` to customize tooltip placement, z-index, etc.
|
|
103
|
+
* - When truncation is active, the `getRef` prop cannot be used as the ref is
|
|
104
|
+
* managed by the tooltip container
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```tsx
|
|
108
|
+
* // Basic chip
|
|
109
|
+
* <Chip variant="modern" bgColor="blue-100" textColor="blue-700">
|
|
110
|
+
* Tag Label
|
|
111
|
+
* </Chip>
|
|
112
|
+
*
|
|
113
|
+
* // Interactive chip
|
|
114
|
+
* <Chip
|
|
115
|
+
* variant="modern"
|
|
116
|
+
* bgColor="gray-100"
|
|
117
|
+
* actionConfig={{
|
|
118
|
+
* onClick: handleRemove,
|
|
119
|
+
* hoverBgColor: "gray-200",
|
|
120
|
+
* activeBgColor: "gray-300",
|
|
121
|
+
* icon: <CloseIcon />
|
|
122
|
+
* }}
|
|
123
|
+
* >
|
|
124
|
+
* Removable Tag
|
|
125
|
+
* </Chip>
|
|
126
|
+
*
|
|
127
|
+
* // Truncated chip
|
|
128
|
+
* <Chip
|
|
129
|
+
* variant="modern"
|
|
130
|
+
* maxCharacters={20}
|
|
131
|
+
* tooltipConfig={{ placement: "top" }}
|
|
132
|
+
* >
|
|
133
|
+
* Very long chip label that will be truncated
|
|
134
|
+
* </Chip>
|
|
135
|
+
* ```
|
|
51
136
|
*/
|
|
52
137
|
function Chip(_a) {
|
|
53
138
|
var _b, _c;
|
|
54
|
-
var _modifierClass = _a._modifierClass, ariaLabel = _a["aria-label"], ariaLabelledby = _a["aria-labelledby"], ariaDescribedby = _a["aria-describedby"], children = _a.children, color = _a.color, bgColor = _a.bgColor, getRef = _a.getRef, icon = _a.icon, id = _a.id, margin = _a.margin, outline = _a.outline, textColor = _a.textColor, title = _a.title, _d = _a.variant, variant = _d === void 0 ? 'legacy' : _d, rest = __rest(_a, ["_modifierClass", 'aria-label', 'aria-labelledby', 'aria-describedby', "children", "color", "bgColor", "getRef", "icon", "id", "margin", "outline", "textColor", "title", "variant"]);
|
|
139
|
+
var _modifierClass = _a._modifierClass, actionConfig = _a.actionConfig, ariaLabel = _a["aria-label"], ariaLabelledby = _a["aria-labelledby"], ariaDescribedby = _a["aria-describedby"], children = _a.children, color = _a.color, bgColor = _a.bgColor, getRef = _a.getRef, icon = _a.icon, id = _a.id, margin = _a.margin, maxCharacters = _a.maxCharacters, outline = _a.outline, textColor = _a.textColor, tooltipConfig = _a.tooltipConfig, title = _a.title, _d = _a.variant, variant = _d === void 0 ? 'legacy' : _d, rest = __rest(_a, ["_modifierClass", "actionConfig", 'aria-label', 'aria-labelledby', 'aria-describedby', "children", "color", "bgColor", "getRef", "icon", "id", "margin", "maxCharacters", "outline", "textColor", "tooltipConfig", "title", "variant"]);
|
|
140
|
+
var truncLength = Math.max(0, Math.floor(Number(maxCharacters) || 0));
|
|
55
141
|
function getContentColor() {
|
|
56
142
|
if (outline)
|
|
57
143
|
return textColor || null;
|
|
@@ -65,16 +151,76 @@ function Chip(_a) {
|
|
|
65
151
|
_b["bg-color--".concat(color)] = color && !outline && !bgColor,
|
|
66
152
|
_b["bg-color--".concat(bgColor)] = bgColor,
|
|
67
153
|
_b['Chip--modern'] = variant === 'modern',
|
|
154
|
+
_b['Chip--interactive'] = !!actionConfig && !actionConfig.disabled,
|
|
68
155
|
_b));
|
|
69
156
|
var contentClassname = (0, class_names_1.default)('Chip__Content', (_c = {},
|
|
70
157
|
_c["color--".concat(contentColor)] = contentColor,
|
|
71
158
|
_c['Chip__Content--modern'] = variant === 'modern',
|
|
72
|
-
_c['Chip__Content--with-icon'] = !!icon,
|
|
159
|
+
_c['Chip__Content--with-icon'] = !!icon || !!(actionConfig === null || actionConfig === void 0 ? void 0 : actionConfig.icon),
|
|
73
160
|
_c));
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
161
|
+
var interactiveProps = (0, react_1.useMemo)(function () {
|
|
162
|
+
if (!actionConfig || actionConfig.disabled) {
|
|
163
|
+
return {
|
|
164
|
+
'aria-disabled': actionConfig === null || actionConfig === void 0 ? void 0 : actionConfig.disabled,
|
|
165
|
+
style: {
|
|
166
|
+
'--Chip____hover-bg-color': "var(--color--".concat(bgColor, ")"),
|
|
167
|
+
'--Chip____active-bg-color': "var(--color--".concat(bgColor, ")")
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
var onClick = actionConfig.onClick, hoverBgColor = actionConfig.hoverBgColor, activeBgColor = actionConfig.activeBgColor;
|
|
172
|
+
return {
|
|
173
|
+
role: 'button',
|
|
174
|
+
onClick: onClick,
|
|
175
|
+
tabIndex: 0,
|
|
176
|
+
onKeyDown: function (e) {
|
|
177
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
178
|
+
e.preventDefault();
|
|
179
|
+
// Delegate to click handler for keyboard activation
|
|
180
|
+
onClick(e);
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
style: {
|
|
184
|
+
'--Chip____hover-bg-color': "var(--color--".concat(hoverBgColor, ")"),
|
|
185
|
+
'--Chip____active-bg-color': "var(--color--".concat(activeBgColor, ")")
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
}, [actionConfig, bgColor]);
|
|
189
|
+
var containerProps = (0, react_1.useMemo)(function () { return (__assign(__assign(__assign({}, (0, data_attributes_1.default)(rest)), interactiveProps), { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, 'aria-describedby': ariaDescribedby, className: chipClassname, id: id, ref: getRef, title: title })); }, [
|
|
190
|
+
ariaDescribedby,
|
|
191
|
+
ariaLabel,
|
|
192
|
+
ariaLabelledby,
|
|
193
|
+
chipClassname,
|
|
194
|
+
getRef,
|
|
195
|
+
id,
|
|
196
|
+
interactiveProps,
|
|
197
|
+
rest,
|
|
198
|
+
title
|
|
199
|
+
]);
|
|
200
|
+
var shouldRenderTooltip = typeof truncLength === 'number' &&
|
|
201
|
+
truncLength > 0 &&
|
|
202
|
+
typeof children === 'string' &&
|
|
203
|
+
children.length > truncLength;
|
|
204
|
+
var chipContent = (0, react_1.useMemo)(function () { return (react_1.default.createElement("span", { className: contentClassname, "aria-label": shouldRenderTooltip ? children : undefined },
|
|
205
|
+
!!icon && icon,
|
|
206
|
+
shouldRenderTooltip
|
|
207
|
+
? "".concat(children.slice(0, truncLength), "...")
|
|
208
|
+
: children,
|
|
209
|
+
!!(actionConfig === null || actionConfig === void 0 ? void 0 : actionConfig.icon) && actionConfig.icon)); }, [
|
|
210
|
+
actionConfig === null || actionConfig === void 0 ? void 0 : actionConfig.icon,
|
|
211
|
+
children,
|
|
212
|
+
contentClassname,
|
|
213
|
+
icon,
|
|
214
|
+
truncLength,
|
|
215
|
+
shouldRenderTooltip
|
|
216
|
+
]);
|
|
217
|
+
if (shouldRenderTooltip) {
|
|
218
|
+
return (react_1.default.createElement(tooltip_container_1.TooltipContainer, __assign({}, (tooltipConfig !== null && tooltipConfig !== void 0 ? tooltipConfig : {}), { tooltipContent: children }), function (_a) {
|
|
219
|
+
var ref = _a.ref;
|
|
220
|
+
return (react_1.default.createElement("span", __assign({}, containerProps, { ref: ref }), chipContent));
|
|
221
|
+
}));
|
|
222
|
+
}
|
|
223
|
+
return react_1.default.createElement("span", __assign({}, containerProps), chipContent);
|
|
78
224
|
}
|
|
79
225
|
exports.Chip = Chip;
|
|
80
226
|
//# sourceMappingURL=chip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chip.js","sourceRoot":"","sources":["../../../src/components/chip.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chip.js","sourceRoot":"","sources":["../../../src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ChB,IAAI;QACJ,WAAW;QACX,mBAAmB;KACpB,CACF,CAAC;IAEF,IAAI,mBAAmB,EAAE;QACvB,OAAO,CACL,8BAAC,oCAAgB,eAAK,CAAC,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,EAAE,CAAC,IAAE,cAAc,EAAE,QAAQ,KAClE,UAAC,EAAO;gBAAL,GAAG,SAAA;YAAO,OAAA,CACZ,mDAAU,cAAc,IAAE,GAAG,EAAE,GAAG,KAC/B,WAAW,CACP,CACR;QAJa,CAIb,CACgB,CACpB,CAAC;KACH;IAED,OAAO,mDAAU,cAAc,GAAG,WAAW,CAAQ,CAAC;AACxD,CAAC;AArJD,oBAqJC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React, { type ComponentProps } from 'react';
|
|
2
|
+
import type { CommonComponentProps, MarginModifierProp, ModifierClassProp } from '../types';
|
|
3
|
+
import type { GetRef } from '../utils/refs';
|
|
4
|
+
import type { BuiltInTooltipConfig } from './tooltip/types';
|
|
5
|
+
import { Chip } from './chip';
|
|
6
|
+
type FilterBase = {
|
|
7
|
+
id: string;
|
|
8
|
+
title: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A compound component that displays a labeled group of removable filter chips.
|
|
12
|
+
* Combines a tooltip-enabled label with a list of interactive or static chips.
|
|
13
|
+
*
|
|
14
|
+
* ## Purpose
|
|
15
|
+
* Designed for filtering interfaces where users need to see applied filters
|
|
16
|
+
* and optionally remove them. The component provides visual grouping with
|
|
17
|
+
* a descriptive label and consistent chip styling.
|
|
18
|
+
*
|
|
19
|
+
* ## Type Safety
|
|
20
|
+
* The component automatically infers the filter type from the `filters` prop
|
|
21
|
+
* while ensuring each filter has required `id` and `title` properties for proper
|
|
22
|
+
* rendering and key management. The full filter type is preserved in callbacks.
|
|
23
|
+
*
|
|
24
|
+
* ## Interaction Modes
|
|
25
|
+
*
|
|
26
|
+
* **Static Mode**: When `onRemoveFilterChip` is not provided, chips are
|
|
27
|
+
* display-only with no interaction capabilities.
|
|
28
|
+
*
|
|
29
|
+
* **Interactive Mode**: When `onRemoveFilterChip` is provided, each chip
|
|
30
|
+
* becomes clickable with a remove icon, hover states, and proper button
|
|
31
|
+
* semantics. The `chipsDisabled` prop can temporarily disable interactions.
|
|
32
|
+
*
|
|
33
|
+
* ## Chip Behavior
|
|
34
|
+
* All chips inherit the modern variant styling and use consistent colors
|
|
35
|
+
* (gray-50 background, gray-800 text). Individual chip truncation and
|
|
36
|
+
* tooltips are controlled via `chipMaxCharacters` and `chipTooltipConfig`.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* // Static display mode
|
|
41
|
+
* <FilterChip
|
|
42
|
+
* label="Applied Filters"
|
|
43
|
+
* icon={<FilterIcon />}
|
|
44
|
+
* filters={[
|
|
45
|
+
* { id: '1', title: 'Active Users' },
|
|
46
|
+
* { id: '2', title: 'Last 30 Days' }
|
|
47
|
+
* ]}
|
|
48
|
+
* tooltipConfig={{ tooltipContent: "Current filter criteria" }}
|
|
49
|
+
* getRef={containerRef}
|
|
50
|
+
* />
|
|
51
|
+
*
|
|
52
|
+
* // Interactive mode with removal
|
|
53
|
+
* <FilterChip
|
|
54
|
+
* label="Active Filters"
|
|
55
|
+
* filters={appliedFilters}
|
|
56
|
+
* onRemoveFilterChip={(filter) => removeFilter(filter.id)}
|
|
57
|
+
* chipsDisabled={isLoading}
|
|
58
|
+
* chipMaxCharacters={25}
|
|
59
|
+
* tooltipConfig={{ tooltipContent: "Click chips to remove" }}
|
|
60
|
+
* getRef={containerRef}
|
|
61
|
+
* />
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
interface FilterChipProps<T extends FilterBase = FilterBase> extends CommonComponentProps, MarginModifierProp, ModifierClassProp {
|
|
65
|
+
chipMaxCharacters?: ComponentProps<typeof Chip>['maxCharacters'];
|
|
66
|
+
chipTooltipConfig?: ComponentProps<typeof Chip>['tooltipConfig'];
|
|
67
|
+
chipsDisabled?: boolean;
|
|
68
|
+
filters: T[];
|
|
69
|
+
getRef: GetRef<HTMLDivElement>;
|
|
70
|
+
icon?: React.ReactNode;
|
|
71
|
+
label: string;
|
|
72
|
+
onRemoveFilterChip?: (filter: T, event: React.MouseEvent) => unknown;
|
|
73
|
+
tooltipConfig: BuiltInTooltipConfig;
|
|
74
|
+
}
|
|
75
|
+
export declare function FilterChip<T extends FilterBase = FilterBase>({ _modifierClass, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, 'aria-describedby': ariaDescribedby, chipMaxCharacters, chipTooltipConfig, chipsDisabled, filters, getRef, icon, label, margin, onRemoveFilterChip, tooltipConfig, ...rest }: FilterChipProps<T>): React.JSX.Element;
|
|
76
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
37
|
+
var t = {};
|
|
38
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
39
|
+
t[p] = s[p];
|
|
40
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
41
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
42
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
43
|
+
t[p[i]] = s[p[i]];
|
|
44
|
+
}
|
|
45
|
+
return t;
|
|
46
|
+
};
|
|
47
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.FilterChip = void 0;
|
|
52
|
+
var react_1 = __importStar(require("react"));
|
|
53
|
+
var class_names_1 = __importDefault(require("../utils/class_names"));
|
|
54
|
+
var modifier_classes_1 = require("../utils/modifier_classes");
|
|
55
|
+
var express_1 = require("../icons/express");
|
|
56
|
+
var data_attributes_1 = __importDefault(require("../utils/data_attributes"));
|
|
57
|
+
var chip_1 = require("./chip");
|
|
58
|
+
var tooltip_container_1 = require("./tooltip/tooltip_container");
|
|
59
|
+
function FilterChip(_a) {
|
|
60
|
+
var _modifierClass = _a._modifierClass, ariaLabel = _a["aria-label"], ariaLabelledby = _a["aria-labelledby"], ariaDescribedby = _a["aria-describedby"], _b = _a.chipMaxCharacters, chipMaxCharacters = _b === void 0 ? 21 : _b, chipTooltipConfig = _a.chipTooltipConfig, chipsDisabled = _a.chipsDisabled, filters = _a.filters, getRef = _a.getRef, icon = _a.icon, label = _a.label, margin = _a.margin, onRemoveFilterChip = _a.onRemoveFilterChip, tooltipConfig = _a.tooltipConfig, rest = __rest(_a, ["_modifierClass", 'aria-label', 'aria-labelledby', 'aria-describedby', "chipMaxCharacters", "chipTooltipConfig", "chipsDisabled", "filters", "getRef", "icon", "label", "margin", "onRemoveFilterChip", "tooltipConfig"]);
|
|
61
|
+
var containerClassnames = (0, class_names_1.default)('FilterChip', (0, modifier_classes_1.getMarginClass)(margin), _modifierClass);
|
|
62
|
+
var getChipInteractiveProps = (0, react_1.useCallback)(function (filter) {
|
|
63
|
+
var chipsAreInteractive = !!onRemoveFilterChip;
|
|
64
|
+
if (!chipsAreInteractive) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
onClick: function (e) {
|
|
69
|
+
return onRemoveFilterChip(filter, e);
|
|
70
|
+
},
|
|
71
|
+
disabled: chipsDisabled,
|
|
72
|
+
activeBgColor: 'gray-200',
|
|
73
|
+
hoverBgColor: 'gray-100',
|
|
74
|
+
icon: (react_1.default.createElement(express_1.ExpressIcons.IconCircleXOutlined, { "aria-hidden": true, color: "gray-500", base: "12" }))
|
|
75
|
+
};
|
|
76
|
+
}, [chipsDisabled, onRemoveFilterChip]);
|
|
77
|
+
// Component is hidden if there are no displayed filters
|
|
78
|
+
if (!filters.length) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
return (react_1.default.createElement("div", __assign({}, (0, data_attributes_1.default)(rest), { className: containerClassnames, ref: getRef, role: "group", "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby, "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : "Applied filters for ".concat(label) }),
|
|
82
|
+
react_1.default.createElement(tooltip_container_1.TooltipContainer, __assign({}, tooltipConfig), function (_a) {
|
|
83
|
+
var ref = _a.ref;
|
|
84
|
+
return (react_1.default.createElement("div", { className: "FilterChip__Parent", ref: ref },
|
|
85
|
+
!!icon && icon,
|
|
86
|
+
react_1.default.createElement("span", { className: "FilterChip__Label" }, label)));
|
|
87
|
+
}),
|
|
88
|
+
react_1.default.createElement("div", { className: "FilterChip__List" }, filters.map(function (filter) { return (react_1.default.createElement(chip_1.Chip, { key: filter.id, variant: "modern", maxCharacters: chipMaxCharacters, bgColor: "gray-50", textColor: "gray-800", tooltipConfig: chipTooltipConfig, actionConfig: getChipInteractiveProps(filter), "aria-label": onRemoveFilterChip ? "Remove filter: ".concat(filter.title) : undefined }, filter.title)); }))));
|
|
89
|
+
}
|
|
90
|
+
exports.FilterChip = FilterChip;
|
|
91
|
+
//# sourceMappingURL=filter_chip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter_chip.js","sourceRoot":"","sources":["../../../src/components/filter_chip.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAgE;AAQhE,qEAA8C;AAC9C,8DAA2D;AAC3D,4CAAgD;AAChD,6EAAyD;AAEzD,+BAA8B;AAC9B,iEAA+D;AAyE/D,SAAgB,UAAU,CAAoC,EAgBzC;IAfnB,IAAA,cAAc,oBAAA,EACA,SAAS,mBAAA,EACJ,cAAc,wBAAA,EACb,eAAe,yBAAA,EACnC,yBAAsB,EAAtB,iBAAiB,mBAAG,EAAE,KAAA,EACtB,iBAAiB,uBAAA,EACjB,aAAa,mBAAA,EACb,OAAO,aAAA,EACP,MAAM,YAAA,EACN,IAAI,UAAA,EACJ,KAAK,WAAA,EACL,MAAM,YAAA,EACN,kBAAkB,wBAAA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AK,CAAQ,CAC9C,CACP;QALa,CAKb,CACgB;QACnB,uCAAK,SAAS,EAAC,kBAAkB,IAC9B,OAAO,CAAC,GAAG,CAAC,UAAC,MAAM,IAAK,OAAA,CACvB,8BAAC,WAAI,IACH,GAAG,EAAE,MAAM,CAAC,EAAE,EACd,OAAO,EAAC,QAAQ,EAChB,aAAa,EAAE,iBAAiB,EAChC,OAAO,EAAC,SAAS,EACjB,SAAS,EAAC,UAAU,EACpB,aAAa,EAAE,iBAAiB,EAChC,YAAY,EAAE,uBAAuB,CAAC,MAAM,CAAC,gBAE3C,kBAAkB,CAAC,CAAC,CAAC,yBAAkB,MAAM,CAAC,KAAK,CAAE,CAAC,CAAC,CAAC,SAAS,IAGlE,MAAM,CAAC,KAAK,CACR,CACR,EAfwB,CAexB,CAAC,CACE,CACF,CACP,CAAC;AACJ,CAAC;AA5FD,gCA4FC"}
|
|
@@ -134,6 +134,7 @@ import { IconLayeredSquaresPlay } from './layered_squares_play';
|
|
|
134
134
|
import { IconLayeredSquaresQuestion } from './layered_squares_question';
|
|
135
135
|
import { IconLayeredSquaresThree } from './layered_squares_three';
|
|
136
136
|
import { IconLinesStaggered } from './lines_staggered';
|
|
137
|
+
import { IconLightbulbFilled } from './lightbulb_filled';
|
|
137
138
|
import { IconLightbulb } from './lightbulb';
|
|
138
139
|
import { IconLineInRectangle } from './line_in_rectangle';
|
|
139
140
|
import { IconLink } from './link';
|
|
@@ -224,6 +225,7 @@ import { IconTriangleDown } from './triangle_down';
|
|
|
224
225
|
import { IconTriangleLeft } from './triangle_left';
|
|
225
226
|
import { IconTriangleRight } from './triangle_right';
|
|
226
227
|
import { IconTriangleUp } from './triangle_up';
|
|
228
|
+
import { IconTriangleExclamationFilled } from './triangle_exclamation_filled';
|
|
227
229
|
import { IconTriangleExclamation } from './triangle_exclamation';
|
|
228
230
|
import { IconTrophy } from './trophy';
|
|
229
231
|
import { IconWand } from './wand';
|
|
@@ -366,6 +368,7 @@ declare const ExpressIcons: {
|
|
|
366
368
|
IconLayeredSquaresQuestion: typeof IconLayeredSquaresQuestion;
|
|
367
369
|
IconLayeredSquaresThree: typeof IconLayeredSquaresThree;
|
|
368
370
|
IconLinesStaggered: typeof IconLinesStaggered;
|
|
371
|
+
IconLightbulbFilled: typeof IconLightbulbFilled;
|
|
369
372
|
IconLightbulb: typeof IconLightbulb;
|
|
370
373
|
IconLineInRectangle: typeof IconLineInRectangle;
|
|
371
374
|
IconLink: typeof IconLink;
|
|
@@ -456,6 +459,7 @@ declare const ExpressIcons: {
|
|
|
456
459
|
IconTriangleLeft: typeof IconTriangleLeft;
|
|
457
460
|
IconTriangleRight: typeof IconTriangleRight;
|
|
458
461
|
IconTriangleUp: typeof IconTriangleUp;
|
|
462
|
+
IconTriangleExclamationFilled: typeof IconTriangleExclamationFilled;
|
|
459
463
|
IconTriangleExclamation: typeof IconTriangleExclamation;
|
|
460
464
|
IconTrophy: typeof IconTrophy;
|
|
461
465
|
IconWand: typeof IconWand;
|