@qoretechnologies/reqore 0.78.0 → 0.78.1-pr.708.g9e025c6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/ButtonRail/index.d.ts.map +1 -1
- package/dist/components/ButtonRail/index.js +9 -1
- package/dist/components/ButtonRail/index.js.map +1 -1
- package/dist/components/DataView/index.d.ts.map +1 -1
- package/dist/components/DataView/index.js +1 -4
- package/dist/components/DataView/index.js.map +1 -1
- package/dist/components/FeatureCard/index.d.ts +2 -27
- package/dist/components/FeatureCard/index.d.ts.map +1 -1
- package/dist/components/FeatureCard/index.js +4 -18
- package/dist/components/FeatureCard/index.js.map +1 -1
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js +1 -1
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/Layout/index.d.ts +1 -12
- package/dist/components/Layout/index.d.ts.map +1 -1
- package/dist/components/Layout/index.js +6 -10
- package/dist/components/Layout/index.js.map +1 -1
- package/dist/components/Panel/index.d.ts +1 -35
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +21 -42
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.js +14 -0
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/components/RichTextEditor/index.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.js +14 -4
- package/dist/components/RichTextEditor/index.js.map +1 -1
- package/dist/components/SegmentedControl/index.d.ts +2 -14
- package/dist/components/SegmentedControl/index.d.ts.map +1 -1
- package/dist/components/SegmentedControl/index.js +24 -34
- package/dist/components/SegmentedControl/index.js.map +1 -1
- package/dist/components/Statistic/index.d.ts +0 -35
- package/dist/components/Statistic/index.d.ts.map +1 -1
- package/dist/components/Statistic/index.js +4 -26
- package/dist/components/Statistic/index.js.map +1 -1
- package/dist/components/Tier/index.d.ts +1 -84
- package/dist/components/Tier/index.d.ts.map +1 -1
- package/dist/components/Tier/index.js +5 -213
- package/dist/components/Tier/index.js.map +1 -1
- package/dist/components/Timeline/index.d.ts +0 -14
- package/dist/components/Timeline/index.d.ts.map +1 -1
- package/dist/components/Timeline/index.js +12 -27
- package/dist/components/Timeline/index.js.map +1 -1
- package/dist/constants/fonts.d.ts +1 -1
- package/dist/constants/fonts.js +1 -1
- package/dist/constants/theme.d.ts +0 -14
- package/dist/constants/theme.d.ts.map +1 -1
- package/dist/constants/theme.js.map +1 -1
- package/dist/containers/UIProvider.d.ts +0 -9
- package/dist/containers/UIProvider.d.ts.map +1 -1
- package/dist/containers/UIProvider.js +4 -8
- package/dist/containers/UIProvider.js.map +1 -1
- package/dist/helpers/utils.d.ts +0 -6
- package/dist/helpers/utils.d.ts.map +1 -1
- package/dist/helpers/utils.js +1 -14
- package/dist/helpers/utils.js.map +1 -1
- package/dist/hooks/useNarrowContainer.d.ts +0 -5
- package/dist/hooks/useNarrowContainer.d.ts.map +1 -1
- package/dist/hooks/useNarrowContainer.js +0 -17
- package/dist/hooks/useNarrowContainer.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/types/global.d.ts +0 -8
- package/dist/types/global.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/components/Tier/group.d.ts +0 -134
- package/dist/components/Tier/group.d.ts.map +0 -1
- package/dist/components/Tier/group.js +0 -607
- package/dist/components/Tier/group.js.map +0 -1
- package/dist/hooks/useCountUp.d.ts +0 -71
- package/dist/hooks/useCountUp.d.ts.map +0 -1
- package/dist/hooks/useCountUp.js +0 -210
- package/dist/hooks/useCountUp.js.map +0 -1
- package/dist/hooks/usePrefersReducedMotion.d.ts +0 -13
- package/dist/hooks/usePrefersReducedMotion.d.ts.map +0 -1
- package/dist/hooks/usePrefersReducedMotion.js +0 -42
- package/dist/hooks/usePrefersReducedMotion.js.map +0 -1
- package/tests.json +0 -1
|
@@ -1,607 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
-
return cooked;
|
|
5
|
-
};
|
|
6
|
-
var __assign = (this && this.__assign) || function () {
|
|
7
|
-
__assign = Object.assign || function(t) {
|
|
8
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
9
|
-
s = arguments[i];
|
|
10
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
11
|
-
t[p] = s[p];
|
|
12
|
-
}
|
|
13
|
-
return t;
|
|
14
|
-
};
|
|
15
|
-
return __assign.apply(this, arguments);
|
|
16
|
-
};
|
|
17
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
-
}
|
|
23
|
-
Object.defineProperty(o, k2, desc);
|
|
24
|
-
}) : (function(o, m, k, k2) {
|
|
25
|
-
if (k2 === undefined) k2 = k;
|
|
26
|
-
o[k2] = m[k];
|
|
27
|
-
}));
|
|
28
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
-
}) : function(o, v) {
|
|
31
|
-
o["default"] = v;
|
|
32
|
-
});
|
|
33
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
34
|
-
var ownKeys = function(o) {
|
|
35
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
36
|
-
var ar = [];
|
|
37
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
38
|
-
return ar;
|
|
39
|
-
};
|
|
40
|
-
return ownKeys(o);
|
|
41
|
-
};
|
|
42
|
-
return function (mod) {
|
|
43
|
-
if (mod && mod.__esModule) return mod;
|
|
44
|
-
var result = {};
|
|
45
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
46
|
-
__setModuleDefault(result, mod);
|
|
47
|
-
return result;
|
|
48
|
-
};
|
|
49
|
-
})();
|
|
50
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
51
|
-
var t = {};
|
|
52
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
53
|
-
t[p] = s[p];
|
|
54
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
55
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
56
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
57
|
-
t[p[i]] = s[p[i]];
|
|
58
|
-
}
|
|
59
|
-
return t;
|
|
60
|
-
};
|
|
61
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
|
-
};
|
|
64
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
-
exports.ReqoreTierGroup = exports.getTierStackItemStyle = exports.getTierSwipeStep = exports.getInitialTierIndex = exports.getTierStackOffset = exports.normalizeTierIndex = exports.TIER_STACK = exports.TIER_GROUP_DOT_MARK_FROM_SIZE = exports.TIER_GROUP_DOT_FROM_SIZE = exports.TIER_GROUP_PEEK_FROM_SIZE = void 0;
|
|
66
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
67
|
-
var polished_1 = require("polished");
|
|
68
|
-
var react_1 = __importStar(require("react"));
|
|
69
|
-
var styled_components_1 = __importStar(require("styled-components"));
|
|
70
|
-
var use_context_selector_1 = require("use-context-selector");
|
|
71
|
-
var sizes_1 = require("../../constants/sizes");
|
|
72
|
-
var ThemeProvider_1 = __importDefault(require("../../containers/ThemeProvider"));
|
|
73
|
-
var CustomThemeContext_1 = __importDefault(require("../../context/CustomThemeContext"));
|
|
74
|
-
var colors_1 = require("../../helpers/colors");
|
|
75
|
-
var utils_1 = require("../../helpers/utils");
|
|
76
|
-
var useNarrowContainer_1 = require("../../hooks/useNarrowContainer");
|
|
77
|
-
var usePrefersReducedMotion_1 = require("../../hooks/usePrefersReducedMotion");
|
|
78
|
-
var useTheme_1 = require("../../hooks/useTheme");
|
|
79
|
-
var Button_1 = __importDefault(require("../Button"));
|
|
80
|
-
var TooltipComponent_1 = require("../TooltipComponent");
|
|
81
|
-
/** How far a neighbour shows past the front tier, on either side, in px. */
|
|
82
|
-
exports.TIER_GROUP_PEEK_FROM_SIZE = {
|
|
83
|
-
micro: 8,
|
|
84
|
-
tiny: 10,
|
|
85
|
-
small: 14,
|
|
86
|
-
normal: 20,
|
|
87
|
-
big: 24,
|
|
88
|
-
huge: 28,
|
|
89
|
-
massive: 32,
|
|
90
|
-
};
|
|
91
|
-
/** A dot's hit area, in px (the mark inside it is `TIER_GROUP_DOT_MARK_FROM_SIZE`). */
|
|
92
|
-
exports.TIER_GROUP_DOT_FROM_SIZE = {
|
|
93
|
-
micro: 16,
|
|
94
|
-
tiny: 20,
|
|
95
|
-
small: 24,
|
|
96
|
-
normal: 28,
|
|
97
|
-
big: 32,
|
|
98
|
-
huge: 36,
|
|
99
|
-
massive: 40,
|
|
100
|
-
};
|
|
101
|
-
/** The dot itself, in px; the front tier's is a pill two and a half times as wide. */
|
|
102
|
-
exports.TIER_GROUP_DOT_MARK_FROM_SIZE = {
|
|
103
|
-
micro: 4,
|
|
104
|
-
tiny: 5,
|
|
105
|
-
small: 6,
|
|
106
|
-
normal: 8,
|
|
107
|
-
big: 10,
|
|
108
|
-
huge: 12,
|
|
109
|
-
massive: 14,
|
|
110
|
-
};
|
|
111
|
-
/** How the stack looks and moves. */
|
|
112
|
-
exports.TIER_STACK = {
|
|
113
|
-
/** A neighbour's scale and turn (degrees: its outer edge comes forward, facing the front). */
|
|
114
|
-
neighbourScale: 0.9,
|
|
115
|
-
neighbourRotate: 12,
|
|
116
|
-
/**
|
|
117
|
-
* How bright a neighbour is drawn, on a dark and on a light theme. Dimmed by brightness, not
|
|
118
|
-
* by opacity: a tier faded towards a page of nearly its own colour disappears, while a darker
|
|
119
|
-
* (or, on a light page, greyer) one reads as standing in the front tier's shadow.
|
|
120
|
-
*/
|
|
121
|
-
neighbourBrightness: { dark: 0.65, light: 0.9 },
|
|
122
|
-
/** A tier two or more steps from the front: smaller still, and faded out. */
|
|
123
|
-
hiddenScale: 0.8,
|
|
124
|
-
/** Of the stack, for the turn: the distance to the viewer, in px. */
|
|
125
|
-
perspective: 900,
|
|
126
|
-
/** The switch: a curve that overshoots a little and settles, like a spring. */
|
|
127
|
-
duration: 480,
|
|
128
|
-
easing: 'cubic-bezier(0.22, 1.25, 0.36, 1)',
|
|
129
|
-
/** A swipe brings the next tier to the front past this share of the tier's width... */
|
|
130
|
-
swipeDistance: 0.18,
|
|
131
|
-
/** ...or faster than this, in px per ms. */
|
|
132
|
-
swipeVelocity: 0.35,
|
|
133
|
-
/** How far a press moves, in px, before it is a swipe and not a click. */
|
|
134
|
-
slop: 8,
|
|
135
|
-
/** How much a drag past an end moves the stack. */
|
|
136
|
-
resistance: 0.3,
|
|
137
|
-
};
|
|
138
|
-
/** `index` wrapped round (`loop`) or held to the ends of `count` tiers. */
|
|
139
|
-
var normalizeTierIndex = function (index, count, loop) {
|
|
140
|
-
if (count <= 0) {
|
|
141
|
-
return 0;
|
|
142
|
-
}
|
|
143
|
-
if (loop) {
|
|
144
|
-
return ((index % count) + count) % count;
|
|
145
|
-
}
|
|
146
|
-
return Math.min(Math.max(index, 0), count - 1);
|
|
147
|
-
};
|
|
148
|
-
exports.normalizeTierIndex = normalizeTierIndex;
|
|
149
|
-
/**
|
|
150
|
-
* Steps from the front tier to tier `index`: negative on the left, positive on the right. With
|
|
151
|
-
* `loop`, the shorter way round (a tie goes to the right).
|
|
152
|
-
*/
|
|
153
|
-
var getTierStackOffset = function (index, front, count, loop) {
|
|
154
|
-
var offset = index - front;
|
|
155
|
-
if (!loop || count <= 1) {
|
|
156
|
-
return offset;
|
|
157
|
-
}
|
|
158
|
-
var forward = ((offset % count) + count) % count;
|
|
159
|
-
return forward > count / 2 ? forward - count : forward;
|
|
160
|
-
};
|
|
161
|
-
exports.getTierStackOffset = getTierStackOffset;
|
|
162
|
-
/**
|
|
163
|
-
* The tier in front at first: `defaultIndex` when given (held to the ends), else the first
|
|
164
|
-
* highlighted tier, else the first.
|
|
165
|
-
*/
|
|
166
|
-
var getInitialTierIndex = function (highlights, defaultIndex) {
|
|
167
|
-
if (!highlights.length) {
|
|
168
|
-
return 0;
|
|
169
|
-
}
|
|
170
|
-
if (typeof defaultIndex === 'number' && !Number.isNaN(defaultIndex)) {
|
|
171
|
-
return (0, exports.normalizeTierIndex)(Math.round(defaultIndex), highlights.length);
|
|
172
|
-
}
|
|
173
|
-
return Math.max(highlights.indexOf(true), 0);
|
|
174
|
-
};
|
|
175
|
-
exports.getInitialTierIndex = getInitialTierIndex;
|
|
176
|
-
/**
|
|
177
|
-
* What a released swipe does: `1` brings the next tier to the front (the stack was dragged to
|
|
178
|
-
* the left), `-1` the previous one, `0` puts the front tier back. A swipe counts when it went
|
|
179
|
-
* far enough (`TIER_STACK.swipeDistance` of the tier's `width`) or was quick enough
|
|
180
|
-
* (`TIER_STACK.swipeVelocity`, in the direction it went).
|
|
181
|
-
*/
|
|
182
|
-
var getTierSwipeStep = function (distance, velocity, width) {
|
|
183
|
-
if (Math.abs(distance) < exports.TIER_STACK.slop) {
|
|
184
|
-
return 0;
|
|
185
|
-
}
|
|
186
|
-
var far = width > 0 && Math.abs(distance) >= width * exports.TIER_STACK.swipeDistance;
|
|
187
|
-
var fast = Math.abs(velocity) >= exports.TIER_STACK.swipeVelocity && Math.sign(velocity) === Math.sign(distance);
|
|
188
|
-
if (!far && !fast) {
|
|
189
|
-
return 0;
|
|
190
|
-
}
|
|
191
|
-
return distance < 0 ? 1 : -1;
|
|
192
|
-
};
|
|
193
|
-
exports.getTierSwipeStep = getTierSwipeStep;
|
|
194
|
-
var round = function (value) { return Math.round(value * 1000) / 1000; };
|
|
195
|
-
/**
|
|
196
|
-
* Where a tier sits in the stack, `position` steps from the front (fractional while a swipe is
|
|
197
|
-
* under way): the front tier at full size; a neighbour scaled to `TIER_STACK.neighbourScale`,
|
|
198
|
-
* dimmed to `brightness`, turned a little and moved out so that `peek` px of it show past the
|
|
199
|
-
* front tier's edge; and a tier further away smaller again and faded out. With `reducedMotion`
|
|
200
|
-
* the neighbours are not turned.
|
|
201
|
-
*/
|
|
202
|
-
var getTierStackItemStyle = function (position, _a) {
|
|
203
|
-
var peek = _a.peek, _b = _a.brightness, brightness = _b === void 0 ? 1 : _b, reducedMotion = _a.reducedMotion;
|
|
204
|
-
var neighbourScale = exports.TIER_STACK.neighbourScale, neighbourRotate = exports.TIER_STACK.neighbourRotate, hiddenScale = exports.TIER_STACK.hiddenScale;
|
|
205
|
-
var distance = Math.abs(position);
|
|
206
|
-
var side = Math.sign(position);
|
|
207
|
-
// From the front to a neighbour, then from a neighbour to a hidden tier.
|
|
208
|
-
var near = Math.min(distance, 1);
|
|
209
|
-
var far = Math.min(Math.max(distance - 1, 0), 1);
|
|
210
|
-
var scale = 1 - near * (1 - neighbourScale) - far * (neighbourScale - hiddenScale);
|
|
211
|
-
// A scaled tier is moved out by half the width it lost, plus the peek, so its outer edge
|
|
212
|
-
// ends `peek` px past the front tier's (the percentage is of its own, unscaled width).
|
|
213
|
-
var percent = near * (1 - neighbourScale) * 50 + far * (neighbourScale - hiddenScale) * 50;
|
|
214
|
-
var pixels = (near + far) * peek;
|
|
215
|
-
var rotate = reducedMotion ? 0 : -side * near * neighbourRotate;
|
|
216
|
-
var dim = 1 - near * (1 - brightness);
|
|
217
|
-
var translate = "translateX(calc(".concat(round(side * percent), "% + ").concat(round(side * pixels), "px))");
|
|
218
|
-
return {
|
|
219
|
-
transform: "".concat(translate, " scale(").concat(round(scale), ")").concat(rotate ? " rotateY(".concat(round(rotate), "deg)") : ''),
|
|
220
|
-
filter: dim < 1 ? "brightness(".concat(round(dim), ")") : undefined,
|
|
221
|
-
opacity: round(1 - far),
|
|
222
|
-
zIndex: Math.max(1, 100 - Math.round(distance * 10)),
|
|
223
|
-
};
|
|
224
|
-
};
|
|
225
|
-
exports.getTierStackItemStyle = getTierStackItemStyle;
|
|
226
|
-
var defaultStackItemLabel = function (name, index, count) {
|
|
227
|
-
return "".concat(name ? "".concat(name, ", ") : '').concat(index + 1, " of ").concat(count);
|
|
228
|
-
};
|
|
229
|
-
/** Layout only: the row (a grid of equal-height columns), or the stack above its controls. */
|
|
230
|
-
var StyledTierGroup = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: relative;\n min-width: 0;\n\n ", "\n"], ["\n position: relative;\n min-width: 0;\n\n ", "\n"])), function (_a) {
|
|
231
|
-
var $stack = _a.$stack, $focusColor = _a.$focusColor, $gap = _a.$gap, $minColumnWidth = _a.$minColumnWidth, $maxColumnWidth = _a.$maxColumnWidth;
|
|
232
|
-
return $stack
|
|
233
|
-
? (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n align-items: stretch;\n gap: ", "px;\n border-radius: ", "px;\n outline: none;\n\n /* The stack takes the focus (it is the carousel the arrow keys move). */\n &:focus-visible {\n outline: 2px solid ", ";\n outline-offset: 4px;\n }\n "], ["\n display: flex;\n flex-direction: column;\n align-items: stretch;\n gap: ", "px;\n border-radius: ", "px;\n outline: none;\n\n /* The stack takes the focus (it is the carousel the arrow keys move). */\n &:focus-visible {\n outline: 2px solid ", ";\n outline-offset: 4px;\n }\n "])), $gap, sizes_1.RADIUS_FROM_RADIUS_SIZE.normal, $focusColor) : (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: grid;\n grid-template-columns: repeat(\n auto-fit,\n minmax(min(100%, ", "), ", ")\n );\n align-items: stretch;\n justify-content: center;\n gap: ", "px;\n "], ["\n display: grid;\n grid-template-columns: repeat(\n auto-fit,\n minmax(min(100%, ", "), ", ")\n );\n align-items: stretch;\n justify-content: center;\n gap: ", "px;\n "])), $minColumnWidth, $maxColumnWidth, $gap);
|
|
234
|
-
});
|
|
235
|
-
/**
|
|
236
|
-
* The stack's frame: it takes the swipes and clips the neighbours at its sides, so a turned or
|
|
237
|
-
* moving tier never widens the page. In the row it is not a box at all.
|
|
238
|
-
*/
|
|
239
|
-
var StyledTierGroupViewport = styled_components_1.default.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (_a) {
|
|
240
|
-
var $stack = _a.$stack, $dragging = _a.$dragging;
|
|
241
|
-
return $stack
|
|
242
|
-
? (0, styled_components_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n position: relative;\n /* Hidden where clip is not supported (which also clips the front tier's shadow). */\n overflow-x: hidden;\n overflow-x: clip;\n touch-action: pan-y;\n\n ", "\n "], ["\n position: relative;\n /* Hidden where clip is not supported (which also clips the front tier's shadow). */\n overflow-x: hidden;\n overflow-x: clip;\n touch-action: pan-y;\n\n ", "\n "])), $dragging && (0, styled_components_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n cursor: grabbing;\n user-select: none;\n "], ["\n cursor: grabbing;\n user-select: none;\n "])))) : (0, styled_components_1.css)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n display: contents;\n "], ["\n display: contents;\n "])));
|
|
243
|
-
});
|
|
244
|
-
/** Every tier of the stack in one grid cell: the stack is as tall as its tallest tier. */
|
|
245
|
-
var StyledTierGroupTrack = styled_components_1.default.div(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (_a) {
|
|
246
|
-
var $stack = _a.$stack;
|
|
247
|
-
return $stack
|
|
248
|
-
? (0, styled_components_1.css)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n display: grid;\n perspective: ", "px;\n "], ["\n display: grid;\n perspective: ", "px;\n "])), exports.TIER_STACK.perspective) : (0, styled_components_1.css)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n display: contents;\n "], ["\n display: contents;\n "])));
|
|
249
|
-
});
|
|
250
|
-
/** The switch: a tier glides on the spring curve; its dimming and fading settle sooner. */
|
|
251
|
-
var TIER_STACK_TRANSITION = [
|
|
252
|
-
"transform ".concat(exports.TIER_STACK.duration, "ms ").concat(exports.TIER_STACK.easing),
|
|
253
|
-
"filter ".concat(Math.round(exports.TIER_STACK.duration * 0.6), "ms ease-out"),
|
|
254
|
-
"opacity ".concat(Math.round(exports.TIER_STACK.duration * 0.6), "ms ease-out"),
|
|
255
|
-
].join(', ');
|
|
256
|
-
/** One tier's cell. A grid of one, so the tier fills it: every tier is as tall as its row. */
|
|
257
|
-
var StyledTierGroupItem = styled_components_1.default.div(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n display: grid;\n min-width: 0;\n\n ", "\n"], ["\n display: grid;\n min-width: 0;\n\n ", "\n"])), function (_a) {
|
|
258
|
-
var $stack = _a.$stack, $peek = _a.$peek, $animate = _a.$animate;
|
|
259
|
-
return $stack && (0, styled_components_1.css)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n position: relative;\n grid-area: 1 / 1;\n justify-self: center;\n width: calc(100% - ", "px);\n transform-origin: 50% 50%;\n will-change: transform, filter, opacity;\n transition: ", ";\n "], ["\n position: relative;\n grid-area: 1 / 1;\n justify-self: center;\n width: calc(100% - ", "px);\n transform-origin: 50% 50%;\n will-change: transform, filter, opacity;\n transition: ", ";\n "])), $peek * 2, $animate ? TIER_STACK_TRANSITION : 'none');
|
|
260
|
-
});
|
|
261
|
-
/** Layout only: the previous button, the dots and the next button, centred under the stack. */
|
|
262
|
-
var StyledTierGroupControls = styled_components_1.default.div(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n justify-content: center;\n gap: ", "px;\n\n .reqore-tier-group-dots {\n display: flex;\n align-items: center;\n }\n"], ["\n display: flex;\n align-items: center;\n justify-content: center;\n gap: ", "px;\n\n .reqore-tier-group-dots {\n display: flex;\n align-items: center;\n }\n"])), function (_a) {
|
|
263
|
-
var $gap = _a.$gap;
|
|
264
|
-
return $gap;
|
|
265
|
-
});
|
|
266
|
-
/**
|
|
267
|
-
* A dot: which tier is in front, and a way to bring any of them there. A plain button rather
|
|
268
|
-
* than a `ReqoreButton` — a pager's dot is a small mark with a finger-sized hit area round it,
|
|
269
|
-
* and a Reqore button has no shape for that.
|
|
270
|
-
*/
|
|
271
|
-
var StyledTierGroupDot = styled_components_1.default.button(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n appearance: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: ", "px;\n height: ", "px;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: ", "px;\n background: none;\n cursor: pointer;\n\n &::before {\n content: '';\n display: block;\n width: ", "px;\n height: ", "px;\n border-radius: ", "px;\n background-color: ", ";\n transition: ", ";\n }\n\n &:focus-visible {\n outline: 2px solid ", ";\n outline-offset: -2px;\n }\n"], ["\n appearance: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: ", "px;\n height: ", "px;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: ", "px;\n background: none;\n cursor: pointer;\n\n &::before {\n content: '';\n display: block;\n width: ", "px;\n height: ", "px;\n border-radius: ", "px;\n background-color: ", ";\n transition: ", ";\n }\n\n &:focus-visible {\n outline: 2px solid ", ";\n outline-offset: -2px;\n }\n"])), function (_a) {
|
|
272
|
-
var $hit = _a.$hit;
|
|
273
|
-
return $hit;
|
|
274
|
-
}, function (_a) {
|
|
275
|
-
var $hit = _a.$hit;
|
|
276
|
-
return $hit;
|
|
277
|
-
}, function (_a) {
|
|
278
|
-
var $hit = _a.$hit;
|
|
279
|
-
return $hit;
|
|
280
|
-
}, function (_a) {
|
|
281
|
-
var $mark = _a.$mark, $active = _a.$active;
|
|
282
|
-
return ($active ? Math.round($mark * 2.5) : $mark);
|
|
283
|
-
}, function (_a) {
|
|
284
|
-
var $mark = _a.$mark;
|
|
285
|
-
return $mark;
|
|
286
|
-
}, function (_a) {
|
|
287
|
-
var $mark = _a.$mark;
|
|
288
|
-
return $mark;
|
|
289
|
-
}, function (_a) {
|
|
290
|
-
var $active = _a.$active, $color = _a.$color, $idleColor = _a.$idleColor;
|
|
291
|
-
return ($active ? $color : $idleColor);
|
|
292
|
-
}, function (_a) {
|
|
293
|
-
var $animate = _a.$animate;
|
|
294
|
-
return $animate ? 'width 0.2s ease-out, background-color 0.2s ease-out' : 'none';
|
|
295
|
-
}, function (_a) {
|
|
296
|
-
var $color = _a.$color;
|
|
297
|
-
return $color;
|
|
298
|
-
});
|
|
299
|
-
/** The front tier's name for a screen reader, said when it changes. Visually hidden. */
|
|
300
|
-
var StyledTierGroupStatus = styled_components_1.default.div(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n"], ["\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n"])));
|
|
301
|
-
exports.ReqoreTierGroup = (0, react_1.memo)((0, react_1.forwardRef)(function (_a, ref) {
|
|
302
|
-
var _b, _c, _d;
|
|
303
|
-
var children = _a.children, appearance = _a.appearance, size = _a.size, intent = _a.intent, customTheme = _a.customTheme, inheritCustomTheme = _a.inheritCustomTheme, tooltip = _a.tooltip, className = _a.className, _e = _a.minColumnWidth, minColumnWidth = _e === void 0 ? '240px' : _e, _f = _a.maxColumnWidth, maxColumnWidth = _f === void 0 ? '1fr' : _f, _g = _a.gapSize, gapSize = _g === void 0 ? 'big' : _g, _h = _a.mobileLayout, mobileLayout = _h === void 0 ? 'columns' : _h, _j = _a.mobileBreakpoint, mobileBreakpoint = _j === void 0 ? useNarrowContainer_1.NARROW_CONTAINER_BREAKPOINT_PX : _j, activeIndex = _a.activeIndex, defaultActiveIndex = _a.defaultActiveIndex, onActiveIndexChange = _a.onActiveIndexChange, _k = _a.loop, loop = _k === void 0 ? false : _k, _l = _a.stackLabel, stackLabel = _l === void 0 ? 'Plans' : _l, _m = _a.previousLabel, previousLabel = _m === void 0 ? 'Previous plan' : _m, _o = _a.nextLabel, nextLabel = _o === void 0 ? 'Next plan' : _o, _p = _a.stackItemLabel, stackItemLabel = _p === void 0 ? defaultStackItemLabel : _p, onKeyDown = _a.onKeyDown, rest = __rest(_a, ["children", "appearance", "size", "intent", "customTheme", "inheritCustomTheme", "tooltip", "className", "minColumnWidth", "maxColumnWidth", "gapSize", "mobileLayout", "mobileBreakpoint", "activeIndex", "defaultActiveIndex", "onActiveIndexChange", "loop", "stackLabel", "previousLabel", "nextLabel", "stackItemLabel", "onKeyDown"]);
|
|
304
|
-
var theme = (0, useTheme_1.useReqoreTheme)('main', customTheme, undefined, undefined, inheritCustomTheme);
|
|
305
|
-
var parentCustomTheme = (0, use_context_selector_1.useContext)(CustomThemeContext_1.default);
|
|
306
|
-
// The group's theme reaches its tiers and its controls; an inherited one is passed on.
|
|
307
|
-
var cascadedCustomTheme = customTheme !== null && customTheme !== void 0 ? customTheme : (inheritCustomTheme === false ? undefined : parentCustomTheme);
|
|
308
|
-
var tiers = (0, react_1.useMemo)(function () {
|
|
309
|
-
return react_1.default.Children.toArray(children).filter(function (child) {
|
|
310
|
-
return (0, react_1.isValidElement)(child);
|
|
311
|
-
});
|
|
312
|
-
}, [children]);
|
|
313
|
-
var count = tiers.length;
|
|
314
|
-
var names = (0, react_1.useMemo)(function () { return tiers.map(function (tier) { return tier.props.name; }); }, [tiers]);
|
|
315
|
-
var _q = (0, useNarrowContainer_1.useNarrowContainer)(mobileBreakpoint), containerRef = _q[0], isNarrow = _q[1];
|
|
316
|
-
var isStack = mobileLayout === 'stack' && isNarrow && count > 0;
|
|
317
|
-
var reducedMotion = (0, usePrefersReducedMotion_1.usePrefersReducedMotion)();
|
|
318
|
-
var highlights = (0, react_1.useMemo)(function () { return tiers.map(function (tier) { return !!tier.props.highlight; }); }, [tiers]);
|
|
319
|
-
// The tier the user brought to the front. Until they do, the front follows the tiers, so a
|
|
320
|
-
// highlighted tier that arrives after the group mounted (the plans load) still starts there.
|
|
321
|
-
var _r = (0, react_1.useState)(undefined), chosenIndex = _r[0], setChosenIndex = _r[1];
|
|
322
|
-
var front = (0, exports.normalizeTierIndex)((_b = activeIndex !== null && activeIndex !== void 0 ? activeIndex : chosenIndex) !== null && _b !== void 0 ? _b : (0, exports.getInitialTierIndex)(highlights, defaultActiveIndex), count);
|
|
323
|
-
var rootRef = (0, react_1.useRef)(null);
|
|
324
|
-
var viewportRef = (0, react_1.useRef)(null);
|
|
325
|
-
var itemRefs = (0, react_1.useRef)([]);
|
|
326
|
-
var gestureRef = (0, react_1.useRef)(null);
|
|
327
|
-
var suppressClickRef = (0, react_1.useRef)(false);
|
|
328
|
-
var _s = (0, react_1.useState)(0), dragOffset = _s[0], setDragOffset = _s[1];
|
|
329
|
-
var _t = (0, react_1.useState)(false), isDragging = _t[0], setIsDragging = _t[1];
|
|
330
|
-
var setRootRef = (0, react_1.useCallback)(function (node) {
|
|
331
|
-
rootRef.current = node;
|
|
332
|
-
containerRef.current = node;
|
|
333
|
-
if (typeof ref === 'function') {
|
|
334
|
-
ref(node);
|
|
335
|
-
}
|
|
336
|
-
else if (ref) {
|
|
337
|
-
ref.current = node;
|
|
338
|
-
}
|
|
339
|
-
}, [ref, containerRef]);
|
|
340
|
-
var resolvedSize = size !== null && size !== void 0 ? size : 'normal';
|
|
341
|
-
var peek = exports.TIER_GROUP_PEEK_FROM_SIZE[resolvedSize];
|
|
342
|
-
var gap = sizes_1.GAP_FROM_SIZE[gapSize];
|
|
343
|
-
var colors = (0, react_1.useMemo)(function () {
|
|
344
|
-
var page = (0, colors_1.getOpaqueColor)((0, colors_1.getMainBackgroundColor)(theme));
|
|
345
|
-
var text = (0, colors_1.getOpaqueColor)((0, colors_1.getReadableColor)(theme, undefined, undefined, true));
|
|
346
|
-
var intentColor = intent ? theme.intents[intent] : undefined;
|
|
347
|
-
var active = intentColor ? (0, colors_1.getReadableAccentColor)(intentColor, page, 3) : text;
|
|
348
|
-
return {
|
|
349
|
-
active: active,
|
|
350
|
-
idle: (0, colors_1.getReadableAccentColor)((0, polished_1.mix)(0.4, text, page), page, 3),
|
|
351
|
-
neighbourBrightness: (0, colors_1.shouldDarken)(page)
|
|
352
|
-
? exports.TIER_STACK.neighbourBrightness.light
|
|
353
|
-
: exports.TIER_STACK.neighbourBrightness.dark,
|
|
354
|
-
};
|
|
355
|
-
}, [theme, intent]);
|
|
356
|
-
var goTo = (0, react_1.useCallback)(function (target) {
|
|
357
|
-
if (!count) {
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
var next = (0, exports.normalizeTierIndex)(target, count, loop);
|
|
361
|
-
if (next === front) {
|
|
362
|
-
return;
|
|
363
|
-
}
|
|
364
|
-
if (activeIndex === undefined) {
|
|
365
|
-
setChosenIndex(next);
|
|
366
|
-
}
|
|
367
|
-
onActiveIndexChange === null || onActiveIndexChange === void 0 ? void 0 : onActiveIndexChange(next);
|
|
368
|
-
}, [count, loop, front, activeIndex, onActiveIndexChange]);
|
|
369
|
-
// A card behind the front one is `inert`: out of the tab order, out of the accessibility
|
|
370
|
-
// tree and out of the pointer's reach (a press on it reaches the stack, which brings it to
|
|
371
|
-
// the front). Set on the element: React 18 has no prop for it.
|
|
372
|
-
(0, react_1.useLayoutEffect)(function () {
|
|
373
|
-
itemRefs.current.length = count;
|
|
374
|
-
itemRefs.current.forEach(function (item, index) {
|
|
375
|
-
if (!item) {
|
|
376
|
-
return;
|
|
377
|
-
}
|
|
378
|
-
if (isStack && index !== front) {
|
|
379
|
-
item.setAttribute('inert', '');
|
|
380
|
-
}
|
|
381
|
-
else {
|
|
382
|
-
item.removeAttribute('inert');
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
|
-
}, [isStack, front, count]);
|
|
386
|
-
// Focus inside the card that is leaving the front, or on a button that is about to be
|
|
387
|
-
// disabled, would be lost: keep it on the stack.
|
|
388
|
-
var keepFocusOnStack = (0, react_1.useCallback)(function () {
|
|
389
|
-
var _a;
|
|
390
|
-
var focused = document.activeElement;
|
|
391
|
-
if (focused && focused !== rootRef.current && ((_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.contains(focused))) {
|
|
392
|
-
rootRef.current.focus({ preventScroll: true });
|
|
393
|
-
}
|
|
394
|
-
}, []);
|
|
395
|
-
var getItemWidth = (0, react_1.useCallback)(function () {
|
|
396
|
-
var viewport = viewportRef.current;
|
|
397
|
-
return viewport ? Math.max(viewport.clientWidth - peek * 2, 0) : 0;
|
|
398
|
-
}, [peek]);
|
|
399
|
-
var handleKeyDown = (0, react_1.useCallback)(function (event) {
|
|
400
|
-
var _a;
|
|
401
|
-
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
402
|
-
if (!isStack ||
|
|
403
|
-
event.defaultPrevented ||
|
|
404
|
-
event.altKey ||
|
|
405
|
-
event.ctrlKey ||
|
|
406
|
-
event.metaKey) {
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
var target = event.target;
|
|
410
|
-
// A key pressed in a portal (a popover a tier opened) bubbles here through React.
|
|
411
|
-
if (!event.currentTarget.contains(target) || (0, utils_1.isTextEntry)(target)) {
|
|
412
|
-
return;
|
|
413
|
-
}
|
|
414
|
-
var next;
|
|
415
|
-
switch (event.key) {
|
|
416
|
-
case 'ArrowLeft':
|
|
417
|
-
next = front - 1;
|
|
418
|
-
break;
|
|
419
|
-
case 'ArrowRight':
|
|
420
|
-
next = front + 1;
|
|
421
|
-
break;
|
|
422
|
-
case 'Home':
|
|
423
|
-
next = 0;
|
|
424
|
-
break;
|
|
425
|
-
case 'End':
|
|
426
|
-
next = count - 1;
|
|
427
|
-
break;
|
|
428
|
-
default:
|
|
429
|
-
return;
|
|
430
|
-
}
|
|
431
|
-
event.preventDefault();
|
|
432
|
-
if ((_a = itemRefs.current[front]) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement)) {
|
|
433
|
-
keepFocusOnStack();
|
|
434
|
-
}
|
|
435
|
-
goTo(next);
|
|
436
|
-
}, [onKeyDown, isStack, front, count, goTo, keepFocusOnStack]);
|
|
437
|
-
var finishGesture = (0, react_1.useCallback)(function (commit) {
|
|
438
|
-
var _a;
|
|
439
|
-
var gesture = gestureRef.current;
|
|
440
|
-
gestureRef.current = null;
|
|
441
|
-
if (!(gesture === null || gesture === void 0 ? void 0 : gesture.dragging)) {
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
444
|
-
var viewport = viewportRef.current;
|
|
445
|
-
if ((_a = viewport === null || viewport === void 0 ? void 0 : viewport.hasPointerCapture) === null || _a === void 0 ? void 0 : _a.call(viewport, gesture.pointerId)) {
|
|
446
|
-
viewport.releasePointerCapture(gesture.pointerId);
|
|
447
|
-
}
|
|
448
|
-
// The click that ends a drag is not a click on whatever it ended over.
|
|
449
|
-
suppressClickRef.current = true;
|
|
450
|
-
setIsDragging(false);
|
|
451
|
-
setDragOffset(0);
|
|
452
|
-
if (commit) {
|
|
453
|
-
var step = (0, exports.getTierSwipeStep)(gesture.lastX - gesture.startX, gesture.velocity, getItemWidth());
|
|
454
|
-
if (step) {
|
|
455
|
-
goTo(front + step);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}, [getItemWidth, goTo, front]);
|
|
459
|
-
var handlePointerDown = (0, react_1.useCallback)(function (event) {
|
|
460
|
-
suppressClickRef.current = false;
|
|
461
|
-
if (!isStack || count < 2 || (event.pointerType === 'mouse' && event.button !== 0)) {
|
|
462
|
-
return;
|
|
463
|
-
}
|
|
464
|
-
gestureRef.current = {
|
|
465
|
-
pointerId: event.pointerId,
|
|
466
|
-
startX: event.clientX,
|
|
467
|
-
startY: event.clientY,
|
|
468
|
-
lastX: event.clientX,
|
|
469
|
-
lastTime: event.timeStamp,
|
|
470
|
-
velocity: 0,
|
|
471
|
-
dragging: false,
|
|
472
|
-
};
|
|
473
|
-
}, [isStack, count]);
|
|
474
|
-
var handlePointerMove = (0, react_1.useCallback)(function (event) {
|
|
475
|
-
var _a;
|
|
476
|
-
var gesture = gestureRef.current;
|
|
477
|
-
if (!gesture || gesture.pointerId !== event.pointerId) {
|
|
478
|
-
return;
|
|
479
|
-
}
|
|
480
|
-
// A mouse let go outside the window: nothing is held on a move that should be a drag.
|
|
481
|
-
if (event.pointerType === 'mouse' && event.buttons === 0) {
|
|
482
|
-
finishGesture(false);
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
485
|
-
var dx = event.clientX - gesture.startX;
|
|
486
|
-
var dy = event.clientY - gesture.startY;
|
|
487
|
-
if (!gesture.dragging) {
|
|
488
|
-
if (Math.abs(dx) < exports.TIER_STACK.slop && Math.abs(dy) < exports.TIER_STACK.slop) {
|
|
489
|
-
return;
|
|
490
|
-
}
|
|
491
|
-
// Mostly vertical: the page is being scrolled, not the stack swiped.
|
|
492
|
-
if (Math.abs(dy) >= Math.abs(dx)) {
|
|
493
|
-
gestureRef.current = null;
|
|
494
|
-
return;
|
|
495
|
-
}
|
|
496
|
-
gesture.dragging = true;
|
|
497
|
-
try {
|
|
498
|
-
(_a = viewportRef.current) === null || _a === void 0 ? void 0 : _a.setPointerCapture(event.pointerId);
|
|
499
|
-
}
|
|
500
|
-
catch (_b) {
|
|
501
|
-
// Capture only keeps the drag going outside the stack; it is not the mechanism.
|
|
502
|
-
}
|
|
503
|
-
setIsDragging(true);
|
|
504
|
-
}
|
|
505
|
-
var elapsed = event.timeStamp - gesture.lastTime;
|
|
506
|
-
if (elapsed > 0) {
|
|
507
|
-
gesture.velocity = (event.clientX - gesture.lastX) / elapsed;
|
|
508
|
-
}
|
|
509
|
-
gesture.lastX = event.clientX;
|
|
510
|
-
gesture.lastTime = event.timeStamp;
|
|
511
|
-
// Past an end, the stack gives a little and springs back.
|
|
512
|
-
var pastEnd = !loop && ((dx > 0 && front === 0) || (dx < 0 && front === count - 1));
|
|
513
|
-
setDragOffset(pastEnd ? dx * exports.TIER_STACK.resistance : dx);
|
|
514
|
-
}, [finishGesture, loop, front, count]);
|
|
515
|
-
var handlePointerUp = (0, react_1.useCallback)(function (event) {
|
|
516
|
-
var _a;
|
|
517
|
-
if (((_a = gestureRef.current) === null || _a === void 0 ? void 0 : _a.pointerId) === event.pointerId) {
|
|
518
|
-
finishGesture(true);
|
|
519
|
-
}
|
|
520
|
-
}, [finishGesture]);
|
|
521
|
-
var handlePointerCancel = (0, react_1.useCallback)(function () { return finishGesture(false); }, [finishGesture]);
|
|
522
|
-
var handleClickCapture = (0, react_1.useCallback)(function (event) {
|
|
523
|
-
if (suppressClickRef.current) {
|
|
524
|
-
suppressClickRef.current = false;
|
|
525
|
-
event.preventDefault();
|
|
526
|
-
event.stopPropagation();
|
|
527
|
-
}
|
|
528
|
-
}, []);
|
|
529
|
-
// A press on a neighbour (inert, so it lands on the stack) brings it to the front.
|
|
530
|
-
var handleViewportClick = (0, react_1.useCallback)(function (event) {
|
|
531
|
-
var frontItem = itemRefs.current[front];
|
|
532
|
-
if (!isStack || !frontItem || frontItem.contains(event.target)) {
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
|
-
var rect = frontItem.getBoundingClientRect();
|
|
536
|
-
if (event.clientX < rect.left) {
|
|
537
|
-
goTo(front - 1);
|
|
538
|
-
}
|
|
539
|
-
else if (event.clientX > rect.right) {
|
|
540
|
-
goTo(front + 1);
|
|
541
|
-
}
|
|
542
|
-
}, [isStack, front, goTo]);
|
|
543
|
-
var handlePrevious = (0, react_1.useCallback)(function () {
|
|
544
|
-
if (!loop && front - 1 <= 0) {
|
|
545
|
-
keepFocusOnStack();
|
|
546
|
-
}
|
|
547
|
-
goTo(front - 1);
|
|
548
|
-
}, [loop, front, goTo, keepFocusOnStack]);
|
|
549
|
-
var handleNext = (0, react_1.useCallback)(function () {
|
|
550
|
-
if (!loop && front + 1 >= count - 1) {
|
|
551
|
-
keepFocusOnStack();
|
|
552
|
-
}
|
|
553
|
-
goTo(front + 1);
|
|
554
|
-
}, [loop, front, count, goTo, keepFocusOnStack]);
|
|
555
|
-
var itemWidth = isDragging ? getItemWidth() : 0;
|
|
556
|
-
// The tiers follow the finger, unless the user asked for less motion: then a swipe still
|
|
557
|
-
// switches them, at once, when it ends.
|
|
558
|
-
var dragProgress = isDragging && !reducedMotion && itemWidth > 0 ? dragOffset / itemWidth : 0;
|
|
559
|
-
var items = tiers.map(function (tier, index) {
|
|
560
|
-
var _a;
|
|
561
|
-
var handed = __assign(__assign({}, (appearance && !tier.props.appearance ? { appearance: appearance } : {})), (size && !tier.props.size ? { size: size } : {}));
|
|
562
|
-
var element = Object.keys(handed).length ? (0, react_1.cloneElement)(tier, handed) : tier;
|
|
563
|
-
var offset = isStack ? (0, exports.getTierStackOffset)(index, front, count, loop) : 0;
|
|
564
|
-
var isFront = isStack && index === front;
|
|
565
|
-
return ((0, jsx_runtime_1.jsx)(StyledTierGroupItem, __assign({ ref: function (node) {
|
|
566
|
-
itemRefs.current[index] = node;
|
|
567
|
-
}, className: "reqore-tier-group-item".concat(isFront ? ' reqore-tier-group-item-front' : ''), "$stack": isStack, "$peek": peek, "$animate": !isDragging && !reducedMotion }, (isStack
|
|
568
|
-
? {
|
|
569
|
-
role: 'group',
|
|
570
|
-
'aria-roledescription': 'slide',
|
|
571
|
-
'aria-label': stackItemLabel(names[index], index, count),
|
|
572
|
-
'data-offset': offset,
|
|
573
|
-
style: (0, exports.getTierStackItemStyle)(offset + dragProgress, {
|
|
574
|
-
peek: peek,
|
|
575
|
-
brightness: colors.neighbourBrightness,
|
|
576
|
-
reducedMotion: reducedMotion,
|
|
577
|
-
}),
|
|
578
|
-
}
|
|
579
|
-
: {}), { children: element }), (_a = tier.key) !== null && _a !== void 0 ? _a : index));
|
|
580
|
-
});
|
|
581
|
-
var root = ((0, jsx_runtime_1.jsxs)(TooltipComponent_1.ReqoreTooltipComponent, __assign({}, rest, (isStack
|
|
582
|
-
? {
|
|
583
|
-
role: 'region',
|
|
584
|
-
'aria-roledescription': 'carousel',
|
|
585
|
-
'aria-label': (_c = rest['aria-label']) !== null && _c !== void 0 ? _c : stackLabel,
|
|
586
|
-
'data-active-index': front,
|
|
587
|
-
tabIndex: (_d = rest.tabIndex) !== null && _d !== void 0 ? _d : 0,
|
|
588
|
-
}
|
|
589
|
-
: {}), { "data-layout": isStack ? 'stack' : 'row', Component: StyledTierGroup, ref: setRootRef, tooltip: tooltip, className: "".concat(className || '', " reqore-tier-group"), onKeyDown: handleKeyDown, "$stack": isStack, "$focusColor": colors.active, "$gap": gap, "$minColumnWidth": minColumnWidth, "$maxColumnWidth": maxColumnWidth, children: [(0, jsx_runtime_1.jsx)(StyledTierGroupViewport, __assign({ ref: viewportRef, className: 'reqore-tier-group-viewport', "$stack": isStack, "$dragging": isDragging }, (isStack
|
|
590
|
-
? {
|
|
591
|
-
onPointerDown: handlePointerDown,
|
|
592
|
-
onPointerMove: handlePointerMove,
|
|
593
|
-
onPointerUp: handlePointerUp,
|
|
594
|
-
onPointerCancel: handlePointerCancel,
|
|
595
|
-
onClickCapture: handleClickCapture,
|
|
596
|
-
onClick: handleViewportClick,
|
|
597
|
-
onDragStart: function (event) { return event.preventDefault(); },
|
|
598
|
-
}
|
|
599
|
-
: {}), { children: (0, jsx_runtime_1.jsx)(StyledTierGroupTrack, { className: 'reqore-tier-group-track', "$stack": isStack, children: items }) })), isStack && count > 1 ? ((0, jsx_runtime_1.jsxs)(StyledTierGroupControls, { className: 'reqore-tier-group-controls', "$gap": gap, children: [(0, jsx_runtime_1.jsx)(Button_1.default, { className: 'reqore-tier-group-previous', icon: 'ArrowLeftSLine', "aria-label": previousLabel, size: resolvedSize, intent: intent, circle: true, disabled: !loop && front === 0, onClick: handlePrevious }), (0, jsx_runtime_1.jsx)("div", { className: 'reqore-tier-group-dots', children: names.map(function (name, index) {
|
|
600
|
-
var _a;
|
|
601
|
-
return ((0, jsx_runtime_1.jsx)(StyledTierGroupDot, { type: 'button', className: "reqore-tier-group-dot".concat(index === front ? ' reqore-tier-group-dot-active' : ''), "aria-label": name || stackItemLabel(name, index, count), "aria-current": index === front ? 'true' : undefined, "$hit": exports.TIER_GROUP_DOT_FROM_SIZE[resolvedSize], "$mark": exports.TIER_GROUP_DOT_MARK_FROM_SIZE[resolvedSize], "$active": index === front, "$animate": !reducedMotion, "$color": colors.active, "$idleColor": colors.idle, onClick: function () { return goTo(index); } }, (_a = tiers[index].key) !== null && _a !== void 0 ? _a : index));
|
|
602
|
-
}) }), (0, jsx_runtime_1.jsx)(Button_1.default, { className: 'reqore-tier-group-next', icon: 'ArrowRightSLine', "aria-label": nextLabel, size: resolvedSize, intent: intent, circle: true, disabled: !loop && front === count - 1, onClick: handleNext })] })) : null, isStack ? ((0, jsx_runtime_1.jsx)(StyledTierGroupStatus, { "aria-live": 'polite', className: 'reqore-tier-group-status', children: stackItemLabel(names[front], front, count) })) : null] })));
|
|
603
|
-
return ((0, jsx_runtime_1.jsx)(ThemeProvider_1.default, { theme: theme, customTheme: cascadedCustomTheme, children: root }));
|
|
604
|
-
}));
|
|
605
|
-
exports.default = exports.ReqoreTierGroup;
|
|
606
|
-
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;
|
|
607
|
-
//# sourceMappingURL=group.js.map
|