@delmaredigital/payload-experiments 0.2.0-rc.6 → 0.3.0-rc.1

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 (291) hide show
  1. package/README.md +129 -11
  2. package/dist/admin/PreviewLinks.d.ts +2 -1
  3. package/dist/admin/PreviewLinks.js +24 -16
  4. package/dist/admin/actions/ConfirmDialog.d.ts +7 -4
  5. package/dist/admin/actions/ConfirmDialog.js +37 -82
  6. package/dist/admin/actions/DecideDialog.d.ts +3 -1
  7. package/dist/admin/actions/DecideDialog.js +30 -13
  8. package/dist/admin/actions/MakeContentResult.d.ts +13 -2
  9. package/dist/admin/actions/MakeContentResult.js +115 -16
  10. package/dist/admin/actions/actions.model.d.ts +2 -4
  11. package/dist/admin/actions/actions.model.js +2 -3
  12. package/dist/admin/allocation.model.js +3 -5
  13. package/dist/admin/api.d.ts +10 -4
  14. package/dist/admin/api.js +11 -7
  15. package/dist/admin/copy/actions.d.ts +39 -3
  16. package/dist/admin/copy/actions.js +40 -4
  17. package/dist/admin/copy/armSelect.js +5 -5
  18. package/dist/admin/copy/arms.d.ts +1 -7
  19. package/dist/admin/copy/arms.js +1 -7
  20. package/dist/admin/copy/audience.d.ts +2 -1
  21. package/dist/admin/copy/audience.js +3 -2
  22. package/dist/admin/copy/common.d.ts +13 -6
  23. package/dist/admin/copy/common.js +14 -8
  24. package/dist/admin/copy/goals.d.ts +21 -6
  25. package/dist/admin/copy/goals.js +27 -6
  26. package/dist/admin/copy/readiness.d.ts +19 -0
  27. package/dist/admin/copy/readiness.js +19 -0
  28. package/dist/admin/copy/recommendation.d.ts +0 -3
  29. package/dist/admin/copy/recommendation.js +0 -3
  30. package/dist/admin/copy/results.d.ts +41 -2
  31. package/dist/admin/copy/results.js +42 -3
  32. package/dist/admin/copy/review.d.ts +1 -1
  33. package/dist/admin/copy/review.js +1 -1
  34. package/dist/admin/copy/setting.d.ts +2 -0
  35. package/dist/admin/copy/setting.js +2 -0
  36. package/dist/admin/copy/surface.d.ts +7 -4
  37. package/dist/admin/copy/surface.js +9 -4
  38. package/dist/admin/copy/testPage.d.ts +12 -0
  39. package/dist/admin/copy/testPage.js +12 -0
  40. package/dist/admin/format/date.d.ts +2 -0
  41. package/dist/admin/format/date.js +10 -0
  42. package/dist/admin/labels.d.ts +2 -7
  43. package/dist/admin/labels.js +2 -7
  44. package/dist/admin/previewLinks.model.d.ts +2 -2
  45. package/dist/admin/previewLinks.model.js +5 -7
  46. package/dist/admin/results/CiChart.js +11 -21
  47. package/dist/admin/results/DataQualityPanel.d.ts +4 -2
  48. package/dist/admin/results/DataQualityPanel.js +30 -17
  49. package/dist/admin/results/DataTable.d.ts +16 -0
  50. package/dist/admin/results/DataTable.js +152 -0
  51. package/dist/admin/results/StatTile.d.ts +7 -0
  52. package/dist/admin/results/StatTile.js +22 -0
  53. package/dist/admin/results/VerdictHero.d.ts +13 -0
  54. package/dist/admin/results/{VerdictCard.js → VerdictHero.js} +15 -12
  55. package/dist/admin/results/releasePages.model.d.ts +17 -0
  56. package/dist/admin/results/releasePages.model.js +10 -0
  57. package/dist/admin/results/results.css +64 -0
  58. package/dist/admin/results/results.model.d.ts +6 -2
  59. package/dist/admin/results/results.model.js +12 -5
  60. package/dist/admin/surface/ResultsRoute.d.ts +1 -1
  61. package/dist/admin/surface/ResultsRoute.js +60 -31
  62. package/dist/admin/surface/SurfaceShell.d.ts +11 -2
  63. package/dist/admin/surface/SurfaceShell.js +49 -14
  64. package/dist/admin/surface/TestsHome.d.ts +6 -1
  65. package/dist/admin/surface/TestsHome.js +183 -112
  66. package/dist/admin/surface/TestsSurface.js +56 -16
  67. package/dist/admin/surface/contracts.d.ts +1 -0
  68. package/dist/admin/surface/goals/GoalForm.js +341 -308
  69. package/dist/admin/surface/goals/GoalsList.js +123 -89
  70. package/dist/admin/surface/goals/data.d.ts +8 -2
  71. package/dist/admin/surface/goals/data.js +11 -3
  72. package/dist/admin/surface/goals/goals.css +10 -13
  73. package/dist/admin/surface/home.model.d.ts +7 -8
  74. package/dist/admin/surface/home.model.js +23 -12
  75. package/dist/admin/surface/newTest/NewTest.js +5 -5
  76. package/dist/admin/surface/pageBlock/parts.js +31 -26
  77. package/dist/admin/surface/readiness/ActionDialogs.js +43 -14
  78. package/dist/admin/surface/readiness/Banner.d.ts +3 -0
  79. package/dist/admin/surface/readiness/Banner.js +63 -36
  80. package/dist/admin/surface/readiness/SaveStatus.d.ts +1 -0
  81. package/dist/admin/surface/readiness/SaveStatus.js +6 -3
  82. package/dist/admin/surface/readiness/readiness.model.d.ts +2 -0
  83. package/dist/admin/surface/readiness/readiness.model.js +18 -9
  84. package/dist/admin/surface/readiness/useTransition.d.ts +1 -0
  85. package/dist/admin/surface/readiness/useTransition.js +2 -1
  86. package/dist/admin/surface/results/ReleasePages.d.ts +14 -0
  87. package/dist/admin/surface/results/ReleasePages.js +116 -0
  88. package/dist/admin/surface/results/ResultsBody.d.ts +15 -2
  89. package/dist/admin/surface/results/ResultsBody.js +281 -107
  90. package/dist/admin/surface/results/ResultsHeader.d.ts +10 -0
  91. package/dist/admin/surface/results/ResultsHeader.js +177 -0
  92. package/dist/admin/surface/results/recommendation.model.js +2 -6
  93. package/dist/admin/surface/results/useResults.d.ts +21 -3
  94. package/dist/admin/surface/results/useResults.js +2 -1
  95. package/dist/admin/surface/setting/parts.js +75 -88
  96. package/dist/admin/surface/setting/setting.css +3 -15
  97. package/dist/admin/surface/surface.css +62 -47
  98. package/dist/admin/surface/test/AdvancedSection.js +55 -48
  99. package/dist/admin/surface/test/GoalSection.js +39 -32
  100. package/dist/admin/surface/test/LengthSection.js +46 -34
  101. package/dist/admin/surface/test/Rail.d.ts +4 -0
  102. package/dist/admin/surface/test/Rail.js +83 -0
  103. package/dist/admin/surface/test/ReadinessBar.d.ts +5 -0
  104. package/dist/admin/surface/test/ReadinessBar.js +33 -0
  105. package/dist/admin/surface/test/Section.d.ts +1 -1
  106. package/dist/admin/surface/test/Section.js +36 -16
  107. package/dist/admin/surface/test/TargetingSection.js +168 -142
  108. package/dist/admin/surface/test/TestPage.d.ts +2 -1
  109. package/dist/admin/surface/test/TestPage.js +146 -59
  110. package/dist/admin/surface/test/VersionsSection.js +151 -120
  111. package/dist/admin/surface/test/fields.d.ts +11 -4
  112. package/dist/admin/surface/test/fields.js +84 -85
  113. package/dist/admin/surface/test/jumpToSection.d.ts +3 -0
  114. package/dist/admin/surface/test/jumpToSection.js +10 -0
  115. package/dist/admin/surface/test/pageParts.js +9 -3
  116. package/dist/admin/surface/test/testPage.css +81 -14
  117. package/dist/admin/surface/useTestDocument.d.ts +1 -0
  118. package/dist/admin/surface/useTestDocument.js +40 -9
  119. package/dist/admin/targeting/targeting.model.d.ts +1 -3
  120. package/dist/admin/targeting/targeting.model.js +3 -8
  121. package/dist/admin/theme.css +115 -36
  122. package/dist/admin/theme.d.ts +38 -0
  123. package/dist/admin/theme.js +38 -1
  124. package/dist/admin/useApi.d.ts +17 -2
  125. package/dist/admin/views/ExperimentsRootView.js +12 -2
  126. package/dist/collections/experiments/config.js +44 -1
  127. package/dist/collections/experiments/lockHook.js +16 -2
  128. package/dist/collections/identities.js +6 -1
  129. package/dist/collections/metrics.js +7 -0
  130. package/dist/collections/metricsGuards.d.ts +9 -0
  131. package/dist/collections/metricsGuards.js +33 -0
  132. package/dist/constants.d.ts +1 -0
  133. package/dist/constants.js +1 -0
  134. package/dist/contentDone.d.ts +4 -0
  135. package/dist/contentDone.js +5 -0
  136. package/dist/db/identities.d.ts +8 -7
  137. package/dist/db/identities.js +9 -6
  138. package/dist/db/metricUsage.d.ts +19 -0
  139. package/dist/db/metricUsage.js +54 -0
  140. package/dist/db/names.d.ts +5 -0
  141. package/dist/db/names.js +5 -0
  142. package/dist/db/publishedContent.d.ts +10 -0
  143. package/dist/db/publishedContent.js +43 -0
  144. package/dist/db/results.d.ts +2 -0
  145. package/dist/db/results.js +6 -2
  146. package/dist/db/snapshots.d.ts +18 -6
  147. package/dist/db/snapshots.js +23 -7
  148. package/dist/db/staleEdit.d.ts +6 -0
  149. package/dist/db/staleEdit.js +10 -0
  150. package/dist/db/sweep.js +11 -6
  151. package/dist/endpoints/events.js +3 -3
  152. package/dist/endpoints/index.js +19 -1
  153. package/dist/endpoints/recompute.js +2 -1
  154. package/dist/endpoints/results.js +5 -0
  155. package/dist/endpoints/sanitizeReadinessDetail.d.ts +1 -0
  156. package/dist/endpoints/sanitizeReadinessDetail.js +2 -0
  157. package/dist/endpoints/summary.js +20 -2
  158. package/dist/endpoints/transitions.d.ts +15 -0
  159. package/dist/endpoints/transitions.js +36 -0
  160. package/dist/errors.d.ts +8 -0
  161. package/dist/errors.js +28 -0
  162. package/dist/exports/adminClient.d.ts +1 -0
  163. package/dist/exports/adminClient.js +1 -0
  164. package/dist/exports/index.d.ts +2 -1
  165. package/dist/exports/index.js +1 -0
  166. package/dist/exports/puckEditor.d.ts +1 -0
  167. package/dist/exports/puckEditor.js +1 -0
  168. package/dist/exports/rsc.d.ts +5 -1
  169. package/dist/exports/rsc.js +2 -0
  170. package/dist/hooks/hostHook.js +3 -2
  171. package/dist/hooks/pageGuard.d.ts +5 -0
  172. package/dist/hooks/pageGuard.js +121 -0
  173. package/dist/labels/arms.d.ts +7 -0
  174. package/dist/labels/arms.js +7 -0
  175. package/dist/log.d.ts +7 -0
  176. package/dist/log.js +38 -0
  177. package/dist/manifest/compile.d.ts +5 -0
  178. package/dist/manifest/compile.js +5 -1
  179. package/dist/options.js +23 -0
  180. package/dist/plugin.js +26 -2
  181. package/dist/puck/copy.d.ts +1 -1
  182. package/dist/puck/copy.js +6 -6
  183. package/dist/puck/editor/editor.chrome.css +235 -0
  184. package/dist/puck/editor/editor.css +241 -43
  185. package/dist/results/aggregate.js +4 -3
  186. package/dist/results/analyse.d.ts +4 -1
  187. package/dist/results/analyse.js +27 -11
  188. package/dist/results/cuped.js +3 -2
  189. package/dist/results/identityCredit.d.ts +15 -7
  190. package/dist/results/identityCredit.js +32 -33
  191. package/dist/results/rolloutUnits.js +2 -1
  192. package/dist/results/snapshot.js +8 -2
  193. package/dist/results/srm.js +2 -1
  194. package/dist/results/verdict.d.ts +2 -0
  195. package/dist/results/verdict.js +18 -1
  196. package/dist/sanitizeReadinessDetail.d.ts +7 -0
  197. package/dist/sanitizeReadinessDetail.js +54 -0
  198. package/dist/server/linkIdentity.d.ts +10 -1
  199. package/dist/server/linkIdentity.js +20 -18
  200. package/dist/server/metadata.d.ts +5 -0
  201. package/dist/server/metadata.js +9 -1
  202. package/dist/server/recordContentChange.js +2 -1
  203. package/dist/server/recordExposures.js +3 -3
  204. package/dist/server/runResults.d.ts +3 -2
  205. package/dist/server/runResults.js +125 -34
  206. package/dist/server/trackConversion.js +5 -6
  207. package/dist/targeting/values.d.ts +4 -0
  208. package/dist/targeting/values.js +10 -0
  209. package/dist/transitions/addMetric.js +8 -0
  210. package/dist/transitions/archive.js +2 -3
  211. package/dist/transitions/checkStart.d.ts +6 -3
  212. package/dist/transitions/checkStart.js +15 -0
  213. package/dist/transitions/contentFields.d.ts +7 -0
  214. package/dist/transitions/contentFields.js +20 -0
  215. package/dist/transitions/decide.js +6 -1
  216. package/dist/transitions/deleteExperiment.js +2 -1
  217. package/dist/transitions/dismissContentEntry.d.ts +8 -0
  218. package/dist/transitions/dismissContentEntry.js +45 -0
  219. package/dist/transitions/makeContent.d.ts +5 -2
  220. package/dist/transitions/makeContent.js +217 -118
  221. package/dist/transitions/phaseRecord.d.ts +8 -2
  222. package/dist/transitions/placements.d.ts +1 -0
  223. package/dist/transitions/placements.js +4 -0
  224. package/dist/transitions/preflightData.d.ts +1 -1
  225. package/dist/transitions/preflightData.js +42 -4
  226. package/dist/transitions/releasePages.d.ts +8 -0
  227. package/dist/transitions/releasePages.js +26 -0
  228. package/dist/transitions/restoreContentEntry.d.ts +8 -0
  229. package/dist/transitions/restoreContentEntry.js +47 -0
  230. package/dist/transitions/start.js +30 -5
  231. package/dist/types/contracts.d.ts +14 -0
  232. package/dist/types/endpoints.d.ts +34 -3
  233. package/dist/types/index.d.ts +1 -0
  234. package/dist/types/index.js +1 -0
  235. package/dist/types/reasons.d.ts +3 -0
  236. package/dist/types/reasons.js +1 -0
  237. package/dist/types/snapshot.d.ts +6 -1
  238. package/dist/ui/Banner.d.ts +2 -0
  239. package/dist/ui/Banner.js +2 -0
  240. package/dist/ui/Breadcrumb.d.ts +7 -0
  241. package/dist/ui/Breadcrumb.js +25 -0
  242. package/dist/ui/Button.d.ts +15 -0
  243. package/dist/ui/Button.js +32 -0
  244. package/dist/ui/Card.d.ts +12 -0
  245. package/dist/ui/Card.js +40 -0
  246. package/dist/ui/Checkbox.d.ts +2 -0
  247. package/dist/ui/Checkbox.js +2 -0
  248. package/dist/{admin/components → ui}/ChipsInput.d.ts +4 -3
  249. package/dist/{admin/components → ui}/ChipsInput.js +20 -12
  250. package/dist/ui/Dialog.d.ts +13 -0
  251. package/dist/ui/Dialog.js +85 -0
  252. package/dist/ui/EmptyState.d.ts +2 -0
  253. package/dist/ui/EmptyState.js +2 -0
  254. package/dist/ui/Feedback.d.ts +24 -0
  255. package/dist/ui/Feedback.js +40 -0
  256. package/dist/ui/Inputs.d.ts +34 -0
  257. package/dist/ui/Inputs.js +225 -0
  258. package/dist/ui/NumberInput.d.ts +2 -0
  259. package/dist/ui/NumberInput.js +2 -0
  260. package/dist/ui/Range.d.ts +2 -0
  261. package/dist/ui/Range.js +2 -0
  262. package/dist/ui/SearchInput.d.ts +2 -0
  263. package/dist/ui/SearchInput.js +2 -0
  264. package/dist/ui/SectionCard.d.ts +2 -0
  265. package/dist/ui/SectionCard.js +2 -0
  266. package/dist/ui/Select.d.ts +2 -0
  267. package/dist/ui/Select.js +2 -0
  268. package/dist/ui/StatusChip.d.ts +2 -0
  269. package/dist/ui/StatusChip.js +2 -0
  270. package/dist/ui/Tabs.d.ts +14 -0
  271. package/dist/ui/Tabs.js +54 -0
  272. package/dist/ui/TextInput.d.ts +2 -0
  273. package/dist/ui/TextInput.js +2 -0
  274. package/dist/ui/Textarea.d.ts +2 -0
  275. package/dist/ui/Textarea.js +2 -0
  276. package/dist/ui/Toggle.d.ts +2 -0
  277. package/dist/ui/Toggle.js +2 -0
  278. package/dist/ui/accent.d.ts +21 -0
  279. package/dist/ui/accent.js +81 -0
  280. package/dist/ui/index.d.ts +9 -0
  281. package/dist/ui/index.js +9 -0
  282. package/dist/ui/ui.css +92 -0
  283. package/package.json +1 -1
  284. package/dist/admin/components/chipsInput.css +0 -11
  285. package/dist/admin/results/ArmTable.d.ts +0 -8
  286. package/dist/admin/results/ArmTable.js +0 -113
  287. package/dist/admin/results/VerdictCard.d.ts +0 -9
  288. package/dist/admin/surface/goals/GoalsBreadcrumb.d.ts +0 -5
  289. package/dist/admin/surface/goals/GoalsBreadcrumb.js +0 -47
  290. package/dist/admin/surface/test/TestHeader.d.ts +0 -4
  291. package/dist/admin/surface/test/TestHeader.js +0 -69
@@ -0,0 +1,85 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useId, useRef } from 'react';
4
+ import './ui.css';
5
+ function focusable(node) {
6
+ return [
7
+ ...node.querySelectorAll('button, a[href], input, select, textarea, [tabindex]')
8
+ ].filter((el)=>{
9
+ if (el.tabIndex < 0 || el.matches(':disabled, input[type="hidden"]') || el.closest('[hidden], [inert]') || el.getAttribute('aria-disabled') === 'true') return false;
10
+ for(let parent = el; parent && parent !== node; parent = parent.parentElement){
11
+ const style = node.ownerDocument.defaultView?.getComputedStyle(parent);
12
+ if (style?.display === 'none' || style?.visibility === 'hidden' || style?.visibility === 'collapse') return false;
13
+ }
14
+ return true;
15
+ });
16
+ }
17
+ /** Native modal stays in its rendering document, including a Puck canvas iframe.
18
+ * `initialFocus="cancel"` targets the focusable control marked `data-dialog-cancel`.
19
+ */ export function Dialog({ open, title, onClose, children, dismissible = true, initialFocus }) {
20
+ const ref = useRef(null);
21
+ const heading = useId();
22
+ const closeRequested = useRef(false);
23
+ const requestClose = ()=>{
24
+ if (!open || !dismissible || closeRequested.current) return;
25
+ closeRequested.current = true;
26
+ onClose();
27
+ };
28
+ useEffect(()=>{
29
+ const node = ref.current;
30
+ if (!node || !open) return;
31
+ const doc = node.ownerDocument;
32
+ const previous = doc.activeElement;
33
+ closeRequested.current = false;
34
+ node.showModal();
35
+ const elements = focusable(node);
36
+ const preferred = initialFocus === 'cancel' ? elements.find((element)=>element.hasAttribute('data-dialog-cancel')) : undefined;
37
+ (preferred ?? elements[0] ?? node).focus();
38
+ return ()=>{
39
+ node.close();
40
+ if (previous?.isConnected) previous.focus();
41
+ };
42
+ }, [
43
+ open,
44
+ initialFocus
45
+ ]);
46
+ return /*#__PURE__*/ _jsxs("dialog", {
47
+ ref: ref,
48
+ "aria-labelledby": heading,
49
+ className: "xp-ui-dialog",
50
+ tabIndex: -1,
51
+ onCancel: (event)=>{
52
+ event.preventDefault();
53
+ requestClose();
54
+ },
55
+ onKeyDown: (event)=>{
56
+ if (event.defaultPrevented) return;
57
+ if (event.key === 'Escape') {
58
+ event.preventDefault();
59
+ requestClose();
60
+ return;
61
+ }
62
+ if (event.key !== 'Tab') return;
63
+ const node = event.currentTarget;
64
+ const elements = focusable(node);
65
+ const first = elements[0], last = elements.at(-1), active = node.ownerDocument.activeElement;
66
+ if (!first) {
67
+ event.preventDefault();
68
+ node.focus();
69
+ } else if (event.shiftKey && (active === first || active === node)) {
70
+ event.preventDefault();
71
+ last?.focus();
72
+ } else if (!event.shiftKey && (active === last || active === node)) {
73
+ event.preventDefault();
74
+ first.focus();
75
+ }
76
+ },
77
+ children: [
78
+ /*#__PURE__*/ _jsx("h2", {
79
+ id: heading,
80
+ children: title
81
+ }),
82
+ children
83
+ ]
84
+ });
85
+ }
@@ -0,0 +1,2 @@
1
+ import './ui.css';
2
+ export { EmptyState } from './Feedback.js';
@@ -0,0 +1,2 @@
1
+ import './ui.css';
2
+ export { EmptyState } from './Feedback.js';
@@ -0,0 +1,24 @@
1
+ import type { ReactNode } from 'react';
2
+ import './ui.css';
3
+ export declare const statusLabels: {
4
+ readonly draft: "Draft";
5
+ readonly ready: "Ready";
6
+ readonly running: "Running";
7
+ readonly 'needs-attention': "Needs attention";
8
+ readonly decided: "Decided";
9
+ readonly archived: "Archived";
10
+ readonly stopped: "Stopped";
11
+ };
12
+ export type UIStatus = keyof typeof statusLabels;
13
+ export declare function StatusChip({ status }: {
14
+ status: UIStatus;
15
+ }): import("react").JSX.Element;
16
+ export declare function Banner({ tone, children, action }: {
17
+ tone?: 'info' | 'warning' | 'error';
18
+ children: ReactNode;
19
+ action?: ReactNode;
20
+ }): import("react").JSX.Element;
21
+ export declare function EmptyState({ children, action }: {
22
+ children: ReactNode;
23
+ action: ReactNode;
24
+ }): import("react").JSX.Element;
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import './ui.css';
3
+ export const statusLabels = {
4
+ draft: 'Draft',
5
+ ready: 'Ready',
6
+ running: 'Running',
7
+ 'needs-attention': 'Needs attention',
8
+ decided: 'Decided',
9
+ archived: 'Archived',
10
+ stopped: 'Stopped'
11
+ };
12
+ export function StatusChip({ status }) {
13
+ return /*#__PURE__*/ _jsx("span", {
14
+ className: `xp-ui-status xp-ui-status--${status}`,
15
+ children: statusLabels[status]
16
+ });
17
+ }
18
+ export function Banner({ tone = 'info', children, action }) {
19
+ return /*#__PURE__*/ _jsxs("div", {
20
+ className: `xp-ui-banner xp-ui-banner--${tone}`,
21
+ role: tone === 'error' ? 'alert' : 'status',
22
+ children: [
23
+ /*#__PURE__*/ _jsx("p", {
24
+ children: children
25
+ }),
26
+ action
27
+ ]
28
+ });
29
+ }
30
+ export function EmptyState({ children, action }) {
31
+ return /*#__PURE__*/ _jsxs("div", {
32
+ className: "xp-ui-empty",
33
+ children: [
34
+ /*#__PURE__*/ _jsx("p", {
35
+ children: children
36
+ }),
37
+ action
38
+ ]
39
+ });
40
+ }
@@ -0,0 +1,34 @@
1
+ import type { InputHTMLAttributes, SelectHTMLAttributes, TextareaHTMLAttributes, ReactNode } from 'react';
2
+ import './ui.css';
3
+ export interface FieldProps {
4
+ id: string;
5
+ label: string;
6
+ help?: string;
7
+ error?: string;
8
+ }
9
+ export type TextInputProps = FieldProps & Omit<InputHTMLAttributes<HTMLInputElement>, 'id'>;
10
+ export declare function TextInput({ label, help, error, className, ...props }: TextInputProps): import("react").JSX.Element;
11
+ export declare function NumberInput(props: TextInputProps): import("react").JSX.Element;
12
+ export declare function SearchInput(props: TextInputProps): import("react").JSX.Element;
13
+ export type SelectProps = FieldProps & {
14
+ labelAction?: ReactNode;
15
+ } & Omit<SelectHTMLAttributes<HTMLSelectElement>, 'id'>;
16
+ export declare function Select({ label, labelAction, help, error, className, ...props }: SelectProps): import("react").JSX.Element;
17
+ export declare function Toggle({ label, help, error, className, ...props }: Omit<TextInputProps, 'type'>): import("react").JSX.Element;
18
+ export type TextareaProps = FieldProps & Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'id'>;
19
+ export declare function Textarea({ label, help, error, className, ...props }: TextareaProps): import("react").JSX.Element;
20
+ export declare function Checkbox({ label, help, error, className, ...props }: Omit<TextInputProps, 'type'>): import("react").JSX.Element;
21
+ export interface CheckboxListProps extends FieldProps {
22
+ children?: ReactNode;
23
+ value: readonly string[];
24
+ options: readonly {
25
+ value: string;
26
+ label: string;
27
+ disabled?: boolean;
28
+ }[];
29
+ onChange: (value: string[]) => void;
30
+ disabled?: boolean;
31
+ 'aria-describedby'?: string;
32
+ }
33
+ export declare function CheckboxList({ value, options, onChange, disabled, children, ...field }: CheckboxListProps): import("react").JSX.Element;
34
+ export declare function Range({ label, help, error, className, ...props }: Omit<TextInputProps, 'type'>): import("react").JSX.Element;
@@ -0,0 +1,225 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import './ui.css';
4
+ function described(props, extra) {
5
+ return [
6
+ extra,
7
+ props.help ? `${props.id}-help` : '',
8
+ props.error ? `${props.id}-error` : ''
9
+ ].filter(Boolean).join(' ') || undefined;
10
+ }
11
+ function Field({ id, label, labelAction, help, error, children }) {
12
+ return /*#__PURE__*/ _jsxs("div", {
13
+ className: "xp-ui-field",
14
+ children: [
15
+ labelAction ? /*#__PURE__*/ _jsxs("div", {
16
+ className: "xp-ui-field-label",
17
+ children: [
18
+ /*#__PURE__*/ _jsx("label", {
19
+ htmlFor: id,
20
+ children: label
21
+ }),
22
+ labelAction
23
+ ]
24
+ }) : /*#__PURE__*/ _jsx("label", {
25
+ htmlFor: id,
26
+ children: label
27
+ }),
28
+ children,
29
+ help ? /*#__PURE__*/ _jsx("p", {
30
+ className: "xp-ui-help",
31
+ id: `${id}-help`,
32
+ children: help
33
+ }) : null,
34
+ error ? /*#__PURE__*/ _jsx("p", {
35
+ className: "xp-ui-error",
36
+ id: `${id}-error`,
37
+ role: "alert",
38
+ children: error
39
+ }) : null
40
+ ]
41
+ });
42
+ }
43
+ export function TextInput({ label, help, error, className = '', ...props }) {
44
+ const field = {
45
+ id: props.id,
46
+ label,
47
+ help,
48
+ error
49
+ };
50
+ return /*#__PURE__*/ _jsx(Field, {
51
+ ...field,
52
+ children: /*#__PURE__*/ _jsx("input", {
53
+ ...props,
54
+ className: `xp-ui-input ${className}`,
55
+ "aria-invalid": Boolean(error) || undefined,
56
+ "aria-describedby": described(field, props['aria-describedby'])
57
+ })
58
+ });
59
+ }
60
+ export function NumberInput(props) {
61
+ return /*#__PURE__*/ _jsx(TextInput, {
62
+ ...props,
63
+ type: "number",
64
+ className: `xp-ui-input--number ${props.className ?? ''}`
65
+ });
66
+ }
67
+ export function SearchInput(props) {
68
+ return /*#__PURE__*/ _jsx(TextInput, {
69
+ ...props,
70
+ type: "search"
71
+ });
72
+ }
73
+ export function Select({ label, labelAction, help, error, className = '', ...props }) {
74
+ const field = {
75
+ id: props.id,
76
+ label,
77
+ help,
78
+ error
79
+ };
80
+ return /*#__PURE__*/ _jsx(Field, {
81
+ ...field,
82
+ labelAction: labelAction,
83
+ children: /*#__PURE__*/ _jsx("select", {
84
+ ...props,
85
+ className: `xp-ui-input xp-ui-select ${className}`,
86
+ "aria-invalid": Boolean(error) || undefined,
87
+ "aria-describedby": described(field, props['aria-describedby'])
88
+ })
89
+ });
90
+ }
91
+ export function Toggle({ label, help, error, className = '', ...props }) {
92
+ const field = {
93
+ id: props.id,
94
+ label,
95
+ help,
96
+ error
97
+ };
98
+ return /*#__PURE__*/ _jsx(Field, {
99
+ ...field,
100
+ children: /*#__PURE__*/ _jsx("input", {
101
+ ...props,
102
+ type: "checkbox",
103
+ role: "switch",
104
+ className: `xp-ui-toggle ${className}`,
105
+ "aria-invalid": Boolean(error) || undefined,
106
+ "aria-describedby": described(field, props['aria-describedby']),
107
+ onKeyDown: (event)=>{
108
+ props.onKeyDown?.(event);
109
+ if (event.key === ' ' && !event.defaultPrevented && !props.disabled) {
110
+ event.preventDefault();
111
+ event.currentTarget.click();
112
+ }
113
+ }
114
+ })
115
+ });
116
+ }
117
+ export function Textarea({ label, help, error, className = '', ...props }) {
118
+ const field = {
119
+ id: props.id,
120
+ label,
121
+ help,
122
+ error
123
+ };
124
+ return /*#__PURE__*/ _jsx(Field, {
125
+ ...field,
126
+ children: /*#__PURE__*/ _jsx("textarea", {
127
+ ...props,
128
+ className: `xp-ui-input xp-ui-textarea ${className}`,
129
+ "aria-invalid": Boolean(error) || undefined,
130
+ "aria-describedby": described(field, props['aria-describedby'])
131
+ })
132
+ });
133
+ }
134
+ export function Checkbox({ label, help, error, className = '', ...props }) {
135
+ const field = {
136
+ id: props.id,
137
+ label,
138
+ help,
139
+ error
140
+ };
141
+ return /*#__PURE__*/ _jsxs("div", {
142
+ className: "xp-ui-field",
143
+ children: [
144
+ /*#__PURE__*/ _jsxs("label", {
145
+ className: "xp-ui-checkbox-label",
146
+ htmlFor: props.id,
147
+ children: [
148
+ /*#__PURE__*/ _jsx("input", {
149
+ ...props,
150
+ type: "checkbox",
151
+ className: `xp-ui-checkbox ${className}`,
152
+ "aria-invalid": Boolean(error) || props['aria-invalid'] || undefined,
153
+ "aria-describedby": described(field, props['aria-describedby'])
154
+ }),
155
+ label
156
+ ]
157
+ }),
158
+ help ? /*#__PURE__*/ _jsx("p", {
159
+ className: "xp-ui-help",
160
+ id: `${props.id}-help`,
161
+ children: help
162
+ }) : null,
163
+ error ? /*#__PURE__*/ _jsx("p", {
164
+ className: "xp-ui-error",
165
+ id: `${props.id}-error`,
166
+ role: "alert",
167
+ children: error
168
+ }) : null
169
+ ]
170
+ });
171
+ }
172
+ export function CheckboxList({ value, options, onChange, disabled, children, ...field }) {
173
+ return /*#__PURE__*/ _jsxs("fieldset", {
174
+ id: field.id,
175
+ className: "xp-ui-field xp-ui-checkbox-list",
176
+ disabled: disabled,
177
+ "aria-invalid": Boolean(field.error) || undefined,
178
+ "aria-describedby": described(field, field['aria-describedby']),
179
+ children: [
180
+ /*#__PURE__*/ _jsx("legend", {
181
+ children: field.label
182
+ }),
183
+ children,
184
+ options.map((option, index)=>/*#__PURE__*/ _jsx(Checkbox, {
185
+ id: `${field.id}-${index}`,
186
+ label: option.label,
187
+ checked: value.includes(option.value),
188
+ disabled: disabled || option.disabled,
189
+ onChange: (event)=>onChange(event.target.checked ? [
190
+ ...value,
191
+ option.value
192
+ ] : value.filter((item)=>item !== option.value))
193
+ }, option.value)),
194
+ field.help ? /*#__PURE__*/ _jsx("p", {
195
+ className: "xp-ui-help",
196
+ id: `${field.id}-help`,
197
+ children: field.help
198
+ }) : null,
199
+ field.error ? /*#__PURE__*/ _jsx("p", {
200
+ className: "xp-ui-error",
201
+ id: `${field.id}-error`,
202
+ role: "alert",
203
+ children: field.error
204
+ }) : null
205
+ ]
206
+ });
207
+ }
208
+ export function Range({ label, help, error, className = '', ...props }) {
209
+ const field = {
210
+ id: props.id,
211
+ label,
212
+ help,
213
+ error
214
+ };
215
+ return /*#__PURE__*/ _jsx(Field, {
216
+ ...field,
217
+ children: /*#__PURE__*/ _jsx("input", {
218
+ ...props,
219
+ type: "range",
220
+ className: `xp-ui-range ${className}`,
221
+ "aria-invalid": Boolean(error) || undefined,
222
+ "aria-describedby": described(field, props['aria-describedby'])
223
+ })
224
+ });
225
+ }
@@ -0,0 +1,2 @@
1
+ import './ui.css';
2
+ export { NumberInput } from './Inputs.js';
@@ -0,0 +1,2 @@
1
+ import './ui.css';
2
+ export { NumberInput } from './Inputs.js';
@@ -0,0 +1,2 @@
1
+ import './ui.css';
2
+ export { Range } from './Inputs.js';
@@ -0,0 +1,2 @@
1
+ import './ui.css';
2
+ export { Range } from './Inputs.js';
@@ -0,0 +1,2 @@
1
+ import './ui.css';
2
+ export { SearchInput } from './Inputs.js';
@@ -0,0 +1,2 @@
1
+ import './ui.css';
2
+ export { SearchInput } from './Inputs.js';
@@ -0,0 +1,2 @@
1
+ import './ui.css';
2
+ export { SectionCard } from './Card.js';
@@ -0,0 +1,2 @@
1
+ import './ui.css';
2
+ export { SectionCard } from './Card.js';
@@ -0,0 +1,2 @@
1
+ import './ui.css';
2
+ export { Select } from './Inputs.js';
@@ -0,0 +1,2 @@
1
+ import './ui.css';
2
+ export { Select } from './Inputs.js';
@@ -0,0 +1,2 @@
1
+ import './ui.css';
2
+ export { StatusChip } from './Feedback.js';
@@ -0,0 +1,2 @@
1
+ import './ui.css';
2
+ export { StatusChip } from './Feedback.js';
@@ -0,0 +1,14 @@
1
+ import type { ReactNode } from 'react';
2
+ import './ui.css';
3
+ export interface Tab {
4
+ id: string;
5
+ label: string;
6
+ content: ReactNode;
7
+ disabled?: boolean;
8
+ }
9
+ export declare function Tabs({ items, label, value, onChange }: {
10
+ items: Tab[];
11
+ label: string;
12
+ value?: string;
13
+ onChange?: (id: string) => void;
14
+ }): import("react").JSX.Element;
@@ -0,0 +1,54 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useId, useState } from 'react';
4
+ import './ui.css';
5
+ export function Tabs({ items, label, value, onChange }) {
6
+ const prefix = useId();
7
+ const [local, setLocal] = useState(()=>items.find((item)=>!item.disabled)?.id);
8
+ const requested = value ?? local;
9
+ const selected = items.find((item)=>item.id === requested && !item.disabled)?.id ?? items.find((item)=>!item.disabled)?.id;
10
+ function select(id) {
11
+ setLocal(id);
12
+ onChange?.(id);
13
+ }
14
+ return /*#__PURE__*/ _jsxs("div", {
15
+ className: "xp-ui-tabs",
16
+ children: [
17
+ /*#__PURE__*/ _jsx("div", {
18
+ role: "tablist",
19
+ "aria-label": label,
20
+ className: "xp-ui-tablist",
21
+ children: items.map((item)=>/*#__PURE__*/ _jsx("button", {
22
+ type: "button",
23
+ role: "tab",
24
+ id: `${prefix}-tab-${item.id}`,
25
+ "aria-controls": `${prefix}-panel-${item.id}`,
26
+ "aria-selected": selected === item.id,
27
+ tabIndex: selected === item.id ? 0 : -1,
28
+ disabled: item.disabled,
29
+ className: "xp-ui-tab",
30
+ onClick: ()=>select(item.id),
31
+ onKeyDown: (event)=>{
32
+ const enabled = items.filter((tab)=>!tab.disabled);
33
+ const index = enabled.findIndex((tab)=>tab.id === item.id);
34
+ const next = event.key === 'ArrowRight' ? enabled[(index + 1) % enabled.length] : event.key === 'ArrowLeft' ? enabled[(index - 1 + enabled.length) % enabled.length] : event.key === 'Home' ? enabled[0] : event.key === 'End' ? enabled.at(-1) : undefined;
35
+ if (!next) return;
36
+ event.preventDefault();
37
+ select(next.id);
38
+ event.currentTarget.ownerDocument.getElementById(`${prefix}-tab-${next.id}`)?.focus();
39
+ },
40
+ children: item.label
41
+ }, item.id))
42
+ }),
43
+ items.map((item)=>/*#__PURE__*/ _jsx("div", {
44
+ role: "tabpanel",
45
+ id: `${prefix}-panel-${item.id}`,
46
+ "aria-labelledby": `${prefix}-tab-${item.id}`,
47
+ hidden: selected !== item.id,
48
+ tabIndex: 0,
49
+ className: "xp-ui-tabpanel",
50
+ children: item.content
51
+ }, item.id))
52
+ ]
53
+ });
54
+ }
@@ -0,0 +1,2 @@
1
+ import './ui.css';
2
+ export { TextInput } from './Inputs.js';
@@ -0,0 +1,2 @@
1
+ import './ui.css';
2
+ export { TextInput } from './Inputs.js';
@@ -0,0 +1,2 @@
1
+ import './ui.css';
2
+ export { Textarea } from './Inputs.js';
@@ -0,0 +1,2 @@
1
+ import './ui.css';
2
+ export { Textarea } from './Inputs.js';
@@ -0,0 +1,2 @@
1
+ import './ui.css';
2
+ export { Toggle } from './Inputs.js';
@@ -0,0 +1,2 @@
1
+ import './ui.css';
2
+ export { Toggle } from './Inputs.js';
@@ -0,0 +1,21 @@
1
+ export interface AccentSet {
2
+ accent: string;
3
+ hover: string;
4
+ active: string;
5
+ subtle: string;
6
+ fg: string;
7
+ focus: string;
8
+ accentText: string;
9
+ accentTextDecoration: 'none' | 'underline';
10
+ }
11
+ /** WCAG 2.x relative luminance contrast. */
12
+ export declare function contrast(a: string, b: string): number;
13
+ /** Pure shared host-accent derivation. Reference surfaces match theme.css's Payload
14
+ * 3.90.2 white / elevation-50 dark. Dark adjustment increases HSL lightness until
15
+ * the quantised hex reaches 3:1. Hover/active move up to 12/24% in the interaction direction, clamped to preserve text contrast; subtle is 8% tint. */
16
+ export declare function deriveAccent(input: string): {
17
+ light: AccentSet;
18
+ dark: AccentSet;
19
+ };
20
+ /** Validated hex values only; specificity exceeds theme.css regardless of load order. */
21
+ export declare function accentStyles(input?: string): string | undefined;