@krizaka/ui 3.70.0 → 3.72.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.
Files changed (306) hide show
  1. package/dist/account-menu.d.ts +1 -1
  2. package/dist/account-menu.js +1 -1
  3. package/dist/account-settings.d.ts +1 -1
  4. package/dist/account-settings.js +1 -1
  5. package/dist/avatar/defaults.d.ts +22 -2
  6. package/dist/avatar/defaults.js +20 -7
  7. package/dist/avatar/defaults.js.map +1 -1
  8. package/dist/{avatar-BdZcfkWR.d.ts → avatar-B_na7r1U.d.ts} +16 -0
  9. package/dist/avatar.d.ts +22 -2
  10. package/dist/avatar.js +20 -7
  11. package/dist/avatar.js.map +1 -1
  12. package/dist/blocks.css +37 -0
  13. package/dist/chat.js +1 -1
  14. package/dist/chunk-3PRYL2LS.js +2 -0
  15. package/dist/chunk-3PRYL2LS.js.map +1 -0
  16. package/dist/{chunk-HK525THY.js → chunk-5MPPIGCB.js} +18 -7
  17. package/dist/chunk-5MPPIGCB.js.map +1 -0
  18. package/dist/{chunk-CSRKYZ53.js → chunk-CZHPWLNW.js} +1 -1
  19. package/dist/{chunk-PZ4FJOD5.js → chunk-HLEBSAGC.js} +5 -1
  20. package/dist/{chunk-PZ4FJOD5.js.map → chunk-HLEBSAGC.js.map} +1 -1
  21. package/dist/chunk-M3T5RQYV.js +34 -0
  22. package/dist/chunk-M3T5RQYV.js.map +1 -0
  23. package/dist/{chunk-EUJ7337V.js → chunk-TISDOZH3.js} +18 -7
  24. package/dist/chunk-TISDOZH3.js.map +1 -0
  25. package/dist/chunk-W64RAX4N.js +79 -0
  26. package/dist/chunk-W64RAX4N.js.map +1 -0
  27. package/dist/chunk-ZFR6ZNXD.js +203 -0
  28. package/dist/chunk-ZFR6ZNXD.js.map +1 -0
  29. package/dist/collection-switcher.d.ts +1 -1
  30. package/dist/{default-avatar-D9kiSFNB.d.ts → default-avatar-BL0nJFti.d.ts} +16 -0
  31. package/dist/entity-header.d.ts +1 -1
  32. package/dist/{frame-D6Xv83t8.d.ts → frame-CNZ5VgDD.d.ts} +11 -4
  33. package/dist/index.js +7 -7
  34. package/dist/kind-config-editor.js +3 -2
  35. package/dist/kind-config-editor.js.map +1 -1
  36. package/dist/map.d.ts +6 -6
  37. package/dist/match-dialog.js +1 -1
  38. package/dist/media-grid.d.ts +16 -0
  39. package/dist/media-grid.js +1 -1
  40. package/dist/money-input.js +6 -70
  41. package/dist/money-input.js.map +1 -1
  42. package/dist/native.d.ts +16 -0
  43. package/dist/native.js +17 -6
  44. package/dist/native.js.map +1 -1
  45. package/dist/nav-bar.d.ts +13 -2
  46. package/dist/nav-bar.js +71 -54
  47. package/dist/nav-bar.js.map +1 -1
  48. package/dist/notification-preferences.js +2 -1
  49. package/dist/notification-preferences.js.map +1 -1
  50. package/dist/price-catalogue-editor.d.ts +117 -0
  51. package/dist/price-catalogue-editor.js +194 -0
  52. package/dist/price-catalogue-editor.js.map +1 -0
  53. package/dist/promo-code-field.js +1 -1
  54. package/dist/schema-DgjBz7-8.d.ts +242 -0
  55. package/dist/schema-form.d.ts +106 -0
  56. package/dist/schema-form.js +268 -0
  57. package/dist/schema-form.js.map +1 -0
  58. package/dist/shop/booking.d.ts +2 -2
  59. package/dist/shop/booking.js +1 -1
  60. package/dist/shop/booking.js.map +1 -1
  61. package/dist/shop/bulletin.js +1 -1
  62. package/dist/shop/faq.d.ts +2 -1
  63. package/dist/shop/faq.js +1 -1
  64. package/dist/shop/faq.js.map +1 -1
  65. package/dist/shop/gallery.js +1 -1
  66. package/dist/shop/look.d.ts +43 -0
  67. package/dist/shop/look.js +52 -0
  68. package/dist/shop/look.js.map +1 -0
  69. package/dist/shop/policies.d.ts +2 -1
  70. package/dist/shop/policies.js +1 -1
  71. package/dist/shop/policies.js.map +1 -1
  72. package/dist/shop/reviews.d.ts +2 -1
  73. package/dist/shop/reviews.js +1 -1
  74. package/dist/shop/reviews.js.map +1 -1
  75. package/dist/shop/services.js +1 -1
  76. package/dist/shop/social.js +1 -1
  77. package/dist/shop/story.d.ts +2 -1
  78. package/dist/shop/story.js +1 -1
  79. package/dist/shop/story.js.map +1 -1
  80. package/dist/shop/team.js +1 -1
  81. package/dist/shop/video.js +1 -1
  82. package/dist/shop/visit.js +1 -1
  83. package/dist/shop-composer.d.ts +29 -0
  84. package/dist/shop-composer.js +156 -89
  85. package/dist/shop-composer.js.map +1 -1
  86. package/dist/shop.d.ts +6 -240
  87. package/dist/shop.js +24 -212
  88. package/dist/shop.js.map +1 -1
  89. package/dist/switch.js +2 -1
  90. package/dist/vertical-video.js +1 -1
  91. package/dist/wall.d.ts +7 -1
  92. package/dist/wall.js +5 -4
  93. package/dist/wall.js.map +1 -1
  94. package/package.json +59 -9
  95. package/registry/account-menu.json +1 -1
  96. package/registry/account-settings.json +1 -1
  97. package/registry/achievement.json +1 -1
  98. package/registry/action-bar.json +1 -1
  99. package/registry/activity-feed.json +1 -1
  100. package/registry/agenda.json +1 -1
  101. package/registry/alert.json +1 -1
  102. package/registry/analysis-report.json +1 -1
  103. package/registry/anatomy-plate.json +1 -1
  104. package/registry/app-frame.json +2 -2
  105. package/registry/app-header.json +1 -1
  106. package/registry/app-shell.json +1 -1
  107. package/registry/argument-card.json +1 -1
  108. package/registry/audio-player.json +1 -1
  109. package/registry/auth-layout.json +1 -1
  110. package/registry/avatar.json +4 -4
  111. package/registry/badge.json +1 -1
  112. package/registry/bird-plate.json +1 -1
  113. package/registry/button.json +1 -1
  114. package/registry/captcha.json +1 -1
  115. package/registry/card-grid.json +1 -1
  116. package/registry/card.json +1 -1
  117. package/registry/catalogue-page.json +1 -1
  118. package/registry/changelog-page.json +1 -1
  119. package/registry/chapter.json +1 -1
  120. package/registry/chat.json +1 -1
  121. package/registry/checkbox.json +1 -1
  122. package/registry/chip-link.json +1 -1
  123. package/registry/chip-row.json +1 -1
  124. package/registry/chip.json +1 -1
  125. package/registry/choice-grid.json +1 -1
  126. package/registry/code-block.json +1 -1
  127. package/registry/collection-switcher.json +1 -1
  128. package/registry/combobox.json +1 -1
  129. package/registry/command.json +1 -1
  130. package/registry/comparison-table.json +1 -1
  131. package/registry/component-page.json +1 -1
  132. package/registry/confirm-button.json +1 -1
  133. package/registry/contact-page.json +1 -1
  134. package/registry/continue-prompt.json +1 -1
  135. package/registry/copy-button.json +1 -1
  136. package/registry/countdown.json +1 -1
  137. package/registry/cover-hero.json +1 -1
  138. package/registry/cta-panel.json +1 -1
  139. package/registry/dashboard-layout.json +1 -1
  140. package/registry/data-table.json +1 -1
  141. package/registry/date-picker.json +1 -1
  142. package/registry/decision-list.json +1 -1
  143. package/registry/description-list.json +1 -1
  144. package/registry/desktop-window.json +1 -1
  145. package/registry/detail-layout.json +1 -1
  146. package/registry/dialog.json +1 -1
  147. package/registry/docs-article-page.json +1 -1
  148. package/registry/docs-hub-page.json +1 -1
  149. package/registry/docs-layout.json +1 -1
  150. package/registry/docs-nav.json +1 -1
  151. package/registry/document-viewer.json +1 -1
  152. package/registry/doodle.json +1 -1
  153. package/registry/drop-overlay.json +1 -1
  154. package/registry/dropdown-menu.json +1 -1
  155. package/registry/elephant.json +2 -2
  156. package/registry/embed-facade.json +1 -1
  157. package/registry/empty-state.json +1 -1
  158. package/registry/engine-flow.json +1 -1
  159. package/registry/entity-header.json +1 -1
  160. package/registry/environment-notice.json +1 -1
  161. package/registry/error-page.json +1 -1
  162. package/registry/examples/price-catalogue-editor/default.d.ts +4 -0
  163. package/registry/examples/price-catalogue-editor/default.js +47 -0
  164. package/registry/examples/price-catalogue-editor/default.tsx +25 -0
  165. package/registry/examples/schema-form/default.d.ts +4 -0
  166. package/registry/examples/schema-form/default.js +29 -0
  167. package/registry/examples/schema-form/default.tsx +27 -0
  168. package/registry/examples/wall/pinned-note.js +2 -1
  169. package/registry/examples/wall/pinned-note.tsx +2 -1
  170. package/registry/field.json +1 -1
  171. package/registry/file-upload.json +1 -1
  172. package/registry/filter-bar.json +1 -1
  173. package/registry/flock.json +1 -1
  174. package/registry/footnote.json +1 -1
  175. package/registry/force-update-screen.json +1 -1
  176. package/registry/form.json +1 -1
  177. package/registry/gallery-page.json +1 -1
  178. package/registry/genui.json +1 -1
  179. package/registry/glossary-term.json +1 -1
  180. package/registry/glossary.json +1 -1
  181. package/registry/glow-card.json +1 -1
  182. package/registry/goal-gauge.json +1 -1
  183. package/registry/grade-stamp.json +1 -1
  184. package/registry/how-it-works-page.json +1 -1
  185. package/registry/image-cropper.json +1 -1
  186. package/registry/index.json +81 -8
  187. package/registry/iso.json +1 -1
  188. package/registry/kanban.json +1 -1
  189. package/registry/kbd.json +1 -1
  190. package/registry/kind-config-editor.json +1 -1
  191. package/registry/kpi-explained.json +1 -1
  192. package/registry/landing-page.json +1 -1
  193. package/registry/landscape.json +1 -1
  194. package/registry/language-switch.json +1 -1
  195. package/registry/legal-page.json +1 -1
  196. package/registry/link-card.json +1 -1
  197. package/registry/list.json +1 -1
  198. package/registry/loader.json +1 -1
  199. package/registry/longform-page.json +1 -1
  200. package/registry/maintenance-screen.json +1 -1
  201. package/registry/map.json +2 -2
  202. package/registry/margin-layout.json +1 -1
  203. package/registry/markdown.json +1 -1
  204. package/registry/marketing-layout.json +1 -1
  205. package/registry/marquee.json +1 -1
  206. package/registry/mascot-quote.json +1 -1
  207. package/registry/mascot-state.json +1 -1
  208. package/registry/mascots.json +1 -1
  209. package/registry/match-dialog.json +1 -1
  210. package/registry/media-capture.json +1 -1
  211. package/registry/media-gallery.json +1 -1
  212. package/registry/media-grid.json +1 -1
  213. package/registry/meta-row.json +1 -1
  214. package/registry/meter.json +1 -1
  215. package/registry/money-input.json +1 -1
  216. package/registry/nav-bar.json +30 -6
  217. package/registry/next-actions.json +1 -1
  218. package/registry/notification-preferences.json +1 -1
  219. package/registry/number-ticker.json +1 -1
  220. package/registry/opening-hours.json +1 -1
  221. package/registry/page-header.json +1 -1
  222. package/registry/page-hero.json +1 -1
  223. package/registry/page-index.json +1 -1
  224. package/registry/page.json +1 -1
  225. package/registry/pagination.json +1 -1
  226. package/registry/photo-grid.json +1 -1
  227. package/registry/pointer-light.json +1 -1
  228. package/registry/popover.json +1 -1
  229. package/registry/price-catalogue-editor.json +228 -0
  230. package/registry/pricing-page.json +1 -1
  231. package/registry/product-page.json +1 -1
  232. package/registry/profile-card.json +1 -1
  233. package/registry/progress.json +1 -1
  234. package/registry/promise-card.json +1 -1
  235. package/registry/promo-code-field.json +1 -1
  236. package/registry/proposal.json +1 -1
  237. package/registry/qr-code.json +1 -1
  238. package/registry/quota-meter.json +1 -1
  239. package/registry/radio-group.json +1 -1
  240. package/registry/rail-nav.json +2 -2
  241. package/registry/recipes.json +1 -1
  242. package/registry/retro-tv.json +1 -1
  243. package/registry/reviews.json +1 -1
  244. package/registry/router.json +1 -1
  245. package/registry/schema-form.json +253 -0
  246. package/registry/scroll-stage.json +1 -1
  247. package/registry/search-field.json +1 -1
  248. package/registry/section-backdrop.json +1 -1
  249. package/registry/separator.json +1 -1
  250. package/registry/service-card.json +1 -1
  251. package/registry/settings-layout.json +1 -1
  252. package/registry/shop-composer.json +10 -6
  253. package/registry/shop-gallery.json +1 -1
  254. package/registry/shop.json +51 -10
  255. package/registry/showcase.json +1 -1
  256. package/registry/signature.json +1 -1
  257. package/registry/site-cahier.json +1 -1
  258. package/registry/site-footer.json +2 -2
  259. package/registry/sites.json +1 -1
  260. package/registry/skeleton.json +1 -1
  261. package/registry/skip-link.json +1 -1
  262. package/registry/slider.json +1 -1
  263. package/registry/slot-picker.json +1 -1
  264. package/registry/slot.json +1 -1
  265. package/registry/specimen-tag.json +1 -1
  266. package/registry/speed-lines.json +1 -1
  267. package/registry/spinner.json +1 -1
  268. package/registry/split-view.json +1 -1
  269. package/registry/stage-banner.json +1 -1
  270. package/registry/stat.json +1 -1
  271. package/registry/status-chip.json +1 -1
  272. package/registry/status-page.json +1 -1
  273. package/registry/step-progress.json +1 -1
  274. package/registry/step-showcase.json +1 -1
  275. package/registry/stepper.json +1 -1
  276. package/registry/sticky-action.json +1 -1
  277. package/registry/stuck.json +1 -1
  278. package/registry/swipe-deck.json +1 -1
  279. package/registry/switch.json +1 -1
  280. package/registry/tabs.json +1 -1
  281. package/registry/tag-input.json +1 -1
  282. package/registry/tag-selector.json +1 -1
  283. package/registry/taped-photo.json +1 -1
  284. package/registry/terminal-replay.json +1 -1
  285. package/registry/text-style.json +1 -1
  286. package/registry/theme.json +1 -1
  287. package/registry/toast.json +1 -1
  288. package/registry/toc.json +1 -1
  289. package/registry/tooltip.json +1 -1
  290. package/registry/tree-view.json +1 -1
  291. package/registry/update-prompt.json +1 -1
  292. package/registry/upload-queue.json +1 -1
  293. package/registry/usage.json +1 -1
  294. package/registry/verified-badge.json +1 -1
  295. package/registry/versus-card.json +1 -1
  296. package/registry/vertical-video.json +1 -1
  297. package/registry/video-player.json +1 -1
  298. package/registry/video-trimmer.json +1 -1
  299. package/registry/virtual.json +1 -1
  300. package/registry/wall.json +47 -4
  301. package/registry/waveform.json +1 -1
  302. package/dist/chunk-A7MQPIEG.js +0 -31
  303. package/dist/chunk-A7MQPIEG.js.map +0 -1
  304. package/dist/chunk-EUJ7337V.js.map +0 -1
  305. package/dist/chunk-HK525THY.js.map +0 -1
  306. /package/dist/{chunk-CSRKYZ53.js.map → chunk-CZHPWLNW.js.map} +0 -0
@@ -0,0 +1,194 @@
1
+ "use client";
2
+ import {
3
+ MoneyInput
4
+ } from "./chunk-W64RAX4N.js";
5
+ import {
6
+ Field,
7
+ Input,
8
+ Select
9
+ } from "./chunk-HLEBSAGC.js";
10
+ import {
11
+ Badge
12
+ } from "./chunk-S4TLZRGZ.js";
13
+ import {
14
+ Button
15
+ } from "./chunk-V7W4RLRW.js";
16
+ import "./chunk-D3T54RSL.js";
17
+ import "./chunk-WEVYKZIF.js";
18
+ import {
19
+ cn
20
+ } from "./chunk-NSLXEDIS.js";
21
+
22
+ // src/price-catalogue-editor/price-catalogue-editor.tsx
23
+ import { currencyDigits } from "@krizaka/intl";
24
+ import * as React from "react";
25
+ import { jsx, jsxs } from "react/jsx-runtime";
26
+ var fill = (template, vars) => template.replace(/\{(\w+)\}/g, (_, name) => String(vars[name] ?? ""));
27
+ var TONES = { public: "success", "founder-limited": "accent", preparing: "warning" };
28
+ var availabilityTone = (id) => TONES[id] ?? "neutral";
29
+ function amountText(cents, currency, locale, onQuote) {
30
+ if (cents === null) return onQuote;
31
+ const digits = currencyDigits(currency);
32
+ return new Intl.NumberFormat(locale, { style: "currency", currency, minimumFractionDigits: digits, maximumFractionDigits: digits }).format(cents / 10 ** digits);
33
+ }
34
+ var dateText = (iso, locale) => new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeZone: "UTC" }).format(new Date(iso));
35
+ var figuresText = (f, currency, locale, w) => f === null ? "\u2014" : `${amountText(f.amountCents, currency, locale, w.onQuote)} ${w.units[f.unit] ?? f.unit}`;
36
+ function EntryForm({ entry, prices, words, locale, today, onSchedule, onDone }) {
37
+ const id = React.useId();
38
+ const [cents, setCents] = React.useState(entry.amountCents);
39
+ const [unit, setUnit] = React.useState(entry.unit);
40
+ const [availability, setAvailability] = React.useState(entry.availability);
41
+ const [limits, setLimits] = React.useState(() => Object.fromEntries(Object.entries(entry.limits).map(([k, v]) => [k, String(v)])));
42
+ const [from, setFrom] = React.useState(today);
43
+ const [error, setError] = React.useState(null);
44
+ const [busy, setBusy] = React.useState(false);
45
+ const limitKeys = Object.keys(entry.limits);
46
+ const dateInvalid = from < today;
47
+ return /* @__PURE__ */ jsxs(
48
+ "form",
49
+ {
50
+ "aria-label": `${words.edit} \u2014 ${entry.product} \xB7 ${entry.plan}`,
51
+ className: "mt-4 grid gap-4 border-t border-border pt-4",
52
+ onSubmit: async (event) => {
53
+ event.preventDefault();
54
+ if (dateInvalid || busy) return;
55
+ setBusy(true);
56
+ const next = {};
57
+ for (const key of limitKeys) next[key] = Number.parseInt(limits[key] ?? "0", 10) || 0;
58
+ const result = await onSchedule(entry.key, { amountCents: cents, unit, availability, limits: next }, from);
59
+ setBusy(false);
60
+ if (result.ok) onDone();
61
+ else setError(result.message);
62
+ },
63
+ children: [
64
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [
65
+ /* @__PURE__ */ jsxs(Field.Root, { children: [
66
+ /* @__PURE__ */ jsx(Field.Label, { htmlFor: `${id}-amount`, children: words.amount }),
67
+ /* @__PURE__ */ jsx(MoneyInput, { id: `${id}-amount`, value: cents, onValueChange: setCents, currency: entry.currency, locale, "aria-describedby": `${id}-amount-hint` }),
68
+ /* @__PURE__ */ jsx(Field.Hint, { id: `${id}-amount-hint`, children: words.emptyIsQuote })
69
+ ] }),
70
+ /* @__PURE__ */ jsxs(Field.Root, { children: [
71
+ /* @__PURE__ */ jsx(Field.Label, { htmlFor: `${id}-unit`, children: words.unit }),
72
+ /* @__PURE__ */ jsx(Select, { id: `${id}-unit`, value: unit, onChange: (e) => setUnit(e.target.value), children: prices.units.map((u) => /* @__PURE__ */ jsx("option", { value: u, children: words.units[u] ?? u }, u)) })
73
+ ] }),
74
+ /* @__PURE__ */ jsxs(Field.Root, { children: [
75
+ /* @__PURE__ */ jsx(Field.Label, { htmlFor: `${id}-availability`, children: words.availability }),
76
+ /* @__PURE__ */ jsx(Select, { id: `${id}-availability`, value: availability, onChange: (e) => setAvailability(e.target.value), children: prices.availabilities.map((a) => /* @__PURE__ */ jsx("option", { value: a, children: words.availabilities[a] ?? a }, a)) })
77
+ ] }),
78
+ /* @__PURE__ */ jsxs(Field.Root, { children: [
79
+ /* @__PURE__ */ jsx(Field.Label, { htmlFor: `${id}-from`, children: words.from }),
80
+ /* @__PURE__ */ jsx(Input, { id: `${id}-from`, type: "date", min: today, value: from, onChange: (e) => setFrom(e.target.value), invalid: dateInvalid })
81
+ ] })
82
+ ] }),
83
+ limitKeys.length > 0 && /* @__PURE__ */ jsxs("fieldset", { className: "grid gap-4 sm:grid-cols-2", children: [
84
+ /* @__PURE__ */ jsx("legend", { className: "mb-2 text-xs font-semibold text-fg-secondary", children: words.limits }),
85
+ limitKeys.map((key) => /* @__PURE__ */ jsxs(Field.Root, { children: [
86
+ /* @__PURE__ */ jsx(Field.Label, { htmlFor: `${id}-limit-${key}`, children: words.limitNames?.[key] ?? key }),
87
+ /* @__PURE__ */ jsx(Input, { id: `${id}-limit-${key}`, inputMode: "numeric", pattern: "[0-9]*", value: limits[key] ?? "", onChange: (e) => setLimits({ ...limits, [key]: e.target.value.replace(/\D/g, "") }) })
88
+ ] }, key))
89
+ ] }),
90
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-fg-secondary", children: words.keepsPrice }),
91
+ error && /* @__PURE__ */ jsx(Field.Error, { children: error }),
92
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
93
+ /* @__PURE__ */ jsx(Button, { type: "submit", size: "sm", variant: "primary", disabled: busy || dateInvalid, children: words.save }),
94
+ /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "ghost", onClick: onDone, children: words.cancel })
95
+ ] })
96
+ ]
97
+ }
98
+ );
99
+ }
100
+ function HistoryFold({ entry, words, locale, loadHistory }) {
101
+ const [lines, setLines] = React.useState(null);
102
+ const asked = React.useRef(false);
103
+ return /* @__PURE__ */ jsxs(
104
+ "details",
105
+ {
106
+ className: "group",
107
+ onToggle: (event) => {
108
+ if (!event.currentTarget.open || asked.current) return;
109
+ asked.current = true;
110
+ void loadHistory(entry.key).then(setLines);
111
+ },
112
+ children: [
113
+ /* @__PURE__ */ jsx("summary", { className: "cursor-pointer text-sm font-medium text-fg-secondary hover:text-fg", children: words.history }),
114
+ lines === null && /* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-fg-secondary", children: words.loading }),
115
+ lines?.length === 0 && /* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-fg-secondary", children: words.historyEmpty }),
116
+ lines && lines.length > 0 && /* @__PURE__ */ jsx("ol", { className: "mt-2 grid gap-1.5 text-sm text-fg-secondary", children: lines.map((line) => /* @__PURE__ */ jsx("li", { children: fill(words.historyLine, {
117
+ actor: line.actorLabel,
118
+ at: dateText(line.at, locale),
119
+ before: figuresText(line.before, entry.currency, locale, words),
120
+ after: figuresText(line.after, entry.currency, locale, words),
121
+ from: dateText(line.effectiveFrom, locale)
122
+ }) }, line.versionId)) })
123
+ ]
124
+ }
125
+ );
126
+ }
127
+ function PriceCatalogueEditor({ prices, words, locale, today, onSchedule, loadHistory, headingLevel = 3, className, ...props }) {
128
+ const [open, setOpen] = React.useState(null);
129
+ const [saved, setSaved] = React.useState(false);
130
+ const Heading = `h${headingLevel}`;
131
+ return /* @__PURE__ */ jsxs("section", { "data-price-catalogue": "", className: cn("grid gap-3", className), ...props, children: [
132
+ /* @__PURE__ */ jsx("ul", { className: "grid gap-3", children: prices.entries.map((entry) => /* @__PURE__ */ jsxs("li", { "data-availability": entry.availability, className: "rounded-xl border border-border bg-surface-1 p-4", children: [
133
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-start justify-between gap-x-4 gap-y-2", children: [
134
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
135
+ /* @__PURE__ */ jsxs(Heading, { className: "text-sm font-semibold text-fg", children: [
136
+ entry.product,
137
+ " \xB7 ",
138
+ entry.plan
139
+ ] }),
140
+ /* @__PURE__ */ jsxs("p", { className: "mt-1 flex flex-wrap items-baseline gap-x-2 text-fg", children: [
141
+ /* @__PURE__ */ jsx("span", { className: "text-xl font-semibold tabular-nums", children: amountText(entry.amountCents, entry.currency, locale, words.onQuote) }),
142
+ entry.amountCents !== null && /* @__PURE__ */ jsxs("span", { className: "text-sm text-fg-secondary", children: [
143
+ words.units[entry.unit] ?? entry.unit,
144
+ " \xB7 ",
145
+ words.plusTaxes
146
+ ] })
147
+ ] })
148
+ ] }),
149
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
150
+ /* @__PURE__ */ jsx(Badge, { tone: availabilityTone(entry.availability), dot: true, children: words.availabilities[entry.availability] ?? entry.availability }),
151
+ open !== entry.key && /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "secondary", "aria-label": `${words.edit} \u2014 ${entry.product} \xB7 ${entry.plan}`, onClick: () => {
152
+ setOpen(entry.key);
153
+ setSaved(false);
154
+ }, children: words.edit })
155
+ ] })
156
+ ] }),
157
+ Object.keys(entry.limits).length > 0 && /* @__PURE__ */ jsx("dl", { className: "mt-2 flex flex-wrap gap-x-4 gap-y-1 text-sm text-fg-secondary", children: Object.entries(entry.limits).map(([key, value]) => /* @__PURE__ */ jsxs("div", { className: "flex gap-1.5", children: [
158
+ /* @__PURE__ */ jsx("dt", { children: words.limitNames?.[key] ?? key }),
159
+ /* @__PURE__ */ jsx("dd", { className: "font-medium tabular-nums text-fg", children: new Intl.NumberFormat(locale).format(value) })
160
+ ] }, key)) }),
161
+ open === entry.key && /* @__PURE__ */ jsx(
162
+ EntryForm,
163
+ {
164
+ entry,
165
+ prices,
166
+ words,
167
+ locale,
168
+ today,
169
+ onSchedule,
170
+ onDone: () => {
171
+ setOpen(null);
172
+ setSaved(true);
173
+ }
174
+ }
175
+ ),
176
+ (entry.upcoming.length > 0 || loadHistory) && /* @__PURE__ */ jsxs("div", { className: "mt-3 grid gap-2", children: [
177
+ entry.upcoming.length > 0 && /* @__PURE__ */ jsxs("details", { children: [
178
+ /* @__PURE__ */ jsx("summary", { className: "cursor-pointer text-sm font-medium text-fg-secondary hover:text-fg", children: fill(words.scheduled, { count: entry.upcoming.length }) }),
179
+ /* @__PURE__ */ jsx("ul", { className: "mt-2 grid gap-1.5 text-sm text-fg-secondary", children: entry.upcoming.map((v) => /* @__PURE__ */ jsxs("li", { children: [
180
+ figuresText(v, entry.currency, locale, words),
181
+ " \xB7 ",
182
+ fill(words.scheduledLine, { from: dateText(v.effectiveFrom, locale) })
183
+ ] }, v.versionId)) })
184
+ ] }),
185
+ loadHistory && /* @__PURE__ */ jsx(HistoryFold, { entry, words, locale, loadHistory })
186
+ ] })
187
+ ] }, entry.key)) }),
188
+ /* @__PURE__ */ jsx("output", { className: "sr-only", children: saved ? words.saved : "" })
189
+ ] });
190
+ }
191
+ export {
192
+ PriceCatalogueEditor
193
+ };
194
+ //# sourceMappingURL=price-catalogue-editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/price-catalogue-editor/price-catalogue-editor.tsx"],"sourcesContent":["\"use client\";\n// Client (the open row, the draft, the folds). An administrator edits a product's price entries: one row per entry, a\n// change that takes effect from a date (today by default, never the past) and says that current subscriptions keep their\n// price, the scheduled changes and the history folded. Fed by `describePrices()` of @krizaka/settings (JSON-safe); the\n// block never fetches, saves or reads the clock: the host passes `onSchedule`, `loadHistory` and `today`. Words are props.\nimport { currencyDigits } from \"@krizaka/intl\";\nimport * as React from \"react\";\n\nimport { Badge } from \"../badge/badge\";\nimport { Button } from \"../button/button\";\nimport { cn } from \"../cn\";\nimport { Field, Input, Select } from \"../field/field\";\nimport { MoneyInput } from \"../money-input/money-input\";\n\n/** The figures of a price: what one version of an entry holds. */\nexport interface PriceFigures {\n /** Integer cents; `null` is « on quote ». */\n amountCents: number | null;\n unit: string;\n availability: string;\n /** Named integers the product reads (`included`, `founderCap`…). */\n limits: Record<string, number>;\n}\n\n/** A change a host scheduled, still waiting for its date. */\nexport interface PriceScheduledView extends PriceFigures {\n versionId: string;\n /** ISO date-time. */\n effectiveFrom: string;\n}\n\n/** An entry as `describePrices()` returns it. */\nexport interface PriceEntryView extends PriceFigures {\n key: string;\n product: string;\n plan: string;\n currency: string;\n versionId: string;\n effectiveFrom: string;\n upcoming: PriceScheduledView[];\n}\n\n/** The catalogue as `describePrices()` returns it: the enumerations the fields offer, and the entries. */\nexport interface PricesView {\n units: string[];\n availabilities: string[];\n entries: PriceEntryView[];\n}\n\n/** One line of an entry's history: who, when, before → after, from when. */\nexport interface PriceHistoryEntry {\n versionId: string;\n /** ISO date-time the change was made. */\n at: string;\n actorLabel: string;\n effectiveFrom: string;\n before: PriceFigures | null;\n after: PriceFigures;\n}\n\n/** The result the host returns after saving. */\nexport type PriceScheduleResult = { ok: true } | { ok: false; message: string };\n\n/** The words, passed translated. `{name}` placeholders are filled by the block. */\nexport interface PriceCatalogueWords {\n /** « Change » — opens an entry's form. */\n edit: string;\n /** « Amount » */\n amount: string;\n /** « On quote » — an entry with no figure. */\n onQuote: string;\n /** « plus taxes » */\n plusTaxes: string;\n /** « Unit » */\n unit: string;\n /** « Availability » */\n availability: string;\n /** « Limits » */\n limits: string;\n /** « From » — the date the change takes effect. */\n from: string;\n /** « Current subscriptions keep their price. » */\n keepsPrice: string;\n /** « Schedule the change » */\n save: string;\n cancel: string;\n /** « Leave empty for “on quote”. » */\n emptyIsQuote: string;\n /** « Scheduled changes ({count}) » */\n scheduled: string;\n /** « History » */\n history: string;\n /** « No change yet. » */\n historyEmpty: string;\n /** « Loading… » */\n loading: string;\n /** « {actor}, {at}: {before} → {after}, from {from} » */\n historyLine: string;\n /** « from {from} » — a scheduled change. */\n scheduledLine: string;\n /** « Saved. » — announced after a change is scheduled. */\n saved: string;\n /** The unit's name by id: `{ month: \"per month\" }`. A missing id shows the id. */\n units: Record<string, string>;\n /** The availability's name by id: `{ public: \"Public\" }`. */\n availabilities: Record<string, string>;\n /** The limit's name by key: `{ founderCap: \"First customers\" }`. A missing key shows the key. */\n limitNames?: Record<string, string>;\n}\n\nexport interface PriceCatalogueEditorProps extends Omit<React.ComponentProps<\"section\">, \"children\"> {\n /** The catalogue as `describePrices()` returns it: the enumerations the fields offer, and the entries. */\n prices: PricesView;\n /** The words, passed translated (see `PriceCatalogueWords`). */\n words: PriceCatalogueWords;\n /** BCP 47 locale for the amounts and the dates: `\"fr-CA\"`. */\n locale: string;\n /** Today as `YYYY-MM-DD`: the earliest date a change may start from (the block never reads the clock). */\n today: string;\n /** Saves a change from a date (`YYYY-MM-DD`). The host validates and returns the refusal in words. */\n onSchedule: (key: string, change: PriceFigures, effectiveFrom: string) => Promise<PriceScheduleResult>;\n /** The history of an entry, asked when its fold opens. Omitted: no history fold. */\n loadHistory?: (key: string) => Promise<PriceHistoryEntry[]>;\n /** Heading level of an entry's name. @default 3 */\n headingLevel?: 2 | 3 | 4;\n}\n\nconst fill = (template: string, vars: Record<string, string | number>) => template.replace(/\\{(\\w+)\\}/g, (_, name: string) => String(vars[name] ?? \"\"));\n\nconst TONES: Record<string, \"success\" | \"accent\" | \"warning\"> = { public: \"success\", \"founder-limited\": \"accent\", preparing: \"warning\" };\nconst availabilityTone = (id: string) => TONES[id] ?? \"neutral\";\n\n/** « 9,99 $ » / « $9.99 » by locale, or the « on quote » word. Cents are bounded integers, so the division is exact for display. */\nfunction amountText(cents: number | null, currency: string, locale: string, onQuote: string): string {\n if (cents === null) return onQuote;\n const digits = currencyDigits(currency);\n return new Intl.NumberFormat(locale, { style: \"currency\", currency, minimumFractionDigits: digits, maximumFractionDigits: digits }).format(cents / 10 ** digits);\n}\n\nconst dateText = (iso: string, locale: string) => new Intl.DateTimeFormat(locale, { dateStyle: \"medium\", timeZone: \"UTC\" }).format(new Date(iso));\nconst figuresText = (f: PriceFigures | null, currency: string, locale: string, w: PriceCatalogueWords) =>\n f === null ? \"—\" : `${amountText(f.amountCents, currency, locale, w.onQuote)} ${w.units[f.unit] ?? f.unit}`;\n\nfunction EntryForm({ entry, prices, words, locale, today, onSchedule, onDone }: Readonly<{ entry: PriceEntryView; prices: PricesView; words: PriceCatalogueWords; locale: string; today: string; onSchedule: PriceCatalogueEditorProps[\"onSchedule\"]; onDone: () => void }>) {\n const id = React.useId();\n const [cents, setCents] = React.useState<number | null>(entry.amountCents);\n const [unit, setUnit] = React.useState(entry.unit);\n const [availability, setAvailability] = React.useState(entry.availability);\n const [limits, setLimits] = React.useState<Record<string, string>>(() => Object.fromEntries(Object.entries(entry.limits).map(([k, v]) => [k, String(v)])));\n const [from, setFrom] = React.useState(today);\n const [error, setError] = React.useState<string | null>(null);\n const [busy, setBusy] = React.useState(false);\n const limitKeys = Object.keys(entry.limits);\n const dateInvalid = from < today;\n return (\n <form\n aria-label={`${words.edit} — ${entry.product} · ${entry.plan}`}\n className=\"mt-4 grid gap-4 border-t border-border pt-4\"\n onSubmit={async (event) => {\n event.preventDefault();\n if (dateInvalid || busy) return;\n setBusy(true);\n const next: Record<string, number> = {};\n for (const key of limitKeys) next[key] = Number.parseInt(limits[key] ?? \"0\", 10) || 0;\n const result = await onSchedule(entry.key, { amountCents: cents, unit, availability, limits: next }, from);\n setBusy(false);\n if (result.ok) onDone();\n else setError(result.message);\n }}\n >\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <Field.Root>\n <Field.Label htmlFor={`${id}-amount`}>{words.amount}</Field.Label>\n <MoneyInput id={`${id}-amount`} value={cents} onValueChange={setCents} currency={entry.currency} locale={locale} aria-describedby={`${id}-amount-hint`} />\n <Field.Hint id={`${id}-amount-hint`}>{words.emptyIsQuote}</Field.Hint>\n </Field.Root>\n <Field.Root>\n <Field.Label htmlFor={`${id}-unit`}>{words.unit}</Field.Label>\n <Select id={`${id}-unit`} value={unit} onChange={(e) => setUnit(e.target.value)}>\n {prices.units.map((u) => (\n <option key={u} value={u}>\n {words.units[u] ?? u}\n </option>\n ))}\n </Select>\n </Field.Root>\n <Field.Root>\n <Field.Label htmlFor={`${id}-availability`}>{words.availability}</Field.Label>\n <Select id={`${id}-availability`} value={availability} onChange={(e) => setAvailability(e.target.value)}>\n {prices.availabilities.map((a) => (\n <option key={a} value={a}>\n {words.availabilities[a] ?? a}\n </option>\n ))}\n </Select>\n </Field.Root>\n <Field.Root>\n <Field.Label htmlFor={`${id}-from`}>{words.from}</Field.Label>\n <Input id={`${id}-from`} type=\"date\" min={today} value={from} onChange={(e) => setFrom(e.target.value)} invalid={dateInvalid} />\n </Field.Root>\n </div>\n {limitKeys.length > 0 && (\n <fieldset className=\"grid gap-4 sm:grid-cols-2\">\n <legend className=\"mb-2 text-xs font-semibold text-fg-secondary\">{words.limits}</legend>\n {limitKeys.map((key) => (\n <Field.Root key={key}>\n <Field.Label htmlFor={`${id}-limit-${key}`}>{words.limitNames?.[key] ?? key}</Field.Label>\n <Input id={`${id}-limit-${key}`} inputMode=\"numeric\" pattern=\"[0-9]*\" value={limits[key] ?? \"\"} onChange={(e) => setLimits({ ...limits, [key]: e.target.value.replace(/\\D/g, \"\") })} />\n </Field.Root>\n ))}\n </fieldset>\n )}\n <p className=\"text-sm text-fg-secondary\">{words.keepsPrice}</p>\n {error && <Field.Error>{error}</Field.Error>}\n <div className=\"flex flex-wrap gap-2\">\n <Button type=\"submit\" size=\"sm\" variant=\"primary\" disabled={busy || dateInvalid}>\n {words.save}\n </Button>\n <Button type=\"button\" size=\"sm\" variant=\"ghost\" onClick={onDone}>\n {words.cancel}\n </Button>\n </div>\n </form>\n );\n}\n\nfunction HistoryFold({ entry, words, locale, loadHistory }: Readonly<{ entry: PriceEntryView; words: PriceCatalogueWords; locale: string; loadHistory: NonNullable<PriceCatalogueEditorProps[\"loadHistory\"]> }>) {\n const [lines, setLines] = React.useState<PriceHistoryEntry[] | null>(null);\n const asked = React.useRef(false);\n return (\n <details\n className=\"group\"\n onToggle={(event) => {\n if (!(event.currentTarget as HTMLDetailsElement).open || asked.current) return;\n asked.current = true;\n void loadHistory(entry.key).then(setLines);\n }}\n >\n <summary className=\"cursor-pointer text-sm font-medium text-fg-secondary hover:text-fg\">{words.history}</summary>\n {lines === null && <p className=\"mt-2 text-sm text-fg-secondary\">{words.loading}</p>}\n {lines?.length === 0 && <p className=\"mt-2 text-sm text-fg-secondary\">{words.historyEmpty}</p>}\n {lines && lines.length > 0 && (\n <ol className=\"mt-2 grid gap-1.5 text-sm text-fg-secondary\">\n {lines.map((line) => (\n <li key={line.versionId}>\n {fill(words.historyLine, {\n actor: line.actorLabel,\n at: dateText(line.at, locale),\n before: figuresText(line.before, entry.currency, locale, words),\n after: figuresText(line.after, entry.currency, locale, words),\n from: dateText(line.effectiveFrom, locale),\n })}\n </li>\n ))}\n </ol>\n )}\n </details>\n );\n}\n\n/** The price entries of a product, each editable from a date, with what is scheduled and its history folded. */\nexport function PriceCatalogueEditor({ prices, words, locale, today, onSchedule, loadHistory, headingLevel = 3, className, ...props }: Readonly<PriceCatalogueEditorProps>) {\n const [open, setOpen] = React.useState<string | null>(null);\n const [saved, setSaved] = React.useState(false);\n const Heading = `h${headingLevel}` as \"h3\";\n return (\n <section data-price-catalogue=\"\" className={cn(\"grid gap-3\", className)} {...props}>\n <ul className=\"grid gap-3\">\n {prices.entries.map((entry) => (\n <li key={entry.key} data-availability={entry.availability} className=\"rounded-xl border border-border bg-surface-1 p-4\">\n <div className=\"flex flex-wrap items-start justify-between gap-x-4 gap-y-2\">\n <div className=\"min-w-0\">\n <Heading className=\"text-sm font-semibold text-fg\">\n {entry.product} · {entry.plan}\n </Heading>\n <p className=\"mt-1 flex flex-wrap items-baseline gap-x-2 text-fg\">\n <span className=\"text-xl font-semibold tabular-nums\">{amountText(entry.amountCents, entry.currency, locale, words.onQuote)}</span>\n {entry.amountCents !== null && (\n <span className=\"text-sm text-fg-secondary\">\n {words.units[entry.unit] ?? entry.unit} · {words.plusTaxes}\n </span>\n )}\n </p>\n </div>\n <div className=\"flex flex-wrap items-center gap-2\">\n <Badge tone={availabilityTone(entry.availability)} dot>\n {words.availabilities[entry.availability] ?? entry.availability}\n </Badge>\n {open !== entry.key && (\n <Button type=\"button\" size=\"sm\" variant=\"secondary\" aria-label={`${words.edit} — ${entry.product} · ${entry.plan}`} onClick={() => {\n setOpen(entry.key);\n setSaved(false);\n }}>\n {words.edit}\n </Button>\n )}\n </div>\n </div>\n {Object.keys(entry.limits).length > 0 && (\n <dl className=\"mt-2 flex flex-wrap gap-x-4 gap-y-1 text-sm text-fg-secondary\">\n {Object.entries(entry.limits).map(([key, value]) => (\n <div key={key} className=\"flex gap-1.5\">\n <dt>{words.limitNames?.[key] ?? key}</dt>\n <dd className=\"font-medium tabular-nums text-fg\">{new Intl.NumberFormat(locale).format(value)}</dd>\n </div>\n ))}\n </dl>\n )}\n {open === entry.key && (\n <EntryForm\n entry={entry}\n prices={prices}\n words={words}\n locale={locale}\n today={today}\n onSchedule={onSchedule}\n onDone={() => {\n setOpen(null);\n setSaved(true);\n }}\n />\n )}\n {(entry.upcoming.length > 0 || loadHistory) && (\n <div className=\"mt-3 grid gap-2\">\n {entry.upcoming.length > 0 && (\n <details>\n <summary className=\"cursor-pointer text-sm font-medium text-fg-secondary hover:text-fg\">{fill(words.scheduled, { count: entry.upcoming.length })}</summary>\n <ul className=\"mt-2 grid gap-1.5 text-sm text-fg-secondary\">\n {entry.upcoming.map((v) => (\n <li key={v.versionId}>\n {figuresText(v, entry.currency, locale, words)} · {fill(words.scheduledLine, { from: dateText(v.effectiveFrom, locale) })}\n </li>\n ))}\n </ul>\n </details>\n )}\n {loadHistory && <HistoryFold entry={entry} words={words} locale={locale} loadHistory={loadHistory} />}\n </div>\n )}\n </li>\n ))}\n </ul>\n <output className=\"sr-only\">{saved ? words.saved : \"\"}</output>\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAKA,SAAS,sBAAsB;AAC/B,YAAY,WAAW;AAqKf,SACE,KADF;AA5CR,IAAM,OAAO,CAAC,UAAkB,SAA0C,SAAS,QAAQ,cAAc,CAAC,GAAG,SAAiB,OAAO,KAAK,IAAI,KAAK,EAAE,CAAC;AAEtJ,IAAM,QAA0D,EAAE,QAAQ,WAAW,mBAAmB,UAAU,WAAW,UAAU;AACvI,IAAM,mBAAmB,CAAC,OAAe,MAAM,EAAE,KAAK;AAGtD,SAAS,WAAW,OAAsB,UAAkB,QAAgB,SAAyB;AACnG,MAAI,UAAU,KAAM,QAAO;AAC3B,QAAM,SAAS,eAAe,QAAQ;AACtC,SAAO,IAAI,KAAK,aAAa,QAAQ,EAAE,OAAO,YAAY,UAAU,uBAAuB,QAAQ,uBAAuB,OAAO,CAAC,EAAE,OAAO,QAAQ,MAAM,MAAM;AACjK;AAEA,IAAM,WAAW,CAAC,KAAa,WAAmB,IAAI,KAAK,eAAe,QAAQ,EAAE,WAAW,UAAU,UAAU,MAAM,CAAC,EAAE,OAAO,IAAI,KAAK,GAA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ED,SAAS,MAAM,OACd;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,QAAQ,MAAM;AACZ,oBAAQ,IAAI;AACZ,qBAAS,IAAI;AAAA,UACf;AAAA;AAAA,MACF;AAAA,OAEA,MAAM,SAAS,SAAS,KAAK,gBAC7B,qBAAC,SAAI,WAAU,mBACZ;AAAA,cAAM,SAAS,SAAS,KACvB,qBAAC,aACC;AAAA,8BAAC,aAAQ,WAAU,sEAAsE,eAAK,MAAM,WAAW,EAAE,OAAO,MAAM,SAAS,OAAO,CAAC,GAAE;AAAA,UACjJ,oBAAC,QAAG,WAAU,+CACX,gBAAM,SAAS,IAAI,CAAC,MACnB,qBAAC,QACE;AAAA,wBAAY,GAAG,MAAM,UAAU,QAAQ,KAAK;AAAA,YAAE;AAAA,YAAI,KAAK,MAAM,eAAe,EAAE,MAAM,SAAS,EAAE,eAAe,MAAM,EAAE,CAAC;AAAA,eADjH,EAAE,SAEX,CACD,GACH;AAAA,WACF;AAAA,QAED,eAAe,oBAAC,eAAY,OAAc,OAAc,QAAgB,aAA0B;AAAA,SACrG;AAAA,SApEK,MAAM,GAsEf,CACD,GACH;AAAA,IACA,oBAAC,YAAO,WAAU,WAAW,kBAAQ,MAAM,QAAQ,IAAG;AAAA,KACxD;AAEJ;","names":[]}
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  Field,
4
4
  Input
5
- } from "./chunk-PZ4FJOD5.js";
5
+ } from "./chunk-HLEBSAGC.js";
6
6
  import {
7
7
  Button
8
8
  } from "./chunk-V7W4RLRW.js";
@@ -0,0 +1,242 @@
1
+ import * as z from 'zod/mini';
2
+
3
+ /** The owner's words, in each language; the product's message is the fallback when a language is absent. */
4
+ declare const localizedText: z.ZodMiniObject<{
5
+ fr: z.ZodMiniOptional<z.ZodMiniString<string>>;
6
+ en: z.ZodMiniOptional<z.ZodMiniString<string>>;
7
+ }, z.core.$strip>;
8
+ type LocalizedText = z.output<typeof localizedText>;
9
+
10
+ type Shape = z.ZodMiniObject;
11
+ type BlockShapes = Record<string, Shape>;
12
+ /** What a section of a type is, once parsed. */
13
+ type ParsedSection<T extends string, V extends string, S extends Shape, B extends BlockShapes> = {
14
+ key: string;
15
+ type: T;
16
+ variant: V;
17
+ disabled?: boolean | undefined;
18
+ settings: z.output<S>;
19
+ text?: {
20
+ title?: z.output<typeof localizedText> | undefined;
21
+ lead?: z.output<typeof localizedText> | undefined;
22
+ } | undefined;
23
+ blocks?: {
24
+ [K in keyof B & string]: {
25
+ key: string;
26
+ type: K;
27
+ settings: z.output<B[K]>;
28
+ text?: Record<string, z.output<typeof localizedText>> | undefined;
29
+ };
30
+ }[keyof B & string][] | undefined;
31
+ };
32
+ type SectionSpec<T extends string, V extends readonly [string, ...string[]], S extends Shape, B extends BlockShapes> = {
33
+ /** The type's name: the `type` of a section. */
34
+ type: T;
35
+ /** Its variants; the first is the default one. */
36
+ variants: V;
37
+ /** The zod schema of its settings. */
38
+ settings: S;
39
+ /** The settings a new section starts with. */
40
+ settingsDefault: z.input<S>;
41
+ /** The block types it allows, each with the zod schema of its settings. None: the section has no blocks. */
42
+ blocks?: B;
43
+ /** The checks that read the whole section (a count, a combination); `issue(path, message)` refuses it. */
44
+ refine?: (section: ParsedSection<T, V[number], S, B>, issue: (path: (string | number)[], message: string) => void) => void;
45
+ };
46
+ type SectionDefinitionOf<T extends string, V extends readonly [string, ...string[]], S extends Shape, B extends BlockShapes> = SectionSpec<T, V, S, B> & {
47
+ readonly defaultVariant: V[number];
48
+ readonly blockTypes: readonly (keyof B & string)[];
49
+ /** The zod schema of a section of this type. */
50
+ readonly schema: z.ZodMiniType<ParsedSection<T, V[number], S, B>>;
51
+ };
52
+ /** Defines a section type. */
53
+ declare function defineSection<const T extends string, const V extends readonly [string, ...string[]], S extends Shape, B extends BlockShapes = Record<never, never>>(spec: SectionSpec<T, V, S, B>): SectionDefinitionOf<T, V, S, B>;
54
+
55
+ /** Every section type, in the order the composer lists them. */
56
+ declare const SECTION_DEFINITIONS: readonly [SectionDefinitionOf<"hero", readonly ["poster", "split", "banner", "tv"], z.ZodMiniObject<{
57
+ media: z.ZodMiniOptional<z.ZodMiniString<string>>;
58
+ focus: z.ZodMiniEnum<{
59
+ center: "center";
60
+ top: "top";
61
+ bottom: "bottom";
62
+ }>;
63
+ }, z.core.$strip>, {
64
+ fact: z.ZodMiniObject<{
65
+ kind: z.ZodMiniEnum<{
66
+ "open-now": "open-now";
67
+ area: "area";
68
+ score: "score";
69
+ }>;
70
+ }, z.core.$strip>;
71
+ }>, SectionDefinitionOf<"services", readonly ["menu", "cards", "index", "carousel"], z.ZodMiniObject<{
72
+ source: z.ZodMiniEnum<{
73
+ all: "all";
74
+ pick: "pick";
75
+ }>;
76
+ groupBy: z.ZodMiniEnum<{
77
+ category: "category";
78
+ none: "none";
79
+ }>;
80
+ columns: z.ZodMiniUnion<[z.ZodMiniLiteral<1 | 2>, z.ZodMiniLiteral<1 | 2>]>;
81
+ aside: z.ZodMiniEnum<{
82
+ none: "none";
83
+ hours: "hours";
84
+ }>;
85
+ }, z.core.$strip>, {
86
+ service: z.ZodMiniObject<{
87
+ serviceId: z.ZodMiniString<string>;
88
+ }, z.core.$strip>;
89
+ }>, SectionDefinitionOf<"booking", readonly ["strip", "panel", "closing", "sticky"], z.ZodMiniObject<{
90
+ serviceId: z.ZodMiniOptional<z.ZodMiniString<string>>;
91
+ count: z.ZodMiniUnion<[z.ZodMiniLiteral<3 | 4 | 6>, z.ZodMiniLiteral<3 | 4 | 6>]>;
92
+ }, z.core.$strip>, Record<never, never>>, SectionDefinitionOf<"gallery", readonly ["mosaic", "filmstrip", "wall", "grid"], z.ZodMiniObject<{
93
+ source: z.ZodMiniEnum<{
94
+ all: "all";
95
+ pick: "pick";
96
+ }>;
97
+ texture: z.ZodMiniEnum<{
98
+ plaster: "plaster";
99
+ brick: "brick";
100
+ ridge: "ridge";
101
+ zellige: "zellige";
102
+ }>;
103
+ }, z.core.$strip>, {
104
+ photo: z.ZodMiniObject<{
105
+ mediaId: z.ZodMiniString<string>;
106
+ caption: z.ZodMiniOptional<z.ZodMiniString<string>>;
107
+ }, z.core.$strip>;
108
+ note: z.ZodMiniObject<{
109
+ text: z.ZodMiniString<string>;
110
+ signature: z.ZodMiniOptional<z.ZodMiniString<string>>;
111
+ }, z.core.$strip>;
112
+ sign: z.ZodMiniObject<{}, z.core.$strip>;
113
+ }>, SectionDefinitionOf<"video", readonly ["tv", "shorts"], z.ZodMiniObject<{
114
+ cabinet: z.ZodMiniEnum<{
115
+ cabinet: "cabinet";
116
+ portable: "portable";
117
+ }>;
118
+ channel: z.ZodMiniOptional<z.ZodMiniString<string>>;
119
+ }, z.core.$strip>, {
120
+ reel: z.ZodMiniObject<{
121
+ platform: z.ZodMiniEnum<{
122
+ tiktok: "tiktok";
123
+ "youtube-shorts": "youtube-shorts";
124
+ instagram: "instagram";
125
+ }>;
126
+ url: z.ZodMiniString<string>;
127
+ }, z.core.$strip>;
128
+ }>, SectionDefinitionOf<"reviews", readonly ["summary-cards", "quote", "strip"], z.ZodMiniObject<{
129
+ rule: z.ZodMiniEnum<{
130
+ best: "best";
131
+ latest: "latest";
132
+ }>;
133
+ count: z.ZodMiniUnion<[z.ZodMiniLiteral<3 | 1 | 2>, z.ZodMiniLiteral<3 | 1 | 2>]>;
134
+ }, z.core.$strip>, Record<never, never>>, SectionDefinitionOf<"bulletin", readonly ["board", "banner"], z.ZodMiniObject<{}, z.core.$strip>, {
135
+ flyer: z.ZodMiniObject<{
136
+ text: z.ZodMiniString<string>;
137
+ signature: z.ZodMiniOptional<z.ZodMiniString<string>>;
138
+ until: z.ZodMiniOptional<z.ZodMiniString<string>>;
139
+ }, z.core.$strip>;
140
+ }>, SectionDefinitionOf<"team", readonly ["row", "cards"], z.ZodMiniObject<{
141
+ source: z.ZodMiniEnum<{
142
+ all: "all";
143
+ pick: "pick";
144
+ }>;
145
+ }, z.core.$strip>, {
146
+ member: z.ZodMiniObject<{
147
+ memberId: z.ZodMiniString<string>;
148
+ }, z.core.$strip>;
149
+ }>, SectionDefinitionOf<"visit", readonly ["card", "map", "split"], z.ZodMiniObject<{
150
+ showPhone: z.ZodMiniBoolean<boolean>;
151
+ }, z.core.$strip>, Record<never, never>>, SectionDefinitionOf<"story", readonly ["quote", "owner"], z.ZodMiniObject<{
152
+ body: z.ZodMiniObject<{
153
+ fr: z.ZodMiniOptional<z.ZodMiniString<string>>;
154
+ en: z.ZodMiniOptional<z.ZodMiniString<string>>;
155
+ }, z.core.$strip>;
156
+ }, z.core.$strip>, Record<never, never>>, SectionDefinitionOf<"social", readonly ["links", "facade"], z.ZodMiniObject<{}, z.core.$strip>, {
157
+ link: z.ZodMiniObject<{
158
+ platform: z.ZodMiniEnum<{
159
+ tiktok: "tiktok";
160
+ "youtube-shorts": "youtube-shorts";
161
+ instagram: "instagram";
162
+ }>;
163
+ url: z.ZodMiniString<string>;
164
+ }, z.core.$strip>;
165
+ }>, SectionDefinitionOf<"faq", readonly ["list"], z.ZodMiniObject<{}, z.core.$strip>, {
166
+ question: z.ZodMiniObject<{
167
+ question: z.ZodMiniObject<{
168
+ fr: z.ZodMiniOptional<z.ZodMiniString<string>>;
169
+ en: z.ZodMiniOptional<z.ZodMiniString<string>>;
170
+ }, z.core.$strip>;
171
+ answer: z.ZodMiniObject<{
172
+ fr: z.ZodMiniOptional<z.ZodMiniString<string>>;
173
+ en: z.ZodMiniOptional<z.ZodMiniString<string>>;
174
+ }, z.core.$strip>;
175
+ }, z.core.$strip>;
176
+ }>, SectionDefinitionOf<"policies", readonly ["inline"], z.ZodMiniObject<{
177
+ show: z.ZodMiniArray<z.ZodMiniEnum<{
178
+ cancellation: "cancellation";
179
+ prices: "prices";
180
+ "booking-window": "booking-window";
181
+ }>>;
182
+ }, z.core.$strip>, Record<never, never>>];
183
+ type SectionDefinition = (typeof SECTION_DEFINITIONS)[number];
184
+ type SectionType = SectionDefinition["type"];
185
+ declare const SECTION_TYPES: readonly SectionType[];
186
+ /** The definition of a type. */
187
+ declare function sectionDefinition<T extends SectionType>(type: T): Extract<SectionDefinition, {
188
+ type: T;
189
+ }>;
190
+
191
+ /** The version of the document's format; migrations are pure functions schema n → n + 1 (`migrate.ts`). */
192
+ declare const SHOP_SCHEMA_VERSION = 1;
193
+ /** A look preset by id and version (`@krizaka/tokens`): `salon-atelier`. The mode is the visitor's, never stored. */
194
+ declare const presetRef: z.ZodMiniObject<{
195
+ id: z.ZodMiniString<string>;
196
+ version: z.ZodMiniInt;
197
+ }, z.core.$strip>;
198
+ declare const shopPageSchema: z.ZodMiniObject<{
199
+ schema: z.ZodMiniLiteral<1>;
200
+ preset: z.ZodMiniObject<{
201
+ id: z.ZodMiniString<string>;
202
+ version: z.ZodMiniInt;
203
+ }, z.core.$strip>;
204
+ density: z.ZodMiniOptional<z.ZodMiniEnum<{
205
+ compact: "compact";
206
+ airy: "airy";
207
+ }>>;
208
+ accent: z.ZodMiniOptional<z.ZodMiniString<string>>;
209
+ sections: z.ZodMiniArray<z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<Readonly<{
210
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
211
+ }>, z.core.$strip>, ...z.ZodMiniObject<Readonly<{
212
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
213
+ }>, z.core.$strip>[]], "type">>;
214
+ }, z.core.$strip>;
215
+ /** A section of any type, as parsed: its `settings` and `blocks` are the type's own. */
216
+ type Section = z.output<(typeof SECTION_DEFINITIONS)[number]["schema"]>;
217
+ type ShopPage = {
218
+ schema: typeof SHOP_SCHEMA_VERSION;
219
+ preset: z.output<typeof presetRef>;
220
+ density?: "compact" | "airy" | undefined;
221
+ accent?: string | undefined;
222
+ sections: Section[];
223
+ };
224
+ type SectionOf<T extends SectionType> = Extract<Section, {
225
+ type: T;
226
+ }>;
227
+ type ShopPageIssue = {
228
+ path: string;
229
+ message: string;
230
+ };
231
+ type ShopPageResult = {
232
+ ok: true;
233
+ page: ShopPage;
234
+ } | {
235
+ ok: false;
236
+ issues: ShopPageIssue[];
237
+ };
238
+ /** Validates a document; an invalid one answers every issue with its path (`sections.2.variant`), for a 422. */
239
+ declare function parseShopPage(input: unknown): ShopPageResult;
240
+
241
+ export { SECTION_DEFINITIONS as b, SECTION_TYPES as c, SHOP_SCHEMA_VERSION as d, defineSection as k, shopPageSchema as l, parseShopPage as p, sectionDefinition as s };
242
+ export type { LocalizedText as L, ParsedSection as P, ShopPage as S, Section as a, SectionDefinition as e, SectionOf as f, SectionSpec as g, SectionType as h, ShopPageIssue as i, ShopPageResult as j };
@@ -0,0 +1,106 @@
1
+ import * as React from 'react';
2
+
3
+ /** What a field is drawn as. */
4
+ type SchemaFieldKind = "text" | "textarea" | "number" | "integer" | "boolean" | "select" | "date" | "money" | "list";
5
+ /** One field of the form, derived from a property of the schema. */
6
+ interface SchemaField {
7
+ key: string;
8
+ kind: SchemaFieldKind;
9
+ /** The title in the page's language (`x-i18n`), else the schema's `title`, else the key. */
10
+ title: string;
11
+ /** A line of help under the field. */
12
+ description: string | null;
13
+ /** An example of what to type. */
14
+ placeholder: string | null;
15
+ required: boolean;
16
+ /** `x-advanced`: folded under « more options ». */
17
+ advanced: boolean;
18
+ /** A closed list: `enum` or `oneOf` of `const`, with the labels of the language. */
19
+ options: {
20
+ value: string;
21
+ label: string;
22
+ }[] | null;
23
+ min: number | null;
24
+ max: number | null;
25
+ minLength: number | null;
26
+ maxLength: number | null;
27
+ maxItems: number | null;
28
+ pattern: string | null;
29
+ /** The ISO 4217 code of a `money` field (`x-money.currency`, default CAD). */
30
+ currency: string;
31
+ /** The value the form starts on, when the schema states one. */
32
+ defaultValue: unknown;
33
+ }
34
+ /** The fields of a JSON Schema object, in the schema's order. A property the form cannot draw (a nested object…) is left out. */
35
+ declare function fieldsFromSchema(schema: unknown, locale: string): SchemaField[];
36
+ /** The words of the checks, passed translated. `{min}`, `{max}` are filled. */
37
+ interface SchemaFormMessages {
38
+ required: string;
39
+ /** « At least {min} characters. » */
40
+ tooShort: string;
41
+ /** « At most {max} characters. » */
42
+ tooLong: string;
43
+ /** « Not below {min}. » */
44
+ belowMin: string;
45
+ /** « Not above {max}. » */
46
+ aboveMax: string;
47
+ /** « Not a number. » */
48
+ notANumber: string;
49
+ /** « Not in the expected form. » */
50
+ badPattern: string;
51
+ /** « At most {max} items. » */
52
+ tooMany: string;
53
+ }
54
+ /** A list typed as « a, b, c »: its items. */
55
+ declare const listItems: (text: string) => string[];
56
+ /** The raw answer of a field as the form holds it (a string, a boolean, or cents), checked against the schema's rules. Returns the message, or null. */
57
+ declare function checkField(field: SchemaField, value: unknown, m: SchemaFormMessages): string | null;
58
+ /** The messages of every field that fails; an empty object is a valid form. */
59
+ declare function checkValues(fields: readonly SchemaField[], values: Record<string, unknown>, m: SchemaFormMessages): Record<string, string>;
60
+ /** What a form holds at the start: the schema's defaults, then the given values. */
61
+ declare function initialValues(fields: readonly SchemaField[], given?: Record<string, unknown>): Record<string, unknown>;
62
+ /** The typed payload the host receives: numbers as numbers, lists as arrays, money as integer cents, empty answers left out. */
63
+ declare function payloadOf(fields: readonly SchemaField[], values: Record<string, unknown>): Record<string, unknown>;
64
+
65
+ /** What a custom field receives to draw itself. */
66
+ interface SchemaFieldContext {
67
+ /** An id to wire the label (`htmlFor`) and the description. */
68
+ id: string;
69
+ /** The raw answer: a string, a boolean, or integer cents for a money field. */
70
+ value: unknown;
71
+ setValue: (value: unknown) => void;
72
+ /** The refusal to show, or `null`. */
73
+ error: string | null;
74
+ disabled: boolean;
75
+ }
76
+ interface SchemaFormWords {
77
+ /** The submit button: « Run ». */
78
+ submit: string;
79
+ /** The fold of the `x-advanced` fields: « More options ». */
80
+ advanced: string;
81
+ }
82
+ interface SchemaFormProps extends Omit<React.ComponentProps<"form">, "onSubmit" | "children"> {
83
+ /** The JSON Schema object (or its JSON text): `properties`, `required`, `x-i18n`, `x-advanced`. */
84
+ schema: unknown;
85
+ /** BCP 47 language for the `x-i18n` words and the money: `"fr-CA"`. */
86
+ locale: string;
87
+ /** The words, passed translated. */
88
+ words: SchemaFormWords;
89
+ /** The checks' words, passed translated. */
90
+ messages: SchemaFormMessages;
91
+ /** Answers to start from, by field key (over the schema's defaults). */
92
+ values?: Record<string, unknown>;
93
+ /** Called with the typed payload once every field passes. */
94
+ onSubmit: (payload: Record<string, unknown>) => void;
95
+ /** The form is being submitted: the fields are blocked and the button shows progress (no second submit). */
96
+ submitting?: boolean;
97
+ /** Draws a field in the host's way (an upload, a picker); return `undefined` for the default. */
98
+ renderField?: (field: SchemaField, context: SchemaFieldContext) => React.ReactNode;
99
+ /** Beside the submit button: a cost line, a note. */
100
+ footer?: React.ReactNode;
101
+ }
102
+ /** A form from a JSON Schema: typed fields, the schema's rules, `x-i18n` words, `x-advanced` folded. */
103
+ declare function SchemaForm({ schema, locale, words, messages, values: given, onSubmit, submitting, renderField, footer, className, ...props }: Readonly<SchemaFormProps>): React.JSX.Element;
104
+
105
+ export { SchemaForm, checkField, checkValues, fieldsFromSchema, initialValues, listItems, payloadOf };
106
+ export type { SchemaField, SchemaFieldContext, SchemaFieldKind, SchemaFormMessages, SchemaFormProps, SchemaFormWords };