@kerf-js/veneer 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +16 -0
- package/README.md +1338 -2
- package/package.json +56 -3
- package/plugin.d.mts +187 -0
- package/plugin.mjs +399 -0
- package/src/Accordion.tsx +98 -0
- package/src/Alert.tsx +55 -0
- package/src/Badge.tsx +39 -0
- package/src/Button.tsx +175 -0
- package/src/Calendar-month.tsx +140 -0
- package/src/Calendar.tsx +335 -0
- package/src/Canvas.tsx +221 -0
- package/src/Card.tsx +85 -0
- package/src/Chart.tsx +278 -0
- package/src/Charts.tsx +158 -0
- package/src/Chip.tsx +61 -0
- package/src/Choice-checkbox.tsx +53 -0
- package/src/Choice-parts.tsx +7 -0
- package/src/Choice-radio.tsx +78 -0
- package/src/Choice-segmented.tsx +76 -0
- package/src/Choice-switch.tsx +51 -0
- package/src/Choice.tsx +4 -0
- package/src/CloseX.tsx +14 -0
- package/src/CodeBlock.tsx +81 -0
- package/src/CodeInput.tsx +256 -0
- package/src/Combobox.tsx +281 -0
- package/src/CommandPalette-controller.ts +314 -0
- package/src/CommandPalette-rows.tsx +137 -0
- package/src/CommandPalette.tsx +196 -0
- package/src/DataGrid-actions.ts +119 -0
- package/src/DataGrid-body.tsx +58 -0
- package/src/DataGrid-controller.ts +145 -0
- package/src/DataGrid-header.tsx +108 -0
- package/src/DataGrid-model.ts +248 -0
- package/src/DataGrid-pivot.tsx +108 -0
- package/src/DataGrid-rows.tsx +296 -0
- package/src/DataGrid-toolbar.tsx +127 -0
- package/src/DataGrid-tree.ts +149 -0
- package/src/DataGrid-viewport.tsx +37 -0
- package/src/DataGrid.tsx +145 -0
- package/src/DateField-presets.tsx +27 -0
- package/src/DateField-range.tsx +370 -0
- package/src/DateField.tsx +295 -0
- package/src/Dither.tsx +313 -0
- package/src/Drawer.tsx +123 -0
- package/src/DurationField.tsx +227 -0
- package/src/Feed.tsx +78 -0
- package/src/Field/view.tsx +147 -0
- package/src/Field.tsx +238 -0
- package/src/HamburgerMenu.tsx +119 -0
- package/src/Icon.tsx +15 -0
- package/src/Kbd.tsx +6 -0
- package/src/KeyValueEditor/actions.ts +75 -0
- package/src/KeyValueEditor/rows.tsx +104 -0
- package/src/KeyValueEditor.tsx +112 -0
- package/src/Layout.tsx +221 -0
- package/src/Markdown.tsx +127 -0
- package/src/MentionsInput/actions.ts +161 -0
- package/src/MentionsInput/end.tsx +82 -0
- package/src/MentionsInput.tsx +103 -0
- package/src/Menu.tsx +221 -0
- package/src/Modal.tsx +109 -0
- package/src/MonthPicker/month.tsx +117 -0
- package/src/MonthPicker/period.tsx +197 -0
- package/src/MonthPicker/shared.tsx +272 -0
- package/src/MonthPicker/week.tsx +103 -0
- package/src/MonthPicker.tsx +11 -0
- package/src/MultiSelect.tsx +139 -0
- package/src/Nav.tsx +36 -0
- package/src/NumberField.tsx +156 -0
- package/src/Pagination.tsx +335 -0
- package/src/PaymentCard.tsx +111 -0
- package/src/Picker.tsx +228 -0
- package/src/PlaceField.tsx +285 -0
- package/src/Popover.tsx +88 -0
- package/src/Presence.tsx +37 -0
- package/src/Progress.tsx +71 -0
- package/src/RecurrenceField.tsx +372 -0
- package/src/RichSelect/codes.tsx +94 -0
- package/src/RichSelect/list.tsx +380 -0
- package/src/RichSelect/phone-view.tsx +114 -0
- package/src/RichSelect/phone.tsx +305 -0
- package/src/RichSelect/search-keys.ts +28 -0
- package/src/RichSelect/timezone.tsx +53 -0
- package/src/RichSelect.tsx +13 -0
- package/src/RichTextEditor/controller.tsx +305 -0
- package/src/RichTextEditor/editor.tsx +61 -0
- package/src/RichTextEditor/tools.tsx +132 -0
- package/src/RichTextEditor/view.tsx +210 -0
- package/src/RichTextEditor.tsx +9 -0
- package/src/ScrollGrid/measure.ts +39 -0
- package/src/ScrollGrid/parts.tsx +112 -0
- package/src/ScrollGrid.tsx +375 -0
- package/src/ScrollRail.tsx +114 -0
- package/src/ScrollView.tsx +57 -0
- package/src/Segments/controller.tsx +148 -0
- package/src/Segments/events.ts +99 -0
- package/src/Segments/view.tsx +77 -0
- package/src/Segments.tsx +2 -0
- package/src/Select.tsx +343 -0
- package/src/Shape.tsx +41 -0
- package/src/Shell/branches.tsx +108 -0
- package/src/Shell/button.tsx +33 -0
- package/src/Shell/shared.tsx +220 -0
- package/src/Shell/shell.tsx +25 -0
- package/src/Shell/state.ts +138 -0
- package/src/Shell/view.tsx +280 -0
- package/src/Shell.tsx +17 -0
- package/src/SideNav/sections.tsx +50 -0
- package/src/SideNav/state.ts +140 -0
- package/src/SideNav.tsx +130 -0
- package/src/SideNavTitle.tsx +25 -0
- package/src/SignaturePad/state.ts +172 -0
- package/src/SignaturePad/view.tsx +69 -0
- package/src/SignaturePad.tsx +76 -0
- package/src/Skeleton.tsx +46 -0
- package/src/Slider.tsx +81 -0
- package/src/Spinner.tsx +21 -0
- package/src/Stage-director.ts +361 -0
- package/src/Stage-look.ts +75 -0
- package/src/Stage-poster.tsx +62 -0
- package/src/Stage-types.ts +206 -0
- package/src/Stage.tsx +147 -0
- package/src/TabBar.tsx +114 -0
- package/src/Table-actions.tsx +51 -0
- package/src/Table-base.ts +70 -0
- package/src/Table-body.tsx +84 -0
- package/src/Table-columns.tsx +58 -0
- package/src/Table-details.tsx +66 -0
- package/src/Table-editor.tsx +66 -0
- package/src/Table-head.tsx +52 -0
- package/src/Table-model.ts +82 -0
- package/src/Table-notice.ts +39 -0
- package/src/Table-paging.ts +50 -0
- package/src/Table-rows.tsx +308 -0
- package/src/Table-selection.ts +63 -0
- package/src/Table-sortbar.tsx +41 -0
- package/src/Table-source.ts +66 -0
- package/src/Table-toolbar.tsx +71 -0
- package/src/Table-types.ts +115 -0
- package/src/Table-view.tsx +87 -0
- package/src/Table.tsx +31 -0
- package/src/Tabs.tsx +129 -0
- package/src/Tag.tsx +40 -0
- package/src/Ticker.tsx +42 -0
- package/src/TimeField-date-model.ts +77 -0
- package/src/TimeField-date-view.tsx +152 -0
- package/src/TimeField-model.ts +80 -0
- package/src/TimeField-options.tsx +224 -0
- package/src/TimeField-slots.tsx +32 -0
- package/src/TimeField-types.ts +33 -0
- package/src/TimeField-view.tsx +124 -0
- package/src/TimeField.tsx +126 -0
- package/src/Toast.tsx +143 -0
- package/src/Toggle.tsx +75 -0
- package/src/Tooltip.tsx +69 -0
- package/src/Type.tsx +136 -0
- package/src/VirtualList-controls.ts +105 -0
- package/src/VirtualList-data.ts +43 -0
- package/src/VirtualList-measure.ts +169 -0
- package/src/VirtualList-metrics.ts +41 -0
- package/src/VirtualList-mount.ts +145 -0
- package/src/VirtualList-rows.tsx +91 -0
- package/src/VirtualList-types.ts +76 -0
- package/src/VirtualList-view.tsx +123 -0
- package/src/VirtualList.tsx +81 -0
- package/src/admin/ApiKeys-actions.ts +124 -0
- package/src/admin/ApiKeys-form.tsx +64 -0
- package/src/admin/ApiKeys-view.tsx +101 -0
- package/src/admin/ApiKeys.tsx +224 -0
- package/src/admin/Audit.tsx +246 -0
- package/src/admin/Billing.tsx +307 -0
- package/src/admin/Cart.tsx +177 -0
- package/src/admin/Checkout-address.tsx +125 -0
- package/src/admin/Checkout-cart.tsx +78 -0
- package/src/admin/Checkout-coupon.ts +34 -0
- package/src/admin/Checkout-done.tsx +31 -0
- package/src/admin/Checkout-model.ts +33 -0
- package/src/admin/Checkout-navigation.ts +76 -0
- package/src/admin/Checkout-payment-view.tsx +49 -0
- package/src/admin/Checkout-payment.ts +80 -0
- package/src/admin/Checkout-review.tsx +60 -0
- package/src/admin/Checkout-shipping.tsx +47 -0
- package/src/admin/Checkout-state.ts +122 -0
- package/src/admin/Checkout-steps.ts +10 -0
- package/src/admin/Checkout-summary.tsx +97 -0
- package/src/admin/Checkout-types.ts +60 -0
- package/src/admin/Checkout-view.tsx +51 -0
- package/src/admin/Checkout.tsx +72 -0
- package/src/admin/CsvImport-actions.ts +131 -0
- package/src/admin/CsvImport.tsx +379 -0
- package/src/admin/Danger.tsx +240 -0
- package/src/admin/Integrations/Card.tsx +82 -0
- package/src/admin/Integrations/Webhooks.tsx +341 -0
- package/src/admin/Integrations.tsx +169 -0
- package/src/admin/InviteDialog.tsx +153 -0
- package/src/admin/Members/columns.tsx +181 -0
- package/src/admin/Members.tsx +316 -0
- package/src/admin/Order.tsx +115 -0
- package/src/admin/PlainTable.tsx +34 -0
- package/src/admin/Plans.tsx +375 -0
- package/src/admin/SaveBar/actions.ts +86 -0
- package/src/admin/SaveBar.tsx +153 -0
- package/src/admin/Secret.tsx +74 -0
- package/src/admin/Settings.tsx +145 -0
- package/src/admin/StepBar.tsx +66 -0
- package/src/admin/TagsInput/actions.ts +60 -0
- package/src/admin/TagsInput.tsx +95 -0
- package/src/admin/atoms.tsx +73 -0
- package/src/admin/index.ts +67 -0
- package/src/agent/Actions/reasons.tsx +38 -0
- package/src/agent/Actions.tsx +166 -0
- package/src/agent/AgentPlan.tsx +86 -0
- package/src/agent/ArtifactPanel.tsx +299 -0
- package/src/agent/Assistant.tsx +168 -0
- package/src/agent/Checkpoint.tsx +19 -0
- package/src/agent/Cite.tsx +70 -0
- package/src/agent/ContextMeter.tsx +70 -0
- package/src/agent/Conversation.tsx +70 -0
- package/src/agent/Message.tsx +92 -0
- package/src/agent/ModelPicker.tsx +167 -0
- package/src/agent/Prompt-model.ts +118 -0
- package/src/agent/Prompt-view.tsx +246 -0
- package/src/agent/Prompt.tsx +128 -0
- package/src/agent/Prose.tsx +118 -0
- package/src/agent/Question.tsx +137 -0
- package/src/agent/Reasoning.tsx +31 -0
- package/src/agent/Shimmer.tsx +11 -0
- package/src/agent/Sources.tsx +23 -0
- package/src/agent/SpeechInput.tsx +243 -0
- package/src/agent/Suggestions.tsx +36 -0
- package/src/agent/ToolCall.tsx +219 -0
- package/src/agent/TraceViewer.tsx +96 -0
- package/src/agent/bits.tsx +88 -0
- package/src/agent/index.ts +38 -0
- package/src/bind.ts +57 -0
- package/src/collab/AutoTrack.tsx +91 -0
- package/src/collab/Comments.tsx +204 -0
- package/src/collab/Composer/state.ts +125 -0
- package/src/collab/Composer/view.tsx +155 -0
- package/src/collab/Composer.tsx +141 -0
- package/src/collab/ConversationList.tsx +120 -0
- package/src/collab/Cursors.tsx +71 -0
- package/src/collab/DataIntegrity.tsx +103 -0
- package/src/collab/Kanban-card.ts +74 -0
- package/src/collab/Kanban.tsx +368 -0
- package/src/collab/Lock.tsx +36 -0
- package/src/collab/PresenceStack.tsx +176 -0
- package/src/collab/ShareDialog.tsx +273 -0
- package/src/collab/Status.tsx +101 -0
- package/src/collab/SyncedForm.tsx +42 -0
- package/src/collab/Thread/Message.tsx +265 -0
- package/src/collab/Thread/rows.tsx +56 -0
- package/src/collab/Thread.tsx +323 -0
- package/src/collab/VersionHistory.tsx +173 -0
- package/src/collab/ViewportRail.tsx +73 -0
- package/src/collab/index.ts +37 -0
- package/src/collab/peer.tsx +42 -0
- package/src/fields.ts +5 -0
- package/src/flow/AuthScreen.tsx +81 -0
- package/src/flow/AuthSteps.tsx +296 -0
- package/src/flow/Checklist.tsx +211 -0
- package/src/flow/ConnBanner.tsx +304 -0
- package/src/flow/Flow.tsx +97 -0
- package/src/flow/MfaSetup.tsx +244 -0
- package/src/flow/Otp.tsx +243 -0
- package/src/flow/ReauthDialog.tsx +79 -0
- package/src/flow/ShortcutsOverlay.tsx +121 -0
- package/src/flow/SignGate.tsx +184 -0
- package/src/flow/SignIn.tsx +136 -0
- package/src/flow/SignUp.tsx +149 -0
- package/src/flow/Sso.tsx +96 -0
- package/src/flow/SystemPage/accounts.tsx +74 -0
- package/src/flow/SystemPage/art.tsx +113 -0
- package/src/flow/SystemPage.tsx +395 -0
- package/src/flow/Tour.tsx +207 -0
- package/src/flow/index.ts +29 -0
- package/src/flow/kit.tsx +334 -0
- package/src/index.ts +237 -0
- package/src/layout.css +4 -0
- package/src/links.css +4 -0
- package/src/live/ActivityFeed.tsx +88 -0
- package/src/live/Bell.tsx +108 -0
- package/src/live/Connection.tsx +113 -0
- package/src/live/Inbox.tsx +113 -0
- package/src/live/InboxFeed.tsx +67 -0
- package/src/live/InboxGestures.ts +41 -0
- package/src/live/InboxHandlers.ts +102 -0
- package/src/live/InboxHeader.tsx +81 -0
- package/src/live/InboxModel.ts +81 -0
- package/src/live/InboxRow.tsx +125 -0
- package/src/live/MeetingRoom.tsx +22 -0
- package/src/live/MeetingRoomControlBar.tsx +197 -0
- package/src/live/MeetingRoomHandlers.ts +53 -0
- package/src/live/MeetingRoomLayout.tsx +27 -0
- package/src/live/MeetingRoomModel.ts +49 -0
- package/src/live/MeetingRoomMount.ts +49 -0
- package/src/live/MeetingRoomParts.tsx +178 -0
- package/src/live/MeetingRoomPerson.tsx +21 -0
- package/src/live/MeetingRoomState.ts +88 -0
- package/src/live/MeetingRoomTile.tsx +84 -0
- package/src/live/MeetingRoomTypes.ts +68 -0
- package/src/live/MeetingRoomView.tsx +36 -0
- package/src/live/NotificationPreferences.tsx +99 -0
- package/src/live/NotificationPreferencesActions.ts +55 -0
- package/src/live/NotificationPreferencesCell.tsx +26 -0
- package/src/live/NotificationPreferencesCells.tsx +59 -0
- package/src/live/NotificationPreferencesGrid.tsx +129 -0
- package/src/live/NotificationPreferencesModel.tsx +91 -0
- package/src/live/NotificationPreferencesSave.ts +85 -0
- package/src/live/NotificationPreferencesWatch.ts +31 -0
- package/src/live/Prejoin.tsx +238 -0
- package/src/live/PrejoinMeter.tsx +26 -0
- package/src/live/PrejoinPreview.tsx +53 -0
- package/src/live/PushSoftAsk.tsx +63 -0
- package/src/live/TransportPicker.tsx +341 -0
- package/src/live/TransportPickerDetails.tsx +130 -0
- package/src/live/index.ts +31 -0
- package/src/live/notify.tsx +22 -0
- package/src/live/shared.tsx +110 -0
- package/src/parts.tsx +199 -0
- package/src/plugin/catalog.mjs +129 -0
- package/src/plugin/dtcg.mjs +79 -0
- package/src/plugin/icons.mjs +7 -0
- package/src/plugin/seed.mjs +40 -0
- package/src/plugin/theme-context.mjs +44 -0
- package/src/plugin/theme-css.mjs +143 -0
- package/src/plugin/theme-motion.mjs +43 -0
- package/src/plugin/theme-parts.d.mts +41 -0
- package/src/plugin/theme-parts.mjs +224 -0
- package/src/plugin/theme-text.mjs +93 -0
- package/src/plugin/theme-values.mjs +15 -0
- package/src/plugin/theme.d.mts +82 -0
- package/src/plugin/theme.mjs +316 -0
- package/src/schedule/Agenda.tsx +124 -0
- package/src/schedule/AgendaActions.ts +31 -0
- package/src/schedule/AgendaDay.tsx +124 -0
- package/src/schedule/AgendaGestures.ts +27 -0
- package/src/schedule/AgendaKeys.ts +52 -0
- package/src/schedule/AgendaModel.ts +82 -0
- package/src/schedule/AgendaNavigation.ts +38 -0
- package/src/schedule/AgendaPage.tsx +39 -0
- package/src/schedule/AgendaStrip.tsx +55 -0
- package/src/schedule/AvailabilityEditor-actions.ts +146 -0
- package/src/schedule/AvailabilityEditor-day.tsx +119 -0
- package/src/schedule/AvailabilityEditor-view.tsx +205 -0
- package/src/schedule/AvailabilityEditor.tsx +113 -0
- package/src/schedule/BookingCalendar.tsx +121 -0
- package/src/schedule/BookingCalendarActions.ts +85 -0
- package/src/schedule/BookingCalendarModel.ts +86 -0
- package/src/schedule/BookingCalendarParts.tsx +87 -0
- package/src/schedule/Calendar/AgendaView.tsx +45 -0
- package/src/schedule/Calendar/CalendarDialogs.tsx +105 -0
- package/src/schedule/Calendar/CalendarMain.tsx +47 -0
- package/src/schedule/Calendar/CalendarToolbar.tsx +106 -0
- package/src/schedule/Calendar/Column.tsx +129 -0
- package/src/schedule/Calendar/EventBlock.tsx +71 -0
- package/src/schedule/Calendar/MiniMonth.tsx +169 -0
- package/src/schedule/Calendar/MonthGrid.tsx +296 -0
- package/src/schedule/Calendar/TimeGrid.tsx +252 -0
- package/src/schedule/Calendar/Timeline.tsx +287 -0
- package/src/schedule/Calendar/ZoneChip.tsx +73 -0
- package/src/schedule/Calendar/calendar-shell.ts +160 -0
- package/src/schedule/Calendar/calendar-state.ts +30 -0
- package/src/schedule/Calendar/now-spans.tsx +33 -0
- package/src/schedule/Calendar/shared.ts +3 -0
- package/src/schedule/Calendar/state-actions.ts +189 -0
- package/src/schedule/Calendar/state-base.ts +143 -0
- package/src/schedule/Calendar/state-keys.ts +128 -0
- package/src/schedule/Calendar/time-fit.ts +84 -0
- package/src/schedule/Calendar.tsx +182 -0
- package/src/schedule/EventEditor.tsx +267 -0
- package/src/schedule/EventPopover.tsx +190 -0
- package/src/schedule/MeetingPlanner-model.ts +222 -0
- package/src/schedule/MeetingPlanner-view.tsx +310 -0
- package/src/schedule/MeetingPlanner.tsx +122 -0
- package/src/schedule/MoveSheet.tsx +168 -0
- package/src/schedule/YearView-model.ts +164 -0
- package/src/schedule/YearView-parts.tsx +147 -0
- package/src/schedule/YearView.tsx +100 -0
- package/src/schedule/bits.tsx +65 -0
- package/src/schedule/index.ts +25 -0
- package/src/skeleton-css.ts +4 -0
- package/src/styles.ts +13 -0
- package/src/type.css +15 -0
- package/src/ui.ts +41 -0
- package/src/use-ui.ts +10 -0
- package/tailwind.css +38 -0
- package/tokens/color.mjs +87 -0
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { FileTextIcon, LockIcon, TrashIcon } from '@kerf-js/veneer-icons'
|
|
2
|
+
import { money } from '@kerf-js/veneer-core'
|
|
3
|
+
import { derived, state, type State } from '@kerf-js/core'
|
|
4
|
+
import { Badge } from '../Badge'
|
|
5
|
+
import { Button, type Tone } from '../Button'
|
|
6
|
+
import { Banner } from '../parts'
|
|
7
|
+
import { Table, type Column } from '../Table'
|
|
8
|
+
import { toast } from '../Toast'
|
|
9
|
+
import { use } from '@kerf-js/veneer-core/kerf'
|
|
10
|
+
import { read } from './atoms'
|
|
11
|
+
import '../styles'
|
|
12
|
+
import '@kerf-js/veneer-core/styles/flows/tokens.css'
|
|
13
|
+
import '@kerf-js/veneer-core/styles/flows/base.css'
|
|
14
|
+
import '@kerf-js/veneer-core/styles/rich/helpers.css'
|
|
15
|
+
import '@kerf-js/veneer-core/styles/layout/tokens.css'
|
|
16
|
+
import '@kerf-js/veneer-core/styles/layout/row.css'
|
|
17
|
+
import '@kerf-js/veneer-core/styles/layout/stack.css'
|
|
18
|
+
import '@kerf-js/veneer-core/styles/data/list.css'
|
|
19
|
+
import '@kerf-js/veneer-core/styles/flows/pay-frame.css'
|
|
20
|
+
import type { ProviderAppearance } from '../PaymentCard'
|
|
21
|
+
|
|
22
|
+
/** Where an invoice stands. */
|
|
23
|
+
export type InvoiceStatus = 'paid' | 'retrying' | 'failed' | 'open'
|
|
24
|
+
/** One invoice in the billing history. */
|
|
25
|
+
export type Invoice = {
|
|
26
|
+
id: string
|
|
27
|
+
date: string
|
|
28
|
+
number: string
|
|
29
|
+
status: InvoiceStatus
|
|
30
|
+
amount: number
|
|
31
|
+
pdf?: string
|
|
32
|
+
}
|
|
33
|
+
const STATUS: Record<InvoiceStatus, [string, Tone]> = {
|
|
34
|
+
paid: ['Paid', 'positive'],
|
|
35
|
+
retrying: ['Retrying', 'caution'],
|
|
36
|
+
failed: ['Failed', 'critical'],
|
|
37
|
+
open: ['Open', 'neutral'],
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Invoices (09 §4.3): a DataTable; a failed payment pins a Banner above it with "Update payment method". */
|
|
41
|
+
export function Invoices({
|
|
42
|
+
invoices,
|
|
43
|
+
currency,
|
|
44
|
+
locale,
|
|
45
|
+
onUpdatePayment,
|
|
46
|
+
onExport,
|
|
47
|
+
}: {
|
|
48
|
+
invoices: readonly Invoice[] | State<readonly Invoice[]>
|
|
49
|
+
currency?: string | undefined
|
|
50
|
+
locale?: string | undefined
|
|
51
|
+
onUpdatePayment?: () => void
|
|
52
|
+
onExport?: () => void
|
|
53
|
+
}) {
|
|
54
|
+
const list = derived(() => read(invoices))
|
|
55
|
+
const failed = derived(() => list.value.some((i) => i.status === 'failed'))
|
|
56
|
+
const columns = invoiceColumns(
|
|
57
|
+
() => currency,
|
|
58
|
+
() => locale,
|
|
59
|
+
)
|
|
60
|
+
const fix = derived(() => (
|
|
61
|
+
<Button size="sm" tone="critical" onClick={() => onUpdatePayment?.()}>
|
|
62
|
+
Update payment method
|
|
63
|
+
</Button>
|
|
64
|
+
)) // one build: Banner reads the prop twice
|
|
65
|
+
const tools = derived(() =>
|
|
66
|
+
onExport ? (
|
|
67
|
+
<Button emphasis="ghost" tone="neutral" size="sm" onClick={onExport}>
|
|
68
|
+
Export CSV
|
|
69
|
+
</Button>
|
|
70
|
+
) : undefined,
|
|
71
|
+
) // one build: Table reads the prop twice
|
|
72
|
+
return (
|
|
73
|
+
<div data-scope="stack">
|
|
74
|
+
{failed.value && (
|
|
75
|
+
<Banner tone="critical" live="polite" actions={fix.value}>
|
|
76
|
+
Your last payment failed. Update your card to keep this plan.
|
|
77
|
+
</Banner>
|
|
78
|
+
)}
|
|
79
|
+
<Table
|
|
80
|
+
caption="Invoices"
|
|
81
|
+
captionHidden
|
|
82
|
+
rows={list}
|
|
83
|
+
columns={columns}
|
|
84
|
+
picker={false}
|
|
85
|
+
heading={3}
|
|
86
|
+
actions={tools.value}
|
|
87
|
+
empty={{
|
|
88
|
+
title: 'No invoices yet',
|
|
89
|
+
text: 'Your first one comes at the end of this period.',
|
|
90
|
+
}}
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function invoiceColumns(
|
|
97
|
+
currency: () => string | undefined,
|
|
98
|
+
locale: () => string | undefined,
|
|
99
|
+
): Column<Invoice>[] {
|
|
100
|
+
return [
|
|
101
|
+
{ id: 'date', header: 'Date', rowHeader: true, card: 'title' },
|
|
102
|
+
{ id: 'number', header: 'Number' },
|
|
103
|
+
{
|
|
104
|
+
id: 'status',
|
|
105
|
+
header: 'Status',
|
|
106
|
+
card: 'badge',
|
|
107
|
+
cell: (i) => (
|
|
108
|
+
<Badge tone={STATUS[i.status][1]} dot>
|
|
109
|
+
{STATUS[i.status][0]}
|
|
110
|
+
</Badge>
|
|
111
|
+
),
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
id: 'amount',
|
|
115
|
+
header: 'Amount',
|
|
116
|
+
numeric: true,
|
|
117
|
+
value: (i) => money(i.amount, currency(), locale()),
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
id: 'pdf',
|
|
121
|
+
header: 'Receipt',
|
|
122
|
+
value: () => '',
|
|
123
|
+
cell: (i) =>
|
|
124
|
+
i.pdf ? (
|
|
125
|
+
<a
|
|
126
|
+
data-scope="button"
|
|
127
|
+
data-emphasis="ghost"
|
|
128
|
+
data-tone="neutral"
|
|
129
|
+
data-size="sm"
|
|
130
|
+
data-icon-only=""
|
|
131
|
+
href={i.pdf}
|
|
132
|
+
aria-label={`PDF for ${i.number}`}
|
|
133
|
+
>
|
|
134
|
+
<FileTextIcon />
|
|
135
|
+
</a>
|
|
136
|
+
) : (
|
|
137
|
+
''
|
|
138
|
+
),
|
|
139
|
+
},
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** A card on file. */
|
|
144
|
+
export type PaymentMethod = {
|
|
145
|
+
id: string
|
|
146
|
+
brand: string
|
|
147
|
+
last4: string
|
|
148
|
+
expires: string
|
|
149
|
+
default?: boolean
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Saved cards (09 §4.3): the last four only. Make default applies at once; remove gives Undo. Details live with the provider. */
|
|
153
|
+
export function PaymentMethods({
|
|
154
|
+
methods,
|
|
155
|
+
onAdd,
|
|
156
|
+
onDefault,
|
|
157
|
+
onRemove,
|
|
158
|
+
onRestore,
|
|
159
|
+
}: {
|
|
160
|
+
methods: readonly PaymentMethod[] | State<readonly PaymentMethod[]>
|
|
161
|
+
onAdd?: () => void
|
|
162
|
+
onDefault: (m: PaymentMethod) => void
|
|
163
|
+
onRemove: (m: PaymentMethod) => void
|
|
164
|
+
onRestore?: (m: PaymentMethod) => void
|
|
165
|
+
}) {
|
|
166
|
+
const list = derived(() => read(methods))
|
|
167
|
+
const name = (m: PaymentMethod) => `${m.brand} ending ${m.last4}`
|
|
168
|
+
return (
|
|
169
|
+
<div data-scope="stack">
|
|
170
|
+
<ul data-scope="list" aria-label="Payment methods">
|
|
171
|
+
{list.value.map((m) => (
|
|
172
|
+
<li key={m.id}>
|
|
173
|
+
<div data-part="item">
|
|
174
|
+
<span></span>
|
|
175
|
+
<span>
|
|
176
|
+
<b>{name(m)}</b>
|
|
177
|
+
<br />
|
|
178
|
+
<span class="muted">Expires {m.expires}</span>
|
|
179
|
+
</span>
|
|
180
|
+
<span class="row">
|
|
181
|
+
{m.default ? (
|
|
182
|
+
<Badge tone="neutral">Default</Badge>
|
|
183
|
+
) : (
|
|
184
|
+
<>
|
|
185
|
+
<Button
|
|
186
|
+
emphasis="link"
|
|
187
|
+
aria-label={`Make default: ${name(m)}`}
|
|
188
|
+
onClick={() => {
|
|
189
|
+
onDefault(m)
|
|
190
|
+
toast.show({ title: 'Default payment method changed', tone: 'positive' })
|
|
191
|
+
}}
|
|
192
|
+
>
|
|
193
|
+
Make default
|
|
194
|
+
</Button>
|
|
195
|
+
<Button
|
|
196
|
+
emphasis="ghost"
|
|
197
|
+
tone="critical"
|
|
198
|
+
size="sm"
|
|
199
|
+
data-icon-only=""
|
|
200
|
+
label={`Remove ${name(m)}`}
|
|
201
|
+
onClick={() => {
|
|
202
|
+
onRemove(m)
|
|
203
|
+
toast.show({
|
|
204
|
+
title: `${name(m)} removed`,
|
|
205
|
+
action: onRestore && { label: 'Undo', onClick: () => onRestore(m) },
|
|
206
|
+
})
|
|
207
|
+
}}
|
|
208
|
+
>
|
|
209
|
+
<TrashIcon />
|
|
210
|
+
</Button>
|
|
211
|
+
</>
|
|
212
|
+
)}
|
|
213
|
+
</span>
|
|
214
|
+
</div>
|
|
215
|
+
</li>
|
|
216
|
+
))}
|
|
217
|
+
</ul>
|
|
218
|
+
{onAdd && (
|
|
219
|
+
<div>
|
|
220
|
+
<Button emphasis="frame" size="sm" onClick={onAdd}>
|
|
221
|
+
Add method
|
|
222
|
+
</Button>
|
|
223
|
+
</div>
|
|
224
|
+
)}
|
|
225
|
+
<span class="muted">
|
|
226
|
+
Card details live with the payment provider; veneer only shows the last four digits.
|
|
227
|
+
</span>
|
|
228
|
+
</div>
|
|
229
|
+
)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** Props for PayFrame. */
|
|
233
|
+
export interface PayFrameProps {
|
|
234
|
+
/** The iframe's title: what's inside it, for a screen reader (09 §1.5). */
|
|
235
|
+
title: string
|
|
236
|
+
/** The provider's hosted page. */
|
|
237
|
+
src?: string
|
|
238
|
+
/** Or mount the provider's fields here, with Veneer's tokens for its appearance API. */
|
|
239
|
+
mount?: (el: HTMLElement, appearance: ProviderAppearance) => { destroy(): void }
|
|
240
|
+
testMode?: boolean
|
|
241
|
+
/** Ready once the provider says so; a `src` frame also flips on its load event. */
|
|
242
|
+
ready?: boolean
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* The payment slot (09 §4.3): Veneer styles it (border, radius, shimmer, test-mode badge) and passes tokens to the
|
|
247
|
+
* provider. It's an iframe slot only: Veneer never renders a card field.
|
|
248
|
+
*/
|
|
249
|
+
export function PayFrame({ title, src, mount, testMode, ready }: PayFrameProps) {
|
|
250
|
+
const loaded = state(false)
|
|
251
|
+
const done = derived(() => !!ready || loaded.value)
|
|
252
|
+
const hosted = derived(() => !!src)
|
|
253
|
+
let host: HTMLDivElement | undefined
|
|
254
|
+
use(
|
|
255
|
+
(el: HTMLDivElement) => {
|
|
256
|
+
if (!mount) return { update() {}, destroy() {} }
|
|
257
|
+
const css = getComputedStyle(el)
|
|
258
|
+
const token = (t: string) => css.getPropertyValue(`--veneer-${t}`).trim()
|
|
259
|
+
const made = mount(el, {
|
|
260
|
+
fontFamily: css.fontFamily,
|
|
261
|
+
fontSize: token('text-control-size'),
|
|
262
|
+
color: token('color-text'),
|
|
263
|
+
errorColor: token('color-critical-text'),
|
|
264
|
+
borderRadius: token('radius-control'),
|
|
265
|
+
borderColor: token('color-border-control'),
|
|
266
|
+
})
|
|
267
|
+
return { update() {}, destroy: () => made.destroy() }
|
|
268
|
+
},
|
|
269
|
+
() => host,
|
|
270
|
+
)
|
|
271
|
+
return (
|
|
272
|
+
<div
|
|
273
|
+
data-scope="pay-frame"
|
|
274
|
+
data-state={done.value ? undefined : 'loading'}
|
|
275
|
+
aria-busy={done.value ? undefined : 'true'}
|
|
276
|
+
>
|
|
277
|
+
<div data-part="head">
|
|
278
|
+
<span class="row">
|
|
279
|
+
<LockIcon />
|
|
280
|
+
Card fields are hosted by your payment provider
|
|
281
|
+
</span>
|
|
282
|
+
{testMode && <Badge tone="caution">Test mode</Badge>}
|
|
283
|
+
</div>
|
|
284
|
+
<div ref={(n) => (host = n)} data-part="slot" role="group" aria-label={title}>
|
|
285
|
+
{!done.value && (
|
|
286
|
+
<>
|
|
287
|
+
<i data-loop=""></i>
|
|
288
|
+
<div>
|
|
289
|
+
<i data-loop=""></i>
|
|
290
|
+
<i data-loop=""></i>
|
|
291
|
+
</div>
|
|
292
|
+
</>
|
|
293
|
+
)}
|
|
294
|
+
{hosted.value && (
|
|
295
|
+
<iframe
|
|
296
|
+
src={src}
|
|
297
|
+
title={title}
|
|
298
|
+
width="100%"
|
|
299
|
+
height="148"
|
|
300
|
+
frameborder="0"
|
|
301
|
+
onLoad={() => (loaded.value = true)}
|
|
302
|
+
></iframe>
|
|
303
|
+
)}
|
|
304
|
+
</div>
|
|
305
|
+
</div>
|
|
306
|
+
)
|
|
307
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { BagIcon, MinusIcon, PlusIcon } from '@kerf-js/veneer-icons'
|
|
2
|
+
import { cartCount, cartTotals, money, type CartLine } from '@kerf-js/veneer-core'
|
|
3
|
+
import { derived, type State } from '@kerf-js/core'
|
|
4
|
+
import { Badge } from '../Badge'
|
|
5
|
+
import { Button } from '../Button'
|
|
6
|
+
import { Drawer } from '../Drawer'
|
|
7
|
+
import { toast } from '../Toast'
|
|
8
|
+
import { afterFlush } from './atoms'
|
|
9
|
+
import '../styles'
|
|
10
|
+
import '@kerf-js/veneer-core/styles/flows/tokens.css'
|
|
11
|
+
import '@kerf-js/veneer-core/styles/flows/base.css'
|
|
12
|
+
import '@kerf-js/veneer-core/styles/rich/helpers.css'
|
|
13
|
+
import '@kerf-js/veneer-core/styles/layout/tokens.css'
|
|
14
|
+
import '@kerf-js/veneer-core/styles/layout/row.css'
|
|
15
|
+
import '@kerf-js/veneer-core/styles/layout/stack.css'
|
|
16
|
+
import '@kerf-js/veneer-core/styles/app/badge.css' // the count's bump
|
|
17
|
+
import '@kerf-js/veneer-core/styles/flows/line-item.css'
|
|
18
|
+
import '@kerf-js/veneer-core/styles/flows/lines.css'
|
|
19
|
+
import '@kerf-js/veneer-core/styles/flows/qty.css'
|
|
20
|
+
|
|
21
|
+
export const setQuantity = (cart: State<CartLine[]>, id: string, quantity: number) =>
|
|
22
|
+
(cart.value = cart.value.map((l) => (l.id === id ? { ...l, quantity } : l)))
|
|
23
|
+
|
|
24
|
+
/** Takes a line out, with Undo back to where it was. */
|
|
25
|
+
export function removeLine(cart: State<CartLine[]>, line: CartLine) {
|
|
26
|
+
const at = cart.value.findIndex((l) => l.id === line.id)
|
|
27
|
+
cart.value = cart.value.filter((l) => l.id !== line.id)
|
|
28
|
+
toast.show({
|
|
29
|
+
title: 'Removed from cart',
|
|
30
|
+
description: line.name,
|
|
31
|
+
action: {
|
|
32
|
+
label: 'Undo',
|
|
33
|
+
onClick: () => {
|
|
34
|
+
const next = [...cart.value]
|
|
35
|
+
next.splice(at, 0, line)
|
|
36
|
+
cart.value = next
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** One line: thumb, name, variant, stepper, price (09 §6.1). The stepper's minus at 1 removes, asks nothing, gives Undo. */
|
|
43
|
+
export function LineItem({
|
|
44
|
+
line,
|
|
45
|
+
cart,
|
|
46
|
+
currency,
|
|
47
|
+
locale,
|
|
48
|
+
problem,
|
|
49
|
+
}: {
|
|
50
|
+
line: CartLine
|
|
51
|
+
cart: State<CartLine[]>
|
|
52
|
+
currency?: string | undefined
|
|
53
|
+
locale?: string | undefined
|
|
54
|
+
problem?: unknown
|
|
55
|
+
}) {
|
|
56
|
+
const down = () =>
|
|
57
|
+
line.quantity <= 1 ? removeLine(cart, line) : setQuantity(cart, line.id, line.quantity - 1)
|
|
58
|
+
return (
|
|
59
|
+
<div data-scope="line-item" data-id={line.id}>
|
|
60
|
+
<span data-part="thumb">{line.art && <img src={line.art} alt="" />}</span>
|
|
61
|
+
<span>
|
|
62
|
+
<b id={`li-${line.id}`}>{line.name}</b>
|
|
63
|
+
<small>
|
|
64
|
+
{line.variant ? `${line.variant} · ` : ''}
|
|
65
|
+
{money(line.price, currency, locale)}
|
|
66
|
+
</small>
|
|
67
|
+
{problem && (
|
|
68
|
+
<>
|
|
69
|
+
<br />
|
|
70
|
+
<Badge tone="critical">{problem}</Badge>
|
|
71
|
+
</>
|
|
72
|
+
)}
|
|
73
|
+
</span>
|
|
74
|
+
<span data-part="price">
|
|
75
|
+
{money(line.price * line.quantity, currency, locale)}
|
|
76
|
+
<span data-scope="qty">
|
|
77
|
+
<button
|
|
78
|
+
type="button"
|
|
79
|
+
aria-label={line.quantity <= 1 ? `Remove ${line.name}` : `Fewer ${line.name}`}
|
|
80
|
+
onClick={down}
|
|
81
|
+
>
|
|
82
|
+
<MinusIcon />
|
|
83
|
+
</button>
|
|
84
|
+
<output aria-live="polite" aria-label={`Quantity of ${line.name}`}>
|
|
85
|
+
{line.quantity}
|
|
86
|
+
</output>
|
|
87
|
+
<button
|
|
88
|
+
type="button"
|
|
89
|
+
aria-label={`More ${line.name}`}
|
|
90
|
+
onClick={() => setQuantity(cart, line.id, line.quantity + 1)}
|
|
91
|
+
>
|
|
92
|
+
<PlusIcon />
|
|
93
|
+
</button>
|
|
94
|
+
</span>
|
|
95
|
+
</span>
|
|
96
|
+
</div>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** The cart button: a count badge, and the count said in words. */
|
|
101
|
+
export function CartButton({ count, onClick }: { count: number; onClick: () => void }) {
|
|
102
|
+
return (
|
|
103
|
+
<Button
|
|
104
|
+
emphasis="ghost"
|
|
105
|
+
tone="neutral"
|
|
106
|
+
data-icon-only=""
|
|
107
|
+
label={`Cart, ${count} items`}
|
|
108
|
+
style="position:relative"
|
|
109
|
+
onClick={onClick}
|
|
110
|
+
>
|
|
111
|
+
<BagIcon />
|
|
112
|
+
{/* keyed by the count, so a new number is a new node and the bump replays once */}
|
|
113
|
+
{[count]
|
|
114
|
+
.filter((n) => n > 0)
|
|
115
|
+
.map((n) => (
|
|
116
|
+
<Badge
|
|
117
|
+
key={n}
|
|
118
|
+
count
|
|
119
|
+
emphasis="solid"
|
|
120
|
+
aria-hidden="true"
|
|
121
|
+
data-bump=""
|
|
122
|
+
style="position:absolute;inset:-2px -4px auto auto"
|
|
123
|
+
>
|
|
124
|
+
{n}
|
|
125
|
+
</Badge>
|
|
126
|
+
))}
|
|
127
|
+
</Button>
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Props for CartDrawer. */
|
|
132
|
+
export interface CartDrawerProps {
|
|
133
|
+
open: State<boolean>
|
|
134
|
+
cart: State<CartLine[]>
|
|
135
|
+
currency?: string | undefined
|
|
136
|
+
locale?: string | undefined
|
|
137
|
+
onCheckout: () => void
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** The cart drawer (09 §6.1): a Sheet, right on wide screens and from the bottom on a phone, with the subtotal and Checkout. */
|
|
141
|
+
export function CartDrawer({ open, cart, currency, locale, onCheckout }: CartDrawerProps) {
|
|
142
|
+
const lines = derived(() => cart.value)
|
|
143
|
+
const n = derived(() => cartCount(lines.value))
|
|
144
|
+
const subtotal = derived(() => cartTotals(lines.value).subtotal)
|
|
145
|
+
const go = () => {
|
|
146
|
+
open.value = false
|
|
147
|
+
afterFlush(onCheckout)
|
|
148
|
+
}
|
|
149
|
+
return (
|
|
150
|
+
<Drawer
|
|
151
|
+
open={open}
|
|
152
|
+
title={`Cart · ${n.value} ${n.value === 1 ? 'item' : 'items'}`}
|
|
153
|
+
footer={
|
|
154
|
+
<div data-scope="stack">
|
|
155
|
+
<dl data-scope="lines">
|
|
156
|
+
<div data-part="total">
|
|
157
|
+
<dt>Subtotal</dt>
|
|
158
|
+
<dd>{money(subtotal.value, currency, locale)}</dd>
|
|
159
|
+
</div>
|
|
160
|
+
</dl>
|
|
161
|
+
<span class="muted">Shipping and tax at checkout.</span>
|
|
162
|
+
<Button size="lg" full disabled={!n.value} autofocus onClick={go}>
|
|
163
|
+
Checkout
|
|
164
|
+
</Button>
|
|
165
|
+
</div>
|
|
166
|
+
}
|
|
167
|
+
>
|
|
168
|
+
{lines.value.length ? (
|
|
169
|
+
lines.value.map((l) => (
|
|
170
|
+
<LineItem key={l.id} line={l} cart={cart} currency={currency} locale={locale} />
|
|
171
|
+
))
|
|
172
|
+
) : (
|
|
173
|
+
<span class="muted">Your cart is empty.</span>
|
|
174
|
+
)}
|
|
175
|
+
</Drawer>
|
|
176
|
+
)
|
|
177
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Alert } from '../Alert'
|
|
2
|
+
import { Button } from '../Button'
|
|
3
|
+
import { Checkbox } from '../Choice'
|
|
4
|
+
import { Input } from '../Field'
|
|
5
|
+
import { AddressField } from '../PlaceField'
|
|
6
|
+
import type { CheckoutModel, CheckoutNav } from './Checkout-view'
|
|
7
|
+
|
|
8
|
+
export function checkoutAddress(model: CheckoutModel, Nav: CheckoutNav) {
|
|
9
|
+
const {
|
|
10
|
+
id,
|
|
11
|
+
step,
|
|
12
|
+
phone,
|
|
13
|
+
address,
|
|
14
|
+
billing,
|
|
15
|
+
sameBilling,
|
|
16
|
+
addressErrors,
|
|
17
|
+
billingErrors,
|
|
18
|
+
addressAlert,
|
|
19
|
+
} = model.s
|
|
20
|
+
const { input } = model
|
|
21
|
+
const live = addressProps(input)
|
|
22
|
+
const { submitAddress } = model.nav
|
|
23
|
+
return (
|
|
24
|
+
<section
|
|
25
|
+
data-part="step"
|
|
26
|
+
data-step="address"
|
|
27
|
+
data-state={step.value === 'address' ? 'active' : undefined}
|
|
28
|
+
aria-labelledby={`${id}-address`}
|
|
29
|
+
>
|
|
30
|
+
<form data-part="step-body" novalidate onSubmit={submitAddress}>
|
|
31
|
+
<h2 data-part="step-title" id={`${id}-address`} tabindex="-1">
|
|
32
|
+
Where should it go?
|
|
33
|
+
</h2>
|
|
34
|
+
{addressAlert.value && <Alert tone="critical">{addressAlert.value}</Alert>}
|
|
35
|
+
{checkoutContact(model)}
|
|
36
|
+
<AddressField
|
|
37
|
+
label="Shipping address"
|
|
38
|
+
value={address}
|
|
39
|
+
countries={live.countries}
|
|
40
|
+
defaultCountry={live.defaultCountry!}
|
|
41
|
+
provider={live.addressProvider}
|
|
42
|
+
locale={live.locale}
|
|
43
|
+
errors={addressErrors.value}
|
|
44
|
+
/>
|
|
45
|
+
<Input
|
|
46
|
+
label="Phone (optional)"
|
|
47
|
+
type="tel"
|
|
48
|
+
autocomplete="tel"
|
|
49
|
+
inputmode="tel"
|
|
50
|
+
hint="Only for the courier, if they can’t find you."
|
|
51
|
+
value={phone.value}
|
|
52
|
+
onInput={(e) => (phone.value = e.currentTarget.value)}
|
|
53
|
+
/>
|
|
54
|
+
<Checkbox
|
|
55
|
+
checked={sameBilling.value}
|
|
56
|
+
onChange={(e: Event) =>
|
|
57
|
+
(sameBilling.value = (e.currentTarget as HTMLInputElement).checked)
|
|
58
|
+
}
|
|
59
|
+
>
|
|
60
|
+
Use as billing address
|
|
61
|
+
</Checkbox>
|
|
62
|
+
{!sameBilling.value && (
|
|
63
|
+
<AddressField
|
|
64
|
+
label="Billing address"
|
|
65
|
+
value={billing}
|
|
66
|
+
countries={live.countries}
|
|
67
|
+
defaultCountry={live.defaultCountry!}
|
|
68
|
+
locale={live.locale}
|
|
69
|
+
errors={billingErrors.value}
|
|
70
|
+
/>
|
|
71
|
+
)}
|
|
72
|
+
<Nav back="cart">
|
|
73
|
+
<Button type="submit">Continue to shipping</Button>
|
|
74
|
+
</Nav>
|
|
75
|
+
</form>
|
|
76
|
+
</section>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function checkoutContact(model: CheckoutModel) {
|
|
81
|
+
const { name, email, nameError, emailError } = model.s
|
|
82
|
+
return (
|
|
83
|
+
<div data-part="cols">
|
|
84
|
+
<Input
|
|
85
|
+
label="Full name"
|
|
86
|
+
autocomplete="name"
|
|
87
|
+
value={name.value}
|
|
88
|
+
error={nameError.value}
|
|
89
|
+
onInput={(e) => {
|
|
90
|
+
name.value = e.currentTarget.value
|
|
91
|
+
nameError.value = ''
|
|
92
|
+
}}
|
|
93
|
+
/>
|
|
94
|
+
<Input
|
|
95
|
+
label="Email for receipt"
|
|
96
|
+
type="email"
|
|
97
|
+
autocomplete="email"
|
|
98
|
+
inputmode="email"
|
|
99
|
+
value={email.value}
|
|
100
|
+
error={emailError.value}
|
|
101
|
+
onInput={(e) => {
|
|
102
|
+
email.value = e.currentTarget.value
|
|
103
|
+
emailError.value = ''
|
|
104
|
+
}}
|
|
105
|
+
/>
|
|
106
|
+
</div>
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function addressProps(input: CheckoutModel['input']) {
|
|
111
|
+
return {
|
|
112
|
+
get countries() {
|
|
113
|
+
return input.countries()
|
|
114
|
+
},
|
|
115
|
+
get defaultCountry() {
|
|
116
|
+
return input.defaultCountry()
|
|
117
|
+
},
|
|
118
|
+
get addressProvider() {
|
|
119
|
+
return input.addressProvider()
|
|
120
|
+
},
|
|
121
|
+
get locale() {
|
|
122
|
+
return input.locale()
|
|
123
|
+
},
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Alert } from '../Alert'
|
|
2
|
+
import { Button } from '../Button'
|
|
3
|
+
import { LineItem } from './Cart'
|
|
4
|
+
import type { CheckoutModel } from './Checkout-view'
|
|
5
|
+
|
|
6
|
+
export function checkoutCart(model: CheckoutModel) {
|
|
7
|
+
const { id, step, outOfStock, lines } = model.s
|
|
8
|
+
const { input } = model
|
|
9
|
+
const live = {
|
|
10
|
+
get cart() {
|
|
11
|
+
return input.cart()
|
|
12
|
+
},
|
|
13
|
+
get currency() {
|
|
14
|
+
return input.currency()
|
|
15
|
+
},
|
|
16
|
+
get locale() {
|
|
17
|
+
return input.locale()
|
|
18
|
+
},
|
|
19
|
+
get onContinueShopping() {
|
|
20
|
+
return input.onContinueShopping()
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
const { count } = model
|
|
24
|
+
const { go } = model.nav
|
|
25
|
+
return (
|
|
26
|
+
<section
|
|
27
|
+
data-part="step"
|
|
28
|
+
data-step="cart"
|
|
29
|
+
data-state={step.value === 'cart' ? 'active' : undefined}
|
|
30
|
+
aria-labelledby={`${id}-cart`}
|
|
31
|
+
>
|
|
32
|
+
<div data-part="step-body">
|
|
33
|
+
<h2 data-part="step-title" id={`${id}-cart`} tabindex="-1">
|
|
34
|
+
Your cart
|
|
35
|
+
</h2>
|
|
36
|
+
{input.signInHref() && (
|
|
37
|
+
<span class="muted">
|
|
38
|
+
Checking out as a guest. <a href={input.signInHref()}>Sign in</a>
|
|
39
|
+
</span>
|
|
40
|
+
)}
|
|
41
|
+
{outOfStock.value && (
|
|
42
|
+
<Alert tone="critical" live title="Part of your order just sold out">
|
|
43
|
+
Remove the marked line to continue.
|
|
44
|
+
</Alert>
|
|
45
|
+
)}
|
|
46
|
+
{lines.value.length ? (
|
|
47
|
+
lines.value.map((l) => (
|
|
48
|
+
<LineItem
|
|
49
|
+
key={l.id}
|
|
50
|
+
line={l}
|
|
51
|
+
cart={live.cart}
|
|
52
|
+
currency={live.currency}
|
|
53
|
+
locale={live.locale}
|
|
54
|
+
problem={l.id === outOfStock.value ? 'Out of stock' : undefined}
|
|
55
|
+
/>
|
|
56
|
+
))
|
|
57
|
+
) : (
|
|
58
|
+
<span class="muted">Your cart is empty.</span>
|
|
59
|
+
)}
|
|
60
|
+
<div data-part="nav">
|
|
61
|
+
{live.onContinueShopping ? (
|
|
62
|
+
<Button emphasis="link" onClick={live.onContinueShopping}>
|
|
63
|
+
Continue shopping
|
|
64
|
+
</Button>
|
|
65
|
+
) : (
|
|
66
|
+
<span></span>
|
|
67
|
+
)}
|
|
68
|
+
<Button
|
|
69
|
+
disabled={!count.value || lines.value.some((l) => l.id === outOfStock.value)}
|
|
70
|
+
onClick={() => go('address')}
|
|
71
|
+
>
|
|
72
|
+
Continue to address
|
|
73
|
+
</Button>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
</section>
|
|
77
|
+
)
|
|
78
|
+
}
|