@qoretechnologies/reqore 0.78.22-pr.723.ge09d885 → 0.78.22
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 +0 -18
- package/dist/components/Accordion/index.d.ts.map +1 -1
- package/dist/components/Accordion/index.js +14 -60
- 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 +21 -58
- 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 +4 -13
- package/dist/components/Bubble/index.js.map +1 -1
- package/dist/components/Button/index.d.ts +0 -67
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +138 -359
- 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 +29 -49
- 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 +36 -112
- 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 +2 -6
- 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 +1 -22
- package/dist/components/ControlGroup/index.js.map +1 -1
- package/dist/components/DataView/index.d.ts.map +1 -1
- package/dist/components/DataView/index.js +10 -13
- package/dist/components/DataView/index.js.map +1 -1
- package/dist/components/DescriptionList/index.d.ts.map +1 -1
- package/dist/components/DescriptionList/index.js +4 -30
- 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 +25 -41
- 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 +14 -19
- package/dist/components/Dropdown/list.js.map +1 -1
- package/dist/components/Effect/index.d.ts +0 -37
- package/dist/components/Effect/index.d.ts.map +1 -1
- package/dist/components/Effect/index.js +58 -224
- 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 +59 -98
- 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 +21 -54
- 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 +4 -7
- 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 +3 -13
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/Input/index.d.ts +1 -44
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js +23 -89
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/InputClearButton/index.d.ts +2 -7
- package/dist/components/InputClearButton/index.d.ts.map +1 -1
- package/dist/components/InputClearButton/index.js +5 -12
- 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 +10 -19
- 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 +1 -6
- 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 +3 -8
- 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 +4 -17
- 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 +5 -3
- 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 +4 -20
- package/dist/components/Message/index.js.map +1 -1
- package/dist/components/NavRail/index.d.ts +0 -2
- package/dist/components/NavRail/index.d.ts.map +1 -1
- package/dist/components/NavRail/index.js +41 -122
- package/dist/components/NavRail/index.js.map +1 -1
- package/dist/components/Notifications/notification.d.ts +2 -6
- package/dist/components/Notifications/notification.d.ts.map +1 -1
- package/dist/components/Notifications/notification.js +18 -78
- package/dist/components/Notifications/notification.js.map +1 -1
- package/dist/components/Notifications/styles.d.ts +0 -20
- package/dist/components/Notifications/styles.d.ts.map +1 -1
- package/dist/components/Notifications/styles.js +9 -37
- 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 +3 -4
- package/dist/components/Paging/index.js.map +1 -1
- package/dist/components/Panel/index.d.ts +0 -3
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +153 -214
- 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 +5 -8
- 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 +8 -20
- 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 +46 -89
- 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 +42 -87
- 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 +5 -8
- 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 +12 -42
- 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 +6 -34
- 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 +53 -128
- 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 +5 -7
- package/dist/components/Table/headerCell.js.map +1 -1
- package/dist/components/Table/helpers.d.ts +5 -0
- package/dist/components/Table/helpers.d.ts.map +1 -1
- package/dist/components/Table/helpers.js +8 -1
- package/dist/components/Table/helpers.js.map +1 -1
- package/dist/components/Table/index.d.ts.map +1 -1
- package/dist/components/Table/index.js +1 -2
- package/dist/components/Table/index.js.map +1 -1
- package/dist/components/Tag/index.d.ts +3 -70
- package/dist/components/Tag/index.d.ts.map +1 -1
- package/dist/components/Tag/index.js +100 -336
- 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 +20 -35
- package/dist/components/Testimonial/index.js.map +1 -1
- package/dist/components/Textarea/index.d.ts +0 -6
- 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/Timeline/index.d.ts +0 -2
- package/dist/components/Timeline/index.d.ts.map +1 -1
- package/dist/components/Timeline/index.js +13 -56
- 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 +19 -23
- package/dist/components/Tree/index.js.map +1 -1
- package/dist/containers/UIProvider.d.ts +0 -10
- package/dist/containers/UIProvider.d.ts.map +1 -1
- package/dist/containers/UIProvider.js +4 -33
- package/dist/containers/UIProvider.js.map +1 -1
- package/dist/helpers/colors.d.ts +2 -184
- package/dist/helpers/colors.d.ts.map +1 -1
- package/dist/helpers/colors.js +86 -739
- package/dist/helpers/colors.js.map +1 -1
- package/dist/hooks/usePrefersReducedMotion.d.ts +0 -5
- package/dist/hooks/usePrefersReducedMotion.d.ts.map +1 -1
- package/dist/hooks/usePrefersReducedMotion.js +1 -9
- package/dist/hooks/usePrefersReducedMotion.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
- package/tests.json +1 -0
- package/vite.config.mts +0 -6
- package/vitest.config.mts +0 -10
- package/dist/context/SurfaceContext.d.ts +0 -18
- package/dist/context/SurfaceContext.d.ts.map +0 -1
- package/dist/context/SurfaceContext.js +0 -39
- package/dist/context/SurfaceContext.js.map +0 -1
- package/dist/helpers/iconProps.d.ts +0 -14
- package/dist/helpers/iconProps.d.ts.map +0 -1
- package/dist/helpers/iconProps.js +0 -33
- package/dist/helpers/iconProps.js.map +0 -1
- package/dist/helpers/surface.d.ts +0 -31
- package/dist/helpers/surface.d.ts.map +0 -1
- package/dist/helpers/surface.js +0 -87
- package/dist/helpers/surface.js.map +0 -1
- package/dist/hooks/useDrawnSurface.d.ts +0 -38
- package/dist/hooks/useDrawnSurface.d.ts.map +0 -1
- package/dist/hooks/useDrawnSurface.js +0 -48
- package/dist/hooks/useDrawnSurface.js.map +0 -1
|
@@ -71,10 +71,11 @@ 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.ButtonBadge = exports.StyledButtonContent = exports.StyledButton = exports.REQORE_BUTTON_STYLE_PROPS = exports.StyledAnimatedTextWrapper = exports.
|
|
74
|
+
exports.ButtonBadge = exports.StyledButtonContent = exports.StyledButton = exports.REQORE_BUTTON_STYLE_PROPS = exports.StyledAnimatedTextWrapper = exports.StyledButtonIndicator = void 0;
|
|
75
75
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
76
76
|
var useMarqueeOnHover_1 = require("../../hooks/useMarqueeOnHover");
|
|
77
77
|
var lodash_1 = require("lodash");
|
|
78
|
+
var polished_1 = require("polished");
|
|
78
79
|
var react_1 = require("react");
|
|
79
80
|
var react_hotkeys_hook_1 = require("react-hotkeys-hook");
|
|
80
81
|
var styled_components_1 = require("styled-components");
|
|
@@ -89,11 +90,9 @@ var useCombinedRefs_1 = require("../../hooks/useCombinedRefs");
|
|
|
89
90
|
var useReqoreContext_1 = require("../../hooks/useReqoreContext");
|
|
90
91
|
var useReqoreEffect_1 = require("../../hooks/useReqoreEffect");
|
|
91
92
|
var useTheme_1 = require("../../hooks/useTheme");
|
|
92
|
-
var SurfaceContext_1 = require("../../context/SurfaceContext");
|
|
93
93
|
var styles_1 = require("../../styles");
|
|
94
94
|
var Effect_1 = require("../Effect");
|
|
95
95
|
var Icon_1 = __importDefault(require("../Icon"));
|
|
96
|
-
var iconProps_1 = require("../../helpers/iconProps");
|
|
97
96
|
var KeyboardShortcut_1 = require("../KeyboardShortcut");
|
|
98
97
|
var Spacer_1 = require("../Spacer");
|
|
99
98
|
var Tag_1 = __importDefault(require("../Tag"));
|
|
@@ -128,251 +127,13 @@ var getButtonMainColor = function (theme, color, effect) {
|
|
|
128
127
|
}
|
|
129
128
|
return theme.main;
|
|
130
129
|
};
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
* translucent color (the muted intent) blended over the theme the button sits on, a transparent button as that
|
|
134
|
-
* theme, a gradient as each of its colors. The text is picked against that, and stands out from all of it by 4.5:1;
|
|
135
|
-
* a minimal or transparent button with a color of its own keeps the color in its text, in a shade that reads.
|
|
136
|
-
*/
|
|
137
|
-
var getButtonColors = function (_a, state) {
|
|
138
|
-
var theme = _a.theme, color = _a.color, minimal = _a.minimal, transparent = _a.transparent, effect = _a.effect, $surface = _a.$surface;
|
|
139
|
-
if (state === void 0) { state = 'rest'; }
|
|
140
|
-
var main = getButtonMainColor(theme, color, effect);
|
|
141
|
-
// what the button is drawn on: one color, or each color of a gradient
|
|
142
|
-
var unders = (0, colors_2.getThemeSurfaces)(theme, $surface);
|
|
143
|
-
var outlined = minimal || transparent;
|
|
144
|
-
var gradient = (0, Effect_1.getPrimaryGradient)(effect === null || effect === void 0 ? void 0 : effect.gradient);
|
|
145
|
-
// an outlined button's text starts from a light tint of its color, lighter hovered
|
|
146
|
-
var tintAmount = state === 'hover' ? 0.9 : 0.8;
|
|
147
|
-
var fills;
|
|
148
|
-
if (gradient && !transparent) {
|
|
149
|
-
var stops = (0, colors_2.getGradientColorList)(theme, gradient.colors);
|
|
150
|
-
if (minimal) {
|
|
151
|
-
// as a minimal gradient is painted: a translucent fill over a translucent ring over the button's wash
|
|
152
|
-
var painted = unders.flatMap(function (under) {
|
|
153
|
-
return (0, Effect_1.getEffectGradientBackgrounds)(theme, gradient.colors, true, (0, colors_2.getColorAtAlpha)(main, 0.2), under);
|
|
154
|
-
});
|
|
155
|
-
return {
|
|
156
|
-
backgrounds: painted,
|
|
157
|
-
text: (0, colors_2.isAchromatic)(main)
|
|
158
|
-
? (0, colors_2.getReadableColorOn)(painted, state === 'rest')
|
|
159
|
-
: (0, colors_2.getReadableAccentColorOn)((0, colors_2.getSaturatedTint)(main, tintAmount), painted),
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
// as the effect draws it: its colors at rest, each a step lighter hovered or pressed
|
|
163
|
-
fills = state === 'rest' ? stops : stops.map(function (stop) { return (0, colors_2.changeLightness)(stop, 0.05); });
|
|
164
|
-
}
|
|
165
|
-
else if (state === 'active') {
|
|
166
|
-
fills = [(0, colors_2.changeLightness)(main, 0.1)];
|
|
167
|
-
}
|
|
168
|
-
else if (state === 'hover') {
|
|
169
|
-
fills = [getButtonHoverFill(theme, color, main, minimal, transparent)];
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
fills = [getButtonRestFill(color, main, minimal, transparent)];
|
|
173
|
-
}
|
|
174
|
-
var backgrounds = unders.flatMap(function (under) {
|
|
175
|
-
return fills.map(function (fill) { return (fill === 'transparent' ? under : (0, colors_2.getDrawnColor)(fill, under)); });
|
|
176
|
-
});
|
|
177
|
-
var dim = state === 'rest';
|
|
178
|
-
var text;
|
|
179
|
-
if (outlined && state !== 'active' && !(0, colors_2.isAchromatic)(main)) {
|
|
180
|
-
// a color the helpers cannot read (a CSS variable) is as it is given: the text is written in it
|
|
181
|
-
text = (0, colors_2.getReadableAccentColorOn)((0, colors_2.getSaturatedTint)(main, tintAmount), backgrounds);
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
text = (0, colors_2.getReadableColorOn)(backgrounds, dim);
|
|
185
|
-
}
|
|
186
|
-
return { backgrounds: backgrounds, text: text };
|
|
187
|
-
};
|
|
188
|
-
exports.getButtonColors = getButtonColors;
|
|
189
|
-
/**
|
|
190
|
-
* The fill a button paints at rest: nothing when transparent, a wash of its color when minimal (one the helpers
|
|
191
|
-
* cannot read, a CSS variable, is washed by the browser), else its color.
|
|
192
|
-
*/
|
|
193
|
-
var getButtonRestFill = function (color, main, minimal, transparent) { return (transparent ? 'transparent' : minimal ? (0, colors_2.getColorAtAlpha)(main, 0.2) : color || main); };
|
|
194
|
-
/** The fill a button paints hovered: a stronger wash when minimal or transparent, else its color a step lighter. */
|
|
195
|
-
var getButtonHoverFill = function (theme, color, main, minimal, transparent) {
|
|
130
|
+
var getButtonTextColor = function (_a) {
|
|
131
|
+
var minimal = _a.minimal, transparent = _a.transparent, color = _a.color, theme = _a.theme;
|
|
196
132
|
return minimal || transparent
|
|
197
|
-
? (0, colors_2.
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
* How a button draws an icon, at rest and hovered alike: in its own color (`color`, in a shade that stands out by
|
|
202
|
-
* 3:1) or the button's text color, at `CONTROL_ICON_OPACITY` or as much more as it needs to stand out by 3:1.
|
|
203
|
-
*/
|
|
204
|
-
var getButtonIconLook = function (style, color, active) {
|
|
205
|
-
return getButtonIconLookIn(style.theme, (0, exports.getButtonStateColors)(style, active), color);
|
|
206
|
-
};
|
|
207
|
-
exports.getButtonIconLook = getButtonIconLook;
|
|
208
|
-
/** `getButtonIconLook`, from the button's colors worked out already (`IReqoreButtonStateColors`). */
|
|
209
|
-
var getButtonIconLookIn = function (theme, states, color) {
|
|
210
|
-
var _a, _b, _c;
|
|
211
|
-
// an active button (a selected menu item) is drawn in its fill, hovered or not
|
|
212
|
-
var rest = (_a = states.active) !== null && _a !== void 0 ? _a : states.rest;
|
|
213
|
-
var hover = (_c = (_b = states.active) !== null && _b !== void 0 ? _b : states.hover) !== null && _c !== void 0 ? _c : rest;
|
|
214
|
-
var look = (0, colors_2.getReadableIconLook)(theme, __spreadArray(__spreadArray([], rest.backgrounds, true), hover.backgrounds, true), rest.text, colors_1.CONTROL_ICON_OPACITY, color);
|
|
215
|
-
// hovered, the text (which an icon without a color of its own is drawn in) may be another color
|
|
216
|
-
return look.color
|
|
217
|
-
? look
|
|
218
|
-
: {
|
|
219
|
-
opacity: Math.max(look.opacity, (0, colors_2.getReadableAlpha)(hover.text, hover.backgrounds, colors_1.CONTROL_ICON_OPACITY, colors_2.READABLE_ICON_CONTRAST)),
|
|
220
|
-
};
|
|
221
|
-
};
|
|
222
|
-
/**
|
|
223
|
-
* A button's colors in the states it is drawn in (`IReqoreButtonStateColors`): at rest, and hovered or - when it
|
|
224
|
-
* is `active` - active.
|
|
225
|
-
*/
|
|
226
|
-
var getButtonStateColors = function (style, active) { return ({
|
|
227
|
-
rest: (0, exports.getButtonColors)(style),
|
|
228
|
-
hover: active ? undefined : (0, exports.getButtonColors)(style, 'hover'),
|
|
229
|
-
active: active ? (0, exports.getButtonColors)(style, 'active') : undefined,
|
|
230
|
-
}); };
|
|
231
|
-
exports.getButtonStateColors = getButtonStateColors;
|
|
232
|
-
/**
|
|
233
|
-
* Everything a button is painted with (`IReqoreButtonPaint`), from its colors in each state. `description`: whether
|
|
234
|
-
* it has one, whose color is then worked out too.
|
|
235
|
-
*/
|
|
236
|
-
var getButtonPaint = function (style, states, description) {
|
|
237
|
-
var _a, _b, _c;
|
|
238
|
-
var theme = style.theme, color = style.color, minimal = style.minimal, transparent = style.transparent, effect = style.effect;
|
|
239
|
-
var main = getButtonMainColor(theme, color, effect);
|
|
240
|
-
var drawn = (_a = states.active) !== null && _a !== void 0 ? _a : states.rest;
|
|
241
|
-
return {
|
|
242
|
-
background: transparent ? 'transparent' : minimal ? (0, colors_2.getColorAtAlpha)(main, 0.2) : color,
|
|
243
|
-
text: states.rest.text,
|
|
244
|
-
edge: (0, colors_2.changeLightness)(main, 0.1),
|
|
245
|
-
ring: (0, colors_2.changeLightness)(main, 0.25),
|
|
246
|
-
hoverBackground: states.hover
|
|
247
|
-
? getButtonHoverFill(theme, color, main, minimal, transparent)
|
|
248
|
-
: undefined,
|
|
249
|
-
hoverText: (_b = states.hover) === null || _b === void 0 ? void 0 : _b.text,
|
|
250
|
-
activeText: (_c = states.active) === null || _c === void 0 ? void 0 : _c.text,
|
|
251
|
-
activeEdge: (0, colors_2.changeLightness)(main, 0.175),
|
|
252
|
-
activeHoverEdge: (0, colors_2.changeLightness)(main, 0.275),
|
|
253
|
-
// on the button as it is drawn: at rest, or filled when active (a selected menu item)
|
|
254
|
-
description: description
|
|
255
|
-
? (0, colors_2.getReadableFadedColor)(drawn.text, drawn.backgrounds, 0.7)
|
|
256
|
-
: undefined,
|
|
257
|
-
/* hovered, the description is on the hover fill, in the hovered text: faded as far as it reads there. Faded for
|
|
258
|
-
the resting fill, it fell to 3.8:1 on an info button's lighter hover fill (qorus#646) */
|
|
259
|
-
hoverDescription: description && states.hover
|
|
260
|
-
? (0, colors_2.getReadableFadedColor)(states.hover.text, states.hover.backgrounds, 0.7)
|
|
261
|
-
: undefined,
|
|
262
|
-
};
|
|
263
|
-
};
|
|
264
|
-
exports.getButtonPaint = getButtonPaint;
|
|
265
|
-
/**
|
|
266
|
-
* What a styled button is painted with: what the button worked out for this render, or - a `StyledButton`
|
|
267
|
-
* rendered on its own - worked out from its props.
|
|
268
|
-
*/
|
|
269
|
-
var getStyledButtonPaint = function (props) {
|
|
270
|
-
var _a;
|
|
271
|
-
return (_a = props.$paint) !== null && _a !== void 0 ? _a : (0, exports.getButtonPaint)(props, (0, exports.getButtonStateColors)(props, props.active), !!props.description);
|
|
272
|
-
};
|
|
273
|
-
/** The CSS variable each color of a button's paint is set in, on the button. */
|
|
274
|
-
var BUTTON_PAINT_VARIABLES = {
|
|
275
|
-
background: '--reqore-button-background',
|
|
276
|
-
text: '--reqore-button-text',
|
|
277
|
-
edge: '--reqore-button-edge',
|
|
278
|
-
ring: '--reqore-button-ring',
|
|
279
|
-
hoverBackground: '--reqore-button-hover-background',
|
|
280
|
-
hoverText: '--reqore-button-hover-text',
|
|
281
|
-
activeText: '--reqore-button-active-text',
|
|
282
|
-
activeEdge: '--reqore-button-active-edge',
|
|
283
|
-
activeHoverEdge: '--reqore-button-active-hover-edge',
|
|
284
|
-
description: '--reqore-button-description',
|
|
285
|
-
hoverDescription: '--reqore-button-hover-description',
|
|
286
|
-
};
|
|
287
|
-
/**
|
|
288
|
-
* A button's paint as CSS variables on the button, which its styles read (`paintOf`). Written into the styles, every
|
|
289
|
-
* color a button is drawn in made a class of its own - a page of buttons in each intent, minimal, flat and active
|
|
290
|
-
* made hundreds, and styled-components warned - where the styles now differ only in what the button is.
|
|
291
|
-
*/
|
|
292
|
-
var getButtonPaintVariables = function (props) {
|
|
293
|
-
var paint = getStyledButtonPaint(props);
|
|
294
|
-
return Object.fromEntries(Object.keys(BUTTON_PAINT_VARIABLES)
|
|
295
|
-
.filter(function (color) { return paint[color]; })
|
|
296
|
-
.map(function (color) { return [BUTTON_PAINT_VARIABLES[color], paint[color]]; }));
|
|
297
|
-
};
|
|
298
|
-
/**
|
|
299
|
-
* The value a button's styles give a property for one of its paint's colors: the variable it is set in, or - a color
|
|
300
|
-
* the paint has none for - nothing, as the color itself was, so the declaration is dropped as before.
|
|
301
|
-
*/
|
|
302
|
-
var paintOf = function (props, color) {
|
|
303
|
-
var value = getStyledButtonPaint(props)[color];
|
|
304
|
-
return value ? "var(".concat(BUTTON_PAINT_VARIABLES[color], ")") : value;
|
|
305
|
-
};
|
|
306
|
-
/** A button's height (and a square one's width): its size's, with its vertical padding's change on both sides. */
|
|
307
|
-
var getButtonBoxPx = function (_a) {
|
|
308
|
-
var size = _a.size, _b = _a.verticalPadding, verticalPadding = _b === void 0 ? 'normal' : _b;
|
|
309
|
-
return sizes_1.SIZE_TO_PX[size] + sizes_1.CONTROL_VERTICAL_PADDING_MODIFIER_FROM_SIZE[verticalPadding] * 2;
|
|
310
|
-
};
|
|
311
|
-
/**
|
|
312
|
-
* The lengths a button is drawn at, as its styles wrote them: from its size, vertical padding and shape, and its own
|
|
313
|
-
* `maxWidth`. `undefined` where it has none (a radius when it is not rounded).
|
|
314
|
-
*/
|
|
315
|
-
var BUTTON_LENGTHS = {
|
|
316
|
-
'--reqore-button-padding': function (_a) {
|
|
317
|
-
var size = _a.size, compact = _a.compact, _b = _a.verticalPadding, verticalPadding = _b === void 0 ? 'normal' : _b, square = _a.square;
|
|
318
|
-
return "".concat(sizes_1.CONTROL_VERTICAL_PADDING_FROM_SIZE[size] +
|
|
319
|
-
sizes_1.CONTROL_VERTICAL_PADDING_MODIFIER_FROM_SIZE[verticalPadding], "px ").concat(square
|
|
320
|
-
? 0
|
|
321
|
-
: compact
|
|
322
|
-
? sizes_1.CONTROL_VERTICAL_PADDING_FROM_SIZE[size]
|
|
323
|
-
: sizes_1.CONTROL_HORIZONTAL_PADDING_FROM_SIZE[size], "px");
|
|
324
|
-
},
|
|
325
|
-
'--reqore-button-font-size': function (_a) {
|
|
326
|
-
var size = _a.size;
|
|
327
|
-
return "".concat(sizes_1.CONTROL_TEXT_FROM_SIZE[size], "px");
|
|
328
|
-
},
|
|
329
|
-
'--reqore-button-min-height': function (props) { return "".concat(getButtonBoxPx(props), "px"); },
|
|
330
|
-
'--reqore-button-min-width': function (props) {
|
|
331
|
-
return "".concat(props.square ? getButtonBoxPx(props) : sizes_1.SIZE_TO_PX[props.size], "px");
|
|
332
|
-
},
|
|
333
|
-
'--reqore-button-width': function (props) { return "".concat(getButtonBoxPx(props), "px"); },
|
|
334
|
-
'--reqore-button-max-width': function (props) {
|
|
335
|
-
return props.square ? "".concat(getButtonBoxPx(props), "px") : props.maxWidth || controlGroup_1.CONTROL_GROUP_CHILD_MAX_WIDTH;
|
|
336
|
-
},
|
|
337
|
-
'--reqore-button-max-height': function (props) { return "".concat(getButtonBoxPx(props), "px"); },
|
|
338
|
-
'--reqore-button-radius': function (_a) {
|
|
339
|
-
var size = _a.size, radiusSize = _a.radiusSize, rounded = _a.rounded, pill = _a.pill, circle = _a.circle;
|
|
340
|
-
return rounded === false
|
|
341
|
-
? undefined
|
|
342
|
-
: circle
|
|
343
|
-
? '9999px'
|
|
344
|
-
: "".concat((0, sizes_1.resolveRadius)(size, radiusSize) * (pill ? sizes_1.PILL_RADIUS_MODIFIER : 1), "px");
|
|
345
|
-
},
|
|
346
|
-
'--reqore-button-description-padding': function (_a) {
|
|
347
|
-
var size = _a.size;
|
|
348
|
-
return "".concat(sizes_1.PADDING_FROM_SIZE[size] / 2, "px");
|
|
349
|
-
},
|
|
350
|
-
};
|
|
351
|
-
/** Whether a length the styles wrote is one CSS takes: not missing, and not made of a size the button lacks. */
|
|
352
|
-
var isUsableLength = function (length) {
|
|
353
|
-
return !!length && !/NaN|undefined/.test(length);
|
|
354
|
-
};
|
|
355
|
-
/**
|
|
356
|
-
* The value a button's styles give a property for one of its lengths: the variable it is set in, or - a length that
|
|
357
|
-
* is not one - what the styles wrote before, which CSS drops as it did.
|
|
358
|
-
*/
|
|
359
|
-
var lengthOf = function (props, variable) {
|
|
360
|
-
var length = BUTTON_LENGTHS[variable](props);
|
|
361
|
-
return isUsableLength(length) ? "var(".concat(variable, ")") : length;
|
|
362
|
-
};
|
|
363
|
-
/**
|
|
364
|
-
* What a button is drawn with as CSS variables on the button, which its styles read: its paint's colors and its
|
|
365
|
-
* lengths. Written into the styles, each color and length made a class of its own - a page of buttons in each
|
|
366
|
-
* intent, size and shape made hundreds, and styled-components warned - where the styles now differ only in what the
|
|
367
|
-
* button is (flat, square, active, read only, ...).
|
|
368
|
-
*/
|
|
369
|
-
var getButtonVariables = function (props) {
|
|
370
|
-
var lengths = Object.keys(BUTTON_LENGTHS)
|
|
371
|
-
.map(function (variable) { return [variable, BUTTON_LENGTHS[variable](props)]; })
|
|
372
|
-
.filter(function (entry) {
|
|
373
|
-
return isUsableLength(entry[1]);
|
|
374
|
-
});
|
|
375
|
-
return __assign(__assign({}, getButtonPaintVariables(props)), Object.fromEntries(lengths));
|
|
133
|
+
? (0, colors_2.isAchromatic)(color)
|
|
134
|
+
? (0, colors_2.getReadableColorFrom)(theme.originalMain, true)
|
|
135
|
+
: (0, polished_1.saturate)(1, (0, polished_1.tint)(0.8, color))
|
|
136
|
+
: (0, colors_2.getReadableColorFrom)(color, true);
|
|
376
137
|
};
|
|
377
138
|
exports.StyledAnimatedTextWrapper = styled_1.default.span(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n min-width: 5px;\n overflow: hidden;\n position: relative;\n text-align: ", ";\n display: flex;\n flex-flow: column;\n align-items: ", ";\n"], ["\n min-width: 5px;\n overflow: hidden;\n position: relative;\n text-align: ", ";\n display: flex;\n flex-flow: column;\n align-items: ", ";\n"])), function (_a) {
|
|
378
139
|
var textAlign = _a.textAlign;
|
|
@@ -437,24 +198,48 @@ exports.REQORE_BUTTON_STYLE_PROPS = (0, styled_1.listReqoreStyleProps)({
|
|
|
437
198
|
verticalPadding: true,
|
|
438
199
|
wrap: true,
|
|
439
200
|
});
|
|
440
|
-
exports.StyledButton = (0, styled_1.default)(Effect_1.StyledEffect)
|
|
441
|
-
.withConfig({
|
|
201
|
+
exports.StyledButton = (0, styled_1.default)(Effect_1.StyledEffect).withConfig({
|
|
442
202
|
// Its own styling props, and the layout flags a containing ControlGroup hands it (`fill`, its
|
|
443
203
|
// place in a stack, ...); `color` is the button's colour, read by its styles.
|
|
444
204
|
shouldForwardProp: styled_1.omitStyleProps.apply(void 0, __spreadArray(__spreadArray(__spreadArray([], exports.REQORE_BUTTON_STYLE_PROPS, false), styled_1.REQORE_CONTROL_GROUP_CHILD_PROPS, false), ['color'], false)),
|
|
445
|
-
})
|
|
446
|
-
.
|
|
447
|
-
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
?
|
|
453
|
-
|
|
205
|
+
})(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n display: flex;\n flex-flow: column;\n justify-content: center;\n /* The page's font (or the theme's, which the layout sets), not the browser's control font:\n a button left to the user-agent stylesheet renders in the platform's form-control face\n whatever font the text around it is in. */\n font-family: inherit;\n font-weight: 570;\n position: relative;\n overflow: hidden;\n vertical-align: middle;\n border: ", ";\n padding: ", ";\n font-size: ", "px;\n outline-offset: -2px;\n\n min-height: ", "px;\n min-width: ", "px;\n ", "\n /* A button is never wider than its container, unless it sets its own maxWidth: fixed means it does not\n stretch, not that it may run past what holds it. A fixed button saying a value and its description stayed as\n wide as both on one line, 487-712px in a 346px card on a phone (qorus#646); capped, its label is clipped as any\n button's is, and its description takes as many lines as it needs. Its container's width is what percentages\n are measured against, so a wrapped stack that pulls the button over its padding adds that back: see\n CONTROL_GROUP_CHILD_MAX_WIDTH. */\n max-width: ", ";\n\n ", "\n\n flex: ", ";\n flex-shrink: ", ";\n flex-grow: ", ";\n align-self: ", ";\n\n border-radius: ", ";\n\n background-color: ", ";\n\n color: ", ";\n\n ", ";\n\n ", "\n\n ", ";\n\n ", ";\n\n &:disabled {\n ", ";\n }\n\n ", "\n\n &:focus,\n &:active {\n outline: 2px solid\n ", ";\n border-color: ", ";\n }\n\n .reqore-button-description {\n padding-top: ", "px;\n color: ", ";\n }\n"], ["\n display: flex;\n flex-flow: column;\n justify-content: center;\n /* The page's font (or the theme's, which the layout sets), not the browser's control font:\n a button left to the user-agent stylesheet renders in the platform's form-control face\n whatever font the text around it is in. */\n font-family: inherit;\n font-weight: 570;\n position: relative;\n overflow: hidden;\n vertical-align: middle;\n border: ", ";\n padding: ", ";\n font-size: ", "px;\n outline-offset: -2px;\n\n min-height: ", "px;\n min-width: ", "px;\n ", "\n /* A button is never wider than its container, unless it sets its own maxWidth: fixed means it does not\n stretch, not that it may run past what holds it. A fixed button saying a value and its description stayed as\n wide as both on one line, 487-712px in a 346px card on a phone (qorus#646); capped, its label is clipped as any\n button's is, and its description takes as many lines as it needs. Its container's width is what percentages\n are measured against, so a wrapped stack that pulls the button over its padding adds that back: see\n CONTROL_GROUP_CHILD_MAX_WIDTH. */\n max-width: ", ";\n\n ", "\n\n flex: ", ";\n flex-shrink: ", ";\n flex-grow: ", ";\n align-self: ", ";\n\n border-radius: ", ";\n\n background-color: ", ";\n\n color: ", ";\n\n ", ";\n\n ", "\n\n ", ";\n\n ", ";\n\n &:disabled {\n ", ";\n }\n\n ", "\n\n &:focus,\n &:active {\n outline: 2px solid\n ", ";\n border-color: ", ";\n }\n\n .reqore-button-description {\n padding-top: ", "px;\n color: ", ";\n }\n"])), function (_a) {
|
|
206
|
+
var theme = _a.theme, color = _a.color, flat = _a.flat, effect = _a.effect;
|
|
207
|
+
return !flat ? "1px solid ".concat((0, colors_2.changeLightness)(getButtonMainColor(theme, color, effect), 0.1)) : 0;
|
|
208
|
+
}, function (_a) {
|
|
209
|
+
var size = _a.size, compact = _a.compact, _b = _a.verticalPadding, verticalPadding = _b === void 0 ? 'normal' : _b, square = _a.square;
|
|
210
|
+
return "".concat(sizes_1.CONTROL_VERTICAL_PADDING_FROM_SIZE[size] +
|
|
211
|
+
sizes_1.CONTROL_VERTICAL_PADDING_MODIFIER_FROM_SIZE[verticalPadding], "px ").concat(square
|
|
212
|
+
? 0
|
|
213
|
+
: compact
|
|
214
|
+
? sizes_1.CONTROL_VERTICAL_PADDING_FROM_SIZE[size]
|
|
215
|
+
: sizes_1.CONTROL_HORIZONTAL_PADDING_FROM_SIZE[size], "px");
|
|
216
|
+
}, function (_a) {
|
|
217
|
+
var size = _a.size;
|
|
218
|
+
return sizes_1.CONTROL_TEXT_FROM_SIZE[size];
|
|
219
|
+
}, function (_a) {
|
|
220
|
+
var size = _a.size, _b = _a.verticalPadding, verticalPadding = _b === void 0 ? 'normal' : _b;
|
|
221
|
+
return sizes_1.SIZE_TO_PX[size] + sizes_1.CONTROL_VERTICAL_PADDING_MODIFIER_FROM_SIZE[verticalPadding] * 2;
|
|
222
|
+
}, function (_a) {
|
|
223
|
+
var size = _a.size, square = _a.square, _b = _a.verticalPadding, verticalPadding = _b === void 0 ? 'normal' : _b;
|
|
224
|
+
return square
|
|
225
|
+
? sizes_1.SIZE_TO_PX[size] + sizes_1.CONTROL_VERTICAL_PADDING_MODIFIER_FROM_SIZE[verticalPadding] * 2
|
|
226
|
+
: sizes_1.SIZE_TO_PX[size];
|
|
227
|
+
}, function (_a) {
|
|
228
|
+
var square = _a.square, size = _a.size, _b = _a.verticalPadding, verticalPadding = _b === void 0 ? 'normal' : _b;
|
|
229
|
+
return square
|
|
230
|
+
? (0, styled_components_1.css)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n width: ", "px;\n "], ["\n width: ", "px;\n "])), sizes_1.SIZE_TO_PX[size] +
|
|
231
|
+
sizes_1.CONTROL_VERTICAL_PADDING_MODIFIER_FROM_SIZE[verticalPadding] * 2) : null;
|
|
232
|
+
}, function (_a) {
|
|
233
|
+
var square = _a.square, maxWidth = _a.maxWidth, size = _a.size, _b = _a.verticalPadding, verticalPadding = _b === void 0 ? 'normal' : _b;
|
|
234
|
+
return square
|
|
235
|
+
? "".concat(sizes_1.SIZE_TO_PX[size] + sizes_1.CONTROL_VERTICAL_PADDING_MODIFIER_FROM_SIZE[verticalPadding] * 2, "px")
|
|
236
|
+
: maxWidth || controlGroup_1.CONTROL_GROUP_CHILD_MAX_WIDTH;
|
|
237
|
+
}, function (_a) {
|
|
454
238
|
var wrap = _a.wrap, description = _a.description;
|
|
455
239
|
return !wrap && !description
|
|
456
|
-
? (0, styled_components_1.css)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n max-height: ", ";\n "], ["\n max-height: ", ";\n "])), function (
|
|
457
|
-
|
|
240
|
+
? (0, styled_components_1.css)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n max-height: ", "px;\n "], ["\n max-height: ", "px;\n "])), function (_a) {
|
|
241
|
+
var size = _a.size, _b = _a.verticalPadding, verticalPadding = _b === void 0 ? 'normal' : _b;
|
|
242
|
+
return sizes_1.SIZE_TO_PX[size] + sizes_1.CONTROL_VERTICAL_PADDING_MODIFIER_FROM_SIZE[verticalPadding] * 2;
|
|
458
243
|
}) : null;
|
|
459
244
|
}, function (_a) {
|
|
460
245
|
var fluid = _a.fluid, fixed = _a.fixed;
|
|
@@ -468,48 +253,86 @@ exports.StyledButton = (0, styled_1.default)(Effect_1.StyledEffect)
|
|
|
468
253
|
}, function (_a) {
|
|
469
254
|
var alignSelf = _a.alignSelf, fixed = _a.fixed, fluid = _a.fluid;
|
|
470
255
|
return alignSelf !== null && alignSelf !== void 0 ? alignSelf : (fixed ? 'flex-start' : fluid ? 'stretch' : undefined);
|
|
471
|
-
}, function (
|
|
256
|
+
}, function (_a) {
|
|
257
|
+
var size = _a.size, radiusSize = _a.radiusSize, rounded = _a.rounded, pill = _a.pill, circle = _a.circle;
|
|
258
|
+
return rounded === false
|
|
259
|
+
? undefined
|
|
260
|
+
: circle
|
|
261
|
+
? '9999px'
|
|
262
|
+
: "".concat((0, sizes_1.resolveRadius)(size, radiusSize) * (pill ? sizes_1.PILL_RADIUS_MODIFIER : 1), "px");
|
|
263
|
+
}, function (_a) {
|
|
264
|
+
var minimal = _a.minimal, color = _a.color, theme = _a.theme, transparent = _a.transparent, effect = _a.effect;
|
|
265
|
+
if (transparent) {
|
|
266
|
+
return 'transparent';
|
|
267
|
+
}
|
|
268
|
+
if (minimal) {
|
|
269
|
+
return (0, styled_components_1.css)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n ", "\n "], ["\n ", "\n "])), (0, polished_1.rgba)(getButtonMainColor(theme, color, effect), 0.2));
|
|
270
|
+
}
|
|
271
|
+
return color;
|
|
272
|
+
}, function (_a) {
|
|
273
|
+
var color = _a.color, minimal = _a.minimal, transparent = _a.transparent, theme = _a.theme, effect = _a.effect;
|
|
274
|
+
var finalColor = getButtonMainColor(theme, color, effect);
|
|
275
|
+
return getButtonTextColor({ minimal: minimal, transparent: transparent, color: finalColor, theme: theme });
|
|
276
|
+
}, styles_1.InactiveIconScale, function (_a) {
|
|
472
277
|
var raised = _a.raised, flat = _a.flat, transparent = _a.transparent;
|
|
473
278
|
return raised && flat && !transparent && styles_1.RaisedElement;
|
|
474
|
-
}, function (
|
|
475
|
-
var readOnly =
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
279
|
+
}, function (_a) {
|
|
280
|
+
var readOnly = _a.readOnly, animate = _a.animate, active = _a.active, theme = _a.theme, color = _a.color, effect = _a.effect;
|
|
281
|
+
return !readOnly && !active
|
|
282
|
+
? (0, styled_components_1.css)(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n &:not(:disabled) {\n ", "\n\n cursor: pointer;\n transition: all 0.2s ease-out;\n\n &:active {\n outline: 3px solid ", ";\n outline-offset: -3px;\n transition: none;\n }\n\n &:hover:not(:active) {\n outline: 2px solid ", ";\n transition: none;\n }\n\n &:hover,\n &:active {\n border-color: ", ";\n background-color: ", ";\n color: ", "\n ", ";\n }\n }\n "], ["\n &:not(:disabled) {\n ", "\n\n cursor: pointer;\n transition: all 0.2s ease-out;\n\n &:active {\n outline: 3px solid ", ";\n outline-offset: -3px;\n transition: none;\n }\n\n &:hover:not(:active) {\n outline: 2px solid ", ";\n transition: none;\n }\n\n &:hover,\n &:active {\n border-color: ", ";\n background-color: ", ";\n color: ", "\n ", ";\n }\n }\n "])), styles_1.ScaleIconOnHover, (0, colors_2.changeLightness)(getButtonMainColor(theme, color, effect), 0.25), (0, colors_2.changeLightness)(getButtonMainColor(theme, color, effect), 0.25), function (_a) {
|
|
283
|
+
var flat = _a.flat, theme = _a.theme, color = _a.color;
|
|
284
|
+
return flat ? undefined : (0, colors_2.changeLightness)(getButtonMainColor(theme, color, effect), 0.25);
|
|
285
|
+
}, function (_a) {
|
|
286
|
+
var theme = _a.theme, color = _a.color, minimal = _a.minimal, transparent = _a.transparent;
|
|
287
|
+
return minimal || transparent
|
|
288
|
+
? (0, polished_1.rgba)((0, colors_2.changeLightness)(getButtonMainColor(theme, color, effect), 0.1), transparent ? 0.2 : 0.4)
|
|
289
|
+
: (0, colors_2.changeLightness)(getButtonMainColor(theme, color), 0.05);
|
|
290
|
+
}, function (_a) {
|
|
291
|
+
var theme = _a.theme, color = _a.color, minimal = _a.minimal, transparent = _a.transparent, effect = _a.effect;
|
|
292
|
+
var finalColor = getButtonMainColor(theme, color, effect);
|
|
293
|
+
return minimal || transparent
|
|
294
|
+
? (0, colors_2.isAchromatic)(finalColor)
|
|
295
|
+
? (0, colors_2.getReadableColorFrom)(theme.originalMain)
|
|
296
|
+
: (0, polished_1.saturate)(1, (0, polished_1.tint)(0.9, finalColor))
|
|
297
|
+
: (0, colors_2.getReadableColorFrom)(finalColor);
|
|
298
|
+
}, animate
|
|
299
|
+
? (0, styled_components_1.css)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n cursor: pointer;\n\n ", " {\n transform: translateY(150%);\n filter: blur(10px);\n opacity: 0;\n }\n\n ", " {\n transform: translateY(0px);\n filter: blur(0);\n opacity: 1;\n }\n "], ["\n cursor: pointer;\n\n ", " {\n transform: translateY(150%);\n filter: blur(10px);\n opacity: 0;\n }\n\n ", " {\n transform: translateY(0px);\n filter: blur(0);\n opacity: 1;\n }\n "])), styles_1.StyledInActiveContent, styles_1.StyledActiveContent) : undefined) : readOnly
|
|
300
|
+
? (0, styled_components_1.css)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n ", ";\n "], ["\n ", ";\n "])), styles_1.ReadOnlyElement) : undefined;
|
|
301
|
+
}, function (_a) {
|
|
302
|
+
var active = _a.active, flat = _a.flat, theme = _a.theme, color = _a.color, effect = _a.effect;
|
|
303
|
+
if (active) {
|
|
304
|
+
return (0, styled_components_1.css)(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n cursor: pointer;\n background-color: ", ";\n color: ", ";\n border-color: ", ";\n\n &:hover,\n &:active,\n &:focus {\n border-color: ", ";\n }\n\n ", "\n "], ["\n cursor: pointer;\n background-color: ", ";\n color: ", ";\n border-color: ", ";\n\n &:hover,\n &:active,\n &:focus {\n border-color: ", ";\n }\n\n ", "\n "])), (0, colors_2.changeLightness)(getButtonMainColor(theme, color, effect), 0.1), (0, colors_2.getReadableColor)({ main: (0, colors_2.changeLightness)(getButtonMainColor(theme, color, effect), 0.1) }, undefined, undefined), flat
|
|
305
|
+
? undefined
|
|
306
|
+
: (0, colors_2.changeLightness)(getButtonMainColor(theme, color, effect), 0.175), flat
|
|
307
|
+
? undefined
|
|
308
|
+
: (0, colors_2.changeLightness)(getButtonMainColor(theme, color, effect), 0.275), styles_1.ActiveIconScale);
|
|
494
309
|
}
|
|
495
310
|
}, styles_1.DisabledElement, function (_a) {
|
|
496
311
|
var $isLink = _a.$isLink;
|
|
497
312
|
return $isLink
|
|
498
|
-
? (0, styled_components_1.css)(
|
|
499
|
-
}, function (
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
313
|
+
? (0, styled_components_1.css)(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n text-decoration: none;\n\n /* A link has no :disabled; a disabled one says so with aria-disabled. */\n &[aria-disabled='true'] {\n ", ";\n }\n "], ["\n text-decoration: none;\n\n /* A link has no :disabled; a disabled one says so with aria-disabled. */\n &[aria-disabled='true'] {\n ", ";\n }\n "])), styles_1.DisabledElement) : undefined;
|
|
314
|
+
}, function (_a) {
|
|
315
|
+
var theme = _a.theme, color = _a.color, effect = _a.effect;
|
|
316
|
+
return (0, colors_2.changeLightness)(getButtonMainColor(theme, color, effect), 0.1);
|
|
317
|
+
}, function (_a) {
|
|
318
|
+
var minimal = _a.minimal, theme = _a.theme, color = _a.color, effect = _a.effect;
|
|
319
|
+
return minimal ? undefined : (0, colors_2.changeLightness)(getButtonMainColor(theme, color, effect), 0.1);
|
|
320
|
+
}, function (_a) {
|
|
321
|
+
var size = _a.size;
|
|
322
|
+
return sizes_1.PADDING_FROM_SIZE[size] / 2;
|
|
323
|
+
}, function (_a) {
|
|
324
|
+
var theme = _a.theme, color = _a.color, minimal = _a.minimal, transparent = _a.transparent;
|
|
325
|
+
return (0, polished_1.rgba)(getButtonTextColor({ minimal: minimal, transparent: transparent, color: color, theme: theme }), 0.7);
|
|
326
|
+
});
|
|
504
327
|
exports.StyledButtonContent = styled_1.default.div.withConfig({
|
|
505
328
|
shouldForwardProp: (0, styled_1.omitStyleProps)('wrap'),
|
|
506
|
-
})(
|
|
329
|
+
})(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n width: 100%;\n height: 100%;\n min-width: ", "px;\n flex: 1;\n flex-shrink: 0;\n\n ", "\n"], ["\n display: flex;\n align-items: center;\n width: 100%;\n height: 100%;\n min-width: ", "px;\n flex: 1;\n flex-shrink: 0;\n\n ", "\n"])), function (_a) {
|
|
507
330
|
var size = _a.size;
|
|
508
331
|
return sizes_1.ICON_FROM_SIZE[size];
|
|
509
332
|
}, function (_a) {
|
|
510
333
|
var wrap = _a.wrap, description = _a.description;
|
|
511
334
|
return !wrap && !description
|
|
512
|
-
? (0, styled_components_1.css)(
|
|
335
|
+
? (0, styled_components_1.css)(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n max-height: ", "px;\n "], ["\n max-height: ", "px;\n "])), function (_a) {
|
|
513
336
|
var size = _a.size;
|
|
514
337
|
return sizes_1.SIZE_TO_PX[size];
|
|
515
338
|
}) : null;
|
|
@@ -562,14 +385,13 @@ exports.ButtonBadge = (0, react_1.memo)(function (_a) {
|
|
|
562
385
|
* Primary Reqore button component that supports intents, icons, and badges.
|
|
563
386
|
*/
|
|
564
387
|
var ReqoreButton = (0, react_1.memo)((0, react_1.forwardRef)(function (_a, ref) {
|
|
565
|
-
var _b, _c, _d
|
|
566
|
-
var icon = _a.icon,
|
|
388
|
+
var _b, _c, _d;
|
|
389
|
+
var icon = _a.icon, _e = _a.size, size = _e === void 0 ? 'normal' : _e, minimal = _a.minimal, transparent = _a.transparent, children = _a.children, tooltip = _a.tooltip, className = _a.className, fluid = _a.fluid, fixed = _a.fixed, alignSelf = _a.alignSelf, intent = _a.intent, active = _a.active, flat = _a.flat, rightIcon = _a.rightIcon, customTheme = _a.customTheme, wrap = _a.wrap, readOnly = _a.readOnly, badge = _a.badge, indicator = _a.indicator, description = _a.description, maxWidth = _a.maxWidth, textAlignProp = _a.textAlign, effect = _a.effect, labelEffect = _a.labelEffect, descriptionEffect = _a.descriptionEffect, leftIconColor = _a.leftIconColor, rightIconColor = _a.rightIconColor, iconColor = _a.iconColor, iconsAlignProp = _a.iconsAlign, leftIconProps = _a.leftIconProps, rightIconProps = _a.rightIconProps, label = _a.label, compact = _a.compact, square = _a.square, as = _a.as, animated = _a.animated, loading = _a.loading, shortcut = _a.shortcut, shortcutHint = _a.shortcutHint, loadingIconType = _a.loadingIconType, href = _a.href, type = _a.type, rest = __rest(_a, ["icon", "size", "minimal", "transparent", "children", "tooltip", "className", "fluid", "fixed", "alignSelf", "intent", "active", "flat", "rightIcon", "customTheme", "wrap", "readOnly", "badge", "indicator", "description", "maxWidth", "textAlign", "effect", "labelEffect", "descriptionEffect", "leftIconColor", "rightIconColor", "iconColor", "iconsAlign", "leftIconProps", "rightIconProps", "label", "compact", "square", "as", "animated", "loading", "shortcut", "shortcutHint", "loadingIconType", "href", "type"]);
|
|
567
390
|
var animations = (0, useReqoreContext_1.useReqoreProperty)('animations');
|
|
568
391
|
var shortcutHintsEnabled = (0, useReqoreContext_1.useReqoreProperty)('shortcutHints');
|
|
569
392
|
var theme = (0, useTheme_1.useReqoreTheme)('main', customTheme, intent);
|
|
570
|
-
var surface = (0, SurfaceContext_1.useReqoreSurface)();
|
|
571
393
|
var fixedEffect = (0, useReqoreEffect_1.useReqoreEffect)('buttons', theme, effect);
|
|
572
|
-
var
|
|
394
|
+
var _f = (0, useCombinedRefs_1.useCombinedRefs)(ref), targetRef = _f.targetRef, setRef = _f.setRef;
|
|
573
395
|
// Square chips have no horizontal padding, so the content would
|
|
574
396
|
// stick to the left edge if we kept `textAlign`'s usual `'left'`
|
|
575
397
|
// default. Default `textAlign` and `iconsAlign` to `'center'` for
|
|
@@ -635,46 +457,6 @@ var ReqoreButton = (0, react_1.memo)((0, react_1.forwardRef)(function (_a, ref)
|
|
|
635
457
|
? "Loader".concat(loadingIconType || '', "Line")
|
|
636
458
|
: icon || (leftIconProps === null || leftIconProps === void 0 ? void 0 : leftIconProps.icon);
|
|
637
459
|
var memoEffect = (0, react_1.useMemo)(function () { return (__assign(__assign({ interactive: !readOnly && !rest.disabled }, fixedEffect), { gradient: intent ? undefined : fixedEffect === null || fixedEffect === void 0 ? void 0 : fixedEffect.gradient })); }, [fixedEffect, intent, readOnly, rest.disabled]);
|
|
638
|
-
/* The button's colors depend on its gradient alone of its effect: an effect the caller writes inline (a new
|
|
639
|
-
object each render) with the same gradient keeps them. */
|
|
640
|
-
var gradientKey = (memoEffect === null || memoEffect === void 0 ? void 0 : memoEffect.gradient) ? JSON.stringify(memoEffect.gradient) : undefined;
|
|
641
|
-
// The icons stand out from what the button is drawn on, as its text does.
|
|
642
|
-
var colorProps = (0, react_1.useMemo)(function () { return ({
|
|
643
|
-
theme: theme,
|
|
644
|
-
color: customColor,
|
|
645
|
-
minimal: minimal,
|
|
646
|
-
transparent: transparent,
|
|
647
|
-
effect: memoEffect,
|
|
648
|
-
$surface: surface,
|
|
649
|
-
}); }, [theme, customColor, minimal, transparent, gradientKey, surface]);
|
|
650
|
-
/* Its colors in the states it is drawn in, and what its styles paint it with, worked out once per render
|
|
651
|
-
rather than in each of its style rules. */
|
|
652
|
-
var states = (0, react_1.useMemo)(function () { return (0, exports.getButtonStateColors)(colorProps, active); }, [colorProps, active]);
|
|
653
|
-
// whether it has a description, not the description: a node given inline is new each render
|
|
654
|
-
var hasDescription = !!description;
|
|
655
|
-
var paint = (0, react_1.useMemo)(function () { return (0, exports.getButtonPaint)(colorProps, states, hasDescription); }, [colorProps, states, hasDescription]);
|
|
656
|
-
// an icon's own color: in its props (which win, as they are spread over the rest), else the button's
|
|
657
|
-
var _k = (0, iconProps_1.splitIconColor)(leftIconProps), leftIconPropsColor = _k[0], leftIconRest = _k[1];
|
|
658
|
-
var _l = (0, iconProps_1.splitIconColor)(rightIconProps), rightIconPropsColor = _l[0], rightIconRest = _l[1];
|
|
659
|
-
var leftIconOwn = leftIconPropsColor || leftIconColor || iconColor;
|
|
660
|
-
var rightIconOwn = rightIconPropsColor || rightIconColor || iconColor;
|
|
661
|
-
// only for the icons the button draws
|
|
662
|
-
var leftIconLook = (0, react_1.useMemo)(function () { return (hasLeftIcon ? getButtonIconLookIn(theme, states, leftIconOwn) : undefined); }, [hasLeftIcon, theme, states, leftIconOwn]);
|
|
663
|
-
var rightIconLook = (0, react_1.useMemo)(function () { return (hasRightIcon ? getButtonIconLookIn(theme, states, rightIconOwn) : undefined); }, [hasRightIcon, theme, states, rightIconOwn]);
|
|
664
|
-
/* What the button holds (its badges, a label given as a node) is drawn on the button: at rest, or in its
|
|
665
|
-
fill when it is active (a selected menu item, whose badges were picked for the resting wash). */
|
|
666
|
-
var restingBackground = ((_d = states.active) !== null && _d !== void 0 ? _d : states.rest).backgrounds;
|
|
667
|
-
/* Its effect's color is written on its own fill, at rest and hovered (or active), not on the surface
|
|
668
|
-
around it: an info text on a success button was read on the page, 2.7:1 on the green. */
|
|
669
|
-
var fillBackgrounds = (0, react_1.useMemo)(function () {
|
|
670
|
-
var _a, _b;
|
|
671
|
-
return states.active
|
|
672
|
-
? states.active.backgrounds
|
|
673
|
-
: __spreadArray(__spreadArray([], states.rest.backgrounds, true), ((_b = (_a = states.hover) === null || _a === void 0 ? void 0 : _a.backgrounds) !== null && _b !== void 0 ? _b : []), true);
|
|
674
|
-
}, [states]);
|
|
675
|
-
// one object for as long as the opacity holds: an icon is a memo component
|
|
676
|
-
var leftIconEffect = (0, react_1.useMemo)(function () { return ({ opacity: leftIconLook === null || leftIconLook === void 0 ? void 0 : leftIconLook.opacity }); }, [leftIconLook === null || leftIconLook === void 0 ? void 0 : leftIconLook.opacity]);
|
|
677
|
-
var rightIconEffect = (0, react_1.useMemo)(function () { return ({ opacity: rightIconLook === null || rightIconLook === void 0 ? void 0 : rightIconLook.opacity }); }, [rightIconLook === null || rightIconLook === void 0 ? void 0 : rightIconLook.opacity]);
|
|
678
460
|
var indicatorConfig = (0, react_1.useMemo)(function () {
|
|
679
461
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
680
462
|
if (!indicator) {
|
|
@@ -694,32 +476,29 @@ var ReqoreButton = (0, react_1.memo)((0, react_1.forwardRef)(function (_a, ref)
|
|
|
694
476
|
// The caller's tab stop wins — a grid or a diagram keeps one of its
|
|
695
477
|
// buttons in the tab order and moves it — except that a disabled
|
|
696
478
|
// button is never one.
|
|
697
|
-
tabIndex: rest.disabled ? -1 : ((
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
: undefined,
|
|
720
|
-
}
|
|
721
|
-
: undefined }))] })), showShortcutHint ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Spacer_1.ReqoreSpacer, { width: sizes_1.PADDING_FROM_SIZE[size] / 2 }), (0, jsx_runtime_1.jsx)(KeyboardShortcut_1.ReqoreKeyboardShortcut, { shortcut: shortcut, size: size, compact: _compact })] })) : null] }), description && ((0, jsx_runtime_1.jsx)(Effect_1.ReqoreTextEffect, { className: 'reqore-button-description', effect: __assign({ textSize: (0, utils_1.getOneLessSize)(size), weight: 'light', textAlign: textAlign }, descriptionEffect), children: description }))] }), indicatorConfig && ((0, jsx_runtime_1.jsx)(exports.StyledButtonIndicator, { className: 'reqore-button-indicator', "$color": indicatorConfig.color, "$diameter": indicatorConfig.diameter, "$offset": indicatorConfig.offset, "$position": indicatorConfig.position, "$pulse": indicatorConfig.pulse, "aria-hidden": 'true' }))] })));
|
|
479
|
+
tabIndex: rest.disabled ? -1 : ((_d = rest.tabIndex) !== null && _d !== void 0 ? _d : 0) }, elementProps, { as: element, theme: theme, fluid: fluid, fixed: fixed, alignSelf: alignSelf, maxWidth: maxWidth, minimal: minimal, transparent: transparent, size: size, intent: intent, color: customColor, animate: animate, flat: _flat, active: active, readOnly: readOnly || loading, wrap: wrap, description: description, className: "".concat(className || '', " reqore-control reqore-button"),
|
|
480
|
+
compact: _compact, square: square, tooltip: tooltip }, useMarqueeOnHover_1.REQORE_MARQUEE_HOST, { Component: exports.StyledButton, ref: setRef, children: [(0, jsx_runtime_1.jsxs)(exports.StyledButtonContent, { size: size, wrap: wrap, description: description, flat: _flat, children: [hasLeftIcon ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Icon_1.default, __assign({ size: size, color: leftIconColor || iconColor, compact: true, effect: {
|
|
481
|
+
opacity: colors_1.CONTROL_ICON_OPACITY,
|
|
482
|
+
} }, leftIconProps, { style: textAlign !== 'left' || iconsAlign === 'center' || !_children
|
|
483
|
+
? {
|
|
484
|
+
marginRight: iconsAlign !== 'center' || !_children ? 'auto' : undefined,
|
|
485
|
+
marginLeft: iconsAlign === 'center' || !_children ? 'auto' : undefined,
|
|
486
|
+
}
|
|
487
|
+
: undefined, animation: loading ? 'spin' : leftIconProps === null || leftIconProps === void 0 ? void 0 : leftIconProps.animation, icon: leftIcon })), _children || hasRightIcon ? ((0, jsx_runtime_1.jsx)(Spacer_1.ReqoreSpacer, { width: sizes_1.PADDING_FROM_SIZE[size] / 2 })) : null] })) : _children ? ((0, jsx_runtime_1.jsx)(Spacer_1.ReqoreHorizontalSpacer, { width: 1, style: textAlign !== 'left' ? { marginRight: 'auto' } : undefined })) : null, _children && ((0, jsx_runtime_1.jsxs)(exports.StyledAnimatedTextWrapper, { textAlign: textAlign, style: textAlign === 'center' && iconsAlign !== 'center' ? { margin: 'auto' } : undefined, children: [!animate && ((0, jsx_runtime_1.jsx)(styles_1.StyledContent, __assign({ wrap: wrap, effect: labelEffect, className: 'reqore-button-text-content' }, useMarqueeOnHover_1.REQORE_MARQUEE_TEXT, { children: _children }))), animate && ((0, jsx_runtime_1.jsx)(styles_1.StyledActiveContent, __assign({ wrap: wrap, effect: labelEffect, className: 'reqore-button-text-content reqore-animated reqore-active' }, useMarqueeOnHover_1.REQORE_MARQUEE_TEXT, { children: _children }))), animate && ((0, jsx_runtime_1.jsx)(styles_1.StyledInActiveContent, __assign({ wrap: wrap, effect: labelEffect, className: 'reqore-button-text-content reqore-animated reqore-inactive' }, useMarqueeOnHover_1.REQORE_MARQUEE_TEXT, { "aria-hidden": 'true', children: _children }))), animate && ((0, jsx_runtime_1.jsx)(styles_1.StyledInvisibleContent, { wrap: wrap, effect: labelEffect, className: 'reqore-button-text-content reqore-animated reqore-invisible', "aria-hidden": 'true', children: _children })), (badge || badge === 0) && wrap ? ((0, jsx_runtime_1.jsx)(exports.ButtonBadge, { content: badge, size: size, wrap: true, active: active })) : null] })), (badge || badge === 0) && !wrap ? ((0, jsx_runtime_1.jsx)(exports.ButtonBadge, { content: badge, size: size, compact: _compact, wrapGroup: false, wrap: false, active: active })) : null, !hasRightIcon ? (_children ? ((0, jsx_runtime_1.jsx)(Spacer_1.ReqoreHorizontalSpacer, { width: 1, style: textAlign !== 'right' && !hasRightAlignedBadge
|
|
488
|
+
? { marginLeft: 'auto' }
|
|
489
|
+
: undefined })) : null) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [_children || badge ? (0, jsx_runtime_1.jsx)(Spacer_1.ReqoreSpacer, { width: sizes_1.PADDING_FROM_SIZE[size] / 2 }) : null, (0, jsx_runtime_1.jsx)(Icon_1.default, __assign({ icon: rightIcon, size: size, color: rightIconColor || iconColor, effect: {
|
|
490
|
+
opacity: colors_1.CONTROL_ICON_OPACITY,
|
|
491
|
+
} }, rightIconProps, { style: textAlign !== 'right' || iconsAlign === 'center'
|
|
492
|
+
? {
|
|
493
|
+
marginLeft: !hasRightAlignedBadge && (iconsAlign !== 'center' || !_children)
|
|
494
|
+
? 'auto'
|
|
495
|
+
: undefined,
|
|
496
|
+
marginRight: iconsAlign === 'center' || (textAlign === 'center' && !_children)
|
|
497
|
+
? 'auto'
|
|
498
|
+
: undefined,
|
|
499
|
+
}
|
|
500
|
+
: undefined }))] })), showShortcutHint ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Spacer_1.ReqoreSpacer, { width: sizes_1.PADDING_FROM_SIZE[size] / 2 }), (0, jsx_runtime_1.jsx)(KeyboardShortcut_1.ReqoreKeyboardShortcut, { shortcut: shortcut, size: size, compact: _compact })] })) : null] }), description && ((0, jsx_runtime_1.jsx)(Effect_1.ReqoreTextEffect, { className: 'reqore-button-description', effect: __assign({ textSize: (0, utils_1.getOneLessSize)(size), weight: 'light', textAlign: textAlign }, descriptionEffect), children: description })), indicatorConfig && ((0, jsx_runtime_1.jsx)(exports.StyledButtonIndicator, { className: 'reqore-button-indicator', "$color": indicatorConfig.color, "$diameter": indicatorConfig.diameter, "$offset": indicatorConfig.offset, "$position": indicatorConfig.position, "$pulse": indicatorConfig.pulse, "aria-hidden": 'true' }))] })));
|
|
722
501
|
}));
|
|
723
502
|
exports.default = ReqoreButton;
|
|
724
|
-
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;
|
|
503
|
+
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;
|
|
725
504
|
//# sourceMappingURL=index.js.map
|