@krizaka/ui 3.69.0 → 3.71.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 (283) 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 +11 -0
  13. package/dist/chat.js +1 -1
  14. package/dist/chunk-2FCQCWIK.js +86 -0
  15. package/dist/chunk-2FCQCWIK.js.map +1 -0
  16. package/dist/chunk-3PRYL2LS.js +2 -0
  17. package/dist/chunk-3PRYL2LS.js.map +1 -0
  18. package/dist/{chunk-HK525THY.js → chunk-5MPPIGCB.js} +18 -7
  19. package/dist/chunk-5MPPIGCB.js.map +1 -0
  20. package/dist/{chunk-CSRKYZ53.js → chunk-CZHPWLNW.js} +1 -1
  21. package/dist/{chunk-PZ4FJOD5.js → chunk-HLEBSAGC.js} +5 -1
  22. package/dist/{chunk-PZ4FJOD5.js.map → chunk-HLEBSAGC.js.map} +1 -1
  23. package/dist/chunk-S4TLZRGZ.js +42 -0
  24. package/dist/chunk-S4TLZRGZ.js.map +1 -0
  25. package/dist/{chunk-EUJ7337V.js → chunk-TISDOZH3.js} +18 -7
  26. package/dist/chunk-TISDOZH3.js.map +1 -0
  27. package/dist/chunk-W64RAX4N.js +79 -0
  28. package/dist/chunk-W64RAX4N.js.map +1 -0
  29. package/dist/collection-switcher.d.ts +1 -1
  30. package/dist/confirm-button.js +5 -78
  31. package/dist/confirm-button.js.map +1 -1
  32. package/dist/{default-avatar-D9kiSFNB.d.ts → default-avatar-BL0nJFti.d.ts} +16 -0
  33. package/dist/entity-header.d.ts +1 -1
  34. package/dist/index.js +7 -7
  35. package/dist/kind-config-editor.js +3 -2
  36. package/dist/kind-config-editor.js.map +1 -1
  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 +74 -57
  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/proposal.d.ts +81 -0
  55. package/dist/proposal.js +71 -0
  56. package/dist/proposal.js.map +1 -0
  57. package/dist/schema-form.d.ts +106 -0
  58. package/dist/schema-form.js +268 -0
  59. package/dist/schema-form.js.map +1 -0
  60. package/dist/shop/map-gate.d.ts +1 -1
  61. package/dist/shop/map-gate.js +1 -1
  62. package/dist/shop/map-gate.js.map +1 -1
  63. package/dist/status-chip.js +16 -43
  64. package/dist/status-chip.js.map +1 -1
  65. package/dist/switch.js +2 -1
  66. package/dist/vertical-video.js +1 -1
  67. package/dist/wall.d.ts +7 -1
  68. package/dist/wall.js +5 -4
  69. package/dist/wall.js.map +1 -1
  70. package/package.json +51 -6
  71. package/registry/account-menu.json +1 -1
  72. package/registry/account-settings.json +1 -1
  73. package/registry/achievement.json +1 -1
  74. package/registry/action-bar.json +1 -1
  75. package/registry/activity-feed.json +1 -1
  76. package/registry/agenda.json +1 -1
  77. package/registry/alert.json +1 -1
  78. package/registry/analysis-report.json +1 -1
  79. package/registry/anatomy-plate.json +1 -1
  80. package/registry/app-frame.json +2 -2
  81. package/registry/app-header.json +1 -1
  82. package/registry/app-shell.json +1 -1
  83. package/registry/argument-card.json +1 -1
  84. package/registry/audio-player.json +1 -1
  85. package/registry/auth-layout.json +1 -1
  86. package/registry/avatar.json +4 -4
  87. package/registry/badge.json +1 -1
  88. package/registry/bird-plate.json +1 -1
  89. package/registry/button.json +1 -1
  90. package/registry/captcha.json +1 -1
  91. package/registry/card-grid.json +1 -1
  92. package/registry/card.json +1 -1
  93. package/registry/catalogue-page.json +1 -1
  94. package/registry/changelog-page.json +1 -1
  95. package/registry/chapter.json +1 -1
  96. package/registry/chat.json +1 -1
  97. package/registry/checkbox.json +1 -1
  98. package/registry/chip-link.json +1 -1
  99. package/registry/chip-row.json +1 -1
  100. package/registry/chip.json +1 -1
  101. package/registry/choice-grid.json +1 -1
  102. package/registry/code-block.json +1 -1
  103. package/registry/collection-switcher.json +1 -1
  104. package/registry/combobox.json +1 -1
  105. package/registry/command.json +1 -1
  106. package/registry/comparison-table.json +1 -1
  107. package/registry/component-page.json +1 -1
  108. package/registry/confirm-button.json +1 -1
  109. package/registry/contact-page.json +1 -1
  110. package/registry/continue-prompt.json +1 -1
  111. package/registry/copy-button.json +1 -1
  112. package/registry/countdown.json +1 -1
  113. package/registry/cover-hero.json +1 -1
  114. package/registry/cta-panel.json +1 -1
  115. package/registry/dashboard-layout.json +1 -1
  116. package/registry/data-table.json +1 -1
  117. package/registry/date-picker.json +1 -1
  118. package/registry/decision-list.json +1 -1
  119. package/registry/description-list.json +1 -1
  120. package/registry/desktop-window.json +1 -1
  121. package/registry/detail-layout.json +1 -1
  122. package/registry/dialog.json +1 -1
  123. package/registry/docs-article-page.json +1 -1
  124. package/registry/docs-hub-page.json +1 -1
  125. package/registry/docs-layout.json +1 -1
  126. package/registry/docs-nav.json +1 -1
  127. package/registry/document-viewer.json +1 -1
  128. package/registry/doodle.json +1 -1
  129. package/registry/drop-overlay.json +1 -1
  130. package/registry/dropdown-menu.json +1 -1
  131. package/registry/elephant.json +2 -2
  132. package/registry/embed-facade.json +1 -1
  133. package/registry/empty-state.json +1 -1
  134. package/registry/engine-flow.json +1 -1
  135. package/registry/entity-header.json +1 -1
  136. package/registry/environment-notice.json +1 -1
  137. package/registry/error-page.json +1 -1
  138. package/registry/examples/price-catalogue-editor/default.d.ts +4 -0
  139. package/registry/examples/price-catalogue-editor/default.js +47 -0
  140. package/registry/examples/price-catalogue-editor/default.tsx +25 -0
  141. package/registry/examples/proposal/default.d.ts +4 -0
  142. package/registry/examples/proposal/default.js +30 -0
  143. package/registry/examples/proposal/default.tsx +24 -0
  144. package/registry/examples/schema-form/default.d.ts +4 -0
  145. package/registry/examples/schema-form/default.js +29 -0
  146. package/registry/examples/schema-form/default.tsx +27 -0
  147. package/registry/examples/wall/pinned-note.js +2 -1
  148. package/registry/examples/wall/pinned-note.tsx +2 -1
  149. package/registry/field.json +1 -1
  150. package/registry/file-upload.json +1 -1
  151. package/registry/filter-bar.json +1 -1
  152. package/registry/flock.json +1 -1
  153. package/registry/footnote.json +1 -1
  154. package/registry/force-update-screen.json +1 -1
  155. package/registry/form.json +1 -1
  156. package/registry/gallery-page.json +1 -1
  157. package/registry/genui.json +1 -1
  158. package/registry/glossary-term.json +1 -1
  159. package/registry/glossary.json +1 -1
  160. package/registry/glow-card.json +1 -1
  161. package/registry/goal-gauge.json +1 -1
  162. package/registry/grade-stamp.json +1 -1
  163. package/registry/how-it-works-page.json +1 -1
  164. package/registry/image-cropper.json +1 -1
  165. package/registry/index.json +114 -8
  166. package/registry/iso.json +1 -1
  167. package/registry/kanban.json +1 -1
  168. package/registry/kbd.json +1 -1
  169. package/registry/kind-config-editor.json +1 -1
  170. package/registry/kpi-explained.json +1 -1
  171. package/registry/landing-page.json +1 -1
  172. package/registry/landscape.json +1 -1
  173. package/registry/language-switch.json +1 -1
  174. package/registry/legal-page.json +1 -1
  175. package/registry/link-card.json +1 -1
  176. package/registry/list.json +1 -1
  177. package/registry/loader.json +1 -1
  178. package/registry/longform-page.json +1 -1
  179. package/registry/maintenance-screen.json +1 -1
  180. package/registry/map.json +2 -2
  181. package/registry/margin-layout.json +1 -1
  182. package/registry/markdown.json +1 -1
  183. package/registry/marketing-layout.json +1 -1
  184. package/registry/marquee.json +1 -1
  185. package/registry/mascot-quote.json +1 -1
  186. package/registry/mascot-state.json +1 -1
  187. package/registry/mascots.json +1 -1
  188. package/registry/match-dialog.json +1 -1
  189. package/registry/media-capture.json +1 -1
  190. package/registry/media-gallery.json +1 -1
  191. package/registry/media-grid.json +1 -1
  192. package/registry/meta-row.json +1 -1
  193. package/registry/meter.json +1 -1
  194. package/registry/money-input.json +1 -1
  195. package/registry/nav-bar.json +30 -6
  196. package/registry/next-actions.json +1 -1
  197. package/registry/notification-preferences.json +1 -1
  198. package/registry/number-ticker.json +1 -1
  199. package/registry/opening-hours.json +1 -1
  200. package/registry/page-header.json +1 -1
  201. package/registry/page-hero.json +1 -1
  202. package/registry/page-index.json +1 -1
  203. package/registry/page.json +1 -1
  204. package/registry/pagination.json +1 -1
  205. package/registry/photo-grid.json +1 -1
  206. package/registry/pointer-light.json +1 -1
  207. package/registry/popover.json +1 -1
  208. package/registry/price-catalogue-editor.json +228 -0
  209. package/registry/pricing-page.json +1 -1
  210. package/registry/product-page.json +1 -1
  211. package/registry/profile-card.json +1 -1
  212. package/registry/progress.json +1 -1
  213. package/registry/promise-card.json +1 -1
  214. package/registry/promo-code-field.json +1 -1
  215. package/registry/proposal.json +353 -0
  216. package/registry/qr-code.json +1 -1
  217. package/registry/quota-meter.json +1 -1
  218. package/registry/radio-group.json +1 -1
  219. package/registry/rail-nav.json +2 -2
  220. package/registry/recipes.json +1 -1
  221. package/registry/retro-tv.json +1 -1
  222. package/registry/reviews.json +1 -1
  223. package/registry/router.json +1 -1
  224. package/registry/schema-form.json +253 -0
  225. package/registry/scroll-stage.json +1 -1
  226. package/registry/search-field.json +1 -1
  227. package/registry/section-backdrop.json +1 -1
  228. package/registry/separator.json +1 -1
  229. package/registry/service-card.json +1 -1
  230. package/registry/settings-layout.json +1 -1
  231. package/registry/shop-composer.json +1 -1
  232. package/registry/shop-gallery.json +1 -1
  233. package/registry/shop.json +3 -3
  234. package/registry/showcase.json +1 -1
  235. package/registry/signature.json +1 -1
  236. package/registry/site-cahier.json +1 -1
  237. package/registry/site-footer.json +2 -2
  238. package/registry/sites.json +1 -1
  239. package/registry/skeleton.json +1 -1
  240. package/registry/skip-link.json +1 -1
  241. package/registry/slider.json +1 -1
  242. package/registry/slot-picker.json +1 -1
  243. package/registry/slot.json +1 -1
  244. package/registry/specimen-tag.json +1 -1
  245. package/registry/speed-lines.json +1 -1
  246. package/registry/spinner.json +1 -1
  247. package/registry/split-view.json +1 -1
  248. package/registry/stage-banner.json +1 -1
  249. package/registry/stat.json +1 -1
  250. package/registry/status-chip.json +1 -1
  251. package/registry/status-page.json +1 -1
  252. package/registry/step-progress.json +1 -1
  253. package/registry/step-showcase.json +1 -1
  254. package/registry/stepper.json +1 -1
  255. package/registry/sticky-action.json +1 -1
  256. package/registry/stuck.json +1 -1
  257. package/registry/swipe-deck.json +1 -1
  258. package/registry/switch.json +1 -1
  259. package/registry/tabs.json +1 -1
  260. package/registry/tag-input.json +1 -1
  261. package/registry/tag-selector.json +1 -1
  262. package/registry/taped-photo.json +1 -1
  263. package/registry/terminal-replay.json +1 -1
  264. package/registry/text-style.json +1 -1
  265. package/registry/theme.json +1 -1
  266. package/registry/toast.json +1 -1
  267. package/registry/toc.json +1 -1
  268. package/registry/tooltip.json +1 -1
  269. package/registry/tree-view.json +1 -1
  270. package/registry/update-prompt.json +1 -1
  271. package/registry/upload-queue.json +1 -1
  272. package/registry/usage.json +1 -1
  273. package/registry/verified-badge.json +1 -1
  274. package/registry/versus-card.json +1 -1
  275. package/registry/vertical-video.json +1 -1
  276. package/registry/video-player.json +1 -1
  277. package/registry/video-trimmer.json +1 -1
  278. package/registry/virtual.json +1 -1
  279. package/registry/wall.json +47 -4
  280. package/registry/waveform.json +1 -1
  281. package/dist/chunk-EUJ7337V.js.map +0 -1
  282. package/dist/chunk-HK525THY.js.map +0 -1
  283. /package/dist/{chunk-CSRKYZ53.js.map → chunk-CZHPWLNW.js.map} +0 -0
@@ -0,0 +1,268 @@
1
+ "use client";
2
+ import {
3
+ MoneyInput
4
+ } from "./chunk-W64RAX4N.js";
5
+ import {
6
+ Field,
7
+ Input,
8
+ Select,
9
+ Textarea
10
+ } from "./chunk-HLEBSAGC.js";
11
+ import {
12
+ Switch
13
+ } from "./chunk-CZHPWLNW.js";
14
+ import {
15
+ Button
16
+ } from "./chunk-V7W4RLRW.js";
17
+ import "./chunk-D3T54RSL.js";
18
+ import "./chunk-WEVYKZIF.js";
19
+ import {
20
+ cn
21
+ } from "./chunk-NSLXEDIS.js";
22
+
23
+ // src/schema-form/schema.ts
24
+ var MULTILINE_OVER = 500;
25
+ var obj = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : null;
26
+ var str = (v) => typeof v === "string" && v.trim() !== "" ? v : null;
27
+ var num = (v) => typeof v === "number" && Number.isFinite(v) ? v : null;
28
+ function wordsFor(i18n, locale) {
29
+ const by = obj(i18n);
30
+ if (!by) return null;
31
+ return obj(by[locale]) ?? obj(by[locale.split("-")[0] ?? ""]) ?? obj(by.en);
32
+ }
33
+ function optionsOf(spec, words) {
34
+ const label = (value) => {
35
+ const w = words?.options?.[value];
36
+ return typeof w === "string" ? w : w?.label ?? null;
37
+ };
38
+ if (Array.isArray(spec.enum)) return spec.enum.map(String).map((value) => ({ value, label: label(value) ?? value }));
39
+ const one = spec.oneOf;
40
+ if (Array.isArray(one) && one.length > 0 && one.every((e) => obj(e) && "const" in e)) {
41
+ return one.map((e) => ({ value: String(e.const), label: label(String(e.const)) ?? str(e.title) ?? String(e.const) }));
42
+ }
43
+ return null;
44
+ }
45
+ function kindOf(spec, options) {
46
+ const items = obj(spec.items);
47
+ if (options) return "select";
48
+ if (spec["x-money"] || spec.format === "money") return "money";
49
+ switch (spec.type) {
50
+ case "boolean":
51
+ return "boolean";
52
+ case "integer":
53
+ return "integer";
54
+ case "number":
55
+ return "number";
56
+ case "array":
57
+ return items && (items.type === void 0 || items.type === "string") ? "list" : null;
58
+ case "string":
59
+ case void 0:
60
+ if (spec.format === "date") return "date";
61
+ return (num(spec.maxLength) ?? 0) > MULTILINE_OVER ? "textarea" : "text";
62
+ default:
63
+ return null;
64
+ }
65
+ }
66
+ function fieldsFromSchema(schema, locale) {
67
+ let root = obj(schema);
68
+ if (typeof schema === "string") {
69
+ try {
70
+ root = obj(JSON.parse(schema));
71
+ } catch {
72
+ root = null;
73
+ }
74
+ }
75
+ const properties = obj(root?.properties);
76
+ if (!properties) return [];
77
+ const required = new Set(Array.isArray(root?.required) ? root.required.map(String) : []);
78
+ const fields = [];
79
+ for (const [key, raw] of Object.entries(properties)) {
80
+ const spec = obj(raw);
81
+ if (!spec) continue;
82
+ const words = wordsFor(spec["x-i18n"], locale);
83
+ const options = optionsOf(spec, words);
84
+ const kind = kindOf(spec, options);
85
+ if (!kind) continue;
86
+ fields.push({
87
+ key,
88
+ kind,
89
+ title: words?.title ?? str(spec.title) ?? key,
90
+ description: words?.description ?? str(spec.description),
91
+ placeholder: words?.placeholder ?? null,
92
+ required: required.has(key),
93
+ advanced: spec["x-advanced"] === true,
94
+ options,
95
+ min: num(spec.minimum),
96
+ max: num(spec.maximum),
97
+ minLength: num(spec.minLength),
98
+ maxLength: num(spec.maxLength),
99
+ maxItems: num(spec.maxItems),
100
+ pattern: str(spec.pattern),
101
+ currency: str(obj(spec["x-money"])?.currency) ?? "CAD",
102
+ defaultValue: spec.default ?? null
103
+ });
104
+ }
105
+ return fields;
106
+ }
107
+ var fill = (template, vars) => template.replace(/\{(\w+)\}/g, (_, k) => String(vars[k] ?? ""));
108
+ var listItems = (text) => text.split(",").map((s) => s.trim()).filter(Boolean);
109
+ var asNumber = (text) => Number(text.replace(",", "."));
110
+ function checkNumber(field, text, m) {
111
+ const n = asNumber(text);
112
+ if (!Number.isFinite(n) || field.kind === "integer" && !Number.isInteger(n)) return m.notANumber;
113
+ if (field.min !== null && n < field.min) return fill(m.belowMin, { min: field.min });
114
+ if (field.max !== null && n > field.max) return fill(m.aboveMax, { max: field.max });
115
+ return null;
116
+ }
117
+ function checkText(field, text, m) {
118
+ if (field.minLength !== null && text.length < field.minLength) return fill(m.tooShort, { min: field.minLength });
119
+ if (field.maxLength !== null && text.length > field.maxLength) return fill(m.tooLong, { max: field.maxLength });
120
+ if (field.pattern !== null && !new RegExp(field.pattern, "u").test(text)) return m.badPattern;
121
+ return null;
122
+ }
123
+ function checkField(field, value, m) {
124
+ if (field.kind === "boolean") return null;
125
+ const empty = field.kind === "money" ? value === null || value === void 0 : textOf(value) === "";
126
+ if (empty) return field.required ? m.required : null;
127
+ if (field.kind === "money") return null;
128
+ const text = textOf(value);
129
+ if (field.kind === "number" || field.kind === "integer") return checkNumber(field, text, m);
130
+ if (field.kind === "list") return field.maxItems !== null && listItems(text).length > field.maxItems ? fill(m.tooMany, { max: field.maxItems }) : null;
131
+ return checkText(field, text, m);
132
+ }
133
+ function checkValues(fields, values, m) {
134
+ const errors = {};
135
+ for (const field of fields) {
136
+ const message = checkField(field, values[field.key], m);
137
+ if (message) errors[field.key] = message;
138
+ }
139
+ return errors;
140
+ }
141
+ var textOf = (v) => typeof v === "string" ? v.trim() : "";
142
+ function startOf(f, v) {
143
+ if (f.kind === "boolean") return v === true;
144
+ if (f.kind === "money") return typeof v === "number" ? v : null;
145
+ if (f.kind === "list" && Array.isArray(v)) return v.join(", ");
146
+ if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") return String(v);
147
+ return "";
148
+ }
149
+ function initialValues(fields, given = {}) {
150
+ return Object.fromEntries(fields.map((f) => [f.key, startOf(f, given[f.key] ?? f.defaultValue)]));
151
+ }
152
+ function typed(f, text) {
153
+ if (f.kind === "number" || f.kind === "integer") return asNumber(text);
154
+ return f.kind === "list" ? listItems(text) : text;
155
+ }
156
+ function payloadOf(fields, values) {
157
+ const out = {};
158
+ for (const f of fields) {
159
+ const v = values[f.key];
160
+ if (f.kind === "boolean") out[f.key] = v === true;
161
+ else if (f.kind === "money") {
162
+ if (typeof v === "number") out[f.key] = v;
163
+ } else if (textOf(v) !== "") out[f.key] = typed(f, textOf(v));
164
+ }
165
+ return out;
166
+ }
167
+
168
+ // src/schema-form/schema-form.tsx
169
+ import * as React from "react";
170
+ import { jsx, jsxs } from "react/jsx-runtime";
171
+ function FieldControl({ field, ctx, locale }) {
172
+ const { id, value, setValue, error, disabled } = ctx;
173
+ const describedBy = [field.description ? `${id}-help` : null, error ? `${id}-error` : null].filter(Boolean).join(" ") || void 0;
174
+ const common = { id, disabled, "aria-describedby": describedBy, "aria-required": field.required || void 0 };
175
+ const text = typeof value === "string" ? value : "";
176
+ switch (field.kind) {
177
+ case "boolean":
178
+ return /* @__PURE__ */ jsx(Switch, { id, disabled, "aria-describedby": describedBy, checked: value === true, onCheckedChange: setValue });
179
+ case "select":
180
+ return /* @__PURE__ */ jsxs(Select, { ...common, invalid: !!error, value: text, onChange: (e) => setValue(e.target.value), children: [
181
+ !field.required && /* @__PURE__ */ jsx("option", { value: "" }),
182
+ field.options?.map((o) => /* @__PURE__ */ jsx("option", { value: o.value, children: o.label }, o.value))
183
+ ] });
184
+ case "textarea":
185
+ return /* @__PURE__ */ jsx(Textarea, { ...common, invalid: !!error, value: text, maxLength: field.maxLength ?? void 0, placeholder: field.placeholder ?? void 0, onChange: (e) => setValue(e.target.value) });
186
+ case "money":
187
+ return /* @__PURE__ */ jsx(MoneyInput, { ...common, invalid: !!error, value: typeof value === "number" ? value : null, onValueChange: setValue, currency: field.currency, locale });
188
+ case "number":
189
+ case "integer":
190
+ return /* @__PURE__ */ jsx(Input, { ...common, invalid: !!error, type: "text", inputMode: field.kind === "integer" ? "numeric" : "decimal", value: text, placeholder: field.placeholder ?? void 0, onChange: (e) => setValue(e.target.value) });
191
+ case "date":
192
+ return /* @__PURE__ */ jsx(Input, { ...common, invalid: !!error, type: "date", value: text, onChange: (e) => setValue(e.target.value) });
193
+ default:
194
+ return /* @__PURE__ */ jsx(Input, { ...common, invalid: !!error, type: "text", value: text, maxLength: field.maxLength ?? void 0, placeholder: field.placeholder ?? void 0, onChange: (e) => setValue(e.target.value) });
195
+ }
196
+ }
197
+ function SchemaForm({ schema, locale, words, messages, values: given, onSubmit, submitting = false, renderField, footer, className, ...props }) {
198
+ const base = React.useId();
199
+ const fields = React.useMemo(() => fieldsFromSchema(schema, locale), [schema, locale]);
200
+ const [answers, setAnswers] = React.useState(() => initialValues(fields, given));
201
+ const [shown, setShown] = React.useState(() => /* @__PURE__ */ new Set());
202
+ const errors = React.useMemo(() => checkValues(fields, answers, messages), [fields, answers, messages]);
203
+ const formRef = React.useRef(null);
204
+ const draw = (field) => {
205
+ const id = `${base}-${field.key}`;
206
+ const error = shown.has(field.key) ? errors[field.key] ?? null : null;
207
+ const ctx = { id, value: answers[field.key], setValue: (v) => setAnswers((a) => ({ ...a, [field.key]: v })), error, disabled: submitting };
208
+ const custom = renderField?.(field, ctx);
209
+ const inline = field.kind === "boolean";
210
+ return /* @__PURE__ */ jsxs(Field.Root, { "data-field": field.key, "data-kind": field.kind, onBlur: () => setShown((s) => s.has(field.key) ? s : new Set(s).add(field.key)), children: [
211
+ /* @__PURE__ */ jsxs("div", { className: cn(inline && "flex items-center justify-between gap-3"), children: [
212
+ /* @__PURE__ */ jsxs(Field.Label, { htmlFor: id, children: [
213
+ field.title,
214
+ field.required && /* @__PURE__ */ jsx("span", { "aria-hidden": true, children: " *" })
215
+ ] }),
216
+ inline && (custom ?? /* @__PURE__ */ jsx(FieldControl, { field, ctx, locale }))
217
+ ] }),
218
+ !inline && (custom ?? /* @__PURE__ */ jsx(FieldControl, { field, ctx, locale })),
219
+ field.description && /* @__PURE__ */ jsx(Field.Hint, { id: `${id}-help`, children: field.description }),
220
+ error && /* @__PURE__ */ jsx(Field.Error, { id: `${id}-error`, children: error })
221
+ ] }, field.key);
222
+ };
223
+ const main = fields.filter((f) => !f.advanced);
224
+ const more = fields.filter((f) => f.advanced);
225
+ return /* @__PURE__ */ jsxs(
226
+ "form",
227
+ {
228
+ ref: formRef,
229
+ noValidate: true,
230
+ "data-schema-form": "",
231
+ className: cn("flex flex-col gap-4", className),
232
+ onSubmit: (event) => {
233
+ event.preventDefault();
234
+ if (submitting) return;
235
+ const failing = Object.keys(errors);
236
+ if (failing.length > 0) {
237
+ setShown(new Set(fields.map((f) => f.key)));
238
+ const first = fields.find((f) => errors[f.key]);
239
+ if (first) formRef.current?.querySelector(`[data-field="${first.key}"] :is(input,select,textarea,button[role=switch])`)?.focus();
240
+ return;
241
+ }
242
+ onSubmit(payloadOf(fields, answers));
243
+ },
244
+ ...props,
245
+ children: [
246
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-3", children: main.map(draw) }),
247
+ more.length > 0 && /* @__PURE__ */ jsxs("details", { className: "rounded-lg border border-border px-3 py-2", open: more.some((f) => shown.has(f.key) && errors[f.key]) || void 0, children: [
248
+ /* @__PURE__ */ jsx("summary", { className: "cursor-pointer select-none text-sm font-medium text-fg-secondary", children: words.advanced }),
249
+ /* @__PURE__ */ jsx("div", { className: "mt-3 flex flex-col gap-3", children: more.map(draw) })
250
+ ] }),
251
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-between gap-3", children: [
252
+ /* @__PURE__ */ jsx("div", { className: "min-w-0 text-xs text-fg-secondary", children: footer }),
253
+ /* @__PURE__ */ jsx(Button, { type: "submit", variant: "primary", size: "md", loading: submitting, children: words.submit })
254
+ ] })
255
+ ]
256
+ }
257
+ );
258
+ }
259
+ export {
260
+ SchemaForm,
261
+ checkField,
262
+ checkValues,
263
+ fieldsFromSchema,
264
+ initialValues,
265
+ listItems,
266
+ payloadOf
267
+ };
268
+ //# sourceMappingURL=schema-form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schema-form/schema.ts","../src/schema-form/schema-form.tsx"],"sourcesContent":["// Pure: no React, no clock. A JSON Schema (an object of properties) read into the fields a form draws, and the checks that\n// the schema states. Extracted from Orazaka's run form (`useInputSchema`): the same vocabulary — `required`, `enum` and\n// `oneOf` of `const`, `x-i18n` words by language, `x-advanced` folded — without the studio's own parts.\n\n/** What a field is drawn as. */\nexport type SchemaFieldKind = \"text\" | \"textarea\" | \"number\" | \"integer\" | \"boolean\" | \"select\" | \"date\" | \"money\" | \"list\";\n\n/** One field of the form, derived from a property of the schema. */\nexport interface SchemaField {\n key: string;\n kind: SchemaFieldKind;\n /** The title in the page's language (`x-i18n`), else the schema's `title`, else the key. */\n title: string;\n /** A line of help under the field. */\n description: string | null;\n /** An example of what to type. */\n placeholder: string | null;\n required: boolean;\n /** `x-advanced`: folded under « more options ». */\n advanced: boolean;\n /** A closed list: `enum` or `oneOf` of `const`, with the labels of the language. */\n options: { value: string; label: string }[] | null;\n min: number | null;\n max: number | null;\n minLength: number | null;\n maxLength: number | null;\n maxItems: number | null;\n pattern: string | null;\n /** The ISO 4217 code of a `money` field (`x-money.currency`, default CAD). */\n currency: string;\n /** The value the form starts on, when the schema states one. */\n defaultValue: unknown;\n}\n\ninterface Words {\n title?: string;\n description?: string;\n placeholder?: string;\n options?: Record<string, string | { label?: string }>;\n}\ntype Raw = Record<string, unknown>;\n\n// @fixed: the schema's own threshold between a line and a text area (Orazaka's studio form: over 500 characters)\nconst MULTILINE_OVER = 500;\n\nconst obj = (v: unknown): Raw | null => (v && typeof v === \"object\" && !Array.isArray(v) ? (v as Raw) : null);\nconst str = (v: unknown) => (typeof v === \"string\" && v.trim() !== \"\" ? v : null);\nconst num = (v: unknown) => (typeof v === \"number\" && Number.isFinite(v) ? v : null);\n\n/** The words of a language: that language (`fr-CA` → `fr`), else English, else nothing. */\nfunction wordsFor(i18n: unknown, locale: string): Words | null {\n const by = obj(i18n);\n if (!by) return null;\n return (obj(by[locale]) ?? obj(by[locale.split(\"-\")[0] ?? \"\"]) ?? obj(by.en)) as Words | null;\n}\n\nfunction optionsOf(spec: Raw, words: Words | null): SchemaField[\"options\"] {\n const label = (value: string) => {\n const w = words?.options?.[value];\n return typeof w === \"string\" ? w : (w?.label ?? null);\n };\n if (Array.isArray(spec.enum)) return spec.enum.map(String).map((value) => ({ value, label: label(value) ?? value }));\n const one = spec.oneOf;\n if (Array.isArray(one) && one.length > 0 && one.every((e) => obj(e) && \"const\" in (e as Raw))) {\n return (one as Raw[]).map((e) => ({ value: String(e.const), label: label(String(e.const)) ?? str(e.title) ?? String(e.const) }));\n }\n return null;\n}\n\nfunction kindOf(spec: Raw, options: SchemaField[\"options\"]): SchemaFieldKind | null {\n const items = obj(spec.items);\n if (options) return \"select\";\n if (spec[\"x-money\"] || spec.format === \"money\") return \"money\";\n switch (spec.type) {\n case \"boolean\":\n return \"boolean\";\n case \"integer\":\n return \"integer\";\n case \"number\":\n return \"number\";\n case \"array\":\n return items && (items.type === undefined || items.type === \"string\") ? \"list\" : null;\n case \"string\":\n case undefined:\n if (spec.format === \"date\") return \"date\";\n return (num(spec.maxLength) ?? 0) > MULTILINE_OVER ? \"textarea\" : \"text\";\n default:\n return null;\n }\n}\n\n/** The fields of a JSON Schema object, in the schema's order. A property the form cannot draw (a nested object…) is left out. */\nexport function fieldsFromSchema(schema: unknown, locale: string): SchemaField[] {\n let root = obj(schema);\n if (typeof schema === \"string\") {\n try {\n root = obj(JSON.parse(schema));\n } catch {\n root = null;\n }\n }\n const properties = obj(root?.properties);\n if (!properties) return [];\n const required = new Set(Array.isArray(root?.required) ? root.required.map(String) : []);\n const fields: SchemaField[] = [];\n for (const [key, raw] of Object.entries(properties)) {\n const spec = obj(raw);\n if (!spec) continue;\n const words = wordsFor(spec[\"x-i18n\"], locale);\n const options = optionsOf(spec, words);\n const kind = kindOf(spec, options);\n if (!kind) continue;\n fields.push({\n key,\n kind,\n title: words?.title ?? str(spec.title) ?? key,\n description: words?.description ?? str(spec.description),\n placeholder: words?.placeholder ?? null,\n required: required.has(key),\n advanced: spec[\"x-advanced\"] === true,\n options,\n min: num(spec.minimum),\n max: num(spec.maximum),\n minLength: num(spec.minLength),\n maxLength: num(spec.maxLength),\n maxItems: num(spec.maxItems),\n pattern: str(spec.pattern),\n currency: str(obj(spec[\"x-money\"])?.currency) ?? \"CAD\",\n defaultValue: spec.default ?? null,\n });\n }\n return fields;\n}\n\n/** The words of the checks, passed translated. `{min}`, `{max}` are filled. */\nexport interface SchemaFormMessages {\n required: string;\n /** « At least {min} characters. » */\n tooShort: string;\n /** « At most {max} characters. » */\n tooLong: string;\n /** « Not below {min}. » */\n belowMin: string;\n /** « Not above {max}. » */\n aboveMax: string;\n /** « Not a number. » */\n notANumber: string;\n /** « Not in the expected form. » */\n badPattern: string;\n /** « At most {max} items. » */\n tooMany: string;\n}\n\nconst fill = (template: string, vars: Record<string, number>) => template.replace(/\\{(\\w+)\\}/g, (_, k: string) => String(vars[k] ?? \"\"));\n\n/** A list typed as « a, b, c »: its items. */\nexport const listItems = (text: string) => text.split(\",\").map((s) => s.trim()).filter(Boolean);\n\nconst asNumber = (text: string) => Number(text.replace(\",\", \".\"));\n\nfunction checkNumber(field: SchemaField, text: string, m: SchemaFormMessages): string | null {\n const n = asNumber(text);\n if (!Number.isFinite(n) || (field.kind === \"integer\" && !Number.isInteger(n))) return m.notANumber;\n if (field.min !== null && n < field.min) return fill(m.belowMin, { min: field.min });\n if (field.max !== null && n > field.max) return fill(m.aboveMax, { max: field.max });\n return null;\n}\n\nfunction checkText(field: SchemaField, text: string, m: SchemaFormMessages): string | null {\n if (field.minLength !== null && text.length < field.minLength) return fill(m.tooShort, { min: field.minLength });\n if (field.maxLength !== null && text.length > field.maxLength) return fill(m.tooLong, { max: field.maxLength });\n if (field.pattern !== null && !new RegExp(field.pattern, \"u\").test(text)) return m.badPattern;\n return null;\n}\n\n/** 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. */\nexport function checkField(field: SchemaField, value: unknown, m: SchemaFormMessages): string | null {\n if (field.kind === \"boolean\") return null;\n const empty = field.kind === \"money\" ? value === null || value === undefined : textOf(value) === \"\";\n if (empty) return field.required ? m.required : null;\n if (field.kind === \"money\") return null;\n const text = textOf(value);\n if (field.kind === \"number\" || field.kind === \"integer\") return checkNumber(field, text, m);\n if (field.kind === \"list\") return field.maxItems !== null && listItems(text).length > field.maxItems ? fill(m.tooMany, { max: field.maxItems }) : null;\n return checkText(field, text, m);\n}\n\n/** The messages of every field that fails; an empty object is a valid form. */\nexport function checkValues(fields: readonly SchemaField[], values: Record<string, unknown>, m: SchemaFormMessages): Record<string, string> {\n const errors: Record<string, string> = {};\n for (const field of fields) {\n const message = checkField(field, values[field.key], m);\n if (message) errors[field.key] = message;\n }\n return errors;\n}\n\nconst textOf = (v: unknown) => (typeof v === \"string\" ? v.trim() : \"\");\n\n/** The answer a field starts on, from what was given or the schema's default. */\nfunction startOf(f: SchemaField, v: unknown): unknown {\n if (f.kind === \"boolean\") return v === true;\n if (f.kind === \"money\") return typeof v === \"number\" ? v : null;\n if (f.kind === \"list\" && Array.isArray(v)) return v.join(\", \");\n if (typeof v === \"string\" || typeof v === \"number\" || typeof v === \"boolean\") return String(v);\n return \"\";\n}\n\n/** What a form holds at the start: the schema's defaults, then the given values. */\nexport function initialValues(fields: readonly SchemaField[], given: Record<string, unknown> = {}): Record<string, unknown> {\n return Object.fromEntries(fields.map((f) => [f.key, startOf(f, given[f.key] ?? f.defaultValue)]));\n}\n\n/** The typed value of a non-empty answer. */\nfunction typed(f: SchemaField, text: string): unknown {\n if (f.kind === \"number\" || f.kind === \"integer\") return asNumber(text);\n return f.kind === \"list\" ? listItems(text) : text;\n}\n\n/** The typed payload the host receives: numbers as numbers, lists as arrays, money as integer cents, empty answers left out. */\nexport function payloadOf(fields: readonly SchemaField[], values: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const f of fields) {\n const v = values[f.key];\n if (f.kind === \"boolean\") out[f.key] = v === true;\n else if (f.kind === \"money\") {\n if (typeof v === \"number\") out[f.key] = v;\n } else if (textOf(v) !== \"\") out[f.key] = typed(f, textOf(v));\n }\n return out;\n}\n","\"use client\";\n// Client (the answers, what has been touched). A form drawn from a JSON Schema: the fields come from `fieldsFromSchema`\n// (pure), are drawn on the package's own fields (`Field`, `Input`, `Select`, `Textarea`, `Switch`, `MoneyInput`), checked\n// by the schema's rules, and handed to the host as a typed payload. The host keeps what is its own — uploads, pickers —\n// through `renderField`. Words are props; the block never fetches and never reads the clock.\nimport * as React from \"react\";\n\nimport { Button } from \"../button/button\";\nimport { cn } from \"../cn\";\nimport { Field, Input, Select, Textarea } from \"../field/field\";\nimport { MoneyInput } from \"../money-input/money-input\";\nimport { Switch } from \"../switch/switch\";\nimport { checkValues, fieldsFromSchema, initialValues, payloadOf, type SchemaField, type SchemaFormMessages } from \"./schema\";\n\n/** What a custom field receives to draw itself. */\nexport interface SchemaFieldContext {\n /** An id to wire the label (`htmlFor`) and the description. */\n id: string;\n /** The raw answer: a string, a boolean, or integer cents for a money field. */\n value: unknown;\n setValue: (value: unknown) => void;\n /** The refusal to show, or `null`. */\n error: string | null;\n disabled: boolean;\n}\n\nexport interface SchemaFormWords {\n /** The submit button: « Run ». */\n submit: string;\n /** The fold of the `x-advanced` fields: « More options ». */\n advanced: string;\n}\n\nexport interface SchemaFormProps extends Omit<React.ComponentProps<\"form\">, \"onSubmit\" | \"children\"> {\n /** The JSON Schema object (or its JSON text): `properties`, `required`, `x-i18n`, `x-advanced`. */\n schema: unknown;\n /** BCP 47 language for the `x-i18n` words and the money: `\"fr-CA\"`. */\n locale: string;\n /** The words, passed translated. */\n words: SchemaFormWords;\n /** The checks' words, passed translated. */\n messages: SchemaFormMessages;\n /** Answers to start from, by field key (over the schema's defaults). */\n values?: Record<string, unknown>;\n /** Called with the typed payload once every field passes. */\n onSubmit: (payload: Record<string, unknown>) => void;\n /** The form is being submitted: the fields are blocked and the button shows progress (no second submit). */\n submitting?: boolean;\n /** Draws a field in the host's way (an upload, a picker); return `undefined` for the default. */\n renderField?: (field: SchemaField, context: SchemaFieldContext) => React.ReactNode;\n /** Beside the submit button: a cost line, a note. */\n footer?: React.ReactNode;\n}\n\nfunction FieldControl({ field, ctx, locale }: Readonly<{ field: SchemaField; ctx: SchemaFieldContext; locale: string }>) {\n const { id, value, setValue, error, disabled } = ctx;\n const describedBy = [field.description ? `${id}-help` : null, error ? `${id}-error` : null].filter(Boolean).join(\" \") || undefined;\n const common = { id, disabled, \"aria-describedby\": describedBy, \"aria-required\": field.required || undefined } as const;\n const text = typeof value === \"string\" ? value : \"\";\n switch (field.kind) {\n case \"boolean\":\n return <Switch id={id} disabled={disabled} aria-describedby={describedBy} checked={value === true} onCheckedChange={setValue} />;\n case \"select\":\n return (\n <Select {...common} invalid={!!error} value={text} onChange={(e) => setValue(e.target.value)}>\n {!field.required && <option value=\"\" />}\n {field.options?.map((o) => (\n <option key={o.value} value={o.value}>\n {o.label}\n </option>\n ))}\n </Select>\n );\n case \"textarea\":\n return <Textarea {...common} invalid={!!error} value={text} maxLength={field.maxLength ?? undefined} placeholder={field.placeholder ?? undefined} onChange={(e) => setValue(e.target.value)} />;\n case \"money\":\n return <MoneyInput {...common} invalid={!!error} value={typeof value === \"number\" ? value : null} onValueChange={setValue} currency={field.currency} locale={locale} />;\n case \"number\":\n case \"integer\":\n return <Input {...common} invalid={!!error} type=\"text\" inputMode={field.kind === \"integer\" ? \"numeric\" : \"decimal\"} value={text} placeholder={field.placeholder ?? undefined} onChange={(e) => setValue(e.target.value)} />;\n case \"date\":\n return <Input {...common} invalid={!!error} type=\"date\" value={text} onChange={(e) => setValue(e.target.value)} />;\n default:\n return <Input {...common} invalid={!!error} type=\"text\" value={text} maxLength={field.maxLength ?? undefined} placeholder={field.placeholder ?? undefined} onChange={(e) => setValue(e.target.value)} />;\n }\n}\n\n/** A form from a JSON Schema: typed fields, the schema's rules, `x-i18n` words, `x-advanced` folded. */\nexport function SchemaForm({ schema, locale, words, messages, values: given, onSubmit, submitting = false, renderField, footer, className, ...props }: Readonly<SchemaFormProps>) {\n const base = React.useId();\n const fields = React.useMemo(() => fieldsFromSchema(schema, locale), [schema, locale]);\n const [answers, setAnswers] = React.useState(() => initialValues(fields, given));\n const [shown, setShown] = React.useState<Set<string>>(() => new Set());\n const errors = React.useMemo(() => checkValues(fields, answers, messages), [fields, answers, messages]);\n const formRef = React.useRef<HTMLFormElement>(null);\n const draw = (field: SchemaField) => {\n const id = `${base}-${field.key}`;\n const error = shown.has(field.key) ? (errors[field.key] ?? null) : null;\n const ctx: SchemaFieldContext = { id, value: answers[field.key], setValue: (v) => setAnswers((a) => ({ ...a, [field.key]: v })), error, disabled: submitting };\n const custom = renderField?.(field, ctx);\n const inline = field.kind === \"boolean\";\n return (\n <Field.Root key={field.key} data-field={field.key} data-kind={field.kind} onBlur={() => setShown((s) => (s.has(field.key) ? s : new Set(s).add(field.key)))}>\n <div className={cn(inline && \"flex items-center justify-between gap-3\")}>\n <Field.Label htmlFor={id}>\n {field.title}\n {field.required && <span aria-hidden> *</span>}\n </Field.Label>\n {inline && (custom ?? <FieldControl field={field} ctx={ctx} locale={locale} />)}\n </div>\n {!inline && (custom ?? <FieldControl field={field} ctx={ctx} locale={locale} />)}\n {field.description && <Field.Hint id={`${id}-help`}>{field.description}</Field.Hint>}\n {error && <Field.Error id={`${id}-error`}>{error}</Field.Error>}\n </Field.Root>\n );\n };\n const main = fields.filter((f) => !f.advanced);\n const more = fields.filter((f) => f.advanced);\n return (\n <form\n ref={formRef}\n noValidate\n data-schema-form=\"\"\n className={cn(\"flex flex-col gap-4\", className)}\n onSubmit={(event) => {\n event.preventDefault();\n if (submitting) return;\n const failing = Object.keys(errors);\n if (failing.length > 0) {\n setShown(new Set(fields.map((f) => f.key)));\n const first = fields.find((f) => errors[f.key]);\n if (first) formRef.current?.querySelector<HTMLElement>(`[data-field=\"${first.key}\"] :is(input,select,textarea,button[role=switch])`)?.focus();\n return;\n }\n onSubmit(payloadOf(fields, answers));\n }}\n {...props}\n >\n <div className=\"flex flex-col gap-3\">{main.map(draw)}</div>\n {more.length > 0 && (\n <details className=\"rounded-lg border border-border px-3 py-2\" open={more.some((f) => shown.has(f.key) && errors[f.key]) || undefined}>\n <summary className=\"cursor-pointer select-none text-sm font-medium text-fg-secondary\">{words.advanced}</summary>\n <div className=\"mt-3 flex flex-col gap-3\">{more.map(draw)}</div>\n </details>\n )}\n <div className=\"flex flex-wrap items-center justify-between gap-3\">\n <div className=\"min-w-0 text-xs text-fg-secondary\">{footer}</div>\n <Button type=\"submit\" variant=\"primary\" size=\"md\" loading={submitting}>\n {words.submit}\n </Button>\n </div>\n </form>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA2CA,IAAM,iBAAiB;AAEvB,IAAM,MAAM,CAAC,MAA4B,KAAK,OAAO,MAAM,YAAY,CAAC,MAAM,QAAQ,CAAC,IAAK,IAAY;AACxG,IAAM,MAAM,CAAC,MAAgB,OAAO,MAAM,YAAY,EAAE,KAAK,MAAM,KAAK,IAAI;AAC5E,IAAM,MAAM,CAAC,MAAgB,OAAO,MAAM,YAAY,OAAO,SAAS,CAAC,IAAI,IAAI;AAG/E,SAAS,SAAS,MAAe,QAA8B;AAC7D,QAAM,KAAK,IAAI,IAAI;AACnB,MAAI,CAAC,GAAI,QAAO;AAChB,SAAQ,IAAI,GAAG,MAAM,CAAC,KAAK,IAAI,GAAG,OAAO,MAAM,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,EAAE;AAC7E;AAEA,SAAS,UAAU,MAAW,OAA6C;AACzE,QAAM,QAAQ,CAAC,UAAkB;AAC/B,UAAM,IAAI,OAAO,UAAU,KAAK;AAChC,WAAO,OAAO,MAAM,WAAW,IAAK,GAAG,SAAS;AAAA,EAClD;AACA,MAAI,MAAM,QAAQ,KAAK,IAAI,EAAG,QAAO,KAAK,KAAK,IAAI,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,OAAO,MAAM,KAAK,KAAK,MAAM,EAAE;AACnH,QAA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,MACL,YAAU;AAAA,MACV,oBAAiB;AAAA,MACjB,WAAW,GAAG,uBAAuB,SAAS;AAAA,MAC9C,UAAU,CAAC,UAAU;AACnB,cAAM,eAAe;AACrB,YAAI,WAAY;AAChB,cAAM,UAAU,OAAO,KAAK,MAAM;AAClC,YAAI,QAAQ,SAAS,GAAG;AACtB,mBAAS,IAAI,IAAI,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAC1C,gBAAM,QAAQ,OAAO,KAAK,CAAC,MAAM,OAAO,EAAE,GAAG,CAAC;AAC9C,cAAI,MAAO,SAAQ,SAAS,cAA2B,gBAAgB,MAAM,GAAG,mDAAmD,GAAG,MAAM;AAC5I;AAAA,QACF;AACA,iBAAS,UAAU,QAAQ,OAAO,CAAC;AAAA,MACrC;AAAA,MACC,GAAG;AAAA,MAEJ;AAAA,4BAAC,SAAI,WAAU,uBAAuB,eAAK,IAAI,IAAI,GAAE;AAAA,QACpD,KAAK,SAAS,KACb,qBAAC,aAAQ,WAAU,6CAA4C,MAAM,KAAK,KAAK,CAAC,MAAM,MAAM,IAAI,EAAE,GAAG,KAAK,OAAO,EAAE,GAAG,CAAC,KAAK,QAC1H;AAAA,8BAAC,aAAQ,WAAU,oEAAoE,gBAAM,UAAS;AAAA,UACtG,oBAAC,SAAI,WAAU,4BAA4B,eAAK,IAAI,IAAI,GAAE;AAAA,WAC5D;AAAA,QAEF,qBAAC,SAAI,WAAU,qDACb;AAAA,8BAAC,SAAI,WAAU,qCAAqC,kBAAO;AAAA,UAC3D,oBAAC,UAAO,MAAK,UAAS,SAAQ,WAAU,MAAK,MAAK,SAAS,YACxD,gBAAM,QACT;AAAA,WACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
@@ -11,7 +11,7 @@ type MapGateProps = {
11
11
  places?: StaticMapProps["places"];
12
12
  /** The button's words (`Show the map`). */
13
13
  showLabel: string;
14
- /** More props of the live map (`brand`, `lang`, `labels`). */
14
+ /** More props of the live map (`brand`, `lang`, `labels`). Its `className` replaces the default `h-full w-full`: the map fills the gate's frame. */
15
15
  map?: Partial<Omit<MapProps, "label" | "center" | "zoom" | "fallback">>;
16
16
  className?: string;
17
17
  };
@@ -16,7 +16,7 @@ function MapGate({ label, center, zoom = 14, places, showLabel, map, className }
16
16
  const live = asked || wide;
17
17
  const still = /* @__PURE__ */ jsx(StaticMap, { label, center, zoom, places });
18
18
  return /* @__PURE__ */ jsx("div", { className, "data-live": live ? "" : void 0, children: /* @__PURE__ */ jsxs("div", { className: "relative aspect-[4/3] w-full overflow-hidden rounded-xl border border-border-default sm:aspect-[16/9]", children: [
19
- live ? /* @__PURE__ */ jsx(LiveMap, { label, center, zoom, fallback: still, ...map }) : still,
19
+ live ? /* @__PURE__ */ jsx(LiveMap, { label, center, zoom, fallback: still, ...map, className: map?.className ?? "h-full w-full" }) : still,
20
20
  !live && /* @__PURE__ */ jsx(
21
21
  "button",
22
22
  {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/shop/map-gate/map-gate.tsx"],"sourcesContent":["\"use client\";\n\n// A map behind a button on a phone (ADR-007 §3, §7). Until it is asked for, the page holds a still drawing of the place\n// (SVG, nothing requested) and a button: no engine, no tile, no request. From `sm` up the live map shows at once, because a\n// laptop can afford it. The tiles are the Krizaka CDN's: no third party.\nimport { Map as LiveMap, type MapProps, StaticMap, type StaticMapProps } from \"@krizaka/ui/map\";\nimport * as React from \"react\";\n\nexport type MapGateProps = {\n /** The map's accessible name (`Where the salon is`). */\n label: string;\n /** Longitude, latitude. */\n center: StaticMapProps[\"center\"];\n zoom?: number;\n /** Places drawn on the still and listed in its name. */\n places?: StaticMapProps[\"places\"];\n /** The button's words (`Show the map`). */\n showLabel: string;\n /** More props of the live map (`brand`, `lang`, `labels`). */\n map?: Partial<Omit<MapProps, \"label\" | \"center\" | \"zoom\" | \"fallback\">>;\n className?: string;\n};\n\nconst WIDE = \"(min-width: 40rem)\";\nfunction subscribeWide(notify: () => void) {\n const q = window.matchMedia(WIDE);\n q.addEventListener(\"change\", notify);\n return () => q.removeEventListener(\"change\", notify);\n}\n\n/** The place as a still, the live map on a click — or at once on a screen that can afford it. */\nexport function MapGate({ label, center, zoom = 14, places, showLabel, map, className }: MapGateProps) {\n const [asked, setAsked] = React.useState(false);\n // A screen that can afford it shows the live map at once; the server and a phone start with the still.\n const wide = React.useSyncExternalStore(subscribeWide, () => window.matchMedia(WIDE).matches, () => false);\n const live = asked || wide;\n const still = <StaticMap label={label} center={center} zoom={zoom} places={places} />;\n return (\n <div className={className} data-live={live ? \"\" : undefined}>\n <div className=\"relative aspect-[4/3] w-full overflow-hidden rounded-xl border border-border-default sm:aspect-[16/9]\">\n {live ? <LiveMap label={label} center={center} zoom={zoom} fallback={still} {...map} /> : still}\n {!live && (\n <button\n type=\"button\"\n onClick={() => setAsked(true)}\n className=\"absolute bottom-3 left-3 inline-flex min-h-11 items-center rounded-md border border-border-control bg-surface-1 px-4 text-sm font-semibold text-fg focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring\"\n >\n {showLabel}\n </button>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;AAKA,SAAS,OAAO,SAAwB,iBAAsC;AAC9E,YAAY,WAAW;AA8BP,cAGV,YAHU;AAbhB,IAAM,OAAO;AACb,SAAS,cAAc,QAAoB;AACzC,QAAM,IAAI,OAAO,WAAW,IAAI;AAChC,IAAE,iBAAiB,UAAU,MAAM;AACnC,SAAO,MAAM,EAAE,oBAAoB,UAAU,MAAM;AACrD;AAGO,SAAS,QAAQ,EAAE,OAAO,QAAQ,OAAO,IAAI,QAAQ,WAAW,KAAK,UAAU,GAAiB;AACrG,QAAM,CAAC,OAAO,QAAQ,IAAU,eAAS,KAAK;AAE9C,QAAM,OAAa,2BAAqB,eAAe,MAAM,OAAO,WAAW,IAAI,EAAE,SAAS,MAAM,KAAK;AACzG,QAAM,OAAO,SAAS;AACtB,QAAM,QAAQ,oBAAC,aAAU,OAAc,QAAgB,MAAY,QAAgB;AACnF,SACE,oBAAC,SAAI,WAAsB,aAAW,OAAO,KAAK,QAChD,+BAAC,SAAI,WAAU,yGACZ;AAAA,WAAO,oBAAC,WAAQ,OAAc,QAAgB,MAAY,UAAU,OAAQ,GAAG,KAAK,IAAK;AAAA,IACzF,CAAC,QACA;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,SAAS,MAAM,SAAS,IAAI;AAAA,QAC5B,WAAU;AAAA,QAET;AAAA;AAAA,IACH;AAAA,KAEJ,GACF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/shop/map-gate/map-gate.tsx"],"sourcesContent":["\"use client\";\n\n// A map behind a button on a phone (ADR-007 §3, §7). Until it is asked for, the page holds a still drawing of the place\n// (SVG, nothing requested) and a button: no engine, no tile, no request. From `sm` up the live map shows at once, because a\n// laptop can afford it. The tiles are the Krizaka CDN's: no third party.\nimport { Map as LiveMap, type MapProps, StaticMap, type StaticMapProps } from \"@krizaka/ui/map\";\nimport * as React from \"react\";\n\nexport type MapGateProps = {\n /** The map's accessible name (`Where the salon is`). */\n label: string;\n /** Longitude, latitude. */\n center: StaticMapProps[\"center\"];\n zoom?: number;\n /** Places drawn on the still and listed in its name. */\n places?: StaticMapProps[\"places\"];\n /** The button's words (`Show the map`). */\n showLabel: string;\n /** More props of the live map (`brand`, `lang`, `labels`). Its `className` replaces the default `h-full w-full`: the map fills the gate's frame. */\n map?: Partial<Omit<MapProps, \"label\" | \"center\" | \"zoom\" | \"fallback\">>;\n className?: string;\n};\n\nconst WIDE = \"(min-width: 40rem)\";\nfunction subscribeWide(notify: () => void) {\n const q = window.matchMedia(WIDE);\n q.addEventListener(\"change\", notify);\n return () => q.removeEventListener(\"change\", notify);\n}\n\n/** The place as a still, the live map on a click — or at once on a screen that can afford it. */\nexport function MapGate({ label, center, zoom = 14, places, showLabel, map, className }: MapGateProps) {\n const [asked, setAsked] = React.useState(false);\n // A screen that can afford it shows the live map at once; the server and a phone start with the still.\n const wide = React.useSyncExternalStore(subscribeWide, () => window.matchMedia(WIDE).matches, () => false);\n const live = asked || wide;\n const still = <StaticMap label={label} center={center} zoom={zoom} places={places} />;\n return (\n <div className={className} data-live={live ? \"\" : undefined}>\n <div className=\"relative aspect-[4/3] w-full overflow-hidden rounded-xl border border-border-default sm:aspect-[16/9]\">\n {live ? <LiveMap label={label} center={center} zoom={zoom} fallback={still} {...map} className={map?.className ?? \"h-full w-full\"} /> : still}\n {!live && (\n <button\n type=\"button\"\n onClick={() => setAsked(true)}\n className=\"absolute bottom-3 left-3 inline-flex min-h-11 items-center rounded-md border border-border-control bg-surface-1 px-4 text-sm font-semibold text-fg focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring\"\n >\n {showLabel}\n </button>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;AAKA,SAAS,OAAO,SAAwB,iBAAsC;AAC9E,YAAY,WAAW;AA8BP,cAGV,YAHU;AAbhB,IAAM,OAAO;AACb,SAAS,cAAc,QAAoB;AACzC,QAAM,IAAI,OAAO,WAAW,IAAI;AAChC,IAAE,iBAAiB,UAAU,MAAM;AACnC,SAAO,MAAM,EAAE,oBAAoB,UAAU,MAAM;AACrD;AAGO,SAAS,QAAQ,EAAE,OAAO,QAAQ,OAAO,IAAI,QAAQ,WAAW,KAAK,UAAU,GAAiB;AACrG,QAAM,CAAC,OAAO,QAAQ,IAAU,eAAS,KAAK;AAE9C,QAAM,OAAa,2BAAqB,eAAe,MAAM,OAAO,WAAW,IAAI,EAAE,SAAS,MAAM,KAAK;AACzG,QAAM,OAAO,SAAS;AACtB,QAAM,QAAQ,oBAAC,aAAU,OAAc,QAAgB,MAAY,QAAgB;AACnF,SACE,oBAAC,SAAI,WAAsB,aAAW,OAAO,KAAK,QAChD,+BAAC,SAAI,WAAU,yGACZ;AAAA,WAAO,oBAAC,WAAQ,OAAc,QAAgB,MAAY,UAAU,OAAQ,GAAG,KAAK,WAAW,KAAK,aAAa,iBAAiB,IAAK;AAAA,IACvI,CAAC,QACA;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,SAAS,MAAM,SAAS,IAAI;AAAA,QAC5B,WAAU;AAAA,QAET;AAAA;AAAA,IACH;AAAA,KAEJ,GACF;AAEJ;","names":[]}
@@ -1,13 +1,14 @@
1
1
  "use client";
2
+ import {
3
+ badgeVariants
4
+ } from "./chunk-S4TLZRGZ.js";
2
5
  import {
3
6
  ChevronGlyph
4
7
  } from "./chunk-Z47KIPCT.js";
5
8
  import {
6
9
  DropdownMenu
7
10
  } from "./chunk-OGWB76BR.js";
8
- import {
9
- defineRecipe
10
- } from "./chunk-D3T54RSL.js";
11
+ import "./chunk-D3T54RSL.js";
11
12
  import "./chunk-J3NC6ER4.js";
12
13
  import {
13
14
  cn
@@ -17,35 +18,7 @@ import {
17
18
  import { movesFrom, stateOf } from "@krizaka/organize/contract";
18
19
  import { DropdownMenu as MenuPrimitive } from "radix-ui";
19
20
  import * as React from "react";
20
-
21
- // src/badge/badge.tsx
22
- import { tv } from "tailwind-variants";
23
-
24
- // src/badge/recipe.ts
25
- var badgeRecipe = defineRecipe({
26
- base: "inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm font-semibold ",
27
- variants: {
28
- tone: {
29
- neutral: "bg-surface-3 text-fg-secondary",
30
- accent: "bg-accent-soft text-fg ring-1 ring-inset ring-accent/40 [&>[data-dot]]:bg-accent",
31
- success: "bg-success/15 text-fg ring-1 ring-inset ring-success/40 [&>[data-dot]]:bg-success",
32
- warning: "bg-warning/15 text-fg ring-1 ring-inset ring-warning/40 [&>[data-dot]]:bg-warning",
33
- danger: "bg-danger/15 text-fg ring-1 ring-inset ring-danger/40 [&>[data-dot]]:bg-danger",
34
- /** On a media: veil and text invariant, identical in both themes. */
35
- scrim: "bg-scrim text-fg-on-media backdrop-blur-md"
36
- },
37
- size: { sm: "px-2 py-0.5 text-[10px]", md: "px-2.5 py-1 text-[11px]" },
38
- pulse: { true: "[&>[data-dot]]:motion-safe:animate-pulse" }
39
- },
40
- defaultVariants: { tone: "neutral", size: "sm" }
41
- });
42
-
43
- // src/badge/badge.tsx
44
21
  import { jsx, jsxs } from "react/jsx-runtime";
45
- var badgeVariants = tv(badgeRecipe);
46
-
47
- // src/status-chip/status-chip.tsx
48
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
49
22
  var defaultLabels = {
50
23
  menu: (state) => `Change the status, now ${state}`,
51
24
  confirm: (target) => `Confirm: ${target}`,
@@ -61,8 +34,8 @@ function StatusChip({ set, state, role, locale, onMove, labels: given, size = "s
61
34
  const [open, setOpen] = React.useState(false);
62
35
  const label = (key) => stateOf(set, key)?.label[locale] ?? key;
63
36
  if (moves.length === 0) {
64
- return /* @__PURE__ */ jsxs2("span", { "data-status": state, "data-tone": tone, className: badgeVariants({ tone, size, className }), children: [
65
- /* @__PURE__ */ jsx2("span", { "data-dot": "", "aria-hidden": true, className: "h-1.5 w-1.5 rounded-full bg-current" }),
37
+ return /* @__PURE__ */ jsxs("span", { "data-status": state, "data-tone": tone, className: badgeVariants({ tone, size, className }), children: [
38
+ /* @__PURE__ */ jsx("span", { "data-dot": "", "aria-hidden": true, className: "h-1.5 w-1.5 rounded-full bg-current" }),
66
39
  text
67
40
  ] });
68
41
  }
@@ -71,7 +44,7 @@ function StatusChip({ set, state, role, locale, onMove, labels: given, size = "s
71
44
  setOpen(false);
72
45
  onMove?.({ transition: move, reason });
73
46
  };
74
- return /* @__PURE__ */ jsxs2(
47
+ return /* @__PURE__ */ jsxs(
75
48
  MenuPrimitive.Root,
76
49
  {
77
50
  open,
@@ -81,7 +54,7 @@ function StatusChip({ set, state, role, locale, onMove, labels: given, size = "s
81
54
  },
82
55
  modal: false,
83
56
  children: [
84
- /* @__PURE__ */ jsxs2(
57
+ /* @__PURE__ */ jsxs(
85
58
  MenuPrimitive.Trigger,
86
59
  {
87
60
  "aria-label": labels.menu(text),
@@ -93,23 +66,23 @@ function StatusChip({ set, state, role, locale, onMove, labels: given, size = "s
93
66
  className
94
67
  ),
95
68
  children: [
96
- /* @__PURE__ */ jsx2("span", { "data-dot": "", "aria-hidden": true, className: "h-1.5 w-1.5 rounded-full bg-current" }),
69
+ /* @__PURE__ */ jsx("span", { "data-dot": "", "aria-hidden": true, className: "h-1.5 w-1.5 rounded-full bg-current" }),
97
70
  text,
98
- /* @__PURE__ */ jsx2(ChevronGlyph, { className: "-mr-0.5 h-3.5 w-3.5" })
71
+ /* @__PURE__ */ jsx(ChevronGlyph, { className: "-mr-0.5 h-3.5 w-3.5" })
99
72
  ]
100
73
  }
101
74
  ),
102
- /* @__PURE__ */ jsx2(DropdownMenu.Content, { align: "start", "aria-label": labels.menu(text), children: moves.map((move) => {
75
+ /* @__PURE__ */ jsx(DropdownMenu.Content, { align: "start", "aria-label": labels.menu(text), children: moves.map((move) => {
103
76
  const target = label(move.to);
104
77
  const reasons = move.reasons ?? [];
105
78
  if (reasons.length > 0) {
106
- return /* @__PURE__ */ jsxs2(DropdownMenu.Sub, { children: [
107
- /* @__PURE__ */ jsx2(DropdownMenu.SubTrigger, { "aria-label": labels.reason(target), children: target }),
108
- /* @__PURE__ */ jsx2(DropdownMenu.SubContent, { children: reasons.map((reason) => /* @__PURE__ */ jsx2(DropdownMenu.Item, { onSelect: () => choose(move, reason.key), children: reason.label[locale] }, reason.key)) })
79
+ return /* @__PURE__ */ jsxs(DropdownMenu.Sub, { children: [
80
+ /* @__PURE__ */ jsx(DropdownMenu.SubTrigger, { "aria-label": labels.reason(target), children: target }),
81
+ /* @__PURE__ */ jsx(DropdownMenu.SubContent, { children: reasons.map((reason) => /* @__PURE__ */ jsx(DropdownMenu.Item, { onSelect: () => choose(move, reason.key), children: reason.label[locale] }, reason.key)) })
109
82
  ] }, move.to);
110
83
  }
111
84
  const waiting = move.confirm && armed === move.to;
112
- return /* @__PURE__ */ jsx2(
85
+ return /* @__PURE__ */ jsx(
113
86
  DropdownMenu.Item,
114
87
  {
115
88
  "data-armed": waiting ? "" : void 0,
@@ -122,7 +95,7 @@ function StatusChip({ set, state, role, locale, onMove, labels: given, size = "s
122
95
  }
123
96
  choose(move, null);
124
97
  },
125
- children: /* @__PURE__ */ jsx2("span", { "aria-live": "polite", children: waiting ? labels.confirm(target) : target })
98
+ children: /* @__PURE__ */ jsx("span", { "aria-live": "polite", children: waiting ? labels.confirm(target) : target })
126
99
  },
127
100
  move.to
128
101
  );
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/status-chip/status-chip.tsx","../src/badge/badge.tsx","../src/badge/recipe.ts"],"sourcesContent":["// Client (a Radix menu). A state of a status set (krizaka-ts#89, `@krizaka/organize`): the set says the states (label in\n// both languages, tone, final) and the transitions (who may move, whether a second press confirms, which reasons may be\n// picked). Read-only when the set is derived (an invoice's « paid » comes from the ledger), when no move is allowed to\n// the role, or when nobody listens (`onMove`); otherwise a menu of the moves the role may make, in the set's order. A\n// reason is picked from a list, never typed. The tone is a tint and a dot: the label always says the state.\nimport { movesFrom, stateOf,type StatusSet, type StatusTone, type StatusTransition } from \"@krizaka/organize/contract\";\nimport { DropdownMenu as MenuPrimitive } from \"radix-ui\";\nimport * as React from \"react\";\n\nimport { badgeVariants } from \"../badge\";\nimport { cn } from \"../cn\";\nimport { DropdownMenu } from \"../dropdown-menu\";\nimport { ChevronGlyph } from \"../glyphs\";\n\nexport type { StatusSet, StatusTone, StatusTransition };\n\nexport type StatusMove = {\n /** The transition the person chose. */\n transition: StatusTransition;\n /** The key of the reason picked from the transition's list, or null when it has none. */\n reason: string | null;\n};\n\nexport type StatusChipLabels = {\n /** The menu's accessible name: `(state) => \"Change the status, now \" + state`. */\n menu: (state: string) => string;\n /** The item that waits for a second press: `(target) => \"Confirm: \" + target`. */\n confirm: (target: string) => string;\n /** The submenu that asks for a reason: `(target) => target + \" — pick a reason\"`. */\n reason: (target: string) => string;\n};\n\nconst defaultLabels: StatusChipLabels = {\n menu: (state) => `Change the status, now ${state}`,\n confirm: (target) => `Confirm: ${target}`,\n reason: (target) => `${target} — pick a reason`,\n};\n\nexport type StatusChipProps = {\n /** The kind's status set (`KindConfig.status`). */\n set: StatusSet;\n /** The key of the entity's state. */\n state: string;\n /** The role of the person: the moves are the ones this role may make. */\n role: string;\n /** The language the labels are read in. */\n locale: \"fr\" | \"en\";\n /** Called when a move is chosen (confirmed, with its reason when it asks for one). Without it the chip is read-only. */\n onMove?: (move: StatusMove) => void;\n /** The words of the menu, passed translated. */\n labels?: Partial<StatusChipLabels>;\n /**\n * sm · md.\n * @default \"sm\"\n */\n size?: \"sm\" | \"md\";\n /** Classes merged on the badge. */\n className?: string;\n};\n\n/** The state of a status set as a badge; a menu of the allowed moves when the set, the role and `onMove` allow it. */\nexport function StatusChip({ set, state, role, locale, onMove, labels: given, size = \"sm\", className }: StatusChipProps) {\n const labels = { ...defaultLabels, ...given };\n const current = stateOf(set, state);\n const text = current ? current.label[locale] : state;\n const tone = current?.tone ?? \"neutral\";\n const moves = onMove && set.mode === \"editable\" ? movesFrom(set, state, role) : [];\n const [armed, setArmed] = React.useState<string | null>(null);\n const [open, setOpen] = React.useState(false);\n const label = (key: string) => stateOf(set, key)?.label[locale] ?? key;\n\n if (moves.length === 0) {\n return (\n <span data-status={state} data-tone={tone} className={badgeVariants({ tone, size, className })}>\n <span data-dot=\"\" aria-hidden className=\"h-1.5 w-1.5 rounded-full bg-current\" />\n {text}\n </span>\n );\n }\n\n const choose = (move: StatusTransition, reason: string | null) => {\n setArmed(null);\n setOpen(false);\n onMove?.({ transition: move, reason });\n };\n\n return (\n <MenuPrimitive.Root\n open={open}\n onOpenChange={(next) => {\n setOpen(next);\n if (!next) setArmed(null);\n }}\n modal={false}\n >\n <MenuPrimitive.Trigger\n aria-label={labels.menu(text)}\n data-status={state}\n data-tone={tone}\n className={cn(\n badgeVariants({ tone, size }),\n \"cursor-pointer transition-colors hover:brightness-110 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\",\n className,\n )}\n >\n <span data-dot=\"\" aria-hidden className=\"h-1.5 w-1.5 rounded-full bg-current\" />\n {text}\n <ChevronGlyph className=\"-mr-0.5 h-3.5 w-3.5\" />\n </MenuPrimitive.Trigger>\n <DropdownMenu.Content align=\"start\" aria-label={labels.menu(text)}>\n {moves.map((move) => {\n const target = label(move.to);\n const reasons = move.reasons ?? [];\n if (reasons.length > 0) {\n return (\n <DropdownMenu.Sub key={move.to}>\n <DropdownMenu.SubTrigger aria-label={labels.reason(target)}>{target}</DropdownMenu.SubTrigger>\n <DropdownMenu.SubContent>\n {reasons.map((reason) => (\n <DropdownMenu.Item key={reason.key} onSelect={() => choose(move, reason.key)}>\n {reason.label[locale]}\n </DropdownMenu.Item>\n ))}\n </DropdownMenu.SubContent>\n </DropdownMenu.Sub>\n );\n }\n const waiting = move.confirm && armed === move.to;\n return (\n <DropdownMenu.Item\n key={move.to}\n data-armed={waiting ? \"\" : undefined}\n className={waiting ? \"font-semibold text-fg-accent\" : undefined}\n onSelect={(event) => {\n if (move.confirm && !waiting) {\n // The first press asks, the second one moves: the menu stays open and says so.\n event.preventDefault();\n setArmed(move.to);\n return;\n }\n choose(move, null);\n }}\n >\n <span aria-live=\"polite\">{waiting ? labels.confirm(target) : target}</span>\n </DropdownMenu.Item>\n );\n })}\n </DropdownMenu.Content>\n </MenuPrimitive.Root>\n );\n}\n","// Server-safe: no hook, no context.\nimport type * as React from \"react\";\nimport { tv, type VariantProps } from \"tailwind-variants\";\n\nimport { badgeRecipe } from \"./recipe\";\n\n// Status tones are soft (a tint, a coloured dot, a text role): the invariant status tokens are too light to carry\n// small text on a light surface, or to sit under white text (WCAG AA).\nexport const badgeVariants = tv(badgeRecipe);\n\nexport type BadgeVariants = VariantProps<typeof badgeVariants>;\n\nexport type BadgeProps = React.ComponentProps<\"span\"> &\n BadgeVariants & {\n /**\n * neutral · accent · success · warning · danger (soft tints, the text stays a text role) · scrim (on a media).\n * @default \"neutral\"\n */\n tone?: BadgeVariants[\"tone\"];\n /**\n * sm · md.\n * @default \"sm\"\n */\n size?: BadgeVariants[\"size\"];\n /** Makes the `dot` pulse (stopped under reduced motion). */\n pulse?: BadgeVariants[\"pulse\"];\n /** A small dot before the text, in the tone's colour (pulsing with `pulse`). */\n dot?: boolean;\n };\n\nexport function Badge({ tone, size, pulse, dot, className, children, ...props }: BadgeProps) {\n return (\n <span data-tone={tone ?? \"neutral\"} className={badgeVariants({ tone, size, pulse, className })} {...props}>\n {dot && <span data-dot=\"\" aria-hidden className=\"h-1.5 w-1.5 rounded-full bg-current\" />}\n {children}\n </span>\n );\n}\n","// The badge's tones and sizes, written once as classes of the Krizaka tokens: the web wears them with `tv(badgeRecipe)`,\n// React Native reads the same classes into styles (native/badge.tsx). Status tones are soft (a tint, a coloured dot, a\n// text role): the invariant status tokens are too light to carry small text on a light surface, or to sit under white\n// text (WCAG AA).\nimport { defineRecipe } from \"../recipes/define\";\n\nexport const badgeRecipe = defineRecipe({\n base: \"inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm font-semibold \",\n variants: {\n tone: {\n neutral: \"bg-surface-3 text-fg-secondary\",\n accent: \"bg-accent-soft text-fg ring-1 ring-inset ring-accent/40 [&>[data-dot]]:bg-accent\",\n success: \"bg-success/15 text-fg ring-1 ring-inset ring-success/40 [&>[data-dot]]:bg-success\",\n warning: \"bg-warning/15 text-fg ring-1 ring-inset ring-warning/40 [&>[data-dot]]:bg-warning\",\n danger: \"bg-danger/15 text-fg ring-1 ring-inset ring-danger/40 [&>[data-dot]]:bg-danger\",\n /** On a media: veil and text invariant, identical in both themes. */\n scrim: \"bg-scrim text-fg-on-media backdrop-blur-md\",\n },\n size: { sm: \"px-2 py-0.5 text-[10px]\", md: \"px-2.5 py-1 text-[11px]\" },\n pulse: { true: \"[&>[data-dot]]:motion-safe:animate-pulse\" },\n },\n defaultVariants: { tone: \"neutral\", size: \"sm\" },\n});\n"],"mappings":";;;;;;;;;;;;;;;;AAKA,SAAS,WAAW,eAAsE;AAC1F,SAAS,gBAAgB,qBAAqB;AAC9C,YAAY,WAAW;;;ACLvB,SAAS,UAA6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AAC,WACZ,gBAAAA,KAAC,aAAa,MAAb,EAAmC,UAAU,MAAM,OAAO,MAAM,OAAO,GAAG,GACxE,iBAAO,MAAM,MAAM,KADE,OAAO,GAE/B,CACD,GACH;AAAA,iBARqB,KAAK,EAS5B;AAAA,UAEJ;AACA,gBAAM,UAAU,KAAK,WAAW,UAAU,KAAK;AAC/C,iBACE,gBAAAA;AAAA,YAAC,aAAa;AAAA,YAAb;AAAA,cAEC,cAAY,UAAU,KAAK;AAAA,cAC3B,WAAW,UAAU,iCAAiC;AAAA,cACtD,UAAU,CAAC,UAAU;AACnB,oBAAI,KAAK,WAAW,CAAC,SAAS;AAE5B,wBAAM,eAAe;AACrB,2BAAS,KAAK,EAAE;AAChB;AAAA,gBACF;AACA,uBAAO,MAAM,IAAI;AAAA,cACnB;AAAA,cAEA,0BAAAA,KAAC,UAAK,aAAU,UAAU,oBAAU,OAAO,QAAQ,MAAM,IAAI,QAAO;AAAA;AAAA,YAb/D,KAAK;AAAA,UAcZ;AAAA,QAEJ,CAAC,GACH;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["jsx","jsxs"]}
1
+ {"version":3,"sources":["../src/status-chip/status-chip.tsx"],"sourcesContent":["// Client (a Radix menu). A state of a status set (krizaka-ts#89, `@krizaka/organize`): the set says the states (label in\n// both languages, tone, final) and the transitions (who may move, whether a second press confirms, which reasons may be\n// picked). Read-only when the set is derived (an invoice's « paid » comes from the ledger), when no move is allowed to\n// the role, or when nobody listens (`onMove`); otherwise a menu of the moves the role may make, in the set's order. A\n// reason is picked from a list, never typed. The tone is a tint and a dot: the label always says the state.\nimport { movesFrom, stateOf,type StatusSet, type StatusTone, type StatusTransition } from \"@krizaka/organize/contract\";\nimport { DropdownMenu as MenuPrimitive } from \"radix-ui\";\nimport * as React from \"react\";\n\nimport { badgeVariants } from \"../badge\";\nimport { cn } from \"../cn\";\nimport { DropdownMenu } from \"../dropdown-menu\";\nimport { ChevronGlyph } from \"../glyphs\";\n\nexport type { StatusSet, StatusTone, StatusTransition };\n\nexport type StatusMove = {\n /** The transition the person chose. */\n transition: StatusTransition;\n /** The key of the reason picked from the transition's list, or null when it has none. */\n reason: string | null;\n};\n\nexport type StatusChipLabels = {\n /** The menu's accessible name: `(state) => \"Change the status, now \" + state`. */\n menu: (state: string) => string;\n /** The item that waits for a second press: `(target) => \"Confirm: \" + target`. */\n confirm: (target: string) => string;\n /** The submenu that asks for a reason: `(target) => target + \" — pick a reason\"`. */\n reason: (target: string) => string;\n};\n\nconst defaultLabels: StatusChipLabels = {\n menu: (state) => `Change the status, now ${state}`,\n confirm: (target) => `Confirm: ${target}`,\n reason: (target) => `${target} — pick a reason`,\n};\n\nexport type StatusChipProps = {\n /** The kind's status set (`KindConfig.status`). */\n set: StatusSet;\n /** The key of the entity's state. */\n state: string;\n /** The role of the person: the moves are the ones this role may make. */\n role: string;\n /** The language the labels are read in. */\n locale: \"fr\" | \"en\";\n /** Called when a move is chosen (confirmed, with its reason when it asks for one). Without it the chip is read-only. */\n onMove?: (move: StatusMove) => void;\n /** The words of the menu, passed translated. */\n labels?: Partial<StatusChipLabels>;\n /**\n * sm · md.\n * @default \"sm\"\n */\n size?: \"sm\" | \"md\";\n /** Classes merged on the badge. */\n className?: string;\n};\n\n/** The state of a status set as a badge; a menu of the allowed moves when the set, the role and `onMove` allow it. */\nexport function StatusChip({ set, state, role, locale, onMove, labels: given, size = \"sm\", className }: StatusChipProps) {\n const labels = { ...defaultLabels, ...given };\n const current = stateOf(set, state);\n const text = current ? current.label[locale] : state;\n const tone = current?.tone ?? \"neutral\";\n const moves = onMove && set.mode === \"editable\" ? movesFrom(set, state, role) : [];\n const [armed, setArmed] = React.useState<string | null>(null);\n const [open, setOpen] = React.useState(false);\n const label = (key: string) => stateOf(set, key)?.label[locale] ?? key;\n\n if (moves.length === 0) {\n return (\n <span data-status={state} data-tone={tone} className={badgeVariants({ tone, size, className })}>\n <span data-dot=\"\" aria-hidden className=\"h-1.5 w-1.5 rounded-full bg-current\" />\n {text}\n </span>\n );\n }\n\n const choose = (move: StatusTransition, reason: string | null) => {\n setArmed(null);\n setOpen(false);\n onMove?.({ transition: move, reason });\n };\n\n return (\n <MenuPrimitive.Root\n open={open}\n onOpenChange={(next) => {\n setOpen(next);\n if (!next) setArmed(null);\n }}\n modal={false}\n >\n <MenuPrimitive.Trigger\n aria-label={labels.menu(text)}\n data-status={state}\n data-tone={tone}\n className={cn(\n badgeVariants({ tone, size }),\n \"cursor-pointer transition-colors hover:brightness-110 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\",\n className,\n )}\n >\n <span data-dot=\"\" aria-hidden className=\"h-1.5 w-1.5 rounded-full bg-current\" />\n {text}\n <ChevronGlyph className=\"-mr-0.5 h-3.5 w-3.5\" />\n </MenuPrimitive.Trigger>\n <DropdownMenu.Content align=\"start\" aria-label={labels.menu(text)}>\n {moves.map((move) => {\n const target = label(move.to);\n const reasons = move.reasons ?? [];\n if (reasons.length > 0) {\n return (\n <DropdownMenu.Sub key={move.to}>\n <DropdownMenu.SubTrigger aria-label={labels.reason(target)}>{target}</DropdownMenu.SubTrigger>\n <DropdownMenu.SubContent>\n {reasons.map((reason) => (\n <DropdownMenu.Item key={reason.key} onSelect={() => choose(move, reason.key)}>\n {reason.label[locale]}\n </DropdownMenu.Item>\n ))}\n </DropdownMenu.SubContent>\n </DropdownMenu.Sub>\n );\n }\n const waiting = move.confirm && armed === move.to;\n return (\n <DropdownMenu.Item\n key={move.to}\n data-armed={waiting ? \"\" : undefined}\n className={waiting ? \"font-semibold text-fg-accent\" : undefined}\n onSelect={(event) => {\n if (move.confirm && !waiting) {\n // The first press asks, the second one moves: the menu stays open and says so.\n event.preventDefault();\n setArmed(move.to);\n return;\n }\n choose(move, null);\n }}\n >\n <span aria-live=\"polite\">{waiting ? labels.confirm(target) : target}</span>\n </DropdownMenu.Item>\n );\n })}\n </DropdownMenu.Content>\n </MenuPrimitive.Root>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAKA,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ACA,uBAAO,MAAM,IAAI;AAAA,cACnB;AAAA,cAEA,8BAAC,UAAK,aAAU,UAAU,oBAAU,OAAO,QAAQ,MAAM,IAAI,QAAO;AAAA;AAAA,YAb/D,KAAK;AAAA,UAcZ;AAAA,QAEJ,CAAC,GACH;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
package/dist/switch.js CHANGED
@@ -1,8 +1,9 @@
1
1
  "use client";
2
+ import "./chunk-3PRYL2LS.js";
2
3
  import {
3
4
  Switch,
4
5
  switchVariants
5
- } from "./chunk-CSRKYZ53.js";
6
+ } from "./chunk-CZHPWLNW.js";
6
7
  export {
7
8
  Switch,
8
9
  switchVariants
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  Avatar
4
- } from "./chunk-HK525THY.js";
4
+ } from "./chunk-5MPPIGCB.js";
5
5
  import {
6
6
  IconButton
7
7
  } from "./chunk-M3GEYLMR.js";
package/dist/wall.d.ts CHANGED
@@ -18,11 +18,17 @@ interface PinnedNoteProps extends Omit<React.ComponentProps<"article">, "childre
18
18
  ink?: "blue" | "margin" | "hue";
19
19
  /** How the note is held, through `Stuck`: a strip of tape or a pin. Takes over `attachment`. @default "tape" */
20
20
  hold?: "tape" | "pin";
21
+ /** The colour of the paper: the page's own, or a real post-it (butter, rose, mint, sky), pale in both themes with the pen dark on it. @default "plain" */
22
+ paper?: "plain" | "butter" | "rose" | "mint" | "sky";
23
+ /** A small action under the words (a link, a button) kept inside the note and reachable by keyboard; it is never part of the capped text. */
24
+ action?: React.ReactNode;
25
+ /** How many Unicode code points of `text` are kept (a flyer longer than a word is read whole). @default 140 */
26
+ limit?: number;
21
27
  /** The lines of the text box, fixed so a late font never shifts the page (the text is read in full by assistive technology). @default 4 */
22
28
  lines?: number;
23
29
  }
24
30
  /** A short word on a cut-corner card, stuck into the notebook. */
25
- declare function PinnedNote({ text, signature, rotation, attachment, attachmentRotation: _attachmentRotation, ink, hold, lines, className, ...props }: PinnedNoteProps): React.JSX.Element;
31
+ declare function PinnedNote({ text, signature, rotation, attachment, attachmentRotation: _attachmentRotation, ink, paper, action, limit, hold, lines, className, ...props }: PinnedNoteProps): React.JSX.Element;
26
32
 
27
33
  interface PolaroidProps extends Omit<React.ComponentProps<"figure">, "children" | "style">, WallObjectProps {
28
34
  /** The photo slot: an img or next/image, including fill inside this positioned frame. Supply its alt text. */
package/dist/wall.js CHANGED
@@ -31,11 +31,12 @@ function Stuck({ children, hold = "tape", tilt, seed = "", doodle, as: Tag = "di
31
31
 
32
32
  // src/wall/pinned-note.tsx
33
33
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
34
- function PinnedNote({ text, signature, rotation = 0, attachment, attachmentRotation: _attachmentRotation, ink = "blue", hold, lines = 4, className, ...props }) {
34
+ function PinnedNote({ text, signature, rotation = 0, attachment, attachmentRotation: _attachmentRotation, ink = "blue", paper = "plain", action, limit = 140, hold, lines = 4, className, ...props }) {
35
35
  const rows = Math.max(1, Math.round(Number.isFinite(lines) ? lines : 4));
36
- return /* @__PURE__ */ jsx2(Stuck, { hold: hold ?? attachment ?? "tape", tilt: Number.isFinite(rotation) ? rotation : 0, className: "kz-wall-object kz-pinned-stuck", children: /* @__PURE__ */ jsx2("article", { ...props, className: cn("kz-pinned-note", className), "data-shape": "cut", "data-ink": ink, style: { "--kz-note-lines": rows }, children: /* @__PURE__ */ jsxs2("div", { className: "kz-pinned-note-paper", children: [
37
- /* @__PURE__ */ jsx2("p", { className: "kz-pinned-note-text", children: Array.from(text).slice(0, 140).join("") }),
38
- signature && /* @__PURE__ */ jsx2("p", { className: "kz-pinned-note-signature", children: signature })
36
+ return /* @__PURE__ */ jsx2(Stuck, { hold: hold ?? attachment ?? "tape", tilt: Number.isFinite(rotation) ? rotation : 0, className: "kz-wall-object kz-pinned-stuck", children: /* @__PURE__ */ jsx2("article", { ...props, className: cn("kz-pinned-note", className), "data-shape": "cut", "data-ink": ink, "data-paper": paper === "plain" ? void 0 : paper, style: { "--kz-note-lines": rows }, children: /* @__PURE__ */ jsxs2("div", { className: "kz-pinned-note-paper", children: [
37
+ /* @__PURE__ */ jsx2("p", { className: "kz-pinned-note-text", children: Array.from(text).slice(0, Number.isFinite(limit) ? Math.max(0, Math.floor(limit)) : 140).join("") }),
38
+ signature && /* @__PURE__ */ jsx2("p", { className: "kz-pinned-note-signature", children: signature }),
39
+ action && /* @__PURE__ */ jsx2("div", { className: "kz-pinned-note-action", children: action })
39
40
  ] }) }) });
40
41
  }
41
42