@escapenavigator/hooks 2.0.7 → 2.0.8
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.
|
@@ -99,6 +99,19 @@ export type PlayersAndVariationPickerProps = {
|
|
|
99
99
|
* сводке рядом с «Итого»). По умолчанию `false` — поведение не меняется.
|
|
100
100
|
*/
|
|
101
101
|
hidePriceHints?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Опция «Определимся на месте» (questroom.playersSelectMode=OPTIONAL).
|
|
104
|
+
* Когда передана, первым тегом в ряду игроков рендерится отложенный
|
|
105
|
+
* выбор состава. Пока он выбран: числовые теги не подсвечены, секция
|
|
106
|
+
* детей скрыта (и дети сброшены в 0), ценовые подсказки пикера не
|
|
107
|
+
* показываются — хост рендерит «базовую стоимость от» сам. Клик по
|
|
108
|
+
* числу автоматически снимает опцию (onSelect(false)).
|
|
109
|
+
*/
|
|
110
|
+
flexPlayersOption?: {
|
|
111
|
+
selected: boolean;
|
|
112
|
+
label: string;
|
|
113
|
+
onSelect: (flex: boolean) => void;
|
|
114
|
+
};
|
|
102
115
|
};
|
|
103
116
|
/**
|
|
104
117
|
* Single shared component that renders the "Variation + Players" picker used
|
|
@@ -62,7 +62,7 @@ const use_players_and_variation_picker_1 = require("../use-players-and-variation
|
|
|
62
62
|
* buttons, kids row, price hint, save button) was reimplemented in three
|
|
63
63
|
* places with subtle drift. This component is the single source of truth.
|
|
64
64
|
*/
|
|
65
|
-
const PlayersAndVariationPicker = ({ slot, currentTariffId, currentDuration, loadSlotDetails, onVariationChange, onVariationResolved, onDetailsLoaded, players = 0, child = 0, tariff: tariffOverride, currency, minPlayers, maxPlayersLimit, slotDiscount, error, t, onChange, onSave, orderId, onLoadingChange, hidePriceHints = false, }) => {
|
|
65
|
+
const PlayersAndVariationPicker = ({ slot, currentTariffId, currentDuration, loadSlotDetails, onVariationChange, onVariationResolved, onDetailsLoaded, players = 0, child = 0, tariff: tariffOverride, currency, minPlayers, maxPlayersLimit, slotDiscount, error, t, onChange, onSave, orderId, onLoadingChange, hidePriceHints = false, flexPlayersOption, }) => {
|
|
66
66
|
var _a, _b;
|
|
67
67
|
const { loading: pickerLoading, options: pickerOptions, selectedOptionId, selectedVariation, buildVariationChange, selectVariation, details, } = (0, use_players_and_variation_picker_1.usePlayersAndVariationPicker)({
|
|
68
68
|
slot,
|
|
@@ -118,14 +118,26 @@ const PlayersAndVariationPicker = ({ slot, currentTariffId, currentDuration, loa
|
|
|
118
118
|
(0, react_1.useEffect)(() => {
|
|
119
119
|
setChildren(child);
|
|
120
120
|
}, [child]);
|
|
121
|
+
const flexSelected = !!(flexPlayersOption === null || flexPlayersOption === void 0 ? void 0 : flexPlayersOption.selected);
|
|
121
122
|
const handleChangePlayers = (value) => {
|
|
122
123
|
setPlayers(value);
|
|
123
124
|
onChange === null || onChange === void 0 ? void 0 : onChange('players', value);
|
|
125
|
+
// Явный выбор числа снимает «Определимся на месте».
|
|
126
|
+
if (flexSelected)
|
|
127
|
+
flexPlayersOption === null || flexPlayersOption === void 0 ? void 0 : flexPlayersOption.onSelect(false);
|
|
124
128
|
};
|
|
125
129
|
const handleChangeChildren = (value) => {
|
|
126
130
|
setChildren(value);
|
|
127
131
|
onChange === null || onChange === void 0 ? void 0 : onChange('children', value);
|
|
128
132
|
};
|
|
133
|
+
const handleSelectFlex = () => {
|
|
134
|
+
if (flexSelected)
|
|
135
|
+
return;
|
|
136
|
+
// Состав не определён — детей тоже сбрасываем (их выбор скрывается).
|
|
137
|
+
if (_children)
|
|
138
|
+
handleChangeChildren(0);
|
|
139
|
+
flexPlayersOption === null || flexPlayersOption === void 0 ? void 0 : flexPlayersOption.onSelect(true);
|
|
140
|
+
};
|
|
129
141
|
// Цена 0 за число игроков = «это кол-во недоступно для выбора». Такие
|
|
130
142
|
// ключи не рендерим кнопками и не учитываем в availablePlayerKeys/clamp.
|
|
131
143
|
const playersOptions = (0, react_1.useMemo)(() => Object.entries(tariff)
|
|
@@ -225,7 +237,11 @@ const PlayersAndVariationPicker = ({ slot, currentTariffId, currentDuration, loa
|
|
|
225
237
|
}
|
|
226
238
|
return (react_1.default.createElement(flex_columns_1.FlexColumns, { columns: 1, gr: 16 },
|
|
227
239
|
showVariations && (react_1.default.createElement(flex_columns_1.FlexColumns, { columns: 1, gr: 8 },
|
|
228
|
-
react_1.default.createElement(typography_1.Typography.Text, { view: 'title', color: 'secondary' },
|
|
240
|
+
react_1.default.createElement(typography_1.Typography.Text, { view: 'title', color: 'secondary' }, (details === null || details === void 0 ? void 0 : details.isFlex) === false
|
|
241
|
+
? t('prices:chooseTariff', {
|
|
242
|
+
defaultValue: 'Выберите подходящий тариф',
|
|
243
|
+
})
|
|
244
|
+
: t('prices:variation')),
|
|
229
245
|
react_1.default.createElement(flex_1.Flex, { gap: 'xs', wrap: true, justify: 'start' }, pickerOptions.map((option) => (react_1.default.createElement("div", { key: option.id, style: option.isFree
|
|
230
246
|
? undefined
|
|
231
247
|
: { opacity: 0.4, pointerEvents: 'none' } },
|
|
@@ -236,14 +252,18 @@ const PlayersAndVariationPicker = ({ slot, currentTariffId, currentDuration, loa
|
|
|
236
252
|
react_1.default.createElement(flex_columns_1.FlexColumns, { columns: 1, gr: 8 },
|
|
237
253
|
react_1.default.createElement(flex_1.Flex, { gap: 'sm', align: 'center', justify: 'between' },
|
|
238
254
|
react_1.default.createElement(typography_1.Typography.Text, { view: 'title', color: 'secondary' }, tariff.child ? t('prices:adults') : t('prices:choosePlayersAmount')),
|
|
239
|
-
!!_children && !!_players && tariff[_players] != null && (react_1.default.createElement(typography_1.Typography.Text, { view: 'title', color: 'secondary' }, (0, format_amount_1.formatAmount)(tariff[_players], currency)))),
|
|
240
|
-
react_1.default.createElement(flex_1.Flex, { gap: 'xs', wrap: true, justify: 'start' },
|
|
241
|
-
.
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
255
|
+
!flexSelected && !!_children && !!_players && tariff[_players] != null && (react_1.default.createElement(typography_1.Typography.Text, { view: 'title', color: 'secondary' }, (0, format_amount_1.formatAmount)(tariff[_players], currency)))),
|
|
256
|
+
react_1.default.createElement(flex_1.Flex, { gap: 'xs', wrap: true, justify: 'start' },
|
|
257
|
+
!!flexPlayersOption && (react_1.default.createElement(tag_1.Tag, { key: 'flex-players', text: flexPlayersOption.label, onClick: handleSelectFlex, view: flexSelected ? 'primary-inverted' : 'primary' })),
|
|
258
|
+
playersOptions
|
|
259
|
+
.filter((p) => {
|
|
260
|
+
const total = p.key + (_children || 0);
|
|
261
|
+
return total >= effectiveMin && total <= effectiveMax;
|
|
262
|
+
})
|
|
263
|
+
.map((p) => (react_1.default.createElement(tag_1.Tag, { key: `adult-${p.key}`, text: `${p.key}`, onClick: () => handleChangePlayers(p.key), view: !flexSelected && _players === p.key
|
|
264
|
+
? 'primary-inverted'
|
|
265
|
+
: 'primary' }))))),
|
|
266
|
+
!flexSelected && !!childrenOptions.length && (react_1.default.createElement(flex_columns_1.FlexColumns, { columns: 1, gr: 8 },
|
|
247
267
|
react_1.default.createElement(flex_1.Flex, { gap: 'sm', align: 'center', justify: 'between' },
|
|
248
268
|
react_1.default.createElement(typography_1.Typography.Text, { view: 'title', color: 'secondary' }, t('prices:kids')),
|
|
249
269
|
!!_children && tariff.child != null && (react_1.default.createElement(typography_1.Typography.Text, { view: 'title', color: 'secondary' }, (0, format_amount_1.formatAmount)(_children * tariff.child, currency)))),
|
|
@@ -255,13 +275,13 @@ const PlayersAndVariationPicker = ({ slot, currentTariffId, currentDuration, loa
|
|
|
255
275
|
const isActive = _children === count;
|
|
256
276
|
return (react_1.default.createElement(tag_1.Tag, { key: `child-${count}`, text: count === 0 ? t('prices:noKids') : `${count}`, onClick: () => handleChangeChildren(isActive ? 0 : count), view: isActive ? 'primary-inverted' : 'primary' }));
|
|
257
277
|
})))),
|
|
258
|
-
!hidePriceHints && !!totalHeads && (react_1.default.createElement(flex_1.Flex, { justify: 'start', gap: 'xs' },
|
|
278
|
+
!hidePriceHints && !flexSelected && !!totalHeads && (react_1.default.createElement(flex_1.Flex, { justify: 'start', gap: 'xs' },
|
|
259
279
|
react_1.default.createElement(InfoMarkS_1.default, { style: { fill: 'var(--color-text-secondary)' } }),
|
|
260
280
|
react_1.default.createElement(typography_1.Typography.Text, { view: 'caps', color: 'secondary' }, t('prices:totalPriceDescription', {
|
|
261
281
|
teamPrice: (0, format_amount_1.formatAmount)(teamPrice, currency),
|
|
262
282
|
personPrice: (0, format_amount_1.formatAmount)(personPrice, currency),
|
|
263
283
|
})))),
|
|
264
|
-
hidePriceHints && (!!totalHeads || !!childDescription) && (react_1.default.createElement("div", { style: {
|
|
284
|
+
hidePriceHints && !flexSelected && (!!totalHeads || !!childDescription) && (react_1.default.createElement("div", { style: {
|
|
265
285
|
display: 'flex',
|
|
266
286
|
flexDirection: 'column',
|
|
267
287
|
gap: 6,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@escapenavigator/hooks",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"test": "jest"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@escapenavigator/services": "^2.0.
|
|
18
|
-
"@escapenavigator/types": "^2.0.
|
|
19
|
-
"@escapenavigator/utils": "^2.0.
|
|
17
|
+
"@escapenavigator/services": "^2.0.8",
|
|
18
|
+
"@escapenavigator/types": "^2.0.8",
|
|
19
|
+
"@escapenavigator/utils": "^2.0.8",
|
|
20
20
|
"libphonenumber-js": "^1.12.24",
|
|
21
21
|
"react": "19.2.6",
|
|
22
22
|
"react-phone-input-2": "^2.15.1"
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"ts-jest": "^29.1.1",
|
|
33
33
|
"typescript": "^5.6"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "f88105efecc1893d1eb103e8b2069161b0e6dd0a"
|
|
36
36
|
}
|