@v-office/website-headless 1.0.0 → 1.1.0

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/README.md CHANGED
@@ -1373,7 +1373,8 @@ Actions: `select(iso)`, `setRange(start, end | null)` (re-validated once the arr
1373
1373
  `maxPersons`, `maxAdults`, and on v9 from SDK 2.28 `childrenAllowed` and `maxPets`; null where the
1374
1374
  SDK states none).
1375
1375
  - `fetchEndAvailability(sdk, input)` (`EndAvailabilityInput`: the window plus `start`) →
1376
- `EndAvailability` (`start`, `canEnd`, `hardBlocked`, `tooltipByDay`).
1376
+ `EndAvailability` (`start`, `canEnd`, `hardBlocked`, `tooltipByDay`, and `priceByDay`: the
1377
+ price on each possible end date on v9 from SDK 2.30, null where the SDK prices no end dates).
1377
1378
  - `dayPriceLabel(formatted, mode)` → the cell text, or null. `DayPrices`: `"rounded"` (whole units,
1378
1379
  half up: truncation would understate every night), `"exact"` (only a zero-cents group dropped),
1379
1380
  `"none"`. Cells state the nightly price, never a total.
package/dist/index.d.mts CHANGED
@@ -818,7 +818,9 @@ interface DayState {
818
818
  selectable: boolean;
819
819
  /** The SDK's formatted nightly price, raw (format it with `dayPriceLabel`), or null: none from the
820
820
  * SDK, past, booked, or a chosen endpoint. Shown on restricted days too — the hub's status decides,
821
- * not the phase (prices on rule-restricted free nights were hidden once; 157 priced days measured). */
821
+ * not the phase (prices on rule-restricted free nights were hidden once; 157 priced days measured).
822
+ * While the end is picked, the departure map's price when the SDK prices end dates (v9 from SDK
823
+ * 2.30), else the arrival price. */
822
824
  price: string | null;
823
825
  /** The SDK's localized block reason; only on a non-selectable day outside the chosen range (a
824
826
  * departure endpoint re-judged as "no arrival" must not flash its tooltip). */
@@ -854,6 +856,10 @@ interface EndAvailability {
854
856
  canEnd: ReadonlySet<IsoDay>;
855
857
  /** Days with a hard status for this start (booked, or a range crossing a booked night). */
856
858
  hardBlocked: ReadonlySet<IsoDay>;
859
+ /** The SDK's raw `formattedPrice` by possible check-out day: the last night of a stay from `start`
860
+ * to that day, at the rate for its length. null when the SDK prices no end dates (v10, v9 before
861
+ * SDK 2.30). */
862
+ priceByDay: ReadonlyMap<IsoDay, string> | null;
857
863
  /** The SDK's localized `tooltip` by day (minimum stay not met, no check-out, …). */
858
864
  tooltipByDay: ReadonlyMap<IsoDay, string>;
859
865
  }
package/dist/index.mjs CHANGED
@@ -5699,10 +5699,17 @@ const fetchEndAvailability = async (sdk, input) => {
5699
5699
  selectedStartDate: input.start
5700
5700
  });
5701
5701
  const canEnd = /* @__PURE__ */ new Set();
5702
- for (const [iso, day] of Object.entries(out.calendarDays)) if (day.canBeEndDate) canEnd.add(iso);
5702
+ const priceByDay = /* @__PURE__ */ new Map();
5703
+ let priced = false;
5704
+ for (const [iso, day] of Object.entries(out.calendarDays)) {
5705
+ if (day.canBeEndDate) canEnd.add(iso);
5706
+ if (day.formattedPrice !== void 0) priced = true;
5707
+ if (day.formattedPrice) priceByDay.set(iso, day.formattedPrice);
5708
+ }
5703
5709
  return {
5704
5710
  start: input.start,
5705
5711
  canEnd,
5712
+ priceByDay: priced ? priceByDay : null,
5706
5713
  ...readCommon(out.calendarDays)
5707
5714
  };
5708
5715
  };
@@ -5728,6 +5735,7 @@ const emptyEnd = (start) => ({
5728
5735
  start,
5729
5736
  canEnd: /* @__PURE__ */ new Set(),
5730
5737
  hardBlocked: /* @__PURE__ */ new Set(),
5738
+ priceByDay: null,
5731
5739
  tooltipByDay: /* @__PURE__ */ new Map()
5732
5740
  });
5733
5741
  /** `months` calendar months after `day`, clamped to the target month's last day. */
@@ -5882,11 +5890,12 @@ const createStayPicker = (source, options) => {
5882
5890
  const selectable = kind === "free";
5883
5891
  const priced = !past && kind !== "booked" && !endpoint;
5884
5892
  const tooltips = phase === "departure" ? currentEnd()?.tooltipByDay : initial?.tooltipByDay;
5893
+ const prices = (phase === "departure" ? currentEnd()?.priceByDay : null) ?? initial?.priceByDay;
5885
5894
  return {
5886
5895
  iso,
5887
5896
  kind,
5888
5897
  selectable,
5889
- price: priced ? initial?.priceByDay.get(iso) ?? null : null,
5898
+ price: priced ? prices?.get(iso) ?? null : null,
5890
5899
  reason: !selectable && selection === null ? tooltips?.get(iso) ?? null : null,
5891
5900
  selection
5892
5901
  };
@@ -4,6 +4,7 @@
4
4
 
5
5
  Release notes of `@v-office/website-headless`, newest first. Each version has its own directory.
6
6
 
7
+ - `versions/1.1.0/CHANGELOG.md`: release notes for 1.1.0
7
8
  - `versions/1.0.0/CHANGELOG.md`: release notes for 1.0.0
8
9
  - `versions/0.2.0/CHANGELOG.md`: release notes for 0.2.0
9
10
  - `versions/0.1.1/CHANGELOG.md`: release notes for 0.1.1
@@ -4,6 +4,7 @@
4
4
 
5
5
  Migration guides of `@v-office/website-headless`, newest first. Apply them in order when skipping versions.
6
6
 
7
+ - `versions/1.1.0/MIGRATION.md`: Migration: 1.0.0 to 1.1.0
7
8
  - `versions/1.0.0/MIGRATION.md`: Migration: 0.2.0 to 1.0.0
8
9
  - `versions/0.2.0/MIGRATION.md`: Migration: 0.1.1 to 0.2.0
9
10
  - `versions/0.1.1/MIGRATION.md`: Migration to 0.1.1
@@ -0,0 +1,19 @@
1
+ # Changelog: 1.1.0
2
+
3
+ On v9, the date picker shows the price of the stay while the guest picks the end date. Many v9
4
+ rentals charge less per night for longer stays. Once a start date is chosen, each possible end
5
+ date now shows the price of the last night of a stay ending there, at the rate for that number
6
+ of nights. This needs `@v-office/website-sdk` 2.30.0 or later.
7
+
8
+ ## Added
9
+
10
+ - `EndAvailability.priceByDay`: the SDK's `formattedPrice` by possible end date, or `null`
11
+ when the SDK prices no end dates (v10, v9 before SDK 2.30).
12
+
13
+ ## Changed
14
+
15
+ - `createStayPicker`: while the guest picks the end date, `day(iso).price` is the end-date
16
+ price when the SDK sends one. A day that cannot be the end date then has no price. Without
17
+ end-date prices (v10, v9 before SDK 2.30) the days keep the arrival price, as before.
18
+
19
+ v10 is unchanged.
@@ -0,0 +1,14 @@
1
+ # Migration: 1.0.0 to 1.1.0
2
+
3
+ ## 1. Upgrade
4
+
5
+ ```sh
6
+ pnpm add @v-office/website-headless@1.1.0
7
+ ```
8
+
9
+ No changes are required. A calendar that renders `day(iso).price` from `createStayPicker`
10
+ shows the end-date prices on its own once the site runs `@v-office/website-sdk` 2.30.0 or
11
+ later on v9.
12
+
13
+ Code that builds an `EndAvailability` itself, such as a test fixture, adds
14
+ `priceByDay: null`.
@@ -0,0 +1,3 @@
1
+ {
2
+ "componentsAffectedByHeadlessChange": []
3
+ }
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@v-office/website-headless",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Framework-free behaviour layer for v-office websites, never UI: stores, pure rules and SDK runners for the search bar, results, map, showcase, quote, checkout and contact form, the rental and card models, and progressive-enhancement engines for server-rendered markup (./enhance)",
5
+ "license": "UNLICENSED",
5
6
  "files": [
6
7
  "dist",
7
8
  "README.md",
@@ -20,7 +21,7 @@
20
21
  },
21
22
  "devDependencies": {
22
23
  "@types/node": "26.5.1",
23
- "@v-office/website-sdk": "2.28.1",
24
+ "@v-office/website-sdk": "2.30.0",
24
25
  "effect": "4.0.0-rc.115",
25
26
  "jsdom": "^30.0.1",
26
27
  "oxfmt": "0.67.0",