@qoretechnologies/reqore 0.78.19 → 0.78.20-pr.723.g9cefab8
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/.claude/CLAUDE.md +47 -1
- package/dist/components/Accordion/index.d.ts.map +1 -1
- package/dist/components/Accordion/index.js +60 -14
- package/dist/components/Accordion/index.js.map +1 -1
- package/dist/components/Breadcrumbs/index.d.ts.map +1 -1
- package/dist/components/Breadcrumbs/index.js +58 -21
- package/dist/components/Breadcrumbs/index.js.map +1 -1
- package/dist/components/Bubble/index.d.ts.map +1 -1
- package/dist/components/Bubble/index.js +13 -4
- package/dist/components/Bubble/index.js.map +1 -1
- package/dist/components/Button/index.d.ts +67 -0
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +359 -142
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Callout/index.d.ts.map +1 -1
- package/dist/components/Callout/index.js +49 -29
- package/dist/components/Callout/index.js.map +1 -1
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index.js +112 -36
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/CollapsibleContent/index.d.ts.map +1 -1
- package/dist/components/CollapsibleContent/index.js +6 -2
- package/dist/components/CollapsibleContent/index.js.map +1 -1
- package/dist/components/ControlGroup/index.d.ts.map +1 -1
- package/dist/components/ControlGroup/index.js +22 -1
- package/dist/components/ControlGroup/index.js.map +1 -1
- package/dist/components/DataView/index.d.ts +8 -0
- package/dist/components/DataView/index.d.ts.map +1 -1
- package/dist/components/DataView/index.js +217 -114
- package/dist/components/DataView/index.js.map +1 -1
- package/dist/components/DatePicker/index.d.ts +3 -1
- package/dist/components/DatePicker/index.d.ts.map +1 -1
- package/dist/components/DatePicker/index.js +75 -43
- package/dist/components/DatePicker/index.js.map +1 -1
- package/dist/components/DescriptionList/index.d.ts.map +1 -1
- package/dist/components/DescriptionList/index.js +30 -4
- package/dist/components/DescriptionList/index.js.map +1 -1
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +41 -25
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Dropdown/list.d.ts.map +1 -1
- package/dist/components/Dropdown/list.js +19 -14
- package/dist/components/Dropdown/list.js.map +1 -1
- package/dist/components/Effect/index.d.ts +37 -0
- package/dist/components/Effect/index.d.ts.map +1 -1
- package/dist/components/Effect/index.js +224 -58
- package/dist/components/Effect/index.js.map +1 -1
- package/dist/components/EntityRow/index.d.ts.map +1 -1
- package/dist/components/EntityRow/index.js +98 -59
- package/dist/components/EntityRow/index.js.map +1 -1
- package/dist/components/FeatureCard/index.d.ts.map +1 -1
- package/dist/components/FeatureCard/index.js +54 -21
- package/dist/components/FeatureCard/index.js.map +1 -1
- package/dist/components/Header/index.d.ts.map +1 -1
- package/dist/components/Header/index.js +7 -4
- package/dist/components/Header/index.js.map +1 -1
- package/dist/components/Icon/index.d.ts.map +1 -1
- package/dist/components/Icon/index.js +13 -3
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/Input/index.d.ts +44 -1
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js +89 -23
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/InputClearButton/index.d.ts +7 -2
- package/dist/components/InputClearButton/index.d.ts.map +1 -1
- package/dist/components/InputClearButton/index.js +12 -5
- package/dist/components/InputClearButton/index.js.map +1 -1
- package/dist/components/InternalPopover/index.d.ts.map +1 -1
- package/dist/components/InternalPopover/index.js +19 -10
- package/dist/components/InternalPopover/index.js.map +1 -1
- package/dist/components/Link/index.d.ts.map +1 -1
- package/dist/components/Link/index.js +6 -1
- package/dist/components/Link/index.js.map +1 -1
- package/dist/components/Menu/divider.d.ts.map +1 -1
- package/dist/components/Menu/divider.js +8 -3
- package/dist/components/Menu/divider.js.map +1 -1
- package/dist/components/Menu/index.d.ts.map +1 -1
- package/dist/components/Menu/index.js +17 -4
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Menu/item.d.ts.map +1 -1
- package/dist/components/Menu/item.js +3 -5
- package/dist/components/Menu/item.js.map +1 -1
- package/dist/components/Message/index.d.ts.map +1 -1
- package/dist/components/Message/index.js +20 -4
- package/dist/components/Message/index.js.map +1 -1
- package/dist/components/NavRail/index.d.ts +2 -0
- package/dist/components/NavRail/index.d.ts.map +1 -1
- package/dist/components/NavRail/index.js +131 -47
- package/dist/components/NavRail/index.js.map +1 -1
- package/dist/components/Notifications/notification.d.ts +6 -2
- package/dist/components/Notifications/notification.d.ts.map +1 -1
- package/dist/components/Notifications/notification.js +78 -18
- package/dist/components/Notifications/notification.js.map +1 -1
- package/dist/components/Notifications/styles.d.ts +20 -0
- package/dist/components/Notifications/styles.d.ts.map +1 -1
- package/dist/components/Notifications/styles.js +37 -9
- package/dist/components/Notifications/styles.js.map +1 -1
- package/dist/components/Paging/index.d.ts.map +1 -1
- package/dist/components/Paging/index.js +4 -3
- package/dist/components/Paging/index.js.map +1 -1
- package/dist/components/Panel/index.d.ts +3 -0
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +214 -153
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/Paragraph/index.d.ts.map +1 -1
- package/dist/components/Paragraph/index.js +8 -5
- package/dist/components/Paragraph/index.js.map +1 -1
- package/dist/components/Progress/index.d.ts.map +1 -1
- package/dist/components/Progress/index.js +1 -1
- package/dist/components/Progress/index.js.map +1 -1
- package/dist/components/Rating/index.d.ts.map +1 -1
- package/dist/components/Rating/index.js +20 -8
- package/dist/components/Rating/index.js.map +1 -1
- package/dist/components/RichTextEditor/index.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.js +89 -46
- package/dist/components/RichTextEditor/index.js.map +1 -1
- package/dist/components/SegmentedControl/index.d.ts.map +1 -1
- package/dist/components/SegmentedControl/index.js +87 -42
- package/dist/components/SegmentedControl/index.js.map +1 -1
- package/dist/components/SeverityRow/index.d.ts.map +1 -1
- package/dist/components/SeverityRow/index.js +1 -1
- package/dist/components/SeverityRow/index.js.map +1 -1
- package/dist/components/Span/index.d.ts.map +1 -1
- package/dist/components/Span/index.js +8 -5
- package/dist/components/Span/index.js.map +1 -1
- package/dist/components/StackedBar/index.d.ts.map +1 -1
- package/dist/components/StackedBar/index.js +42 -12
- package/dist/components/StackedBar/index.js.map +1 -1
- package/dist/components/Statistic/index.d.ts.map +1 -1
- package/dist/components/Statistic/index.js +34 -6
- package/dist/components/Statistic/index.js.map +1 -1
- package/dist/components/Table/cell.d.ts.map +1 -1
- package/dist/components/Table/cell.js +128 -53
- package/dist/components/Table/cell.js.map +1 -1
- package/dist/components/Table/headerCell.d.ts.map +1 -1
- package/dist/components/Table/headerCell.js +7 -5
- package/dist/components/Table/headerCell.js.map +1 -1
- package/dist/components/Table/index.d.ts.map +1 -1
- package/dist/components/Table/index.js +2 -1
- package/dist/components/Table/index.js.map +1 -1
- package/dist/components/Table/scrollbar.d.ts.map +1 -1
- package/dist/components/Table/scrollbar.js +17 -9
- package/dist/components/Table/scrollbar.js.map +1 -1
- package/dist/components/Tag/index.d.ts +70 -3
- package/dist/components/Tag/index.d.ts.map +1 -1
- package/dist/components/Tag/index.js +336 -100
- package/dist/components/Tag/index.js.map +1 -1
- package/dist/components/Testimonial/index.d.ts.map +1 -1
- package/dist/components/Testimonial/index.js +35 -20
- package/dist/components/Testimonial/index.js.map +1 -1
- package/dist/components/Textarea/index.d.ts +6 -0
- package/dist/components/Textarea/index.d.ts.map +1 -1
- package/dist/components/Textarea/index.js +20 -20
- package/dist/components/Textarea/index.js.map +1 -1
- package/dist/components/Tier/group.d.ts +2 -0
- package/dist/components/Tier/group.d.ts.map +1 -1
- package/dist/components/Tier/group.js +4 -2
- package/dist/components/Tier/group.js.map +1 -1
- package/dist/components/Timeline/index.d.ts +2 -0
- package/dist/components/Timeline/index.d.ts.map +1 -1
- package/dist/components/Timeline/index.js +56 -13
- package/dist/components/Timeline/index.js.map +1 -1
- package/dist/components/Tree/index.d.ts.map +1 -1
- package/dist/components/Tree/index.js +23 -19
- package/dist/components/Tree/index.js.map +1 -1
- package/dist/containers/ReqoreProvider.d.ts.map +1 -1
- package/dist/containers/ReqoreProvider.js +4 -1
- package/dist/containers/ReqoreProvider.js.map +1 -1
- package/dist/containers/UIProvider.d.ts +11 -1
- package/dist/containers/UIProvider.d.ts.map +1 -1
- package/dist/containers/UIProvider.js +33 -4
- package/dist/containers/UIProvider.js.map +1 -1
- package/dist/context/ReqoreContext.d.ts +6 -0
- package/dist/context/ReqoreContext.d.ts.map +1 -1
- package/dist/context/ReqoreContext.js +2 -0
- package/dist/context/ReqoreContext.js.map +1 -1
- package/dist/context/SurfaceContext.d.ts +18 -0
- package/dist/context/SurfaceContext.d.ts.map +1 -0
- package/dist/context/SurfaceContext.js +39 -0
- package/dist/context/SurfaceContext.js.map +1 -0
- package/dist/helpers/colors.d.ts +184 -2
- package/dist/helpers/colors.d.ts.map +1 -1
- package/dist/helpers/colors.js +739 -86
- package/dist/helpers/colors.js.map +1 -1
- package/dist/helpers/iconProps.d.ts +14 -0
- package/dist/helpers/iconProps.d.ts.map +1 -0
- package/dist/helpers/iconProps.js +33 -0
- package/dist/helpers/iconProps.js.map +1 -0
- package/dist/helpers/locale.d.ts +20 -0
- package/dist/helpers/locale.d.ts.map +1 -0
- package/dist/helpers/locale.js +61 -0
- package/dist/helpers/locale.js.map +1 -0
- package/dist/helpers/schedule.d.ts +12 -0
- package/dist/helpers/schedule.d.ts.map +1 -0
- package/dist/helpers/schedule.js +10 -0
- package/dist/helpers/schedule.js.map +1 -0
- package/dist/helpers/surface.d.ts +31 -0
- package/dist/helpers/surface.d.ts.map +1 -0
- package/dist/helpers/surface.js +87 -0
- package/dist/helpers/surface.js.map +1 -0
- package/dist/hooks/useDrawnSurface.d.ts +38 -0
- package/dist/hooks/useDrawnSurface.d.ts.map +1 -0
- package/dist/hooks/useDrawnSurface.js +48 -0
- package/dist/hooks/useDrawnSurface.js.map +1 -0
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/hooks/useFocusTrap.js +24 -6
- package/dist/hooks/useFocusTrap.js.map +1 -1
- package/dist/hooks/usePrefersReducedMotion.d.ts +5 -0
- package/dist/hooks/usePrefersReducedMotion.d.ts.map +1 -1
- package/dist/hooks/usePrefersReducedMotion.js +9 -1
- package/dist/hooks/usePrefersReducedMotion.js.map +1 -1
- package/dist/hooks/useTextareaAutoSize.d.ts +15 -0
- package/dist/hooks/useTextareaAutoSize.d.ts.map +1 -1
- package/dist/hooks/useTextareaAutoSize.js +90 -12
- package/dist/hooks/useTextareaAutoSize.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/{vite.config.ts → vite.config.mts} +6 -0
- package/vitest.config.mts +241 -0
- package/tests.json +0 -1
- package/vitest.config.ts +0 -152
|
@@ -71,7 +71,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
71
71
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
72
72
|
};
|
|
73
73
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
74
|
-
exports.StyledTag = exports.REQORE_TAG_STYLE_PROPS = exports.getTagAppearanceColors = exports.TAG_SOFT_BACKGROUND_OPACITY = void 0;
|
|
74
|
+
exports.StyledTag = exports.REQORE_TAG_STYLE_PROPS = exports.getTagAppearanceColors = exports.TAG_SOFT_BACKGROUND_OPACITY = exports.getTagPaint = exports.getTagSolidColors = void 0;
|
|
75
75
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
76
76
|
var classnames_1 = __importDefault(require("classnames"));
|
|
77
77
|
var size_1 = __importDefault(require("lodash/size"));
|
|
@@ -83,11 +83,117 @@ var colors_1 = require("../../constants/colors");
|
|
|
83
83
|
var fonts_1 = require("../../constants/fonts");
|
|
84
84
|
var sizes_1 = require("../../constants/sizes");
|
|
85
85
|
var colors_2 = require("../../helpers/colors");
|
|
86
|
+
var SurfaceContext_1 = require("../../context/SurfaceContext");
|
|
86
87
|
var styled_1 = __importStar(require("../../helpers/styled"));
|
|
88
|
+
var iconProps_1 = require("../../helpers/iconProps");
|
|
87
89
|
var styles_1 = require("../../styles");
|
|
88
90
|
var Effect_1 = require("../Effect");
|
|
89
91
|
var Icon_1 = __importDefault(require("../Icon"));
|
|
90
92
|
var TooltipComponent_1 = require("../TooltipComponent");
|
|
93
|
+
/**
|
|
94
|
+
* The fill a solid tag paints, at rest or hovered: its colour (the theme's a step lighter without one), or a wash
|
|
95
|
+
* of it when minimal. A colour the helpers cannot read (a CSS variable) is washed by the browser.
|
|
96
|
+
*/
|
|
97
|
+
var getTagFill = function (theme, color, minimal, hover) {
|
|
98
|
+
return minimal
|
|
99
|
+
? color
|
|
100
|
+
? (0, colors_2.getColorAtAlpha)(color, hover ? 0.5 : 0.2)
|
|
101
|
+
: (0, colors_2.getColorAtAlpha)((0, colors_2.changeLightness)('#000000', 0.05), hover ? 0.4 : 0.3)
|
|
102
|
+
: color || (0, colors_2.changeLightness)(theme.main, hover ? 0.15 : 0.1);
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* What a solid tag is drawn on and in, at rest or hovered: its fill as drawn over the theme's surface (a minimal
|
|
106
|
+
* tag's wash, a translucent colour, each colour of a gradient), the key darkened over it, and a label and a key
|
|
107
|
+
* that read on them. A minimal tag with a colour keeps the colour in its label, in a shade that reads.
|
|
108
|
+
*/
|
|
109
|
+
var getTagSolidColors = function (theme, color, minimal, labelKey, effect, hovered, surface) {
|
|
110
|
+
if (hovered === void 0) { hovered = false; }
|
|
111
|
+
// what the tag is drawn on: one color, or each color of a gradient (a button's, a panel's)
|
|
112
|
+
var unders = (0, colors_2.getThemeSurfaces)(theme, surface);
|
|
113
|
+
var named = color && color !== 'transparent' ? color : undefined;
|
|
114
|
+
var gradient = (0, Effect_1.getPrimaryGradient)(effect === null || effect === void 0 ? void 0 : effect.gradient);
|
|
115
|
+
var paint = function (hover) {
|
|
116
|
+
return unders.flatMap(function (under) {
|
|
117
|
+
/* A gradient is read as it is painted: a minimal one's translucent fill shows its ring and the tag's own
|
|
118
|
+
wash through it. */
|
|
119
|
+
return gradient
|
|
120
|
+
? (0, Effect_1.getEffectGradientBackgrounds)(theme, gradient.colors, minimal, getTagFill(theme, named, minimal, false), under)
|
|
121
|
+
: [(0, colors_2.getDrawnColor)(getTagFill(theme, named, minimal, hover), under)];
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
var backgrounds = paint(hovered);
|
|
125
|
+
/* The key is drawn darker than the label, so it has a text colour of its own: black at 30% (10% minimal) over
|
|
126
|
+
the fill, or darker, as far as it takes for one text colour to read on all of it - over a light colour the key
|
|
127
|
+
lands in the mid-tones, where neither light nor dark text reads. The shade is the one the tag is painted with
|
|
128
|
+
at rest, hovered too. */
|
|
129
|
+
var shadeOver = function (fill, alpha) {
|
|
130
|
+
return fill.map(function (background) { return (0, colors_2.getDrawnColor)((0, polished_1.rgba)('#000000', alpha), background); });
|
|
131
|
+
};
|
|
132
|
+
var readsOn = function (fill) {
|
|
133
|
+
var text = (0, colors_2.getReadableColorOn)(fill);
|
|
134
|
+
return fill.every(function (background) { return (0, colors_2.getContrastRatio)(text, background) >= colors_2.READABLE_TEXT_CONTRAST; });
|
|
135
|
+
};
|
|
136
|
+
var resting = hovered ? paint(false) : backgrounds;
|
|
137
|
+
var keyAlpha = minimal ? 0.1 : 0.3;
|
|
138
|
+
while (labelKey && keyAlpha < 0.8 && !readsOn(shadeOver(resting, keyAlpha))) {
|
|
139
|
+
keyAlpha = Math.round((keyAlpha + 0.05) * 100) / 100;
|
|
140
|
+
}
|
|
141
|
+
var keyShade = (0, polished_1.rgba)('#000000', keyAlpha);
|
|
142
|
+
var keyBackgrounds = labelKey ? shadeOver(backgrounds, keyAlpha) : backgrounds;
|
|
143
|
+
if (minimal && named && !(0, colors_2.isAchromatic)(named) && !hovered && !gradient) {
|
|
144
|
+
// a colour the helpers cannot read is as it is given: its label is written in it, on the wash of it
|
|
145
|
+
var text = (0, colors_2.getReadableAccentColorOn)((0, colors_2.getSaturatedTint)(named, 0.8), backgrounds);
|
|
146
|
+
return {
|
|
147
|
+
backgrounds: backgrounds,
|
|
148
|
+
keyBackgrounds: keyBackgrounds,
|
|
149
|
+
keyShade: keyShade,
|
|
150
|
+
text: text,
|
|
151
|
+
keyText: (0, colors_2.getReadableAccentColorOn)(text, keyBackgrounds),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
backgrounds: backgrounds,
|
|
156
|
+
keyBackgrounds: keyBackgrounds,
|
|
157
|
+
keyShade: keyShade,
|
|
158
|
+
text: (0, colors_2.getReadableColorOn)(backgrounds),
|
|
159
|
+
keyText: (0, colors_2.getReadableColorOn)(keyBackgrounds),
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
exports.getTagSolidColors = getTagSolidColors;
|
|
163
|
+
/**
|
|
164
|
+
* Everything a tag is painted with (`IReqoreTagPaint`), and the solid colours it is worked out from: `resting`,
|
|
165
|
+
* and `hovered` when the tag answers the pointer. A soft or text tag (`solid` false) has its own colours
|
|
166
|
+
* (`getTagAppearanceColors`), so none of the solid ones are worked out for it.
|
|
167
|
+
*/
|
|
168
|
+
var getTagPaint = function (theme, color, minimal, labelKey, effect, interactive, surface, solid) {
|
|
169
|
+
var own = color || theme.main;
|
|
170
|
+
var paint = {
|
|
171
|
+
edge: (0, colors_2.changeLightness)(own, 0.2),
|
|
172
|
+
outline: (0, colors_2.changeLightness)(own, 0.25),
|
|
173
|
+
};
|
|
174
|
+
if (!solid) {
|
|
175
|
+
return { paint: paint };
|
|
176
|
+
}
|
|
177
|
+
var resting = (0, exports.getTagSolidColors)(theme, color, minimal, labelKey, effect, false, surface);
|
|
178
|
+
var hovered = interactive
|
|
179
|
+
? (0, exports.getTagSolidColors)(theme, color, minimal, labelKey, effect, true, surface)
|
|
180
|
+
: undefined;
|
|
181
|
+
paint.rest = {
|
|
182
|
+
background: getTagFill(theme, color, minimal, false),
|
|
183
|
+
text: resting.text,
|
|
184
|
+
keyShade: resting.keyShade,
|
|
185
|
+
keyText: resting.keyText,
|
|
186
|
+
};
|
|
187
|
+
if (hovered) {
|
|
188
|
+
paint.hover = {
|
|
189
|
+
background: getTagFill(theme, color, minimal, true),
|
|
190
|
+
text: hovered.text,
|
|
191
|
+
keyText: hovered.keyText,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
return { paint: paint, resting: resting, hovered: hovered };
|
|
195
|
+
};
|
|
196
|
+
exports.getTagPaint = getTagPaint;
|
|
91
197
|
/** Share of the colour laid over the surface behind a soft tag. */
|
|
92
198
|
exports.TAG_SOFT_BACKGROUND_OPACITY = 0.2;
|
|
93
199
|
/**
|
|
@@ -98,33 +204,155 @@ exports.TAG_SOFT_BACKGROUND_OPACITY = 0.2;
|
|
|
98
204
|
* is the tag's own colour pushed lighter (dark theme) or darker (light theme) until it
|
|
99
205
|
* reaches a 4.5:1 contrast there — a green label stays green, only a shade that reads.
|
|
100
206
|
* With no colour at all the tag is neutral: the surface's readable text colour plays
|
|
101
|
-
* the part of the colour.
|
|
207
|
+
* the part of the colour. The surface is `drawnOn` when the tag knows what it is drawn on
|
|
208
|
+
* (`useReqoreSurface`; every colour of a gradient), the theme's surface otherwise
|
|
209
|
+
* (`getThemeSurfaces`). A colour the helpers cannot read (a CSS variable) is drawn as it
|
|
210
|
+
* is given: the label in it, over a wash of it the browser mixes.
|
|
102
211
|
*/
|
|
103
|
-
var getTagAppearanceColors = function (theme, appearance, color) {
|
|
104
|
-
var
|
|
105
|
-
var
|
|
212
|
+
var getTagAppearanceColors = function (theme, appearance, color, drawnOn) {
|
|
213
|
+
var surfaces = (0, colors_2.getThemeSurfaces)(theme, drawnOn);
|
|
214
|
+
var neutral = (0, colors_2.getReadableColorOn)(surfaces);
|
|
215
|
+
var base = (0, colors_2.getOpaqueColor)(color && color !== 'transparent' ? color : neutral);
|
|
106
216
|
if (appearance === 'soft') {
|
|
107
|
-
|
|
108
|
-
var
|
|
217
|
+
// the wash as drawn over each color of the surface; over what it cannot be read on, the surface
|
|
218
|
+
var backgrounds = (0, colors_2.isReadableColor)(base)
|
|
219
|
+
? surfaces.map(function (surface) { return (0, polished_1.mix)(exports.TAG_SOFT_BACKGROUND_OPACITY, base, surface); })
|
|
220
|
+
: surfaces;
|
|
221
|
+
var text_1 = (0, colors_2.getReadableAccentColorOn)(base, backgrounds);
|
|
222
|
+
var keyBackground_1 = (0, colors_2.getColorAtAlpha)(base, 0.15);
|
|
223
|
+
var drawnKeyBackgrounds_1 = backgrounds.map(function (background) {
|
|
224
|
+
return (0, colors_2.getDrawnColor)(keyBackground_1, background);
|
|
225
|
+
});
|
|
109
226
|
return {
|
|
110
227
|
text: text_1,
|
|
111
|
-
background: (0,
|
|
112
|
-
hoverBackground: (0,
|
|
113
|
-
border: (0,
|
|
114
|
-
keyBackground:
|
|
115
|
-
|
|
228
|
+
background: (0, colors_2.getColorAtAlpha)(base, exports.TAG_SOFT_BACKGROUND_OPACITY),
|
|
229
|
+
hoverBackground: (0, colors_2.getColorAtAlpha)(base, exports.TAG_SOFT_BACKGROUND_OPACITY + 0.1),
|
|
230
|
+
border: (0, colors_2.getColorAtAlpha)(text_1, 0.6),
|
|
231
|
+
keyBackground: keyBackground_1,
|
|
232
|
+
keyText: (0, colors_2.getReadableAccentColorOn)(text_1, drawnKeyBackgrounds_1),
|
|
233
|
+
drawnBackground: backgrounds[0],
|
|
234
|
+
drawnBackgrounds: backgrounds,
|
|
235
|
+
drawnKeyBackground: drawnKeyBackgrounds_1[0],
|
|
236
|
+
drawnKeyBackgrounds: drawnKeyBackgrounds_1,
|
|
237
|
+
buttonHoverBackground: (0, colors_2.getColorAtAlpha)(base, 0.25),
|
|
116
238
|
};
|
|
117
239
|
}
|
|
118
|
-
var text = (0, colors_2.
|
|
240
|
+
var text = (0, colors_2.getReadableAccentColorOn)(base, surfaces);
|
|
241
|
+
var keyBackground = (0, colors_2.getColorAtAlpha)(neutral, 0.08);
|
|
242
|
+
var drawnKeyBackgrounds = surfaces.map(function (surface) { return (0, colors_2.getDrawnColor)(keyBackground, surface); });
|
|
119
243
|
return {
|
|
120
244
|
text: text,
|
|
121
245
|
background: 'transparent',
|
|
122
|
-
hoverBackground: (0,
|
|
123
|
-
keyBackground:
|
|
124
|
-
|
|
246
|
+
hoverBackground: (0, colors_2.getColorAtAlpha)(text, 0.1),
|
|
247
|
+
keyBackground: keyBackground,
|
|
248
|
+
keyText: (0, colors_2.getReadableAccentColorOn)(text, drawnKeyBackgrounds),
|
|
249
|
+
drawnBackground: surfaces[0],
|
|
250
|
+
drawnBackgrounds: surfaces,
|
|
251
|
+
drawnKeyBackground: drawnKeyBackgrounds[0],
|
|
252
|
+
drawnKeyBackgrounds: drawnKeyBackgrounds,
|
|
253
|
+
buttonHoverBackground: (0, colors_2.getColorAtAlpha)(text, 0.15),
|
|
125
254
|
};
|
|
126
255
|
};
|
|
127
256
|
exports.getTagAppearanceColors = getTagAppearanceColors;
|
|
257
|
+
/**
|
|
258
|
+
* What a styled tag is painted with: what the tag worked out for this render, or - a `StyledTag` rendered on its
|
|
259
|
+
* own - worked out from its props.
|
|
260
|
+
*/
|
|
261
|
+
var getStyledTagPaint = function (props) {
|
|
262
|
+
var _a;
|
|
263
|
+
return (_a = props.$paint) !== null && _a !== void 0 ? _a : (0, exports.getTagPaint)(props.theme, props.color, props.minimal, !!props.labelKey, props.effect, !!props.interactive, props.$surface, !props.$appearanceColors).paint;
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* The colors and lengths a tag is drawn with, each set in a CSS variable on the tag: its paint (a solid tag's fill
|
|
267
|
+
* and text, at rest and hovered, and its key's), a soft or text tag's own colors, its widths, and its size's font,
|
|
268
|
+
* height and radius, as its styles wrote them. `undefined` where the tag has none.
|
|
269
|
+
*/
|
|
270
|
+
var TAG_VARIABLES = {
|
|
271
|
+
'--reqore-tag-edge': function (props) { return getStyledTagPaint(props).edge; },
|
|
272
|
+
'--reqore-tag-outline': function (props) { return getStyledTagPaint(props).outline; },
|
|
273
|
+
'--reqore-tag-background': function (props) { var _a; return (_a = getStyledTagPaint(props).rest) === null || _a === void 0 ? void 0 : _a.background; },
|
|
274
|
+
'--reqore-tag-text': function (props) { var _a; return (_a = getStyledTagPaint(props).rest) === null || _a === void 0 ? void 0 : _a.text; },
|
|
275
|
+
'--reqore-tag-key-shade': function (props) { var _a; return (_a = getStyledTagPaint(props).rest) === null || _a === void 0 ? void 0 : _a.keyShade; },
|
|
276
|
+
'--reqore-tag-key-text': function (props) { var _a; return (_a = getStyledTagPaint(props).rest) === null || _a === void 0 ? void 0 : _a.keyText; },
|
|
277
|
+
'--reqore-tag-hover-background': function (props) { var _a; return (_a = getStyledTagPaint(props).hover) === null || _a === void 0 ? void 0 : _a.background; },
|
|
278
|
+
'--reqore-tag-hover-text': function (props) { var _a; return (_a = getStyledTagPaint(props).hover) === null || _a === void 0 ? void 0 : _a.text; },
|
|
279
|
+
'--reqore-tag-hover-key-text': function (props) { var _a; return (_a = getStyledTagPaint(props).hover) === null || _a === void 0 ? void 0 : _a.keyText; },
|
|
280
|
+
'--reqore-tag-appearance-background': function (_a) {
|
|
281
|
+
var $appearanceColors = _a.$appearanceColors;
|
|
282
|
+
return $appearanceColors === null || $appearanceColors === void 0 ? void 0 : $appearanceColors.background;
|
|
283
|
+
},
|
|
284
|
+
'--reqore-tag-appearance-text': function (_a) {
|
|
285
|
+
var $appearanceColors = _a.$appearanceColors;
|
|
286
|
+
return $appearanceColors === null || $appearanceColors === void 0 ? void 0 : $appearanceColors.text;
|
|
287
|
+
},
|
|
288
|
+
'--reqore-tag-appearance-border': function (_a) {
|
|
289
|
+
var $appearanceColors = _a.$appearanceColors;
|
|
290
|
+
return $appearanceColors === null || $appearanceColors === void 0 ? void 0 : $appearanceColors.border;
|
|
291
|
+
},
|
|
292
|
+
'--reqore-tag-appearance-key-background': function (_a) {
|
|
293
|
+
var $appearanceColors = _a.$appearanceColors;
|
|
294
|
+
return $appearanceColors === null || $appearanceColors === void 0 ? void 0 : $appearanceColors.keyBackground;
|
|
295
|
+
},
|
|
296
|
+
'--reqore-tag-appearance-key-text': function (_a) {
|
|
297
|
+
var $appearanceColors = _a.$appearanceColors;
|
|
298
|
+
return $appearanceColors === null || $appearanceColors === void 0 ? void 0 : $appearanceColors.keyText;
|
|
299
|
+
},
|
|
300
|
+
'--reqore-tag-appearance-hover-background': function (_a) {
|
|
301
|
+
var $appearanceColors = _a.$appearanceColors;
|
|
302
|
+
return $appearanceColors === null || $appearanceColors === void 0 ? void 0 : $appearanceColors.hoverBackground;
|
|
303
|
+
},
|
|
304
|
+
'--reqore-tag-appearance-outline': function (_a) {
|
|
305
|
+
var $appearance = _a.$appearance, $appearanceColors = _a.$appearanceColors;
|
|
306
|
+
return $appearanceColors &&
|
|
307
|
+
($appearance === 'soft'
|
|
308
|
+
? $appearanceColors.border
|
|
309
|
+
: (0, colors_2.getColorAtAlpha)($appearanceColors.text, 0.5));
|
|
310
|
+
},
|
|
311
|
+
'--reqore-tag-max-width': function (_a) {
|
|
312
|
+
var $maxWidth = _a.$maxWidth, fixed = _a.fixed;
|
|
313
|
+
return $maxWidth !== null && $maxWidth !== void 0 ? $maxWidth : (fixed !== true ? '100%' : undefined);
|
|
314
|
+
},
|
|
315
|
+
'--reqore-tag-width': function (_a) {
|
|
316
|
+
var width = _a.width;
|
|
317
|
+
return width || undefined;
|
|
318
|
+
},
|
|
319
|
+
'--reqore-tag-font-size': function (_a) {
|
|
320
|
+
var size = _a.size;
|
|
321
|
+
return "".concat(sizes_1.TAG_TEXT_FROM_SIZE[size], "px");
|
|
322
|
+
},
|
|
323
|
+
'--reqore-tag-height': function (_a) {
|
|
324
|
+
var size = _a.size, asBadge = _a.asBadge;
|
|
325
|
+
return "".concat(asBadge ? sizes_1.BADGE_SIZE_TO_PX[size] : sizes_1.TAG_SIZE_TO_PX[size], "px");
|
|
326
|
+
},
|
|
327
|
+
'--reqore-tag-radius': function (_a) {
|
|
328
|
+
var asBadge = _a.asBadge, size = _a.size, radiusSize = _a.radiusSize, rounded = _a.rounded;
|
|
329
|
+
return rounded === false
|
|
330
|
+
? undefined
|
|
331
|
+
: asBadge
|
|
332
|
+
? "".concat((0, sizes_1.resolveRadius)(size, radiusSize, sizes_1.BADGE_RADIUS_FROM_SIZE, sizes_1.BADGE_RADIUS_FROM_RADIUS_SIZE), "px")
|
|
333
|
+
: "".concat((0, sizes_1.resolveRadius)(size, radiusSize, sizes_1.TAG_RADIUS_FROM_SIZE, sizes_1.TAG_RADIUS_FROM_RADIUS_SIZE), "px");
|
|
334
|
+
},
|
|
335
|
+
};
|
|
336
|
+
/** Whether a value is one CSS takes: not missing, and not a length made of a size the tag lacks. */
|
|
337
|
+
var isUsableValue = function (value) { return !!value && !/NaN|undefined/.test(value); };
|
|
338
|
+
/**
|
|
339
|
+
* What a tag is drawn with as CSS variables on the tag, which its styles read (`tagValueOf`). Written into the
|
|
340
|
+
* styles, each color and length made a class of its own - a page of tags in each color, appearance, size and width
|
|
341
|
+
* made hundreds, and styled-components warned - where the styles now differ only in what the tag is.
|
|
342
|
+
*/
|
|
343
|
+
var getTagVariables = function (props) {
|
|
344
|
+
return Object.fromEntries(Object.keys(TAG_VARIABLES)
|
|
345
|
+
.map(function (variable) { return [variable, TAG_VARIABLES[variable](props)]; })
|
|
346
|
+
.filter(function (entry) { return isUsableValue(entry[1]); }));
|
|
347
|
+
};
|
|
348
|
+
/**
|
|
349
|
+
* The value a tag's styles give a property: the variable it is set in, or - a value the tag has none for, or a length
|
|
350
|
+
* of a size it lacks - what the styles wrote before, which CSS drops as it did.
|
|
351
|
+
*/
|
|
352
|
+
var tagValueOf = function (props, variable) {
|
|
353
|
+
var value = TAG_VARIABLES[variable](props);
|
|
354
|
+
return isUsableValue(value) ? "var(".concat(variable, ")") : value;
|
|
355
|
+
};
|
|
128
356
|
/**
|
|
129
357
|
* Every tag prop that only styles or configures the tag. None of them reaches the rendered
|
|
130
358
|
* element — the `span`, or a component given as `as`. The compiler checks the record against
|
|
@@ -181,46 +409,28 @@ exports.REQORE_TAG_STYLE_PROPS = (0, styled_1.listReqoreStyleProps)({
|
|
|
181
409
|
});
|
|
182
410
|
// The layout flags a containing `ReqoreControlGroup` hands the tag are not the element's either
|
|
183
411
|
// (`fill` is an SVG attribute, so a `span` would keep it).
|
|
184
|
-
exports.StyledTag = (0, styled_1.default)(Effect_1.StyledEffect)
|
|
412
|
+
exports.StyledTag = (0, styled_1.default)(Effect_1.StyledEffect)
|
|
413
|
+
.withConfig({
|
|
185
414
|
shouldForwardProp: styled_1.omitStyleProps.apply(void 0, __spreadArray(__spreadArray([], exports.REQORE_TAG_STYLE_PROPS, false), styled_1.REQORE_CONTROL_GROUP_CHILD_PROPS, false)),
|
|
186
|
-
})
|
|
415
|
+
})
|
|
416
|
+
.attrs(function (props) { return ({
|
|
417
|
+
style: getTagVariables(props),
|
|
418
|
+
}); })(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n display: inline-flex;\n justify-content: center;\n flex-shrink: 0;\n align-items: stretch;\n /* Only when the caller has not asked for a family. StyledTag extends StyledEffect,\n so an unconditional declaration here always won the cascade over effect.fontFamily\n \u2014 which is why ReqoreDataView had to force monospace back on with a specificity-\n boosted descendant override instead of just setting the effect.\n NO BACKTICKS in this comment: it lives inside a template literal and they end it. */\n ", "\n overflow: hidden;\n vertical-align: ", ";\n font-size: ", ";\n line-height: 1.1;\n\n min-width: ", ";\n /* An explicit cap wins over the implicit one: a caller asking for 30ch means 30ch\n even inside a container wider than that, and 100% would let the tag grow past it. */\n max-width: ", ";\n flex: ", ";\n justify-self: ", ";\n border: ", ";\n /* Same flat !== false guard as EntityRow / FeatureCard / Callout: the inset\n highlight and the border are two ways of drawing the same edge, so a tag that\n already has a border does not also get the raised shading. */\n ", "\n border-radius: ", ";\n width: ", ";\n transition: all 0.2s ease-out;\n\n ", "\n\n ", ";\n\n ", "\n\n /* How a solid tag colours its label: against what it is actually drawn on\n (getTagSolidColors), never against the colour it is made from.\n\n Minimal paints the colour at 20% alpha, so what the label actually sits on\n is mostly the surface underneath \u2014 not the colour. For a CHROMATIC colour a\n tint of it, in a shade that reads there, keeps the colour in the label. For\n an ACHROMATIC one there is no tint to take: a 20% wash of grey over the\n surface IS the surface, so the label is read against that.\n\n It used to fall through to the readable colour for the colour at FULL\n strength. A near-white muted intent is light, so that returned BLACK, and\n the tag rendered black text on a 20% wash over a near-black page \u2014 reported\n as \"black text on a dark grey background; it's very hard to read\", and true\n of every minimal tag with a grey intent. The key beside the label is drawn\n darker, so it has a text colour of its own. */\n ", "\n\n ", "\n\n /* Soft and text tags: the colour draws the label (and, soft, the ring and a wash)\n instead of filling the tag. The ring is an inset shadow rather than a border so a\n soft tag keeps the exact box of a solid one \u2014 side by side in a group they line\n up \u2014 and it replaces any flat={false} border and the raised shading. */\n ", "\n\n ", "\n\n /* Read only is NOT disabled: the tag keeps its pointer events, so its tooltip and\n its actions still answer \u2014 it only stops advertising itself as something to\n press. Same meaning the prop has on ReqoreButton, ReqoreCheckbox and\n ReqoreRating. Last, so it wins over the interactive block's cursor: pointer. */\n ", "\n\n /* Only gate on hover where hover exists \u2014 see the same guard on ReqorePanel.\n On touch a `show: 'hover'` tag action would otherwise be display:none with\n no route to it at all. */\n @media (hover: hover) and (pointer: fine) {\n &:not(:hover) {\n .reqore-tag-action-hidden {\n display: none;\n }\n }\n }\n\n &:focus,\n &:active {\n outline: 2px solid ", ";\n outline-offset: -2px;\n }\n"], ["\n display: inline-flex;\n justify-content: center;\n flex-shrink: 0;\n align-items: stretch;\n /* Only when the caller has not asked for a family. StyledTag extends StyledEffect,\n so an unconditional declaration here always won the cascade over effect.fontFamily\n \u2014 which is why ReqoreDataView had to force monospace back on with a specificity-\n boosted descendant override instead of just setting the effect.\n NO BACKTICKS in this comment: it lives inside a template literal and they end it. */\n ", "\n overflow: hidden;\n vertical-align: ", ";\n font-size: ", ";\n line-height: 1.1;\n\n min-width: ", ";\n /* An explicit cap wins over the implicit one: a caller asking for 30ch means 30ch\n even inside a container wider than that, and 100% would let the tag grow past it. */\n max-width: ", ";\n flex: ", ";\n justify-self: ", ";\n border: ", ";\n /* Same flat !== false guard as EntityRow / FeatureCard / Callout: the inset\n highlight and the border are two ways of drawing the same edge, so a tag that\n already has a border does not also get the raised shading. */\n ", "\n border-radius: ", ";\n width: ", ";\n transition: all 0.2s ease-out;\n\n ", "\n\n ", ";\n\n ", "\n\n /* How a solid tag colours its label: against what it is actually drawn on\n (getTagSolidColors), never against the colour it is made from.\n\n Minimal paints the colour at 20% alpha, so what the label actually sits on\n is mostly the surface underneath \u2014 not the colour. For a CHROMATIC colour a\n tint of it, in a shade that reads there, keeps the colour in the label. For\n an ACHROMATIC one there is no tint to take: a 20% wash of grey over the\n surface IS the surface, so the label is read against that.\n\n It used to fall through to the readable colour for the colour at FULL\n strength. A near-white muted intent is light, so that returned BLACK, and\n the tag rendered black text on a 20% wash over a near-black page \u2014 reported\n as \"black text on a dark grey background; it's very hard to read\", and true\n of every minimal tag with a grey intent. The key beside the label is drawn\n darker, so it has a text colour of its own. */\n ", "\n\n ", "\n\n /* Soft and text tags: the colour draws the label (and, soft, the ring and a wash)\n instead of filling the tag. The ring is an inset shadow rather than a border so a\n soft tag keeps the exact box of a solid one \u2014 side by side in a group they line\n up \u2014 and it replaces any flat={false} border and the raised shading. */\n ", "\n\n ", "\n\n /* Read only is NOT disabled: the tag keeps its pointer events, so its tooltip and\n its actions still answer \u2014 it only stops advertising itself as something to\n press. Same meaning the prop has on ReqoreButton, ReqoreCheckbox and\n ReqoreRating. Last, so it wins over the interactive block's cursor: pointer. */\n ", "\n\n /* Only gate on hover where hover exists \u2014 see the same guard on ReqorePanel.\n On touch a \\`show: 'hover'\\` tag action would otherwise be display:none with\n no route to it at all. */\n @media (hover: hover) and (pointer: fine) {\n &:not(:hover) {\n .reqore-tag-action-hidden {\n display: none;\n }\n }\n }\n\n &:focus,\n &:active {\n outline: 2px solid ", ";\n outline-offset: -2px;\n }\n"])), function (_a) {
|
|
187
419
|
var effect = _a.effect;
|
|
188
420
|
return !(effect === null || effect === void 0 ? void 0 : effect.fontFamily) && (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n font-family: ", ";\n "], ["\n font-family: ", ";\n "])), fonts_1.SYSTEM_FONT);
|
|
189
421
|
}, function (_a) {
|
|
190
422
|
var _b = _a.verticalAlign, verticalAlign = _b === void 0 ? 'middle' : _b;
|
|
191
423
|
return verticalAlign;
|
|
192
|
-
}, function (_a) {
|
|
193
|
-
var size = _a.size;
|
|
194
|
-
return sizes_1.TAG_TEXT_FROM_SIZE[size];
|
|
195
|
-
}, function (_a) {
|
|
196
|
-
var size = _a.size, asBadge = _a.asBadge;
|
|
197
|
-
return (asBadge ? sizes_1.BADGE_SIZE_TO_PX[size] : sizes_1.TAG_SIZE_TO_PX[size]);
|
|
198
|
-
}, function (_a) {
|
|
199
|
-
var $maxWidth = _a.$maxWidth, fixed = _a.fixed;
|
|
200
|
-
return $maxWidth !== null && $maxWidth !== void 0 ? $maxWidth : (fixed !== true ? '100%' : undefined);
|
|
201
|
-
}, function (_a) {
|
|
424
|
+
}, function (props) { return tagValueOf(props, '--reqore-tag-font-size'); }, function (props) { return tagValueOf(props, '--reqore-tag-height'); }, function (props) { return tagValueOf(props, '--reqore-tag-max-width'); }, function (_a) {
|
|
202
425
|
var fluid = _a.fluid, fixed = _a.fixed;
|
|
203
426
|
return (fixed === true ? '0 0 auto' : fluid ? '1 auto' : '0 0 auto');
|
|
204
427
|
}, function (_a) {
|
|
205
428
|
var fixed = _a.fixed, fluid = _a.fluid;
|
|
206
429
|
return fixed === true ? 'flex-start' : fluid ? 'stretch' : undefined;
|
|
207
|
-
}, function (_a) {
|
|
208
|
-
var theme = _a.theme, color = _a.color, _b = _a.flat, flat = _b === void 0 ? true : _b;
|
|
209
|
-
return !flat ? "1px solid ".concat((0, colors_2.changeLightness)(color || theme.main, 0.2)) : 0;
|
|
210
|
-
}, function (_a) {
|
|
430
|
+
}, function (props) { var _a; return !((_a = props.flat) !== null && _a !== void 0 ? _a : true) ? "1px solid ".concat(tagValueOf(props, '--reqore-tag-edge')) : 0; }, function (_a) {
|
|
211
431
|
var raised = _a.raised, _b = _a.flat, flat = _b === void 0 ? true : _b;
|
|
212
432
|
return raised && flat !== false && styles_1.RaisedElement;
|
|
213
|
-
}, function (_a) {
|
|
214
|
-
var asBadge = _a.asBadge, size = _a.size, radiusSize = _a.radiusSize, rounded = _a.rounded;
|
|
215
|
-
return rounded === false
|
|
216
|
-
? undefined
|
|
217
|
-
: asBadge
|
|
218
|
-
? "".concat((0, sizes_1.resolveRadius)(size, radiusSize, sizes_1.BADGE_RADIUS_FROM_SIZE, sizes_1.BADGE_RADIUS_FROM_RADIUS_SIZE), "px")
|
|
219
|
-
: "".concat((0, sizes_1.resolveRadius)(size, radiusSize, sizes_1.TAG_RADIUS_FROM_SIZE, sizes_1.TAG_RADIUS_FROM_RADIUS_SIZE), "px");
|
|
220
|
-
}, function (_a) {
|
|
221
|
-
var width = _a.width;
|
|
222
|
-
return width || undefined;
|
|
223
|
-
}, function (_a) {
|
|
433
|
+
}, function (props) { return tagValueOf(props, '--reqore-tag-radius'); }, function (props) { return tagValueOf(props, '--reqore-tag-width'); }, function (_a) {
|
|
224
434
|
var align = _a.align;
|
|
225
435
|
if (align === 'left') {
|
|
226
436
|
return (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin-right: auto;\n "], ["\n margin-right: auto;\n "])));
|
|
@@ -234,58 +444,33 @@ exports.StyledTag = (0, styled_1.default)(Effect_1.StyledEffect).withConfig({
|
|
|
234
444
|
}, styles_1.InactiveIconScale, function (_a) {
|
|
235
445
|
var $wrap = _a.$wrap, $hasWidth = _a.$hasWidth;
|
|
236
446
|
return $wrap || $hasWidth
|
|
237
|
-
? (0, styled_components_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n min-height: ", "
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
var size = _a.size, asBadge = _a.asBadge;
|
|
242
|
-
return asBadge ? sizes_1.BADGE_SIZE_TO_PX[size] : sizes_1.TAG_SIZE_TO_PX[size];
|
|
243
|
-
});
|
|
244
|
-
}, function (_a) {
|
|
245
|
-
var theme = _a.theme, color = _a.color, labelKey = _a.labelKey, minimal = _a.minimal, $appearanceColors = _a.$appearanceColors;
|
|
246
|
-
if ($appearanceColors) {
|
|
447
|
+
? (0, styled_components_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n min-height: ", ";\n "], ["\n min-height: ", ";\n "])), function (props) { return tagValueOf(props, '--reqore-tag-height'); }) : (0, styled_components_1.css)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n height: ", ";\n "], ["\n height: ", ";\n "])), function (props) { return tagValueOf(props, '--reqore-tag-height'); });
|
|
448
|
+
}, function (props) {
|
|
449
|
+
var rest = getStyledTagPaint(props).rest;
|
|
450
|
+
if (props.$appearanceColors || !rest) {
|
|
247
451
|
return undefined;
|
|
248
452
|
}
|
|
249
|
-
return (0, styled_components_1.css)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n background-color: ", ";\n color: ", ";\n\n ", " {\n background-color: ", ";\n }\n "], ["\n background-color: ", ";\n color: ", ";\n\n ", " {\n background-color: ", ";\n }\n "])),
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
: color || (0, colors_2.changeLightness)(theme.main, 0.1), minimal && color && color !== 'transparent'
|
|
254
|
-
? (0, colors_2.isAchromatic)(color)
|
|
255
|
-
? (0, colors_2.getReadableColorFrom)((0, colors_2.changeLightness)(theme.main, 0.1))
|
|
256
|
-
: (0, polished_1.saturate)(1, (0, polished_1.tint)(0.8, color))
|
|
257
|
-
: color && color !== 'transparent'
|
|
258
|
-
? (0, colors_2.getReadableColorFrom)(color)
|
|
259
|
-
: (0, colors_2.getReadableColorFrom)((0, colors_2.changeLightness)(theme.main, 0.1)), StyledTagKeyWrapper, labelKey ? (0, polished_1.rgba)('#000000', minimal ? 0.1 : 0.3) : undefined);
|
|
260
|
-
}, function (_a) {
|
|
261
|
-
var theme = _a.theme, color = _a.color, interactive = _a.interactive, minimal = _a.minimal, effect = _a.effect, $appearanceColors = _a.$appearanceColors;
|
|
453
|
+
return (0, styled_components_1.css)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n background-color: ", ";\n color: ", ";\n\n ", " {\n background-color: ", ";\n color: ", ";\n }\n "], ["\n background-color: ", ";\n color: ", ";\n\n ", " {\n background-color: ", ";\n color: ", ";\n }\n "])), tagValueOf(props, '--reqore-tag-background'), tagValueOf(props, '--reqore-tag-text'), StyledTagKeyWrapper, props.labelKey ? tagValueOf(props, '--reqore-tag-key-shade') : undefined, props.labelKey ? tagValueOf(props, '--reqore-tag-key-text') : undefined);
|
|
454
|
+
}, function (props) {
|
|
455
|
+
var interactive = props.interactive, effect = props.effect, labelKey = props.labelKey, $appearanceColors = props.$appearanceColors;
|
|
456
|
+
var hover = (interactive && !$appearanceColors ? getStyledTagPaint(props) : {}).hover;
|
|
262
457
|
return interactive && !$appearanceColors
|
|
263
|
-
? (0, styled_components_1.css)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n cursor: pointer;\n &:hover {\n .reqore-tag-content,\n .reqore-tag-key-content {\n ", "\n }\n\n ", "\n }\n "], ["\n cursor: pointer;\n &:hover {\n .reqore-tag-content,\n .reqore-tag-key-content {\n ", "\n }\n\n ", "\n }\n "])), styles_1.ActiveIconScale, !(effect === null || effect === void 0 ? void 0 : effect.gradient) &&
|
|
264
|
-
?
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}, function (_a) {
|
|
273
|
-
var $appearance = _a.$appearance, $appearanceColors = _a.$appearanceColors, labelKey = _a.labelKey, interactive = _a.interactive, effect = _a.effect;
|
|
274
|
-
return $appearanceColors && (0, styled_components_1.css)(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n background-color: ", ";\n color: ", ";\n border: 0;\n box-shadow: ", ";\n\n ", " {\n background-color: ", ";\n }\n\n ", "\n\n &:focus,\n &:active {\n outline-color: ", ";\n }\n "], ["\n background-color: ", ";\n color: ", ";\n border: 0;\n box-shadow: ", ";\n\n ", " {\n background-color: ", ";\n }\n\n ", "\n\n &:focus,\n &:active {\n outline-color: ", ";\n }\n "])), $appearanceColors.background, $appearanceColors.text, $appearanceColors.border
|
|
275
|
-
? "inset 0 0 0 1px ".concat($appearanceColors.border)
|
|
276
|
-
: 'none', StyledTagKeyWrapper, labelKey ? $appearanceColors.keyBackground : undefined, interactive && (0, styled_components_1.css)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n cursor: pointer;\n &:hover {\n .reqore-tag-content,\n .reqore-tag-key-content {\n ", "\n }\n\n ", "\n }\n "], ["\n cursor: pointer;\n &:hover {\n .reqore-tag-content,\n .reqore-tag-key-content {\n ", "\n }\n\n ", "\n }\n "])), styles_1.ActiveIconScale, !(effect === null || effect === void 0 ? void 0 : effect.gradient) && (0, styled_components_1.css)(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n background-color: ", ";\n "], ["\n background-color: ", ";\n "])), $appearanceColors.hoverBackground)), $appearance === 'soft'
|
|
277
|
-
? $appearanceColors.border
|
|
278
|
-
: (0, polished_1.rgba)($appearanceColors.text, 0.5));
|
|
458
|
+
? (0, styled_components_1.css)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n cursor: pointer;\n &:hover {\n .reqore-tag-content,\n .reqore-tag-key-content {\n ", "\n }\n\n ", "\n }\n "], ["\n cursor: pointer;\n &:hover {\n .reqore-tag-content,\n .reqore-tag-key-content {\n ", "\n }\n\n ", "\n }\n "])), styles_1.ActiveIconScale, !(effect === null || effect === void 0 ? void 0 : effect.gradient) &&
|
|
459
|
+
hover && (0, styled_components_1.css)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n background-color: ", ";\n color: ", ";\n\n ", " {\n color: ", ";\n }\n "], ["\n background-color: ", ";\n color: ", ";\n\n ", " {\n color: ", ";\n }\n "])), tagValueOf(props, '--reqore-tag-hover-background'), tagValueOf(props, '--reqore-tag-hover-text'), StyledTagKeyWrapper, labelKey ? tagValueOf(props, '--reqore-tag-hover-key-text') : undefined)) : undefined;
|
|
460
|
+
}, function (props) {
|
|
461
|
+
var $appearanceColors = props.$appearanceColors, labelKey = props.labelKey, interactive = props.interactive, effect = props.effect;
|
|
462
|
+
return ($appearanceColors && (0, styled_components_1.css)(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n background-color: ", ";\n color: ", ";\n border: 0;\n box-shadow: ", ";\n\n ", " {\n background-color: ", ";\n color: ", ";\n }\n\n ", "\n\n &:focus,\n &:active {\n outline-color: ", ";\n }\n "], ["\n background-color: ", ";\n color: ", ";\n border: 0;\n box-shadow: ", ";\n\n ", " {\n background-color: ", ";\n color: ", ";\n }\n\n ", "\n\n &:focus,\n &:active {\n outline-color: ", ";\n }\n "])), tagValueOf(props, '--reqore-tag-appearance-background'), tagValueOf(props, '--reqore-tag-appearance-text'), $appearanceColors.border
|
|
463
|
+
? "inset 0 0 0 1px ".concat(tagValueOf(props, '--reqore-tag-appearance-border'))
|
|
464
|
+
: 'none', StyledTagKeyWrapper, labelKey
|
|
465
|
+
? tagValueOf(props, '--reqore-tag-appearance-key-background')
|
|
466
|
+
: undefined, labelKey ? tagValueOf(props, '--reqore-tag-appearance-key-text') : undefined, interactive && (0, styled_components_1.css)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n cursor: pointer;\n &:hover {\n .reqore-tag-content,\n .reqore-tag-key-content {\n ", "\n }\n\n ", "\n }\n "], ["\n cursor: pointer;\n &:hover {\n .reqore-tag-content,\n .reqore-tag-key-content {\n ", "\n }\n\n ", "\n }\n "])), styles_1.ActiveIconScale, !(effect === null || effect === void 0 ? void 0 : effect.gradient) && (0, styled_components_1.css)(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n background-color: ", ";\n "], ["\n background-color: ", ";\n "])), tagValueOf(props, '--reqore-tag-appearance-hover-background'))), tagValueOf(props, '--reqore-tag-appearance-outline')));
|
|
279
467
|
}, function (_a) {
|
|
280
468
|
var disabled = _a.disabled;
|
|
281
469
|
return disabled && (0, styled_components_1.css)(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n opacity: 0.5;\n pointer-events: none;\n cursor: not-allowed;\n "], ["\n opacity: 0.5;\n pointer-events: none;\n cursor: not-allowed;\n "])));
|
|
282
470
|
}, function (_a) {
|
|
283
471
|
var $readOnly = _a.$readOnly;
|
|
284
472
|
return $readOnly && (0, styled_components_1.css)(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n ", ";\n "], ["\n ", ";\n "])), styles_1.ReadOnlyElement);
|
|
285
|
-
}, function (
|
|
286
|
-
var theme = _a.theme, color = _a.color;
|
|
287
|
-
return (0, colors_2.changeLightness)(color || theme.main, 0.25);
|
|
288
|
-
});
|
|
473
|
+
}, function (props) { return tagValueOf(props, '--reqore-tag-outline'); });
|
|
289
474
|
var StyledTagKeyWrapper = styled_1.default.span(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n justify-content: center;\n /* A key normally GROWS to share the tag with the label, which is what gives an\n uncapped key/value tag its even split. Under a cap that split is wrong twice\n over: the key takes half the width to render four characters, and the label is\n left with too little room for a tail it is not allowed to shrink \u2014 so the tail\n runs out past the tag's edge with a hole where the key's unused half was. Capped,\n the key takes what it needs and the label gets the rest. */\n flex: ", ";\n flex-shrink: 0;\n min-height: 100%;\n padding-left: ", ";\n padding-right: ", ";\n"], ["\n display: flex;\n align-items: center;\n justify-content: center;\n /* A key normally GROWS to share the tag with the label, which is what gives an\n uncapped key/value tag its even split. Under a cap that split is wrong twice\n over: the key takes half the width to render four characters, and the label is\n left with too little room for a tail it is not allowed to shrink \u2014 so the tail\n runs out past the tag's edge with a hole where the key's unused half was. Capped,\n the key takes what it needs and the label gets the rest. */\n flex: ", ";\n flex-shrink: 0;\n min-height: 100%;\n padding-left: ", ";\n padding-right: ", ";\n"])), function (_a) {
|
|
290
475
|
var hasKey = _a.hasKey, fixed = _a.fixed, $capped = _a.$capped;
|
|
291
476
|
return hasKey ? (fixed === 'key' || $capped ? '0 0 auto' : 1) : undefined;
|
|
@@ -398,10 +583,11 @@ var StyledButtonWrapper = styled_1.default.span.withConfig({
|
|
|
398
583
|
? (0, colors_2.changeLightness)(color, 0.09)
|
|
399
584
|
: (0, polished_1.rgba)('#000000', 0.2));
|
|
400
585
|
});
|
|
401
|
-
var
|
|
402
|
-
var _b, _c, _d;
|
|
403
|
-
var tooltip = _a.tooltip, label = _a.label, labelKey = _a.labelKey, icon = _a.icon, rightIcon = _a.rightIcon, className = _a.className, onClick = _a.onClick,
|
|
586
|
+
var ReqoreTagComponent = (0, react_1.forwardRef)(function (_a, ref) {
|
|
587
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
588
|
+
var tooltip = _a.tooltip, label = _a.label, labelKey = _a.labelKey, icon = _a.icon, rightIcon = _a.rightIcon, className = _a.className, onClick = _a.onClick, _m = _a.size, size = _m === void 0 ? 'normal' : _m, paddingSize = _a.paddingSize, onRemoveClick = _a.onRemoveClick, actions = _a.actions, asBadge = _a.asBadge, intent = _a.intent, color = _a.color, minimal = _a.minimal, customTheme = _a.customTheme, inheritCustomTheme = _a.inheritCustomTheme, _o = _a.wrap, wrap = _o === void 0 ? false : _o, width = _a.width, maxWidth = _a.maxWidth, _p = _a.truncate, truncate = _p === void 0 ? 'end' : _p, leftIconColor = _a.leftIconColor, rightIconColor = _a.rightIconColor, iconColor = _a.iconColor, _q = _a.labelKeyAlign, labelKeyAlign = _q === void 0 ? 'left' : _q, labelAlign = _a.labelAlign, labelEffect = _a.labelEffect, labelKeyEffect = _a.labelKeyEffect, leftIconProps = _a.leftIconProps, rightIconProps = _a.rightIconProps, loading = _a.loading, loadingIconType = _a.loadingIconType, compact = _a.compact, readOnly = _a.readOnly, _r = _a.removeTooltip, removeTooltip = _r === void 0 ? 'Remove' : _r, _s = _a.appearance, appearance = _s === void 0 ? 'solid' : _s, rest = __rest(_a, ["tooltip", "label", "labelKey", "icon", "rightIcon", "className", "onClick", "size", "paddingSize", "onRemoveClick", "actions", "asBadge", "intent", "color", "minimal", "customTheme", "inheritCustomTheme", "wrap", "width", "maxWidth", "truncate", "leftIconColor", "rightIconColor", "iconColor", "labelKeyAlign", "labelAlign", "labelEffect", "labelKeyEffect", "leftIconProps", "rightIconProps", "loading", "loadingIconType", "compact", "readOnly", "removeTooltip", "appearance"]);
|
|
404
589
|
var theme = (0, __1.useReqoreTheme)('main', customTheme, undefined, undefined, inheritCustomTheme);
|
|
590
|
+
var surface = (0, SurfaceContext_1.useReqoreSurface)();
|
|
405
591
|
// If color or intent was specified, set the color
|
|
406
592
|
var getCustomColor = (0, react_1.useCallback)(function (itemIntent) {
|
|
407
593
|
var customColor = itemIntent
|
|
@@ -440,9 +626,9 @@ var ReqoreTag = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
440
626
|
(((_b = rest.effect) === null || _b === void 0 ? void 0 : _b.color) ? (0, colors_2.getColorFromMaybeString)(theme, rest.effect.color) : undefined);
|
|
441
627
|
var appearanceColors = (0, react_1.useMemo)(function () {
|
|
442
628
|
return appearance === 'soft' || appearance === 'text'
|
|
443
|
-
? (0, exports.getTagAppearanceColors)(theme, appearance, appearanceColor)
|
|
629
|
+
? (0, exports.getTagAppearanceColors)(theme, appearance, appearanceColor, surface)
|
|
444
630
|
: undefined;
|
|
445
|
-
}, [appearance, theme, appearanceColor]);
|
|
631
|
+
}, [appearance, theme, appearanceColor, surface]);
|
|
446
632
|
/* When effect.color IS the soft / text tag's colour, it has been turned into a
|
|
447
633
|
readable shade already — left in the effect it would repaint the label in the
|
|
448
634
|
raw colour, which is what the appearance exists to avoid. */
|
|
@@ -451,7 +637,61 @@ var ReqoreTag = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
451
637
|
var _a;
|
|
452
638
|
return (__assign(__assign(__assign({}, rest.effect), (effectColorIsTagColor ? { color: undefined } : {})), { gradient: intent ? undefined : (_a = rest.effect) === null || _a === void 0 ? void 0 : _a.gradient, interactive: interactive }));
|
|
453
639
|
}, [intent, interactive, effectColorIsTagColor, JSON.stringify(rest.effect)]);
|
|
454
|
-
|
|
640
|
+
/* What the tag is painted with, worked out once per render rather than in each of its
|
|
641
|
+
style rules: a solid tag's colours at rest and, when it answers the pointer, hovered. */
|
|
642
|
+
var _t = (0, react_1.useMemo)(function () {
|
|
643
|
+
return (0, exports.getTagPaint)(theme, tagColor, minimal, !!labelKey, effect, interactive, surface, !appearanceColors);
|
|
644
|
+
}, [theme, tagColor, minimal, labelKey, effect, interactive, surface, appearanceColors]), paint = _t.paint, resting = _t.resting, hovered = _t.hovered;
|
|
645
|
+
/* The icons stand out from what they are drawn on, as the text does: the left one
|
|
646
|
+
sits in the key, the right one and the actions beside the label. */
|
|
647
|
+
var sides = (0, react_1.useMemo)(function () {
|
|
648
|
+
if (appearanceColors) {
|
|
649
|
+
var label_1 = {
|
|
650
|
+
backgrounds: appearanceColors.drawnBackgrounds,
|
|
651
|
+
text: appearanceColors.text,
|
|
652
|
+
};
|
|
653
|
+
return {
|
|
654
|
+
// the key's own wash is drawn only with a key: an icon alone sits on the tag
|
|
655
|
+
key: labelKey
|
|
656
|
+
? { backgrounds: appearanceColors.drawnKeyBackgrounds, text: appearanceColors.keyText }
|
|
657
|
+
: label_1,
|
|
658
|
+
label: label_1,
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
var hover = hovered !== null && hovered !== void 0 ? hovered : resting;
|
|
662
|
+
return {
|
|
663
|
+
key: {
|
|
664
|
+
backgrounds: __spreadArray(__spreadArray([], resting.keyBackgrounds, true), hover.keyBackgrounds, true),
|
|
665
|
+
text: resting.keyText,
|
|
666
|
+
},
|
|
667
|
+
label: {
|
|
668
|
+
backgrounds: __spreadArray(__spreadArray([], resting.backgrounds, true), hover.backgrounds, true),
|
|
669
|
+
text: resting.text,
|
|
670
|
+
},
|
|
671
|
+
};
|
|
672
|
+
}, [appearanceColors, labelKey, resting, hovered]);
|
|
673
|
+
// an icon's own color: in its props (which win, as they are spread over the rest), else the tag's
|
|
674
|
+
var _u = (0, iconProps_1.splitIconColor)(leftIconProps), leftIconPropsColor = _u[0], leftIconRest = _u[1];
|
|
675
|
+
var _v = (0, iconProps_1.splitIconColor)(rightIconProps), rightIconPropsColor = _v[0], rightIconRest = _v[1];
|
|
676
|
+
var leftIconOwn = leftIconPropsColor || leftIconColor || iconColor;
|
|
677
|
+
var rightIconOwn = rightIconPropsColor || rightIconColor || iconColor;
|
|
678
|
+
var hasActions = !!(0, size_1.default)(actions);
|
|
679
|
+
// only for the icons the tag draws
|
|
680
|
+
var iconLooks = (0, react_1.useMemo)(function () {
|
|
681
|
+
var look = function (side, own) {
|
|
682
|
+
return (0, colors_2.getReadableIconLook)(theme, side.backgrounds, side.text, colors_1.CONTROL_ICON_OPACITY, own);
|
|
683
|
+
};
|
|
684
|
+
return {
|
|
685
|
+
left: hasLeftIcon ? look(sides.key, leftIconOwn) : undefined,
|
|
686
|
+
right: hasRightIcon ? look(sides.label, rightIconOwn) : undefined,
|
|
687
|
+
action: hasActions ? look(sides.label) : undefined,
|
|
688
|
+
};
|
|
689
|
+
}, [sides, theme, leftIconOwn, rightIconOwn, hasLeftIcon, hasRightIcon, hasActions]);
|
|
690
|
+
// one object per icon for as long as its opacity holds: an icon is a memo component
|
|
691
|
+
var leftIconEffect = (0, react_1.useMemo)(function () { var _a; return ({ opacity: (_a = iconLooks.left) === null || _a === void 0 ? void 0 : _a.opacity }); }, [(_d = iconLooks.left) === null || _d === void 0 ? void 0 : _d.opacity]);
|
|
692
|
+
var rightIconEffect = (0, react_1.useMemo)(function () { var _a; return ({ opacity: (_a = iconLooks.right) === null || _a === void 0 ? void 0 : _a.opacity }); }, [(_e = iconLooks.right) === null || _e === void 0 ? void 0 : _e.opacity]);
|
|
693
|
+
var actionIconEffect = (0, react_1.useMemo)(function () { var _a; return ({ opacity: (_a = iconLooks.action) === null || _a === void 0 ? void 0 : _a.opacity }); }, [(_f = iconLooks.action) === null || _f === void 0 ? void 0 : _f.opacity]);
|
|
694
|
+
return ((0, jsx_runtime_1.jsxs)(TooltipComponent_1.ReqoreTooltipComponent, __assign({}, rest, { Component: exports.StyledTag, tooltip: tooltip, theme: theme, "$surface": surface, "$backgrounds": sides.label.backgrounds, "$paint": paint, effect: effect, width: width, "$maxWidth": maxWidth, labelKey: labelKey, color: tagColor, "$appearance": appearanceColors ? appearance : undefined, "$appearanceColors": appearanceColors, className: "".concat(className || '', " reqore-tag"), size: size, ref: ref, asBadge: asBadge, minimal: minimal, removable: !!onRemoveClick, interactive: interactive, "$readOnly": readOnly,
|
|
455
695
|
/* `interactive`, not `onClick`, decides the tab stop. A read-only tag
|
|
456
696
|
keeps its handler — refusing the CHANGE is the picker's job, not the
|
|
457
697
|
tag's — but it has stopped advertising itself as something to press,
|
|
@@ -461,11 +701,7 @@ var ReqoreTag = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
461
701
|
keeps a `tabIndex` it is given, as a button does: a tag inside a
|
|
462
702
|
control that is itself the tab stop (a chip in a text editor) is
|
|
463
703
|
reached with that control's own keys, not with Tab. */
|
|
464
|
-
tabIndex: interactive ? ((
|
|
465
|
-
opacity: colors_1.CONTROL_ICON_OPACITY,
|
|
466
|
-
} }, leftIconProps, { animation: loading ? 'spin' : leftIconProps === null || leftIconProps === void 0 ? void 0 : leftIconProps.animation, icon: leftIcon }))) : null, labelKey && ((0, jsx_runtime_1.jsx)(StyledTagContentKey, { "$wrap": wrap, "$hasWidth": !!width, size: size, "$paddingSize": paddingSize, labelAlign: labelKeyAlign, compact: compact, effect: __assign({ weight: 'bold' }, labelKeyEffect), children: labelKey }))] })) : null, label || label === 0 || hasRightIcon ? ((0, jsx_runtime_1.jsxs)(StyledTagContentWrapper, { size: size, className: 'reqore-tag-content', onClick: rest.disabled ? undefined : onClick, "$wrap": wrap, "$hasWidth": !!width, "$capped": capped, hasKey: !!labelKey, fixed: rest.fixed, children: [label || label === 0 ? ((0, jsx_runtime_1.jsx)(StyledTagContent, { size: size, "$paddingSize": paddingSize, "$wrap": wrap, "$hasWidth": !!width, "$capped": capped, labelAlign: labelAlign || (labelKey ? 'left' : 'center'), compact: compact, effect: __assign({ weight: 'bold' }, labelEffect), children: !capped ? (label) : middleParts ? ((0, jsx_runtime_1.jsxs)(StyledMiddleTruncatedLabel, { className: 'reqore-tag-label', children: [(0, jsx_runtime_1.jsx)(StyledTruncatedLabelHead, { className: 'reqore-tag-label-head', children: middleParts[0] }), (0, jsx_runtime_1.jsx)(StyledTruncatedLabelTail, { className: 'reqore-tag-label-tail', children: middleParts[1] })] })) : ((0, jsx_runtime_1.jsx)(StyledTruncatedLabel, { className: 'reqore-tag-label', children: label })) })) : null, hasRightIcon ? ((0, jsx_runtime_1.jsx)(Icon_1.default, __assign({ icon: rightIcon, size: "".concat(sizes_1.TAG_ICON_FROM_SIZE[size], "px"), margin: label || (!icon && !labelKey) ? 'right' : 'both', color: rightIconColor || iconColor, compact: compact, effect: {
|
|
467
|
-
opacity: colors_1.CONTROL_ICON_OPACITY,
|
|
468
|
-
} }, rightIconProps))) : null] })) : null, (0, size_1.default)(actions)
|
|
704
|
+
tabIndex: interactive ? ((_g = rest.tabIndex) !== null && _g !== void 0 ? _g : 0) : undefined, "aria-disabled": rest.disabled ? true : undefined, "$wrap": wrap, "$hasWidth": !!width, children: [labelKey || hasLeftIcon ? ((0, jsx_runtime_1.jsxs)(StyledTagKeyWrapper, { size: size, className: 'reqore-tag-key-content', onClick: rest.disabled ? undefined : onClick, "$wrap": wrap, "$hasWidth": !!width, "$capped": capped, hasKey: !!labelKey, hasIcon: hasLeftIcon, padOnRight: !label && !labelKey && !hasRightIcon, fixed: rest.fixed, children: [leftIcon || (leftIconProps === null || leftIconProps === void 0 ? void 0 : leftIconProps.image) ? ((0, jsx_runtime_1.jsx)(Icon_1.default, __assign({ size: "".concat(sizes_1.TAG_ICON_FROM_SIZE[size], "px"), color: (_j = (_h = iconLooks.left) === null || _h === void 0 ? void 0 : _h.color) !== null && _j !== void 0 ? _j : leftIconOwn, compact: compact, effect: leftIconEffect }, leftIconRest, { animation: loading ? 'spin' : leftIconProps === null || leftIconProps === void 0 ? void 0 : leftIconProps.animation, icon: leftIcon }))) : null, labelKey && ((0, jsx_runtime_1.jsx)(StyledTagContentKey, { "$wrap": wrap, "$hasWidth": !!width, size: size, "$paddingSize": paddingSize, labelAlign: labelKeyAlign, compact: compact, "$backgrounds": sides.key.backgrounds, effect: __assign({ weight: 'bold' }, labelKeyEffect), children: labelKey }))] })) : null, label || label === 0 || hasRightIcon ? ((0, jsx_runtime_1.jsxs)(StyledTagContentWrapper, { size: size, className: 'reqore-tag-content', onClick: rest.disabled ? undefined : onClick, "$wrap": wrap, "$hasWidth": !!width, "$capped": capped, hasKey: !!labelKey, fixed: rest.fixed, children: [label || label === 0 ? ((0, jsx_runtime_1.jsx)(StyledTagContent, { size: size, "$paddingSize": paddingSize, "$wrap": wrap, "$hasWidth": !!width, "$capped": capped, labelAlign: labelAlign || (labelKey ? 'left' : 'center'), compact: compact, "$backgrounds": sides.label.backgrounds, effect: __assign({ weight: 'bold' }, labelEffect), children: !capped ? (label) : middleParts ? ((0, jsx_runtime_1.jsxs)(StyledMiddleTruncatedLabel, { className: 'reqore-tag-label', children: [(0, jsx_runtime_1.jsx)(StyledTruncatedLabelHead, { className: 'reqore-tag-label-head', children: middleParts[0] }), (0, jsx_runtime_1.jsx)(StyledTruncatedLabelTail, { className: 'reqore-tag-label-tail', children: middleParts[1] })] })) : ((0, jsx_runtime_1.jsx)(StyledTruncatedLabel, { className: 'reqore-tag-label', children: label })) })) : null, hasRightIcon ? ((0, jsx_runtime_1.jsx)(Icon_1.default, __assign({ icon: rightIcon, size: "".concat(sizes_1.TAG_ICON_FROM_SIZE[size], "px"), margin: label || (!icon && !labelKey) ? 'right' : 'both', color: (_l = (_k = iconLooks.right) === null || _k === void 0 ? void 0 : _k.color) !== null && _l !== void 0 ? _l : rightIconOwn, compact: compact, effect: rightIconEffect }, rightIconRest))) : null] })) : null, (0, size_1.default)(actions)
|
|
469
705
|
? actions
|
|
470
706
|
.filter(function (action) { return action.show !== false; })
|
|
471
707
|
.map(function (_a, index) {
|
|
@@ -479,9 +715,7 @@ var ReqoreTag = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
479
715
|
? typeof tooltip === 'string'
|
|
480
716
|
? { tooltip: tooltip }
|
|
481
717
|
: tooltip
|
|
482
|
-
: {}), { isReqoreComponent: true, children: (0, jsx_runtime_1.jsx)(Icon_1.default, { icon: icon, size: "".concat(sizes_1.TAG_ICON_FROM_SIZE[size], "px"), effect:
|
|
483
|
-
opacity: colors_1.CONTROL_ICON_OPACITY,
|
|
484
|
-
} }) })) }, index));
|
|
718
|
+
: {}), { isReqoreComponent: true, children: (0, jsx_runtime_1.jsx)(Icon_1.default, { icon: icon, size: "".concat(sizes_1.TAG_ICON_FROM_SIZE[size], "px"), effect: actionIconEffect }) })) }, index));
|
|
485
719
|
})
|
|
486
720
|
: null, onRemoveClick && !rest.disabled ? ((0, jsx_runtime_1.jsx)(__1.ReqorePopover, { component: StyledButtonWrapper, componentProps: {
|
|
487
721
|
size: size,
|
|
@@ -492,6 +726,8 @@ var ReqoreTag = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
492
726
|
$appearanceColors: appearanceColors,
|
|
493
727
|
}, isReqoreComponent: true, content: removeTooltip, children: (0, jsx_runtime_1.jsx)(Icon_1.default, { icon: 'CloseLine', size: size }) })) : null] })));
|
|
494
728
|
});
|
|
729
|
+
/** A memo component, as Reqore's components are: a tag re-renders when its props or what it reads change. */
|
|
730
|
+
var ReqoreTag = (0, react_1.memo)(ReqoreTagComponent);
|
|
495
731
|
exports.default = ReqoreTag;
|
|
496
732
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17, templateObject_18, templateObject_19, templateObject_20, templateObject_21, templateObject_22, templateObject_23, templateObject_24, templateObject_25, templateObject_26, templateObject_27, templateObject_28, templateObject_29, templateObject_30, templateObject_31, templateObject_32;
|
|
497
733
|
//# sourceMappingURL=index.js.map
|