@delmaredigital/payload-experiments 0.2.0-rc.7 → 0.3.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +202 -26
- package/dist/admin/PreviewLinks.d.ts +2 -1
- package/dist/admin/PreviewLinks.js +50 -21
- package/dist/admin/TestsNavLink.d.ts +3 -1
- package/dist/admin/TestsNavLink.js +2 -2
- package/dist/admin/actions/ConfirmDialog.d.ts +7 -4
- package/dist/admin/actions/ConfirmDialog.js +37 -82
- package/dist/admin/actions/DecideDialog.d.ts +3 -1
- package/dist/admin/actions/DecideDialog.js +30 -13
- package/dist/admin/actions/MakeContentResult.d.ts +13 -2
- package/dist/admin/actions/MakeContentResult.js +115 -16
- package/dist/admin/actions/actions.model.d.ts +2 -4
- package/dist/admin/actions/actions.model.js +2 -3
- package/dist/admin/allocation.model.js +3 -5
- package/dist/admin/api.d.ts +10 -4
- package/dist/admin/api.js +11 -7
- package/dist/admin/armSelect/ArmSelectField.js +14 -22
- package/dist/admin/arms/arms.model.d.ts +1 -21
- package/dist/admin/arms/arms.model.js +1 -153
- package/dist/admin/copy/actions.d.ts +39 -3
- package/dist/admin/copy/actions.js +40 -4
- package/dist/admin/copy/armSelect.js +5 -5
- package/dist/admin/copy/arms.d.ts +1 -6
- package/dist/admin/copy/arms.js +1 -16
- package/dist/admin/copy/audience.d.ts +2 -1
- package/dist/admin/copy/audience.js +3 -2
- package/dist/admin/copy/common.d.ts +13 -6
- package/dist/admin/copy/common.js +14 -8
- package/dist/admin/copy/goals.d.ts +21 -6
- package/dist/admin/copy/goals.js +27 -6
- package/dist/admin/copy/readiness.d.ts +22 -0
- package/dist/admin/copy/readiness.js +21 -0
- package/dist/admin/copy/recommendation.d.ts +0 -3
- package/dist/admin/copy/recommendation.js +0 -3
- package/dist/admin/copy/results.d.ts +43 -2
- package/dist/admin/copy/results.js +44 -3
- package/dist/admin/copy/review.d.ts +2 -2
- package/dist/admin/copy/review.js +2 -2
- package/dist/admin/copy/setting.d.ts +2 -0
- package/dist/admin/copy/setting.js +2 -0
- package/dist/admin/copy/surface.d.ts +7 -5
- package/dist/admin/copy/surface.js +9 -5
- package/dist/admin/copy/testPage.d.ts +10 -0
- package/dist/admin/copy/testPage.js +10 -0
- package/dist/admin/format/date.d.ts +2 -0
- package/dist/admin/format/date.js +10 -0
- package/dist/admin/paths.d.ts +2 -1
- package/dist/admin/paths.js +2 -1
- package/dist/admin/previewLinks.model.d.ts +4 -2
- package/dist/admin/previewLinks.model.js +8 -7
- package/dist/admin/results/CiChart.js +11 -21
- package/dist/admin/results/DataQualityPanel.d.ts +4 -2
- package/dist/admin/results/DataQualityPanel.js +30 -17
- package/dist/admin/results/DataTable.d.ts +16 -0
- package/dist/admin/results/DataTable.js +152 -0
- package/dist/admin/results/StatTile.d.ts +7 -0
- package/dist/admin/results/StatTile.js +22 -0
- package/dist/admin/results/VerdictHero.d.ts +13 -0
- package/dist/admin/results/{VerdictCard.js → VerdictHero.js} +15 -12
- package/dist/admin/results/legacy.d.ts +16 -0
- package/dist/admin/results/legacy.js +27 -0
- package/dist/admin/results/releasePages.model.d.ts +17 -0
- package/dist/admin/results/releasePages.model.js +10 -0
- package/dist/admin/results/results.css +64 -0
- package/dist/admin/results/results.model.d.ts +11 -7
- package/dist/admin/results/results.model.js +24 -7
- package/dist/admin/results/snapshot.d.ts +14 -0
- package/dist/admin/results/snapshot.js +3 -0
- package/dist/admin/surface/ResultsRoute.d.ts +1 -1
- package/dist/admin/surface/ResultsRoute.js +59 -34
- package/dist/admin/surface/SurfaceShell.d.ts +11 -2
- package/dist/admin/surface/SurfaceShell.js +49 -14
- package/dist/admin/surface/TestsHome.d.ts +6 -1
- package/dist/admin/surface/TestsHome.js +182 -114
- package/dist/admin/surface/TestsSurface.js +56 -16
- package/dist/admin/surface/goals/GoalForm.js +341 -308
- package/dist/admin/surface/goals/GoalsList.js +123 -89
- package/dist/admin/surface/goals/data.d.ts +8 -2
- package/dist/admin/surface/goals/data.js +24 -16
- package/dist/admin/surface/goals/goals.css +10 -13
- package/dist/admin/surface/home.model.d.ts +8 -8
- package/dist/admin/surface/home.model.js +23 -12
- package/dist/admin/surface/newTest/NewTest.js +9 -9
- package/dist/admin/surface/pageBlock/parts.js +31 -26
- package/dist/admin/surface/readiness/ActionDialogs.js +47 -19
- package/dist/admin/surface/readiness/Banner.d.ts +3 -0
- package/dist/admin/surface/readiness/Banner.js +58 -33
- package/dist/admin/surface/readiness/SaveStatus.d.ts +1 -0
- package/dist/admin/surface/readiness/SaveStatus.js +6 -3
- package/dist/admin/surface/readiness/readiness.model.d.ts +2 -0
- package/dist/admin/surface/readiness/readiness.model.js +25 -9
- package/dist/admin/surface/readiness/useTransition.d.ts +1 -0
- package/dist/admin/surface/readiness/useTransition.js +2 -1
- package/dist/admin/surface/results/ReleasePages.d.ts +14 -0
- package/dist/admin/surface/results/ReleasePages.js +116 -0
- package/dist/admin/surface/results/ResultsBody.d.ts +11 -1
- package/dist/admin/surface/results/ResultsBody.js +277 -105
- package/dist/admin/surface/results/ResultsHeader.d.ts +10 -0
- package/dist/admin/surface/results/ResultsHeader.js +177 -0
- package/dist/admin/surface/results/recommendation.model.d.ts +3 -2
- package/dist/admin/surface/results/recommendation.model.js +12 -9
- package/dist/admin/surface/results/useResults.d.ts +21 -3
- package/dist/admin/surface/results/useResults.js +2 -1
- package/dist/admin/surface/setting/parts.js +75 -88
- package/dist/admin/surface/setting/setting.css +3 -15
- package/dist/admin/surface/surface.css +61 -47
- package/dist/admin/surface/test/AdvancedSection.js +55 -48
- package/dist/admin/surface/test/GoalSection.js +46 -47
- package/dist/admin/surface/test/LengthSection.js +46 -34
- package/dist/admin/surface/test/Rail.d.ts +4 -0
- package/dist/admin/surface/test/Rail.js +83 -0
- package/dist/admin/surface/test/ReadinessBar.d.ts +5 -0
- package/dist/admin/surface/test/ReadinessBar.js +33 -0
- package/dist/admin/surface/test/Section.d.ts +1 -1
- package/dist/admin/surface/test/Section.js +36 -16
- package/dist/admin/surface/test/TargetingSection.js +168 -142
- package/dist/admin/surface/test/TestPage.d.ts +2 -1
- package/dist/admin/surface/test/TestPage.js +146 -68
- package/dist/admin/surface/test/VersionsSection.js +151 -120
- package/dist/admin/surface/test/fields.d.ts +11 -4
- package/dist/admin/surface/test/fields.js +84 -85
- package/dist/admin/surface/test/jumpToSection.d.ts +3 -0
- package/dist/admin/surface/test/jumpToSection.js +10 -0
- package/dist/admin/surface/test/pageParts.js +9 -3
- package/dist/admin/surface/test/testPage.css +81 -14
- package/dist/admin/surface/test/testPage.model.d.ts +2 -3
- package/dist/admin/surface/test/testPage.model.js +1 -21
- package/dist/admin/surface/useTestDocument.js +12 -5
- package/dist/admin/targeting/targeting.model.d.ts +1 -3
- package/dist/admin/targeting/targeting.model.js +3 -8
- package/dist/admin/theme.css +115 -36
- package/dist/admin/theme.d.ts +38 -0
- package/dist/admin/theme.js +38 -1
- package/dist/admin/useApi.d.ts +17 -2
- package/dist/admin/useLayerUsage.js +14 -23
- package/dist/admin/views/ExperimentsRootView.js +12 -2
- package/dist/admin/views/TestsNavLinkServer.d.ts +2 -0
- package/dist/admin/views/TestsNavLinkServer.js +43 -0
- package/dist/arms/copy.d.ts +6 -0
- package/dist/arms/copy.js +16 -0
- package/dist/arms/model.d.ts +23 -0
- package/dist/arms/model.js +173 -0
- package/dist/collections/experiments/config.js +25 -0
- package/dist/collections/experiments/lockHook.js +3 -1
- package/dist/collections/identities.js +6 -1
- package/dist/collections/metrics.js +7 -0
- package/dist/collections/metricsGuards.d.ts +9 -0
- package/dist/collections/metricsGuards.js +33 -0
- package/dist/contentDone.d.ts +4 -0
- package/dist/contentDone.js +5 -0
- package/dist/db/appends.d.ts +6 -2
- package/dist/db/appends.js +10 -4
- package/dist/db/identities.d.ts +8 -7
- package/dist/db/identities.js +9 -6
- package/dist/db/locks.d.ts +6 -0
- package/dist/db/locks.js +13 -1
- package/dist/db/metricUsage.d.ts +19 -0
- package/dist/db/metricUsage.js +54 -0
- package/dist/db/names.d.ts +5 -0
- package/dist/db/names.js +5 -0
- package/dist/db/pageOccupancy.d.ts +12 -0
- package/dist/db/pageOccupancy.js +45 -0
- package/dist/db/publishedContent.d.ts +10 -0
- package/dist/db/publishedContent.js +43 -0
- package/dist/db/results.d.ts +2 -0
- package/dist/db/results.js +6 -2
- package/dist/db/snapshots.d.ts +18 -6
- package/dist/db/snapshots.js +25 -8
- package/dist/db/sweep.js +11 -6
- package/dist/endpoints/index.js +19 -1
- package/dist/endpoints/results.js +5 -0
- package/dist/endpoints/sanitizeReadinessDetail.d.ts +1 -0
- package/dist/endpoints/sanitizeReadinessDetail.js +2 -0
- package/dist/endpoints/summary.js +20 -2
- package/dist/endpoints/transitions.d.ts +15 -0
- package/dist/endpoints/transitions.js +36 -0
- package/dist/errors.d.ts +8 -0
- package/dist/errors.js +28 -0
- package/dist/exports/adminRsc.d.ts +1 -0
- package/dist/exports/adminRsc.js +1 -0
- package/dist/exports/index.d.ts +2 -1
- package/dist/exports/index.js +1 -0
- package/dist/exports/puck.d.ts +2 -1
- package/dist/exports/puck.js +1 -1
- package/dist/exports/puckEditor.d.ts +4 -1
- package/dist/exports/puckEditor.js +3 -1
- package/dist/exports/rsc.d.ts +6 -1
- package/dist/exports/rsc.js +2 -0
- package/dist/hooks/pageGuard.d.ts +5 -0
- package/dist/hooks/pageGuard.js +139 -0
- package/dist/lib/fetchAllDocs.d.ts +16 -0
- package/dist/lib/fetchAllDocs.js +56 -0
- package/dist/log.js +6 -3
- package/dist/manifest/compile.d.ts +5 -0
- package/dist/manifest/compile.js +5 -1
- package/dist/options.js +16 -0
- package/dist/plugin.js +30 -2
- package/dist/puck/ExperimentPicker.js +47 -16
- package/dist/puck/ExperimentSlot.d.ts +51 -1
- package/dist/puck/ExperimentSlot.js +23 -12
- package/dist/puck/copy.d.ts +6 -5
- package/dist/puck/copy.js +6 -5
- package/dist/puck/editor/CreateExperimentDrawer.js +46 -56
- package/dist/puck/editor/ExperimentSlotEditor.d.ts +52 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +292 -137
- package/dist/puck/editor/ResultsReadout.d.ts +6 -0
- package/dist/puck/editor/ResultsReadout.js +99 -0
- package/dist/puck/editor/VersionBuilder.d.ts +34 -0
- package/dist/puck/editor/VersionBuilder.js +317 -0
- package/dist/puck/editor/armWrites.d.ts +7 -0
- package/dist/puck/editor/armWrites.js +71 -0
- package/dist/puck/editor/armsCache.d.ts +14 -0
- package/dist/puck/editor/armsCache.js +78 -0
- package/dist/puck/editor/copy.d.ts +33 -1
- package/dist/puck/editor/copy.js +45 -8
- package/dist/puck/editor/createTest.d.ts +1 -1
- package/dist/puck/editor/createTest.js +25 -14
- package/dist/puck/editor/editor.chrome.css +121 -0
- package/dist/puck/editor/editor.css +288 -204
- package/dist/puck/editor/editor.model.d.ts +4 -1
- package/dist/puck/editor/editor.model.js +10 -7
- package/dist/puck/editor/experimentOutlinePlugin.d.ts +3 -0
- package/dist/puck/editor/experimentOutlinePlugin.js +89 -0
- package/dist/puck/experimentSlotField.d.ts +2 -0
- package/dist/puck/experimentSlotField.js +11 -3
- package/dist/puck/hostContext.d.ts +10 -0
- package/dist/puck/hostContext.js +12 -0
- package/dist/puck/routes.d.ts +12 -0
- package/dist/puck/routes.js +11 -0
- package/dist/puck/slotConfig.d.ts +1 -1
- package/dist/puck/slotConfig.js +2 -2
- package/dist/results/aggregate.js +4 -3
- package/dist/results/analyse.d.ts +4 -1
- package/dist/results/analyse.js +27 -11
- package/dist/results/cuped.js +3 -2
- package/dist/results/identityCredit.d.ts +15 -7
- package/dist/results/identityCredit.js +32 -33
- package/dist/results/rolloutUnits.js +2 -1
- package/dist/results/snapshot.js +8 -2
- package/dist/results/srm.js +2 -1
- package/dist/sanitizeReadinessDetail.d.ts +7 -0
- package/dist/sanitizeReadinessDetail.js +63 -0
- package/dist/server/linkIdentity.d.ts +10 -1
- package/dist/server/linkIdentity.js +17 -15
- package/dist/server/metadata.d.ts +5 -0
- package/dist/server/metadata.js +18 -3
- package/dist/server/normaliseContentRelationships.d.ts +7 -0
- package/dist/server/normaliseContentRelationships.js +62 -0
- package/dist/server/recordContentChange.d.ts +1 -1
- package/dist/server/recordContentChange.js +17 -8
- package/dist/server/runResults.d.ts +3 -2
- package/dist/server/runResults.js +157 -35
- package/dist/targeting/values.d.ts +4 -0
- package/dist/targeting/values.js +10 -0
- package/dist/transitions/addMetric.js +8 -0
- package/dist/transitions/archive.js +2 -3
- package/dist/transitions/checkStart.d.ts +10 -3
- package/dist/transitions/checkStart.js +25 -0
- package/dist/transitions/contentFields.d.ts +7 -0
- package/dist/transitions/contentFields.js +20 -0
- package/dist/transitions/decide.js +22 -2
- package/dist/transitions/dismissContentEntry.d.ts +8 -0
- package/dist/transitions/dismissContentEntry.js +45 -0
- package/dist/transitions/makeContent.d.ts +5 -2
- package/dist/transitions/makeContent.js +217 -118
- package/dist/transitions/phaseRecord.d.ts +8 -2
- package/dist/transitions/placements.d.ts +3 -6
- package/dist/transitions/placements.js +12 -1
- package/dist/transitions/preflightData.d.ts +9 -1
- package/dist/transitions/preflightData.js +138 -20
- package/dist/transitions/releasePages.d.ts +8 -0
- package/dist/transitions/releasePages.js +26 -0
- package/dist/transitions/restoreContentEntry.d.ts +8 -0
- package/dist/transitions/restoreContentEntry.js +47 -0
- package/dist/transitions/start.js +62 -7
- package/dist/types/contracts.d.ts +24 -4
- package/dist/types/endpoints.d.ts +34 -3
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/reasons.d.ts +3 -0
- package/dist/types/reasons.js +1 -0
- package/dist/types/snapshot.d.ts +6 -1
- package/dist/ui/Banner.d.ts +2 -0
- package/dist/ui/Banner.js +2 -0
- package/dist/ui/Breadcrumb.d.ts +7 -0
- package/dist/ui/Breadcrumb.js +25 -0
- package/dist/ui/Button.d.ts +15 -0
- package/dist/ui/Button.js +32 -0
- package/dist/ui/Card.d.ts +12 -0
- package/dist/ui/Card.js +40 -0
- package/dist/ui/Checkbox.d.ts +2 -0
- package/dist/ui/Checkbox.js +2 -0
- package/dist/{admin/components → ui}/ChipsInput.d.ts +4 -3
- package/dist/{admin/components → ui}/ChipsInput.js +20 -12
- package/dist/ui/Dialog.d.ts +13 -0
- package/dist/ui/Dialog.js +85 -0
- package/dist/ui/EmptyState.d.ts +2 -0
- package/dist/ui/EmptyState.js +2 -0
- package/dist/ui/Feedback.d.ts +24 -0
- package/dist/ui/Feedback.js +40 -0
- package/dist/ui/Inputs.d.ts +34 -0
- package/dist/ui/Inputs.js +225 -0
- package/dist/ui/NumberInput.d.ts +2 -0
- package/dist/ui/NumberInput.js +2 -0
- package/dist/ui/Range.d.ts +2 -0
- package/dist/ui/Range.js +2 -0
- package/dist/ui/SearchInput.d.ts +2 -0
- package/dist/ui/SearchInput.js +2 -0
- package/dist/ui/SectionCard.d.ts +2 -0
- package/dist/ui/SectionCard.js +2 -0
- package/dist/ui/Select.d.ts +2 -0
- package/dist/ui/Select.js +2 -0
- package/dist/ui/StatusChip.d.ts +2 -0
- package/dist/ui/StatusChip.js +2 -0
- package/dist/ui/Tabs.d.ts +16 -0
- package/dist/ui/Tabs.js +61 -0
- package/dist/ui/TextInput.d.ts +2 -0
- package/dist/ui/TextInput.js +2 -0
- package/dist/ui/Textarea.d.ts +2 -0
- package/dist/ui/Textarea.js +2 -0
- package/dist/ui/Toggle.d.ts +2 -0
- package/dist/ui/Toggle.js +2 -0
- package/dist/ui/accent.d.ts +40 -0
- package/dist/ui/accent.js +139 -0
- package/dist/ui/index.d.ts +9 -0
- package/dist/ui/index.js +9 -0
- package/dist/ui/ui.css +92 -0
- package/package.json +5 -2
- package/dist/admin/components/chipsInput.css +0 -11
- package/dist/admin/results/ArmTable.d.ts +0 -8
- package/dist/admin/results/ArmTable.js +0 -113
- package/dist/admin/results/VerdictCard.d.ts +0 -9
- package/dist/admin/surface/goals/GoalsBreadcrumb.d.ts +0 -5
- package/dist/admin/surface/goals/GoalsBreadcrumb.js +0 -47
- package/dist/admin/surface/test/TestHeader.d.ts +0 -4
- package/dist/admin/surface/test/TestHeader.js +0 -70
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import './ui.css';
|
|
3
|
+
export function Breadcrumb({ items }) {
|
|
4
|
+
return /*#__PURE__*/ _jsx("nav", {
|
|
5
|
+
className: "xp-ui-breadcrumb",
|
|
6
|
+
"aria-label": "Breadcrumb",
|
|
7
|
+
children: /*#__PURE__*/ _jsx("ol", {
|
|
8
|
+
children: items.map((item, index)=>/*#__PURE__*/ _jsxs("li", {
|
|
9
|
+
children: [
|
|
10
|
+
index ? /*#__PURE__*/ _jsx("span", {
|
|
11
|
+
"aria-hidden": "true",
|
|
12
|
+
children: "›"
|
|
13
|
+
}) : null,
|
|
14
|
+
index === items.length - 1 ? /*#__PURE__*/ _jsx("span", {
|
|
15
|
+
"aria-current": "page",
|
|
16
|
+
children: item.label
|
|
17
|
+
}) : /*#__PURE__*/ _jsx("a", {
|
|
18
|
+
href: item.href,
|
|
19
|
+
children: item.label
|
|
20
|
+
})
|
|
21
|
+
]
|
|
22
|
+
}, index))
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AnchorHTMLAttributes, ButtonHTMLAttributes } from 'react';
|
|
2
|
+
import './ui.css';
|
|
3
|
+
type Shared = {
|
|
4
|
+
variant?: 'primary' | 'secondary' | 'quiet' | 'link' | 'danger';
|
|
5
|
+
size?: 'md' | 'sm';
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
busy?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type ButtonProps = Shared & (ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
10
|
+
href?: never;
|
|
11
|
+
} | AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
12
|
+
href: string;
|
|
13
|
+
});
|
|
14
|
+
export declare function Button({ variant, size, disabled, busy, className, children, ...props }: ButtonProps): import("react").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import './ui.css';
|
|
4
|
+
export function Button({ variant = 'secondary', size = 'md', disabled, busy, className = '', children, ...props }) {
|
|
5
|
+
const classes = `xp-ui-button xp-ui-button--${variant} xp-ui-button--${size} ${className}`;
|
|
6
|
+
const blocked = disabled || busy;
|
|
7
|
+
if (props.href !== undefined) {
|
|
8
|
+
const { href, onClick, ...rest } = props;
|
|
9
|
+
return /*#__PURE__*/ _jsx("a", {
|
|
10
|
+
...rest,
|
|
11
|
+
className: classes,
|
|
12
|
+
href: blocked ? undefined : href,
|
|
13
|
+
role: blocked ? 'link' : undefined,
|
|
14
|
+
"aria-disabled": blocked || undefined,
|
|
15
|
+
"aria-busy": busy || undefined,
|
|
16
|
+
tabIndex: blocked ? -1 : rest.tabIndex,
|
|
17
|
+
onClick: (event)=>{
|
|
18
|
+
if (blocked) event.preventDefault();
|
|
19
|
+
else onClick?.(event);
|
|
20
|
+
},
|
|
21
|
+
children: children
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return /*#__PURE__*/ _jsx("button", {
|
|
25
|
+
...props,
|
|
26
|
+
type: props.type ?? 'button',
|
|
27
|
+
className: classes,
|
|
28
|
+
disabled: blocked,
|
|
29
|
+
"aria-busy": busy || undefined,
|
|
30
|
+
children: children
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import './ui.css';
|
|
3
|
+
export declare function Card({ className, ...props }: HTMLAttributes<HTMLDivElement>): import("react").JSX.Element;
|
|
4
|
+
export declare function SectionCard({ number, title, complete, children, id, headingId, className }: {
|
|
5
|
+
number: number;
|
|
6
|
+
title: string;
|
|
7
|
+
complete?: boolean;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
id?: string;
|
|
10
|
+
headingId?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
}): import("react").JSX.Element;
|
package/dist/ui/Card.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import './ui.css';
|
|
3
|
+
export function Card({ className = '', ...props }) {
|
|
4
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
5
|
+
...props,
|
|
6
|
+
className: `xp-ui-card ${className}`
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
export function SectionCard({ number, title, complete = false, children, id, headingId, className = '' }) {
|
|
10
|
+
return /*#__PURE__*/ _jsxs("section", {
|
|
11
|
+
id: id,
|
|
12
|
+
"aria-labelledby": headingId,
|
|
13
|
+
className: `xp-ui-card xp-ui-section ${className}`,
|
|
14
|
+
children: [
|
|
15
|
+
/*#__PURE__*/ _jsxs("header", {
|
|
16
|
+
className: "xp-ui-section-head",
|
|
17
|
+
children: [
|
|
18
|
+
/*#__PURE__*/ _jsx("span", {
|
|
19
|
+
className: "xp-ui-section-number",
|
|
20
|
+
children: number
|
|
21
|
+
}),
|
|
22
|
+
/*#__PURE__*/ _jsx("h2", {
|
|
23
|
+
id: headingId,
|
|
24
|
+
tabIndex: -1,
|
|
25
|
+
children: title
|
|
26
|
+
}),
|
|
27
|
+
/*#__PURE__*/ _jsx("span", {
|
|
28
|
+
className: "xp-ui-section-complete",
|
|
29
|
+
"aria-label": complete ? 'Complete' : 'Incomplete',
|
|
30
|
+
children: complete ? '✓' : '○'
|
|
31
|
+
})
|
|
32
|
+
]
|
|
33
|
+
}),
|
|
34
|
+
/*#__PURE__*/ _jsx("div", {
|
|
35
|
+
className: "xp-ui-section-body",
|
|
36
|
+
children: children
|
|
37
|
+
})
|
|
38
|
+
]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import './chipsInput.css';
|
|
1
|
+
import './ui.css';
|
|
3
2
|
export interface ChipsInputProps {
|
|
4
3
|
value: string[];
|
|
5
4
|
onChange: (value: string[]) => void;
|
|
6
5
|
label: string;
|
|
7
6
|
description?: string;
|
|
7
|
+
help?: string;
|
|
8
|
+
error?: string;
|
|
8
9
|
placeholder?: string;
|
|
9
10
|
disabled?: boolean;
|
|
10
11
|
id: string;
|
|
11
12
|
}
|
|
12
|
-
export declare function ChipsInput({ value, onChange, label, description, placeholder, disabled, id }: ChipsInputProps): import("react").JSX.Element;
|
|
13
|
+
export declare function ChipsInput({ value, onChange, label, description, help, error, placeholder, disabled, id }: ChipsInputProps): import("react").JSX.Element;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useRef, useState } from 'react';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import './chipsInput.css';
|
|
7
|
-
export function ChipsInput({ value, onChange, label, description, placeholder, disabled = false, id }) {
|
|
4
|
+
import './ui.css';
|
|
5
|
+
export function ChipsInput({ value, onChange, label, description, help = description, error, placeholder, disabled = false, id }) {
|
|
8
6
|
const [draft, setDraft] = useState('');
|
|
9
7
|
const input = useRef(null);
|
|
10
8
|
const commit = (text)=>{
|
|
@@ -24,7 +22,7 @@ export function ChipsInput({ value, onChange, label, description, placeholder, d
|
|
|
24
22
|
input.current?.focus();
|
|
25
23
|
};
|
|
26
24
|
return /*#__PURE__*/ _jsxs("div", {
|
|
27
|
-
className: "xp-chips",
|
|
25
|
+
className: "xp-ui-chips",
|
|
28
26
|
role: "group",
|
|
29
27
|
"aria-labelledby": `${id}-label`,
|
|
30
28
|
"aria-disabled": disabled,
|
|
@@ -35,10 +33,10 @@ export function ChipsInput({ value, onChange, label, description, placeholder, d
|
|
|
35
33
|
children: label
|
|
36
34
|
}),
|
|
37
35
|
/*#__PURE__*/ _jsxs("div", {
|
|
38
|
-
className:
|
|
36
|
+
className: `xp-ui-chips-control${error ? ' xp-ui-chips-control--invalid' : ''}`,
|
|
39
37
|
children: [
|
|
40
38
|
value.map((item, index)=>/*#__PURE__*/ _jsxs("span", {
|
|
41
|
-
className: "xp-chips-item",
|
|
39
|
+
className: "xp-ui-chips-item",
|
|
42
40
|
children: [
|
|
43
41
|
/*#__PURE__*/ _jsx("span", {
|
|
44
42
|
children: item
|
|
@@ -46,9 +44,9 @@ export function ChipsInput({ value, onChange, label, description, placeholder, d
|
|
|
46
44
|
/*#__PURE__*/ _jsx("button", {
|
|
47
45
|
type: "button",
|
|
48
46
|
disabled: disabled,
|
|
49
|
-
"aria-label":
|
|
47
|
+
"aria-label": `Remove ${item}`,
|
|
50
48
|
onClick: ()=>remove(index),
|
|
51
|
-
children:
|
|
49
|
+
children: '×'
|
|
52
50
|
})
|
|
53
51
|
]
|
|
54
52
|
}, item)),
|
|
@@ -59,7 +57,11 @@ export function ChipsInput({ value, onChange, label, description, placeholder, d
|
|
|
59
57
|
value: draft,
|
|
60
58
|
disabled: disabled,
|
|
61
59
|
placeholder: placeholder,
|
|
62
|
-
"aria-
|
|
60
|
+
"aria-invalid": Boolean(error) || undefined,
|
|
61
|
+
"aria-describedby": [
|
|
62
|
+
help ? `${id}-description` : '',
|
|
63
|
+
error ? `${id}-error` : ''
|
|
64
|
+
].filter(Boolean).join(' ') || undefined,
|
|
63
65
|
onChange: (event)=>setDraft(event.target.value),
|
|
64
66
|
onBlur: ()=>{
|
|
65
67
|
if (draft.trim()) commit(draft);
|
|
@@ -87,9 +89,15 @@ export function ChipsInput({ value, onChange, label, description, placeholder, d
|
|
|
87
89
|
})
|
|
88
90
|
]
|
|
89
91
|
}),
|
|
90
|
-
|
|
92
|
+
help ? /*#__PURE__*/ _jsx("p", {
|
|
91
93
|
id: `${id}-description`,
|
|
92
|
-
children:
|
|
94
|
+
children: help
|
|
95
|
+
}) : null,
|
|
96
|
+
error ? /*#__PURE__*/ _jsx("p", {
|
|
97
|
+
className: "xp-ui-error",
|
|
98
|
+
id: `${id}-error`,
|
|
99
|
+
role: "alert",
|
|
100
|
+
children: error
|
|
93
101
|
}) : null
|
|
94
102
|
]
|
|
95
103
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import './ui.css';
|
|
3
|
+
/** Native modal stays in its rendering document, including a Puck canvas iframe.
|
|
4
|
+
* `initialFocus="cancel"` targets the focusable control marked `data-dialog-cancel`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function Dialog({ open, title, onClose, children, dismissible, initialFocus }: {
|
|
7
|
+
open: boolean;
|
|
8
|
+
dismissible?: boolean;
|
|
9
|
+
initialFocus?: 'cancel';
|
|
10
|
+
title: string;
|
|
11
|
+
onClose: () => void;
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
@@ -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,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
|
+
}
|