@eifi1/ui-kit 0.39.0 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/README.md +8 -7
  2. package/dist/billing/billing-overview.d.ts +12 -2
  3. package/dist/billing/pay-page.js +1 -1
  4. package/dist/billing/pay-page.js.map +1 -1
  5. package/dist/bin/eifi1-pay-page.mjs +1 -1
  6. package/dist/components/autocomplete.js +5 -1
  7. package/dist/components/autocomplete.js.map +1 -1
  8. package/dist/components/combobox-core.d.ts +14 -1
  9. package/dist/components/combobox-core.js +4 -0
  10. package/dist/components/combobox-core.js.map +1 -1
  11. package/dist/components/combobox.js +9 -3
  12. package/dist/components/combobox.js.map +1 -1
  13. package/dist/components/data-table-labels.d.ts +5 -0
  14. package/dist/components/data-table-labels.js +2 -0
  15. package/dist/components/data-table-labels.js.map +1 -1
  16. package/dist/components/data-table-mobile.d.ts +36 -1
  17. package/dist/components/data-table-mobile.js +162 -15
  18. package/dist/components/data-table-mobile.js.map +1 -1
  19. package/dist/components/data-table.d.ts +39 -12
  20. package/dist/components/data-table.js +74 -13
  21. package/dist/components/data-table.js.map +1 -1
  22. package/dist/components/inline-entity-combobox.js +10 -3
  23. package/dist/components/inline-entity-combobox.js.map +1 -1
  24. package/dist/components/picker-sheet.d.ts +18 -1
  25. package/dist/components/picker-sheet.js +20 -2
  26. package/dist/components/picker-sheet.js.map +1 -1
  27. package/dist/components/tabs.d.ts +26 -2
  28. package/dist/components/tabs.js +41 -2
  29. package/dist/components/tabs.js.map +1 -1
  30. package/dist/components/translation-review-parts.d.ts +2 -1
  31. package/dist/components/translation-review-parts.js +1 -1
  32. package/dist/components/translation-review-parts.js.map +1 -1
  33. package/dist/components/ui-labels.js +3 -1
  34. package/dist/components/ui-labels.js.map +1 -1
  35. package/dist/eslint/index.js +1 -1
  36. package/dist/feedback/feedback-comment-thread.d.ts +8 -1
  37. package/dist/feedback/feedback-comment-thread.js +26 -1
  38. package/dist/feedback/feedback-comment-thread.js.map +1 -1
  39. package/dist/feedback/feedback-labels.d.ts +2 -1
  40. package/dist/feedback/feedback-labels.js +1 -0
  41. package/dist/feedback/feedback-labels.js.map +1 -1
  42. package/dist/feedback/feedback-menu-labels.js +3 -1
  43. package/dist/feedback/feedback-menu-labels.js.map +1 -1
  44. package/dist/feedback/feedback-menu.d.ts +31 -24
  45. package/dist/feedback/feedback-menu.js +16 -7
  46. package/dist/feedback/feedback-menu.js.map +1 -1
  47. package/dist/feedback/feedback-public-labels.d.ts +3 -2
  48. package/dist/feedback/feedback-public-labels.js +1 -1
  49. package/dist/feedback/feedback-public-labels.js.map +1 -1
  50. package/dist/feedback/feedback-public-list.js +1 -0
  51. package/dist/feedback/feedback-public-list.js.map +1 -1
  52. package/dist/feedback/feedback-public-types.d.ts +16 -3
  53. package/dist/feedback/feedback-record.d.ts +20 -3
  54. package/dist/feedback/feedback-record.js +15 -0
  55. package/dist/feedback/feedback-record.js.map +1 -1
  56. package/dist/feedback/feedback-replies.d.ts +13 -2
  57. package/dist/feedback/feedback-replies.js +67 -33
  58. package/dist/feedback/feedback-replies.js.map +1 -1
  59. package/dist/feedback/feedback-rework-entry-chip.d.ts +9 -0
  60. package/dist/feedback/feedback-rework-entry-chip.js +13 -0
  61. package/dist/feedback/feedback-rework-entry-chip.js.map +1 -0
  62. package/dist/feedback/feedback-row-detail.d.ts +31 -8
  63. package/dist/feedback/feedback-row-detail.js +31 -7
  64. package/dist/feedback/feedback-row-detail.js.map +1 -1
  65. package/dist/feedback/feedback-table-labels.js +1 -1
  66. package/dist/feedback/feedback-table-labels.js.map +1 -1
  67. package/dist/feedback/feedback-table.d.ts +5 -2
  68. package/dist/feedback/feedback-table.js +2 -2
  69. package/dist/feedback/feedback-table.js.map +1 -1
  70. package/dist/feedback/feedback-thread.js +3 -1
  71. package/dist/feedback/feedback-thread.js.map +1 -1
  72. package/dist/feedback/feedback-vocabulary.d.ts +9 -6
  73. package/dist/feedback/feedback-vocabulary.js +16 -1
  74. package/dist/feedback/feedback-vocabulary.js.map +1 -1
  75. package/dist/hooks/use-long-press.d.ts +30 -0
  76. package/dist/hooks/use-long-press.js +77 -0
  77. package/dist/hooks/use-long-press.js.map +1 -0
  78. package/dist/hooks/use-overlay-history.js +37 -3
  79. package/dist/hooks/use-overlay-history.js.map +1 -1
  80. package/dist/i18n/german.js +13 -5
  81. package/dist/i18n/german.js.map +1 -1
  82. package/dist/i18n/kit-labels.d.ts +3 -0
  83. package/dist/i18n/kit-labels.js.map +1 -1
  84. package/dist/i18n/locales/en.js +12 -5
  85. package/dist/i18n/locales/en.js.map +2 -2
  86. package/dist/i18n/locales/es.js +13 -5
  87. package/dist/i18n/locales/es.js.map +1 -1
  88. package/dist/i18n/locales/fr.js +13 -5
  89. package/dist/i18n/locales/fr.js.map +1 -1
  90. package/dist/i18n/locales/hu.js +13 -5
  91. package/dist/i18n/locales/hu.js.map +1 -1
  92. package/dist/i18n/locales/it.js +13 -5
  93. package/dist/i18n/locales/it.js.map +1 -1
  94. package/dist/i18n/locales/zh.js +13 -5
  95. package/dist/i18n/locales/zh.js.map +1 -1
  96. package/dist/i18n/shared-labels.js +1 -1
  97. package/dist/i18n/shared-labels.js.map +1 -1
  98. package/dist/pay/pay.js +1 -1
  99. package/dist/shell/app-shell.js +9 -0
  100. package/dist/shell/app-shell.js.map +1 -1
  101. package/dist/shell/fill-height.d.ts +38 -0
  102. package/dist/shell/fill-height.js +12 -0
  103. package/dist/shell/fill-height.js.map +1 -0
  104. package/dist/shell.d.ts +2 -0
  105. package/dist/shell.js +3 -0
  106. package/dist/shell.js.map +1 -1
  107. package/package.json +1 -1
  108. package/src/billing/billing-overview.ts +12 -2
  109. package/src/billing/pay-page.ts +1 -1
  110. package/src/components/autocomplete.tsx +5 -1
  111. package/src/components/combobox-core.tsx +20 -1
  112. package/src/components/combobox.tsx +9 -3
  113. package/src/components/data-table-labels.ts +7 -0
  114. package/src/components/data-table-mobile.tsx +193 -9
  115. package/src/components/data-table.tsx +141 -24
  116. package/src/components/inline-entity-combobox.tsx +12 -4
  117. package/src/components/picker-sheet.tsx +38 -1
  118. package/src/components/tabs.tsx +73 -3
  119. package/src/components/translation-review-parts.tsx +3 -2
  120. package/src/components/ui-labels.ts +2 -0
  121. package/src/feedback/feedback-comment-thread.tsx +39 -1
  122. package/src/feedback/feedback-labels.ts +3 -1
  123. package/src/feedback/feedback-menu-labels.ts +2 -0
  124. package/src/feedback/feedback-menu.tsx +48 -30
  125. package/src/feedback/feedback-public-labels.ts +4 -3
  126. package/src/feedback/feedback-public-list.tsx +4 -1
  127. package/src/feedback/feedback-public-types.ts +17 -3
  128. package/src/feedback/feedback-record.ts +34 -3
  129. package/src/feedback/feedback-replies.tsx +100 -31
  130. package/src/feedback/feedback-rework-entry-chip.tsx +18 -0
  131. package/src/feedback/feedback-row-detail.tsx +65 -12
  132. package/src/feedback/feedback-table-labels.ts +1 -1
  133. package/src/feedback/feedback-table.tsx +7 -4
  134. package/src/feedback/feedback-thread.tsx +5 -1
  135. package/src/feedback/feedback-vocabulary.ts +27 -6
  136. package/src/hooks/use-long-press.ts +126 -0
  137. package/src/hooks/use-overlay-history.ts +74 -3
  138. package/src/i18n/german.ts +10 -2
  139. package/src/i18n/kit-labels.tsx +3 -0
  140. package/src/i18n/locales/es.ts +10 -2
  141. package/src/i18n/locales/fr.ts +10 -2
  142. package/src/i18n/locales/hu.ts +10 -2
  143. package/src/i18n/locales/it.ts +10 -2
  144. package/src/i18n/locales/zh.ts +10 -2
  145. package/src/i18n/shared-labels.ts +1 -1
  146. package/src/shell/app-shell.tsx +9 -0
  147. package/src/shell/fill-height.tsx +45 -0
  148. package/src/shell.ts +3 -0
package/README.md CHANGED
@@ -556,20 +556,20 @@ columns, strings and permissions (see the note at the top of `src/feedback/feedb
556
556
 
557
557
  <!-- BEGIN GENERATED: exports — node scripts/gen-export-inventory.mjs -->
558
558
 
559
- **1975 names from 321 modules** — 912 values and 1063 types. _Italic_ is a type-only export.
559
+ **1982 names from 322 modules** — 916 values and 1066 types. _Italic_ is a type-only export.
560
560
 
561
561
  Generated from `dist/index.d.ts` by `node scripts/gen-export-inventory.mjs`; the count
562
562
  is pinned by `src/__tests__/public-surface.test.ts`. Do not edit between the markers.
563
563
 
564
564
  | Entry point | Names |
565
565
  |---|---|
566
- | `@eifi1/ui-kit` | 1975 |
566
+ | `@eifi1/ui-kit` | 1982 |
567
567
  | `@eifi1/ui-kit/chart` | 92 |
568
- | `@eifi1/ui-kit/shell` | 77 |
568
+ | `@eifi1/ui-kit/shell` | 80 |
569
569
  | `@eifi1/ui-kit/data-table` | 51 |
570
570
  | `@eifi1/ui-kit/wizard` | 24 |
571
571
  | `@eifi1/ui-kit/tour` | 7 |
572
- | `@eifi1/ui-kit/feedback` | 201 |
572
+ | `@eifi1/ui-kit/feedback` | 205 |
573
573
  | `@eifi1/ui-kit/search` | 23 |
574
574
  | `@eifi1/ui-kit/dates` | 22 |
575
575
  | `@eifi1/ui-kit/table-text` | 14 |
@@ -818,6 +818,7 @@ re-slicing of it, never a second API.
818
818
  | `shell/topbar-action-menu` | `TopBarActionMenu`, _`TopBarMenuEntry`_, _`TopBarMenuHeader`_ |
819
819
  | `shell/top-bar-brand` | `TopBarBrand`, _`TopBarBrandProps`_ |
820
820
  | `shell/auth-layout` | `AuthLayout`, _`AuthLayoutProps`_ |
821
+ | `shell/fill-height` | `FILL_HEIGHT_CLASS`, `FillHeight`, _`FillHeightProps`_ |
821
822
  | `shell/company-switcher` | `CompanySwitcher`, `DEFAULT_COMPANY_SWITCHER_LABELS`, _`CompanySwitcherCompany`_, _`CompanySwitcherLabels`_, _`CompanySwitcherProps`_ |
822
823
 
823
824
  ### settings
@@ -856,7 +857,7 @@ re-slicing of it, never a second API.
856
857
  | `feedback/feedback-dialog` | `DEFAULT_FEEDBACK_DIALOG_LABELS`, `FeedbackDialog`, _`FeedbackAttachmentLabels`_, _`FeedbackCategoryOption`_, _`FeedbackDialogLabels`_, _`FeedbackDialogMultipleProps`_, _`FeedbackDialogProps`_, _`FeedbackDialogSingleProps`_, _`FeedbackDialogTextLabels`_, _`FeedbackMultipleSubmission`_, _`FeedbackSubmission`_, _`FeedbackSubmitHint`_ |
857
858
  | `feedback/feedback-inbox` | `FeedbackCategoryBadge`, `FeedbackDetail`, `FeedbackDetailSection`, `FeedbackNoteEditor`, `FeedbackProse`, `FeedbackStatusBadge`, `FeedbackStatusTransitions`, _`FeedbackNoteAttachment`_ |
858
859
  | `feedback/feedback-thread` | `ChatComposer`, `DEFAULT_FEEDBACK_COMPOSER_LABELS`, `DEFAULT_FEEDBACK_THREAD_LABELS`, `FeedbackThread`, _`ChatComposerHandle`_, _`ChatComposerLabels`_, _`ChatComposerProps`_, _`ChatComposerSlotContext`_, _`FeedbackComposerAttachment`_, _`FeedbackComposerHandle`_, _`FeedbackComposerLabels`_, _`FeedbackComposerProps`_, _`FeedbackComposerSlotContext`_, _`FeedbackThreadAttachment`_, _`FeedbackThreadEvent`_, _`FeedbackThreadItem`_, _`FeedbackThreadLabels`_, _`FeedbackThreadMessage`_, _`FeedbackThreadProps`_ |
859
- | `feedback/feedback-record` | `appendRework`, `attachmentName`, `FEEDBACK_ATTACHMENT_ACCEPT`, `FEEDBACK_AUTHOR_EDITABLE_STATUSES`, `FEEDBACK_AWAITING_STATUSES`, `FEEDBACK_COMMENT_MAX`, `FEEDBACK_DECIDED_STATUSES`, `FEEDBACK_PICKABLE_CATEGORIES`, `FEEDBACK_REPLY_MAX`, `FEEDBACK_REWORKABLE_STATUSES`, `feedbackAttachmentLine`, `isImageAttachment`, `replaceDescription`, `reworkCount`, `splitBodyAttachments`, `splitDescription`, _`FeedbackContext`_, _`FeedbackEnvironment`_, _`FeedbackRecord`_ |
860
+ | `feedback/feedback-record` | `appendRework`, `attachmentName`, `FEEDBACK_ATTACHMENT_ACCEPT`, `FEEDBACK_AUTHOR_EDITABLE_STATUSES`, `FEEDBACK_AWAITING_STATUSES`, `FEEDBACK_COMMENT_MAX`, `FEEDBACK_DECIDED_STATUSES`, `FEEDBACK_PICKABLE_CATEGORIES`, `FEEDBACK_QUEUE_STATUSES`, `FEEDBACK_REPLY_MAX`, `FEEDBACK_REWORKABLE_STATUSES`, `feedbackAttachmentLine`, `feedbackReworkCount`, `isImageAttachment`, `replaceDescription`, `reworkCount`, `splitBodyAttachments`, `splitDescription`, _`FeedbackContext`_, _`FeedbackEnvironment`_, _`FeedbackRecord`_ |
860
861
  | `feedback/feedback-labels` | `DEFAULT_FEEDBACK_CATEGORY_LABELS`, `DEFAULT_FEEDBACK_STATUS_LABELS`, `DEFAULT_FEEDBACK_TOAST_LABELS`, `useFeedbackCategoryLabels`, `useFeedbackStatusLabels`, `useFeedbackToastLabels`, _`FeedbackCategoryLabels`_, _`FeedbackStatusLabels`_, _`FeedbackToastLabels`_ |
861
862
  | `feedback/feedback-status-undo` | `FEEDBACK_UNDO_DURATION`, `useFeedbackStatusUndo`, _`FeedbackStatusChange`_, _`FeedbackStatusMutate`_, _`FeedbackStatusPatch`_, _`FeedbackStatusRow`_, _`FeedbackStatusUndoOptions`_ |
862
863
  | `feedback/feedback-swipe` | `DEFAULT_FEEDBACK_SWIPE`, `FEEDBACK_SWIPE_ACTIONS`, `feedbackSwipePlan`, _`FeedbackSwipeAction`_, _`FeedbackSwipeBinding`_, _`FeedbackSwipeOptions`_ |
@@ -865,11 +866,11 @@ re-slicing of it, never a second API.
865
866
  | `feedback/feedback-capture` | `captureAppScreenshot`, _`CaptureAppScreenshotOptions`_ |
866
867
  | `feedback/feedback-submit` | `useFeedbackSubmit`, _`FeedbackCreatePayload`_, _`FeedbackSubmit`_, _`UseFeedbackSubmitOptions`_ |
867
868
  | `feedback/feedback-table` | `DEFAULT_FEEDBACK_PAGE_LABELS`, `FeedbackAwaitingToggle`, `feedbackColumns`, `FeedbackEmptyState`, `feedbackEnvironment`, `FeedbackMobileCard`, `feedbackMobileGroupBy`, `FeedbackSubject`, `feedbackSubmitter`, `feedbackSubmitterEmail`, `isFeedbackAwaiting`, `useFeedbackColumns`, `useFeedbackPageLabels`, `useFeedbackRenderDate`, _`FeedbackAwaitingToggleProps`_, _`FeedbackColumnsOptions`_, _`FeedbackEmptyStateProps`_, _`FeedbackMobileCardProps`_, _`FeedbackPageLabels`_, _`FeedbackRenderDate`_, _`FeedbackSubjectProps`_, _`FeedbackTableRow`_, _`UseFeedbackColumnsOptions`_ |
868
- | `feedback/feedback-row-detail` | `DEFAULT_FEEDBACK_DETAIL_LABELS`, `feedbackAttachmentUrls`, `feedbackPageHref`, `feedbackPagePath`, `feedbackPageUrl`, `FeedbackReworkSection`, `feedbackRowAccess`, `FeedbackRowDetail`, `useFeedbackDetailLabels`, _`FeedbackDetailLabels`_, _`FeedbackDetailPatch`_, _`FeedbackDetailUpdate`_, _`FeedbackReworkSectionProps`_, _`FeedbackRowAccess`_, _`FeedbackRowDetailProps`_, _`FeedbackUpload`_ |
869
+ | `feedback/feedback-row-detail` | `DEFAULT_FEEDBACK_DETAIL_LABELS`, `feedbackAttachmentUrls`, `feedbackPageHref`, `feedbackPagePath`, `feedbackPageUrl`, `FeedbackReworkSection`, `feedbackRowAccess`, `FeedbackRowDetail`, `useFeedbackDetailLabels`, _`FeedbackDetailLabels`_, _`FeedbackDetailPatch`_, _`FeedbackDetailUpdate`_, _`FeedbackReworkSectionProps`_, _`FeedbackReworkSend`_, _`FeedbackRowAccess`_, _`FeedbackRowDetailProps`_, _`FeedbackUpload`_ |
869
870
  | `feedback/feedback-crash` | `createCrashReporter`, _`CrashFiling`_, _`CrashReportCreate`_, _`CrashReporter`_, _`CrashReporterOptions`_, _`CrashReportResponse`_ |
870
871
  | `feedback/feedback-public-switch` | `FeedbackPublicSwitch`, `feedbackPublicSwitchAllowed`, _`FeedbackPublicSwitchProps`_, _`FeedbackPublicSwitchRow`_, _`FeedbackPublicSwitchViewer`_ |
871
872
  | `feedback/feedback-public-list` | `DEFAULT_FEEDBACK_PUBLIC_LABELS`, `FeedbackPublicDetail`, `FeedbackPublicList`, `useFeedbackPublicLabels`, _`FeedbackPublicDetailProps`_, _`FeedbackPublicLabels`_, _`FeedbackPublicListProps`_ |
872
- | `feedback/feedback-public-types` | _`FeedbackComment`_, _`FeedbackPublicListItem`_, _`FeedbackPublicRecord`_, _`FeedbackPublicSort`_, _`FeedbackReply`_, _`FeedbackVoteState`_ |
873
+ | `feedback/feedback-public-types` | _`FeedbackComment`_, _`FeedbackEntryKind`_, _`FeedbackPublicListItem`_, _`FeedbackPublicRecord`_, _`FeedbackPublicSort`_, _`FeedbackReply`_, _`FeedbackVoteState`_ |
873
874
  | `feedback/feedback-vote-button` | `DEFAULT_FEEDBACK_VOTE_LABELS`, `FeedbackVoteButton`, _`FeedbackVoteButtonProps`_, _`FeedbackVoteLabels`_ |
874
875
  | `feedback/feedback-comment-thread` | `DEFAULT_FEEDBACK_COMMENTS_LABELS`, `FeedbackCommentThread`, _`FeedbackCommentsLabels`_, _`FeedbackCommentThreadProps`_ |
875
876
  | `feedback/feedback-replies` | `DEFAULT_FEEDBACK_REPLIES_LABELS`, `FeedbackReplyComposer`, `feedbackReplyNudge`, `FeedbackReplyTimeline`, `useFeedbackRepliesLabels`, _`FeedbackRepliesLabels`_, _`FeedbackReplyComposerProps`_, _`FeedbackReplyTimelineProps`_ |
@@ -41,6 +41,16 @@ export interface BillingOverview {
41
41
  * is what shows that a switch landed; `checkoutFingerprint` reads it.
42
42
  */
43
43
  paid: PaidPrice | null;
44
+ /**
45
+ * 0.40 (server-kit 0.13, §15.2.10): a provider subscription runs — the server's own
46
+ * rule, the one its checkout (409 `billing_already_subscribed`) and switch (409
47
+ * `billing_not_subscribed`) routes apply, so exactly one of the two answers. While it
48
+ * is true a `PlanPicker` pick opens `PlanSwitchConfirm` (`POST /billing/plan/preview`,
49
+ * then `POST /billing/plan`); while false, the checkout (`POST /billing/checkout`).
50
+ * Read it instead of mirroring the rule on the client. Optional so an overview from
51
+ * server-kit before 0.13 still type-checks; absent, read it as false.
52
+ */
53
+ switching?: boolean;
44
54
  }
45
55
  /** 0.39: what the payer pays at the provider (server-kit's `PaidPrice`, §15.2.10),
46
56
  * read from the row's `provider_price_id`. */
@@ -70,9 +80,9 @@ export interface PlanSwitchPreview {
70
80
  * charges. */
71
81
  now_minor: number;
72
82
  /** The next regular charge, in minor units. */
73
- next_minor: number | null;
83
+ next_minor?: number | null;
74
84
  /** When it is charged; null when Paddle names no date. */
75
- next_billed_at: string | null;
85
+ next_billed_at?: string | null;
76
86
  /** The plan and period switched to. */
77
87
  plan: string;
78
88
  interval: BillingInterval;
@@ -64,7 +64,7 @@ function appAt(name, site, returnPath) {
64
64
  }
65
65
  const PAY_PAGE_APPS = Object.freeze({
66
66
  keksdose: Object.freeze(appAt("Keksdose", "https://keksdose.app", "/settings/subscription")),
67
- kastlan: Object.freeze(appAt("kastlan", "https://kastlan.app", "/admin/billing")),
67
+ kastlan: Object.freeze(appAt("Kastlan", "https://kastlan.app", "/admin/billing")),
68
68
  kurvenschmiede: Object.freeze(appAt("Kurvenschmiede", "https://kurvenschmiede.app", "/settings/subscription"))
69
69
  });
70
70
  const TOKEN_PREFIX = { sandbox: "test_", live: "live_" };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/billing/pay-page.ts"],"sourcesContent":["import type { UiKitLabels } from \"../i18n/kit-labels\";\n\n/**\n * The kit's pay page (docs/billing-harmonization.md §14.4, decision 19 as amended by\n * §15.2): a standalone static page that ui-kit ships as `dist/pay/`, and that each app\n * serves on its own pay host, `pay.<app domain>` — a separate origin, approved in Paddle,\n * where Paddle.js shares the origin with nothing: no sign-in, no app code, no storage.\n * Since 0.39 every pay page serves ANY app's transaction: it names the app from the\n * transaction's custom data, from the kit's map {@link PAY_PAGE_APPS}, not from its\n * domain — Paddle's single default payment link reaches one host for all three apps.\n *\n * Paddle's create-transaction answers `checkout.url`: the pay page's URL plus\n * `?_ptxn=<txn>`, and Paddle.js on that page opens the transaction by itself. The app\n * sends the buyer there with {@link payPageUrl}, which adds the buyer's language; the\n * page maps it to Paddle's checkout locale ({@link paddleLocale}). Everything else the\n * page needs — the client-side token, sandbox or live, the host's app and the map of\n * apps with their ways back — is the host's `pay-config.json`, written at its web build\n * by the `eifi1-pay-page` script.\n *\n * Pure, and React-free: the page's own script (`pay-page/pay.ts`) and that build script\n * bundle this module. The barrel exports the link's parts and the app map ({@link PAY_PAGE_APPS},\n * {@link PayPageApp}); the exports marked @internal are theirs.\n */\n\n/** Paddle's two environments: the sandbox's client-side tokens start `test_`, live\n * ones `live_`. */\nexport type PaddleEnvironment = \"sandbox\" | \"live\";\n\n/** The pay page's language parameter: `?lang=<kit locale>`. */\nexport const PAY_PAGE_LANG_PARAM = \"lang\";\n\n/** The kit's seven languages (`KitLanguageCode`), as the page reads them. */\nconst PAY_PAGE_LANGUAGES = [\"de-CH\", \"en\", \"es\", \"fr\", \"it\", \"hu\", \"zh\"] as const;\n\n/** One of the kit's languages, as the page speaks it. */\nexport type PayPageLanguage = (typeof PAY_PAGE_LANGUAGES)[number];\n\n/**\n * The kit's language → Paddle's checkout locale (`Paddle.Checkout.open`,\n * `settings.locale`, read 2026-10-09: ar, zh-Hans, zh-TW, da, nl, en, fr, de, it, ja, ko,\n * no, pl, pt, pt-BR, tr, ru, es, sv). Paddle has no Hungarian: a Hungarian buyer gets\n * English always, not Paddle's guess from the browser. The page's own lines stay in the\n * kit's language, Hungarian included.\n */\nconst PADDLE_LOCALES: Readonly<Record<PayPageLanguage, string>> = {\n en: \"en\",\n \"de-CH\": \"de\",\n fr: \"fr\",\n it: \"it\",\n es: \"es\",\n zh: \"zh-Hans\",\n hu: \"en\",\n};\n\n/** Paddle's transaction parameter on a pay page link. @internal */\nexport const PAY_PAGE_TRANSACTION_PARAM = \"_ptxn\";\n\n/**\n * The kit language one tag names, or undefined — `resolveLanguage`'s rule\n * (src/i18n/languages.ts), restated here because that module loads the seven catalogues\n * and the page must stay a few kilobytes: exact first, ignoring case and reading `_` as\n * `-`; then by language, so every German is `de-CH`, every Chinese `zh` (Simplified),\n * and any regional form its base (`fr-CA` → `fr`).\n */\nfunction kitLanguageOf(tag: unknown): PayPageLanguage | undefined {\n if (typeof tag !== \"string\") return undefined;\n const clean = tag.trim().replace(/_/g, \"-\");\n if (!clean) return undefined;\n const lower = clean.toLowerCase();\n const exact = PAY_PAGE_LANGUAGES.find((code) => code.toLowerCase() === lower);\n if (exact) return exact;\n const language = lower.split(\"-\")[0];\n return PAY_PAGE_LANGUAGES.find((code) => code.split(\"-\")[0].toLowerCase() === language);\n}\n\n/**\n * The kit's locale → Paddle's checkout locale: `de-CH` → `de`, `zh` → `zh-Hans`, `hu` →\n * `en` (Paddle has no Hungarian), the others as they are. Any tag is read as the kit\n * reads it (`de-AT` is the one German, `zh-TW` the one Chinese); one the kit doesn't\n * ship is English, and so is `undefined` (0.33.1) — `useKitLocale()` with no provider\n * locale.\n */\nexport function paddleLocale(kitLocale: string | undefined): string {\n return PADDLE_LOCALES[kitLanguageOf(kitLocale) ?? \"en\"];\n}\n\n/**\n * The checkout's `{url}` with the buyer's language: `lang=<kit locale>` on a pay page\n * link (one that carries `_ptxn`); any other URL — a hosted checkout's, which takes its\n * own `locale` — unchanged, as is a locale the kit doesn't ship.\n *\n * const { url } = await api.checkout({ plan, interval, currency });\n * noteCheckoutStarted(user.id, overview);\n * window.location.assign(payPageUrl(url, locale)); // locale = useKitLocale()\n *\n * `locale` may be `undefined` (0.33.1, keksdose): `useKitLocale()` answers that with no\n * provider locale, the runtime's language. The link then goes without `lang`, and the\n * page speaks the browser's language, else English — what a missing or wrong `lang`\n * already did: it costs nothing but the language.\n */\nexport function payPageUrl(checkoutUrl: string, locale: string | undefined): string {\n const language = kitLanguageOf(locale);\n if (!language) return checkoutUrl;\n let url: URL;\n try {\n url = new URL(checkoutUrl);\n } catch {\n return checkoutUrl;\n }\n if (!url.searchParams.has(PAY_PAGE_TRANSACTION_PARAM)) return checkoutUrl;\n url.searchParams.set(PAY_PAGE_LANG_PARAM, language);\n return url.toString();\n}\n\n/**\n * The language the page speaks: its `lang` parameter, else the browser's languages in\n * their order, each matched to the kit's; else English. @internal\n */\nexport function payPageLanguage(\n lang: string | null | undefined,\n browserLanguages: readonly string[] = [],\n): PayPageLanguage {\n for (const candidate of [lang, ...browserLanguages]) {\n const found = kitLanguageOf(candidate);\n if (found) return found;\n }\n return \"en\";\n}\n\n/* ── The page's words ──────────────────────────────────────────────────────── */\n\n/**\n * The page's words in one language — built into `pay.js` at the kit's build from the\n * seven catalogues, since the page has no React and no provider. @internal\n */\nexport interface PayPageStrings {\n /** `billing.payOpening`, while the checkout opens. */\n opening: string;\n /** `billing.payNothing`: no `_ptxn`, or no token (billing off). */\n nothing: string;\n /** `billing.payFailed`: Paddle.js didn't load, or the configuration is wrong. */\n failed: string;\n /** `billing.payBack`: the buyer closed the checkout. */\n closed: string;\n /** `billing.payDone` (0.39): paid, for a transaction that names no app the page\n * knows — there is no way back to offer. */\n done: string;\n /** `common.back`: the link to the app's subscription page. */\n back: string;\n /** `legal.links.terms` and `legal.links.privacy`: the footer's links. */\n terms: string;\n privacy: string;\n /** `legal.navLabel`: the footer's `<nav>`. */\n legal: string;\n}\n\n/** The page's words, read from one of the kit's catalogues. @internal */\nexport function payPageStrings(labels: UiKitLabels): PayPageStrings {\n return {\n opening: labels.billing.payOpening,\n nothing: labels.billing.payNothing,\n failed: labels.billing.payFailed,\n closed: labels.billing.payBack,\n done: labels.billing.payDone,\n back: labels.common.back,\n terms: labels.legal.links.terms,\n privacy: labels.legal.links.privacy,\n legal: labels.legal.navLabel,\n };\n}\n\n/* ── pay-config.json ───────────────────────────────────────────────────────── */\n\n/** The configuration file beside the page, written at each app's web build. @internal */\nexport const PAY_CONFIG_FILE = \"pay-config.json\";\n\n/**\n * One app a pay page serves (docs/billing-harmonization.md §15.2.6): its name, the way\n * back and its Terms and Privacy. Every pay page knows every app, because Paddle's links\n * — its single default payment link, a payment-method update from its e-mails — reach\n * whichever page the account names, whatever app the transaction is for.\n */\nexport interface PayPageApp {\n /** The app's display name: the footer's line and the page's title. */\n name: string;\n /** The app's subscription page. Once paid, the page goes to\n * `checkoutReturnUrl(returnUrl)`; \"Back\" goes here. */\n returnUrl: string;\n termsUrl: string;\n privacyUrl: string;\n}\n\n/** An app's tag: server-kit's `billing_app` pattern, the key of {@link PAY_PAGE_APPS}\n * and the `app` of a transaction's custom data (§14.3). */\nconst APP_TAG = /^[a-z][a-z0-9_-]{0,63}$/;\n\n/** An app on its site: the name, the Terms and Privacy at `/terms` and `/privacy`, and\n * its subscription page. */\nfunction appAt(name: string, site: string, returnPath: string): PayPageApp {\n return { name, returnUrl: `${site}${returnPath}`, termsUrl: `${site}/terms`, privacyUrl: `${site}/privacy` };\n}\n\n/**\n * The apps the kit's pay pages serve, by their `billing_app` tag (§15.2.6) — one source,\n * so the three pay hosts can't drift. A new app, or a page that moves, is a kit release.\n * The bin writes it into `pay-config.json`; `--app-url` moves the host's own app to\n * another site (a local stack, a dev deploy) and `--apps <file>` merges a map over it.\n */\nexport const PAY_PAGE_APPS: Readonly<Record<string, Readonly<PayPageApp>>> = Object.freeze({\n keksdose: Object.freeze(appAt(\"Keksdose\", \"https://keksdose.app\", \"/settings/subscription\")),\n kastlan: Object.freeze(appAt(\"kastlan\", \"https://kastlan.app\", \"/admin/billing\")),\n kurvenschmiede: Object.freeze(appAt(\"Kurvenschmiede\", \"https://kurvenschmiede.app\", \"/settings/subscription\")),\n});\n\n/**\n * `pay-config.json`: what the page needs that differs per deployment (§15.2.6). Read by\n * the page from its own origin — never from the query, where Paddle's own links (it\n * puts only `_ptxn` there) would lack it and a return URL would be an open redirect on\n * an approved payment domain. @internal\n */\nexport interface PayPageConfig {\n /** Paddle's client-side token (`test_…` for the sandbox, `live_…` for live); null\n * while billing is off, and the page says `payNothing`. */\n token: string | null;\n environment: PaddleEnvironment | null;\n /** The host's own app, a key of `apps`: the page shows it until the checkout loads,\n * and its Terms and Privacy stay for a transaction that names no app. */\n app: string;\n /** Every app the page serves, by tag. The transaction's `custom_data.app` picks one;\n * a return URL only ever comes from here. */\n apps: Record<string, PayPageApp>;\n}\n\n/** Paddle's client-side token prefixes, per environment. */\nconst TOKEN_PREFIX: Readonly<Record<PaddleEnvironment, string>> = { sandbox: \"test_\", live: \"live_\" };\n\n/** `https://`, or `http://` on this machine only (`localhost`, `127.0.0.1`, `[::1]`). @internal */\nexport function isPayPageUrl(value: unknown): boolean {\n if (typeof value !== \"string\") return false;\n let url: URL;\n try {\n url = new URL(value);\n } catch {\n return false;\n }\n if (url.protocol === \"https:\") return true;\n return url.protocol === \"http:\" && [\"localhost\", \"127.0.0.1\", \"[::1]\"].includes(url.hostname);\n}\n\n/** Whether `tag` is a tag of `apps`, its own key — never `__proto__` or `constructor`. */\nfunction hasApp(apps: unknown, tag: unknown): tag is string {\n return (\n typeof tag === \"string\" &&\n APP_TAG.test(tag) &&\n typeof apps === \"object\" &&\n apps !== null &&\n Object.prototype.hasOwnProperty.call(apps, tag)\n );\n}\n\n/**\n * The app a transaction's custom data names (`custom_data.app`, §14.3), from the page's\n * map — or undefined for none, or a tag the map doesn't know. @internal\n */\nexport function payPageAppFor(config: Pick<PayPageConfig, \"apps\">, tag: unknown): PayPageApp | undefined {\n return hasApp(config.apps, tag) ? config.apps[tag] : undefined;\n}\n\n/** The problems of one app of the map. */\nfunction appProblems(tag: string, app: unknown): string[] {\n if (typeof app !== \"object\" || app === null) return [`apps.${tag} is not an object`];\n const a = app as Record<string, unknown>;\n const problems: string[] = [];\n if (typeof a.name !== \"string\" || a.name.trim() === \"\") problems.push(`apps.${tag}.name is missing`);\n for (const key of [\"returnUrl\", \"termsUrl\", \"privacyUrl\"] as const) {\n if (!isPayPageUrl(a[key])) problems.push(`apps.${tag}.${key} must be an https:// URL (http:// for localhost only)`);\n }\n return problems;\n}\n\n/**\n * What is wrong with a `pay-config.json`, one line each — `[]` when nothing is. The\n * build script refuses to write a file with any (so a wrong pairing fails the build,\n * not a buyer), and the page says `payFailed` for one it reads:\n *\n * - a token whose prefix disagrees with the environment (`test_` ↔ sandbox, `live_` ↔\n * live), or a token without an environment;\n * - an app tag that isn't a `billing_app` tag (`^[a-z][a-z0-9_-]{0,63}$`), an app\n * without a name, or a return, terms or privacy URL that isn't `https://` (`http://`\n * for localhost only);\n * - no `app`, or one that isn't in `apps`. @internal\n */\nexport function payPageConfigProblems(config: unknown): string[] {\n if (typeof config !== \"object\" || config === null) return [\"the configuration is not an object\"];\n const c = config as Record<string, unknown>;\n const problems: string[] = [];\n const { token, environment } = c;\n if (environment !== null && environment !== undefined && environment !== \"sandbox\" && environment !== \"live\") {\n problems.push(`environment must be \"sandbox\" or \"live\", not ${JSON.stringify(environment)}`);\n }\n if (token !== null && token !== undefined) {\n if (typeof token !== \"string\" || token === \"\") {\n problems.push(\"token must be Paddle's client-side token, or null while billing is off\");\n } else if (environment !== \"sandbox\" && environment !== \"live\") {\n problems.push(\"a token needs its environment: sandbox or live\");\n } else if (!token.startsWith(TOKEN_PREFIX[environment]) || token.length === TOKEN_PREFIX[environment].length) {\n const other = environment === \"sandbox\" ? \"live\" : \"sandbox\";\n problems.push(\n token.startsWith(TOKEN_PREFIX[other])\n ? `the token is a ${other} token (${TOKEN_PREFIX[other]}…), but the environment is ${environment}`\n : `a ${environment} token starts with ${TOKEN_PREFIX[environment]}`,\n );\n }\n }\n const { apps, app } = c;\n if (typeof apps !== \"object\" || apps === null || Array.isArray(apps) || Object.keys(apps).length === 0) {\n problems.push(\"apps must map each app's tag to its name and URLs\");\n } else {\n for (const [tag, entry] of Object.entries(apps)) {\n if (!APP_TAG.test(tag)) problems.push(`apps: ${JSON.stringify(tag)} is not an app tag (a-z, 0-9, _ and -)`);\n else problems.push(...appProblems(tag, entry));\n }\n }\n if (typeof app !== \"string\" || app === \"\") problems.push(\"app is missing: the host's own app tag\");\n else if (!hasApp(apps, app)) {\n const known = typeof apps === \"object\" && apps !== null ? Object.keys(apps).join(\", \") : \"\";\n problems.push(`app ${JSON.stringify(app)} is not in apps${known ? ` (${known})` : \"\"}`);\n }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gBAAgB,YAAY,SAAS;AACnD,eAAS;AAAA,QACP,MAAM,WAAW,aAAa,KAAK,CAAC,IAChC,kBAAkB,KAAK,WAAW,aAAa,KAAK,CAAC,mCAA8B,WAAW,KAC9F,KAAK,WAAW,sBAAsB,aAAa,WAAW,CAAC;AAAA,MACrE;AAAA,IACF;AAAA,EACF;AACA,QAAM,EAAE,MAAM,IAAI,IAAI;AACtB,MAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,MAAM,QAAQ,IAAI,KAAK,OAAO,KAAK,IAAI,EAAE,WAAW,GAAG;AACtG,aAAS,KAAK,mDAAmD;AAAA,EACnE,OAAO;AACL,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,IAAI,GAAG;AAC/C,UAAI,CAAC,QAAQ,KAAK,GAAG,EAAG,UAAS,KAAK,SAAS,KAAK,UAAU,GAAG,CAAC,wCAAwC;AAAA,UACrG,UAAS,KAAK,GAAG,YAAY,KAAK,KAAK,CAAC;AAAA,IAC/C;AAAA,EACF;AACA,MAAI,OAAO,QAAQ,YAAY,QAAQ,GAAI,UAAS,KAAK,wCAAwC;AAAA,WACxF,CAAC,OAAO,MAAM,GAAG,GAAG;AAC3B,UAAM,QAAQ,OAAO,SAAS,YAAY,SAAS,OAAO,OAAO,KAAK,IAAI,EAAE,KAAK,IAAI,IAAI;AACzF,aAAS,KAAK,OAAO,KAAK,UAAU,GAAG,CAAC,kBAAkB,QAAQ,KAAK,KAAK,MAAM,EAAE,EAAE;AAAA,EACxF;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/billing/pay-page.ts"],"sourcesContent":["import type { UiKitLabels } from \"../i18n/kit-labels\";\n\n/**\n * The kit's pay page (docs/billing-harmonization.md §14.4, decision 19 as amended by\n * §15.2): a standalone static page that ui-kit ships as `dist/pay/`, and that each app\n * serves on its own pay host, `pay.<app domain>` — a separate origin, approved in Paddle,\n * where Paddle.js shares the origin with nothing: no sign-in, no app code, no storage.\n * Since 0.39 every pay page serves ANY app's transaction: it names the app from the\n * transaction's custom data, from the kit's map {@link PAY_PAGE_APPS}, not from its\n * domain — Paddle's single default payment link reaches one host for all three apps.\n *\n * Paddle's create-transaction answers `checkout.url`: the pay page's URL plus\n * `?_ptxn=<txn>`, and Paddle.js on that page opens the transaction by itself. The app\n * sends the buyer there with {@link payPageUrl}, which adds the buyer's language; the\n * page maps it to Paddle's checkout locale ({@link paddleLocale}). Everything else the\n * page needs — the client-side token, sandbox or live, the host's app and the map of\n * apps with their ways back — is the host's `pay-config.json`, written at its web build\n * by the `eifi1-pay-page` script.\n *\n * Pure, and React-free: the page's own script (`pay-page/pay.ts`) and that build script\n * bundle this module. The barrel exports the link's parts and the app map ({@link PAY_PAGE_APPS},\n * {@link PayPageApp}); the exports marked @internal are theirs.\n */\n\n/** Paddle's two environments: the sandbox's client-side tokens start `test_`, live\n * ones `live_`. */\nexport type PaddleEnvironment = \"sandbox\" | \"live\";\n\n/** The pay page's language parameter: `?lang=<kit locale>`. */\nexport const PAY_PAGE_LANG_PARAM = \"lang\";\n\n/** The kit's seven languages (`KitLanguageCode`), as the page reads them. */\nconst PAY_PAGE_LANGUAGES = [\"de-CH\", \"en\", \"es\", \"fr\", \"it\", \"hu\", \"zh\"] as const;\n\n/** One of the kit's languages, as the page speaks it. */\nexport type PayPageLanguage = (typeof PAY_PAGE_LANGUAGES)[number];\n\n/**\n * The kit's language → Paddle's checkout locale (`Paddle.Checkout.open`,\n * `settings.locale`, read 2026-10-09: ar, zh-Hans, zh-TW, da, nl, en, fr, de, it, ja, ko,\n * no, pl, pt, pt-BR, tr, ru, es, sv). Paddle has no Hungarian: a Hungarian buyer gets\n * English always, not Paddle's guess from the browser. The page's own lines stay in the\n * kit's language, Hungarian included.\n */\nconst PADDLE_LOCALES: Readonly<Record<PayPageLanguage, string>> = {\n en: \"en\",\n \"de-CH\": \"de\",\n fr: \"fr\",\n it: \"it\",\n es: \"es\",\n zh: \"zh-Hans\",\n hu: \"en\",\n};\n\n/** Paddle's transaction parameter on a pay page link. @internal */\nexport const PAY_PAGE_TRANSACTION_PARAM = \"_ptxn\";\n\n/**\n * The kit language one tag names, or undefined — `resolveLanguage`'s rule\n * (src/i18n/languages.ts), restated here because that module loads the seven catalogues\n * and the page must stay a few kilobytes: exact first, ignoring case and reading `_` as\n * `-`; then by language, so every German is `de-CH`, every Chinese `zh` (Simplified),\n * and any regional form its base (`fr-CA` → `fr`).\n */\nfunction kitLanguageOf(tag: unknown): PayPageLanguage | undefined {\n if (typeof tag !== \"string\") return undefined;\n const clean = tag.trim().replace(/_/g, \"-\");\n if (!clean) return undefined;\n const lower = clean.toLowerCase();\n const exact = PAY_PAGE_LANGUAGES.find((code) => code.toLowerCase() === lower);\n if (exact) return exact;\n const language = lower.split(\"-\")[0];\n return PAY_PAGE_LANGUAGES.find((code) => code.split(\"-\")[0].toLowerCase() === language);\n}\n\n/**\n * The kit's locale → Paddle's checkout locale: `de-CH` → `de`, `zh` → `zh-Hans`, `hu` →\n * `en` (Paddle has no Hungarian), the others as they are. Any tag is read as the kit\n * reads it (`de-AT` is the one German, `zh-TW` the one Chinese); one the kit doesn't\n * ship is English, and so is `undefined` (0.33.1) — `useKitLocale()` with no provider\n * locale.\n */\nexport function paddleLocale(kitLocale: string | undefined): string {\n return PADDLE_LOCALES[kitLanguageOf(kitLocale) ?? \"en\"];\n}\n\n/**\n * The checkout's `{url}` with the buyer's language: `lang=<kit locale>` on a pay page\n * link (one that carries `_ptxn`); any other URL — a hosted checkout's, which takes its\n * own `locale` — unchanged, as is a locale the kit doesn't ship.\n *\n * const { url } = await api.checkout({ plan, interval, currency });\n * noteCheckoutStarted(user.id, overview);\n * window.location.assign(payPageUrl(url, locale)); // locale = useKitLocale()\n *\n * `locale` may be `undefined` (0.33.1, keksdose): `useKitLocale()` answers that with no\n * provider locale, the runtime's language. The link then goes without `lang`, and the\n * page speaks the browser's language, else English — what a missing or wrong `lang`\n * already did: it costs nothing but the language.\n */\nexport function payPageUrl(checkoutUrl: string, locale: string | undefined): string {\n const language = kitLanguageOf(locale);\n if (!language) return checkoutUrl;\n let url: URL;\n try {\n url = new URL(checkoutUrl);\n } catch {\n return checkoutUrl;\n }\n if (!url.searchParams.has(PAY_PAGE_TRANSACTION_PARAM)) return checkoutUrl;\n url.searchParams.set(PAY_PAGE_LANG_PARAM, language);\n return url.toString();\n}\n\n/**\n * The language the page speaks: its `lang` parameter, else the browser's languages in\n * their order, each matched to the kit's; else English. @internal\n */\nexport function payPageLanguage(\n lang: string | null | undefined,\n browserLanguages: readonly string[] = [],\n): PayPageLanguage {\n for (const candidate of [lang, ...browserLanguages]) {\n const found = kitLanguageOf(candidate);\n if (found) return found;\n }\n return \"en\";\n}\n\n/* ── The page's words ──────────────────────────────────────────────────────── */\n\n/**\n * The page's words in one language — built into `pay.js` at the kit's build from the\n * seven catalogues, since the page has no React and no provider. @internal\n */\nexport interface PayPageStrings {\n /** `billing.payOpening`, while the checkout opens. */\n opening: string;\n /** `billing.payNothing`: no `_ptxn`, or no token (billing off). */\n nothing: string;\n /** `billing.payFailed`: Paddle.js didn't load, or the configuration is wrong. */\n failed: string;\n /** `billing.payBack`: the buyer closed the checkout. */\n closed: string;\n /** `billing.payDone` (0.39): paid, for a transaction that names no app the page\n * knows — there is no way back to offer. */\n done: string;\n /** `common.back`: the link to the app's subscription page. */\n back: string;\n /** `legal.links.terms` and `legal.links.privacy`: the footer's links. */\n terms: string;\n privacy: string;\n /** `legal.navLabel`: the footer's `<nav>`. */\n legal: string;\n}\n\n/** The page's words, read from one of the kit's catalogues. @internal */\nexport function payPageStrings(labels: UiKitLabels): PayPageStrings {\n return {\n opening: labels.billing.payOpening,\n nothing: labels.billing.payNothing,\n failed: labels.billing.payFailed,\n closed: labels.billing.payBack,\n done: labels.billing.payDone,\n back: labels.common.back,\n terms: labels.legal.links.terms,\n privacy: labels.legal.links.privacy,\n legal: labels.legal.navLabel,\n };\n}\n\n/* ── pay-config.json ───────────────────────────────────────────────────────── */\n\n/** The configuration file beside the page, written at each app's web build. @internal */\nexport const PAY_CONFIG_FILE = \"pay-config.json\";\n\n/**\n * One app a pay page serves (docs/billing-harmonization.md §15.2.6): its name, the way\n * back and its Terms and Privacy. Every pay page knows every app, because Paddle's links\n * — its single default payment link, a payment-method update from its e-mails — reach\n * whichever page the account names, whatever app the transaction is for.\n */\nexport interface PayPageApp {\n /** The app's display name: the footer's line and the page's title. */\n name: string;\n /** The app's subscription page. Once paid, the page goes to\n * `checkoutReturnUrl(returnUrl)`; \"Back\" goes here. */\n returnUrl: string;\n termsUrl: string;\n privacyUrl: string;\n}\n\n/** An app's tag: server-kit's `billing_app` pattern, the key of {@link PAY_PAGE_APPS}\n * and the `app` of a transaction's custom data (§14.3). */\nconst APP_TAG = /^[a-z][a-z0-9_-]{0,63}$/;\n\n/** An app on its site: the name, the Terms and Privacy at `/terms` and `/privacy`, and\n * its subscription page. */\nfunction appAt(name: string, site: string, returnPath: string): PayPageApp {\n return { name, returnUrl: `${site}${returnPath}`, termsUrl: `${site}/terms`, privacyUrl: `${site}/privacy` };\n}\n\n/**\n * The apps the kit's pay pages serve, by their `billing_app` tag (§15.2.6) — one source,\n * so the three pay hosts can't drift. A new app, or a page that moves, is a kit release.\n * The bin writes it into `pay-config.json`; `--app-url` moves the host's own app to\n * another site (a local stack, a dev deploy) and `--apps <file>` merges a map over it.\n */\nexport const PAY_PAGE_APPS: Readonly<Record<string, Readonly<PayPageApp>>> = Object.freeze({\n keksdose: Object.freeze(appAt(\"Keksdose\", \"https://keksdose.app\", \"/settings/subscription\")),\n kastlan: Object.freeze(appAt(\"Kastlan\", \"https://kastlan.app\", \"/admin/billing\")),\n kurvenschmiede: Object.freeze(appAt(\"Kurvenschmiede\", \"https://kurvenschmiede.app\", \"/settings/subscription\")),\n});\n\n/**\n * `pay-config.json`: what the page needs that differs per deployment (§15.2.6). Read by\n * the page from its own origin — never from the query, where Paddle's own links (it\n * puts only `_ptxn` there) would lack it and a return URL would be an open redirect on\n * an approved payment domain. @internal\n */\nexport interface PayPageConfig {\n /** Paddle's client-side token (`test_…` for the sandbox, `live_…` for live); null\n * while billing is off, and the page says `payNothing`. */\n token: string | null;\n environment: PaddleEnvironment | null;\n /** The host's own app, a key of `apps`: the page shows it until the checkout loads,\n * and its Terms and Privacy stay for a transaction that names no app. */\n app: string;\n /** Every app the page serves, by tag. The transaction's `custom_data.app` picks one;\n * a return URL only ever comes from here. */\n apps: Record<string, PayPageApp>;\n}\n\n/** Paddle's client-side token prefixes, per environment. */\nconst TOKEN_PREFIX: Readonly<Record<PaddleEnvironment, string>> = { sandbox: \"test_\", live: \"live_\" };\n\n/** `https://`, or `http://` on this machine only (`localhost`, `127.0.0.1`, `[::1]`). @internal */\nexport function isPayPageUrl(value: unknown): boolean {\n if (typeof value !== \"string\") return false;\n let url: URL;\n try {\n url = new URL(value);\n } catch {\n return false;\n }\n if (url.protocol === \"https:\") return true;\n return url.protocol === \"http:\" && [\"localhost\", \"127.0.0.1\", \"[::1]\"].includes(url.hostname);\n}\n\n/** Whether `tag` is a tag of `apps`, its own key — never `__proto__` or `constructor`. */\nfunction hasApp(apps: unknown, tag: unknown): tag is string {\n return (\n typeof tag === \"string\" &&\n APP_TAG.test(tag) &&\n typeof apps === \"object\" &&\n apps !== null &&\n Object.prototype.hasOwnProperty.call(apps, tag)\n );\n}\n\n/**\n * The app a transaction's custom data names (`custom_data.app`, §14.3), from the page's\n * map — or undefined for none, or a tag the map doesn't know. @internal\n */\nexport function payPageAppFor(config: Pick<PayPageConfig, \"apps\">, tag: unknown): PayPageApp | undefined {\n return hasApp(config.apps, tag) ? config.apps[tag] : undefined;\n}\n\n/** The problems of one app of the map. */\nfunction appProblems(tag: string, app: unknown): string[] {\n if (typeof app !== \"object\" || app === null) return [`apps.${tag} is not an object`];\n const a = app as Record<string, unknown>;\n const problems: string[] = [];\n if (typeof a.name !== \"string\" || a.name.trim() === \"\") problems.push(`apps.${tag}.name is missing`);\n for (const key of [\"returnUrl\", \"termsUrl\", \"privacyUrl\"] as const) {\n if (!isPayPageUrl(a[key])) problems.push(`apps.${tag}.${key} must be an https:// URL (http:// for localhost only)`);\n }\n return problems;\n}\n\n/**\n * What is wrong with a `pay-config.json`, one line each — `[]` when nothing is. The\n * build script refuses to write a file with any (so a wrong pairing fails the build,\n * not a buyer), and the page says `payFailed` for one it reads:\n *\n * - a token whose prefix disagrees with the environment (`test_` ↔ sandbox, `live_` ↔\n * live), or a token without an environment;\n * - an app tag that isn't a `billing_app` tag (`^[a-z][a-z0-9_-]{0,63}$`), an app\n * without a name, or a return, terms or privacy URL that isn't `https://` (`http://`\n * for localhost only);\n * - no `app`, or one that isn't in `apps`. @internal\n */\nexport function payPageConfigProblems(config: unknown): string[] {\n if (typeof config !== \"object\" || config === null) return [\"the configuration is not an object\"];\n const c = config as Record<string, unknown>;\n const problems: string[] = [];\n const { token, environment } = c;\n if (environment !== null && environment !== undefined && environment !== \"sandbox\" && environment !== \"live\") {\n problems.push(`environment must be \"sandbox\" or \"live\", not ${JSON.stringify(environment)}`);\n }\n if (token !== null && token !== undefined) {\n if (typeof token !== \"string\" || token === \"\") {\n problems.push(\"token must be Paddle's client-side token, or null while billing is off\");\n } else if (environment !== \"sandbox\" && environment !== \"live\") {\n problems.push(\"a token needs its environment: sandbox or live\");\n } else if (!token.startsWith(TOKEN_PREFIX[environment]) || token.length === TOKEN_PREFIX[environment].length) {\n const other = environment === \"sandbox\" ? \"live\" : \"sandbox\";\n problems.push(\n token.startsWith(TOKEN_PREFIX[other])\n ? `the token is a ${other} token (${TOKEN_PREFIX[other]}…), but the environment is ${environment}`\n : `a ${environment} token starts with ${TOKEN_PREFIX[environment]}`,\n );\n }\n }\n const { apps, app } = c;\n if (typeof apps !== \"object\" || apps === null || Array.isArray(apps) || Object.keys(apps).length === 0) {\n problems.push(\"apps must map each app's tag to its name and URLs\");\n } else {\n for (const [tag, entry] of Object.entries(apps)) {\n if (!APP_TAG.test(tag)) problems.push(`apps: ${JSON.stringify(tag)} is not an app tag (a-z, 0-9, _ and -)`);\n else problems.push(...appProblems(tag, entry));\n }\n }\n if (typeof app !== \"string\" || app === \"\") problems.push(\"app is missing: the host's own app tag\");\n else if (!hasApp(apps, app)) {\n const known = typeof apps === \"object\" && apps !== null ? Object.keys(apps).join(\", \") : \"\";\n problems.push(`app ${JSON.stringify(app)} is not in apps${known ? ` (${known})` : \"\"}`);\n }\n return problems;\n}\n"],"mappings":";AA6BO,MAAM,sBAAsB;AAGnC,MAAM,qBAAqB,CAAC,SAAS,MAAM,MAAM,MAAM,MAAM,MAAM,IAAI;AAYvE,MAAM,iBAA4D;AAAA,EAChE,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAGO,MAAM,6BAA6B;AAS1C,SAAS,cAAc,KAA2C;AAChE,MAAI,OAAO,QAAQ,SAAU,QAAO;AACpC,QAAM,QAAQ,IAAI,KAAK,EAAE,QAAQ,MAAM,GAAG;AAC1C,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,QAAQ,MAAM,YAAY;AAChC,QAAM,QAAQ,mBAAmB,KAAK,CAAC,SAAS,KAAK,YAAY,MAAM,KAAK;AAC5E,MAAI,MAAO,QAAO;AAClB,QAAM,WAAW,MAAM,MAAM,GAAG,EAAE,CAAC;AACnC,SAAO,mBAAmB,KAAK,CAAC,SAAS,KAAK,MAAM,GAAG,EAAE,CAAC,EAAE,YAAY,MAAM,QAAQ;AACxF;AASO,SAAS,aAAa,WAAuC;AAClE,SAAO,eAAe,cAAc,SAAS,KAAK,IAAI;AACxD;AAgBO,SAAS,WAAW,aAAqB,QAAoC;AAClF,QAAM,WAAW,cAAc,MAAM;AACrC,MAAI,CAAC,SAAU,QAAO;AACtB,MAAI;AACJ,MAAI;AACF,UAAM,IAAI,IAAI,WAAW;AAAA,EAC3B,QAAQ;AACN,WAAO;AAAA,EACT;AACA,MAAI,CAAC,IAAI,aAAa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  }
18
18
  var PAY_PAGE_APPS = Object.freeze({
19
19
  keksdose: Object.freeze(appAt("Keksdose", "https://keksdose.app", "/settings/subscription")),
20
- kastlan: Object.freeze(appAt("kastlan", "https://kastlan.app", "/admin/billing")),
20
+ kastlan: Object.freeze(appAt("Kastlan", "https://kastlan.app", "/admin/billing")),
21
21
  kurvenschmiede: Object.freeze(appAt("Kurvenschmiede", "https://kurvenschmiede.app", "/settings/subscription"))
22
22
  });
23
23
  var TOKEN_PREFIX = { sandbox: "test_", live: "live_" };
@@ -13,6 +13,7 @@ import {
13
13
  ComboboxFieldLabel,
14
14
  DISABLED_ROW_CLASS,
15
15
  endHintRowProps,
16
+ GROUP_HEADING_STICKY,
16
17
  isOptionEnabled,
17
18
  stepEnabled,
18
19
  SUGGESTION_LIST_CLASS,
@@ -275,7 +276,10 @@ function Autocomplete(props) {
275
276
  "li",
276
277
  {
277
278
  role: "presentation",
278
- className: "px-3 pb-0.5 pt-2 text-caption font-semibold uppercase tracking-wide text-muted first:pt-1",
279
+ className: cn(
280
+ GROUP_HEADING_STICKY,
281
+ "px-3 pb-0.5 pt-2 text-caption font-semibold uppercase tracking-wide text-muted first:pt-1"
282
+ ),
279
283
  children: o.group
280
284
  }
281
285
  ),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/autocomplete.tsx"],"sourcesContent":["import { Fragment, useId, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode, Ref } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { cn } from \"../lib/cn\";\nimport { FIELD_BASE, FIELD_FLOATING_PAD, FIELD_INVALID } from \"./field-base\";\nimport { Spinner } from \"./spinner\";\nimport { useAnchoredPanel } from \"../hooks/use-anchored-panel\";\nimport { takeEscape, useDismissLayer } from \"../hooks/use-dismiss\";\nimport { isImeEnter } from \"../lib/ime\";\nimport { useAnchorDir } from \"./use-anchor-dir\";\nimport {\n ComboboxFieldLabel,\n DISABLED_ROW_CLASS,\n endHintRowProps,\n isOptionEnabled,\n stepEnabled,\n SUGGESTION_LIST_CLASS,\n suggestionRowClass,\n useActiveOptionScroll,\n useOptionSource,\n type ComboOption,\n} from \"./combobox-core\";\nimport { DEFAULT_COMBOBOX_LABELS, useKitLabels } from \"../i18n/kit-labels\";\nimport {\n EndHintRow,\n FieldCaption,\n LABEL_IN_ROW,\n LockedReason,\n mergeDescribedBy,\n StaticLabelRow,\n useFieldError,\n useFieldHint,\n useLockReason,\n type DisabledReasonDisplay,\n type FieldHelpProps,\n} from \"./field-parts\";\nimport type { CommitScope } from \"./write-lock\";\n\n/**\n * `value`/`onChange` are the TEXT's, and `onSelect` is \"a suggestion was taken\" —\n * not the DOM's text-selection event — so the input's own spellings of those three\n * are omitted. Everything else reaches the `<input>`, the way it does on {@link Input}.\n */\nexport interface AutocompleteProps<V extends string | number = string>\n extends Omit<\n ComponentPropsWithoutRef<\"input\">,\n \"value\" | \"defaultValue\" | \"onChange\" | \"onSelect\" | \"children\" | \"type\" | \"size\"\n >,\n FieldHelpProps {\n /** What is in the field. Controlled, and never reset by the component: opening,\n * closing and a failed lookup all leave it exactly as typed. */\n value: string;\n /** Every keystroke — and, with `fillOnSelect`, the label of a taken suggestion. */\n onChange: (text: string) => void;\n /** Suggestions the caller already has (e.g. from its own query hook). Narrowed by\n * the text unless `filter={false}`. An option with `disabled: true` is listed but\n * cannot be taken — see {@link ComboOption.disabled}. */\n options?: ComboOption<V>[];\n /** Or: fetch them. Debounced (`debounceMs`), race-safe, only at `minChars` and up,\n * never while the field is idle; a rejection shows `loadErrorLabel` and empties\n * the list rather than leaving the previous text's rows under it. */\n loadOptions?: (query: string) => Promise<ComboOption<V>[]>;\n /** Narrow `options` by label/sublabel substring. Default `true`. Pass `false` for\n * a list a server has already searched and ranked — it is shown as given. */\n filter?: boolean;\n /** External loading flag (a caller-side fetch), OR-ed with `loadOptions`'. */\n loading?: boolean;\n /** Below this many characters nothing is offered or fetched. Default 1: an empty\n * field asks nothing — focusing it is not a search. */\n minChars?: number;\n /** Quiet time before `loadOptions` runs. Default 300 ms — an ordinary typist's\n * inter-key interval is 150–250 ms, so the pickers' 150 fires on nearly every\n * letter, which a rate-limited geocoder cannot afford. */\n debounceMs?: number;\n /**\n * Whether the list MAY show — controlled. Omit (or pass `undefined`) and the field\n * decides: open while focused, until Escape, Tab or a taken row. `false` keeps it\n * shut whatever the user does, and stops `loadOptions` asking — keksdose's address\n * search, with its confirm map up, where it used to pass `minChars={Infinity}`.\n * `true` shows it even unfocused.\n *\n * Even open, the list only APPEARS when it has something to show (rows, or a\n * status line); `aria-expanded` follows what appears, not this flag.\n */\n open?: boolean;\n /** The field wants the list open or shut — focus, typing, ↓/↑ open it; blur,\n * Escape, Tab and taking a row shut it. Called on every change, controlled or not. */\n onOpenChange?: (open: boolean) => void;\n /**\n * `\"sm\"`: the 28px, 12px-type field of {@link Select}'s `size=\"sm\"`, with the icon,\n * spinner and list rows scaled to match — for a card or toolbar whose buttons are\n * small. `\"md\"` (default) is the form field. Unlabelled only, as on `Select`: a\n * floating label needs the tall box, so a labelled field ignores `\"sm\"`.\n *\n * A NUMBER is still the native `size` attribute (the width in characters), passed\n * straight through.\n */\n size?: \"sm\" | \"md\" | number;\n /** A suggestion was taken (click, or Enter on the highlighted row). */\n onSelect?: (option: ComboOption<V>) => void;\n /**\n * Put the taken suggestion's label into the field (`onChange(label)`). Default\n * `true` — the free-text case, where the text IS the value and a suggestion only\n * completes it (an address field). Pass `false` where taking a row is an ACTION\n * and the field is only the search that found it; the text then stays as typed.\n */\n fillOnSelect?: boolean;\n /** A floating label, as on {@link Combobox} — a real `<label for>` on the input.\n * Names the field (`aria-labelledby`) unless an `aria-label` is given. */\n label?: ReactNode;\n /** Leading decoration inside the field (a pin, a magnifier). Decorative: the\n * label names the field. An `<svg>` child is sized by the field — 16px, or 14px\n * at `size=\"sm\"` — so a lucide icon needs no class of its own. */\n icon?: ReactNode;\n /** Required and unanswered — {@link FIELD_INVALID}. */\n invalid?: boolean;\n /** What is wrong with the VALUE, as {@link Input}'s `error`: under the field, on\n * its `aria-describedby`, implies `invalid`. Not a failed lookup — that is\n * `loadErrorLabel`, shown in the list. */\n error?: ReactNode;\n /**\n * Standing advice — {@link Combobox}'s `hint`, so this field reads like every other\n * (keksdose K4): plain TEXT is a caption under the field on the input's\n * `aria-describedby`, before any error; a {@link FieldHint} \"?\" rides the label line,\n * or with no label sits at the field's end edge, outside the box. Not the list's\n * `status` line, which talks about the lookup, not the field.\n *\n * Pass it — even as `undefined` — on a field whose hint comes and goes (0.24): the\n * unlabelled field then keeps its end-hint row whether or not a \"?\" is in it, so the\n * `<input>` is never re-parented, and focus and caret survive the toggle. The rule\n * the rest of the family has had since 0.23 (and the fields since 0.22).\n */\n hint?: ReactNode;\n /**\n * The caller's own line in the list, replacing the automatic one (loading / failed\n * / no results). For what only the caller knows: \"offline\", \"the address service\n * is switched off\", a privacy note, the hint a caller-fetched list needs below its\n * own minimum. While set, the list opens even with no rows. Announced politely.\n */\n status?: ReactNode;\n /** Default: `combobox.noResults` from the {@link UiKitProvider}, else English. */\n emptyLabel?: string;\n /** Default: `combobox.loadError`. */\n loadErrorLabel?: string;\n /** Classes for the `<input>` itself; `className` styles the wrapper. */\n inputClassName?: string;\n /**\n * Why the field cannot be changed — {@link Button}'s `disabledReason`, the Combobox\n * family's write lock (keksdose G2, 0.23), for a field whose pick SAVES: an address\n * search whose taken row writes the address, a lookup that links a record.\n *\n * With a reason the input stays focusable and `aria-disabled`, is `readOnly` (the\n * settled grey FIELD_BASE gives a `[readonly]` field), opens no list and asks no\n * `loadOptions` — whatever `open` says — and nothing reaches `onChange`, `onSelect` or\n * `onOpenChange(true)`. Enter is swallowed, so a locked field does not submit the form\n * around it, and a caller's `onKeyDown` does not hear it; every other key still\n * reaches the caller (an Escape that closes its panel) and the caret. The reason is in\n * the kit {@link Tooltip} and on the input's `aria-describedby`. Wins over `disabled`.\n */\n disabledReason?: ReactNode;\n /**\n * This field COMMITS. Under a locked {@link WriteLockProvider} it is locked the\n * `disabledReason` way with the lock's reason (which wins over its own). A search\n * whose result is only draft state — the form's Save writes it — leaves this off and\n * stays live under the lock. No provider, or an unlocked one: no effect.\n */\n commit?: CommitScope;\n /** Where the reason shows — {@link Button}'s `disabledReasonDisplay`: a line under the\n * field at Large and on a touch screen by default, the tooltip otherwise (DUP-3). */\n disabledReasonDisplay?: DisabledReasonDisplay;\n /** The `<input>`. A React 19 ref prop since 0.34 (MOD-4, refactor audit 2026-10): it was\n * `forwardRef`, cast back to a generic function, with a `displayName` line beside it. */\n ref?: Ref<HTMLInputElement>;\n}\n\n/**\n * An inline, async-capable text field with a suggestion list under it — the\n * WAI-ARIA APG \"editable combobox with list autocomplete\".\n *\n * Two jobs, one control:\n * - **free text** (kastlan's address field): the text is the value, the list only\n * offers completions, and taking one fills the field (`fillOnSelect`, default);\n * - **search-then-act** (keksdose's address search): the text is a query, taking a\n * row calls `onSelect` and nothing is held (`fillOnSelect={false}`).\n *\n * How it differs from its siblings: {@link Combobox} is free text over a STATIC\n * string pool and opens on focus; {@link EntityCombobox} is a trigger holding an id.\n * This one keeps no value of its own, never resets the text, asks nothing below\n * `minChars`, and reports a failed lookup instead of showing stale rows.\n *\n * Focus never leaves the `<input>`: `aria-activedescendant` names the highlighted\n * row, `aria-controls` the list, and a polite live region says what the list now\n * holds. Keyboard: ↓/↑ move (↓ opens) over every row but a `disabled` one, Enter\n * takes the highlighted row (with none,\n * Enter is left to the form), Escape closes, Tab closes and moves on; Home/End stay\n * with the caret. An Escape that closes an open list is consumed and never reaches the\n * caller; with the list closed it does. For every other key a caller's `onKeyDown`\n * runs first and may `preventDefault()` to\n * keep a key for itself.\n *\n * The list is portalled and anchored under the field on every screen size: the\n * field already carries the keyboard, and `useAnchoredPanel` keeps the list clear\n * of it on a phone. There is no full-screen sheet as {@link Combobox} has.\n *\n * Generic over the option value (`ComboOption<V>`); the ref is the `<input>`'s.\n */\nexport function Autocomplete<V extends string | number = string>(props: AutocompleteProps<V>) {\n const {\n ref,\n value,\n onChange,\n options,\n loadOptions,\n filter,\n loading,\n minChars = 1,\n debounceMs = 300,\n onSelect,\n fillOnSelect = true,\n label,\n icon,\n invalid,\n error,\n hint,\n help,\n status,\n emptyLabel,\n loadErrorLabel,\n open: openProp,\n onOpenChange,\n size,\n className,\n inputClassName,\n id,\n disabled,\n disabledReason,\n disabledReasonDisplay,\n commit,\n onKeyDown,\n onFocus,\n onBlur,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...rest\n } = props;\n const generated = useId();\n const fieldId = id ?? generated;\n // Off the GENERATED id: a caller's `id` is theirs to collide with.\n const listboxId = `${generated}-listbox`;\n const labelId = `${generated}-label`;\n const optionId = (index: number) => `${generated}-option-${index}`;\n const fieldRef = useRef<HTMLDivElement>(null);\n const labels = useKitLabels(\"combobox\", DEFAULT_COMBOBOX_LABELS, {\n noResults: emptyLabel,\n loadError: loadErrorLabel,\n });\n const hintParts = useFieldHint(hint, ariaDescribedBy, { help, name: label ?? ariaLabel });\n // A form library's `aria-invalid` paints as well as announces (DUP-8: it only\n // announced, through the spread below).\n const field = useFieldError(error, invalid, hintParts.describedBy, rest[\"aria-invalid\"]);\n\n /** The user's intent: the field is focused and the list has not been dismissed.\n * Whether anything SHOWS is decided below, from what there is to show. */\n const [ownOpen, setOwnOpen] = useState(false);\n // Controlled when the caller passes a boolean. The own state is kept up to date\n // either way, so a caller that controls only SOMETIMES (`open={confirming ? false :\n // undefined}`) hands back a field that is exactly as open as focus says it is.\n const open = openProp ?? ownOpen;\n const setOpen = (next: boolean) => {\n setOwnOpen(next);\n if (next !== open) onOpenChange?.(next);\n };\n const [active, setActive] = useState(-1);\n // The lock: focusable, `readOnly`, no list — see `disabledReason`. Folded into `live`,\n // so a locked field asks nothing and shows nothing even with `open` held true.\n const lock = useLockReason(commit, disabledReason);\n const locked = lock.locked;\n const live = open && !disabled && !locked;\n const { results, busy, failed, tooShort } = useOptionSource<V>({\n options,\n loadOptions,\n loading,\n filter,\n minChars,\n debounceMs,\n query: value,\n active: live,\n });\n\n const hasStatus = status !== undefined && status !== null && status !== false && status !== \"\";\n // The visible line under the rows. Nothing below `minChars` unless the caller has\n // something to say — an empty field opening a box that says \"type more\" is noise.\n const statusLine: ReactNode = hasStatus\n ? status\n : tooShort\n ? null\n : busy && results.length === 0\n ? labels.loading\n : failed\n ? labels.loadError\n : !busy && results.length === 0\n ? labels.noResults\n : null;\n const expanded = live && (results.length > 0 || statusLine !== null);\n // A disabled row is never the keyboard's — not even when a list that changed under\n // the highlight put one there.\n const activeId = expanded && isOptionEnabled(results[active]) ? optionId(active) : undefined;\n useActiveOptionScroll(activeId);\n const { rect, top, bottom, maxHeight, above } = useAnchoredPanel(fieldRef, expanded, { preferredHeight: 256 });\n const dir = useAnchorDir(fieldRef, expanded);\n\n const close = () => {\n setOpen(false);\n setActive(-1);\n };\n // The list is a layer on the kit's Escape stack while it shows (Wave 2, DUP-1).\n useDismissLayer(expanded, close);\n const take = (o: ComboOption<V>) => {\n if (o.disabled || locked) return;\n if (fillOnSelect) onChange(o.label);\n onSelect?.(o);\n close();\n };\n\n const hasLabel = label !== undefined;\n // `size=\"sm\"` is for an UNLABELLED field, as on Select: the floating label needs the\n // tall box. A number is the native attribute.\n const small = size === \"sm\" && !hasLabel;\n const nativeSize = typeof size === \"number\" ? size : undefined;\n // The caller's name wins; else the floating label, by reference so a non-string\n // label still names the field.\n const labelledBy =\n ariaLabel === undefined ? (ariaLabelledBy ?? (hasLabel ? labelId : undefined)) : undefined;\n // While locked the field sits in the reason's Tooltip — in a fragment with a hidden\n // copy of the reason, Button's anatomy; `block` so a full-width field stays full width.\n const withLock = (box: ReactNode) =>\n locked ? (\n <LockedReason lock={lock} display={disabledReasonDisplay} className=\"block\">\n {box}\n </LockedReason>\n ) : (\n box\n );\n\n return (\n // `relative`: the floating label and the live region's `sr-only` both need a\n // local containing block.\n <div className={cn(\"relative\", className)}>\n {/* A real <label for> (lenkbank), and still `aria-labelledby`'s target, so the\n name — and the listbox's, which borrows it — is exactly what it was. */}\n {hasLabel && hintParts.labelHint === undefined && (\n <ComboboxFieldLabel id={labelId} htmlFor={fieldId}>\n {label}\n </ComboboxFieldLabel>\n )}\n {/* `\"hint\" in props`: the family's 0.22 rule (see `endHintRowProps`) — passed at\n all, even as `undefined`, a hint keeps the unlabelled field's end-hint row, so\n a \"?\" coming and going never re-parents the <input> under the caret (0.24, the\n last of the family to get it; the siblings had it in 0.23). */}\n <EndHintRow {...endHintRowProps(\"hint\" in props, hasLabel, hintParts.labelHint)}>\n {withLock(\n <div ref={fieldRef} className={cn(\"relative\", locked && \"cursor-not-allowed\")}>\n {icon && (\n <span\n aria-hidden\n className={cn(\n \"pointer-events-none absolute flex text-muted\",\n small ? \"start-2 [&>svg]:size-3.5\" : \"start-2.5 [&>svg]:size-4\",\n // Labelled, the icon sits on the VALUE's line — the one line box below\n // FIELD_FLOATING_PAD's `pt-4` and the 1px border — not on the middle of\n // the box. Centred on the box it rose into the top strip and sat on the\n // label's first letters, which float at the same start inset. On the\n // value line it is beside what it describes, and the label keeps the\n // start edge every other label in the form's column shares.\n // At Large the label stands above the field and the strip is gone\n // (0.33, §10.17): the value's line is under FIELD_BASE's `py-2`.\n hasLabel\n ? \"top-[calc(1rem+1px)] h-5 items-center large:top-[calc(0.5rem+1px)]\"\n : \"top-1/2 -translate-y-1/2\",\n )}\n >\n {icon}\n </span>\n )}\n <input\n {...rest}\n ref={ref}\n id={fieldId}\n size={nativeSize}\n type=\"text\"\n value={value}\n // Locked: focusable, `readOnly`, `aria-disabled` — see `disabledReason`.\n disabled={locked ? undefined : disabled}\n readOnly={locked || rest.readOnly}\n aria-disabled={locked || rest[\"aria-disabled\"]}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded={expanded}\n // Required by the role, and set while closed too, as on the siblings.\n aria-controls={listboxId}\n aria-activedescendant={activeId}\n aria-label={ariaLabel}\n aria-labelledby={labelledBy}\n aria-invalid={field.isInvalid || rest[\"aria-invalid\"] || undefined}\n aria-describedby={mergeDescribedBy(field.describedBy, locked && lock.reasonId)}\n autoComplete=\"off\"\n onFocus={(e) => {\n onFocus?.(e);\n // A locked field takes focus to say why, and opens nothing.\n if (locked) return;\n // A seeded field (keksdose's `initialQuery`) is looked up as it is\n // focused; an empty one asks nothing, because of `minChars`.\n setOpen(true);\n }}\n onBlur={(e) => {\n onBlur?.(e);\n close();\n }}\n onChange={(e) => {\n if (locked) return;\n onChange(e.target.value);\n setOpen(true);\n setActive(-1);\n }}\n onKeyDown={(e) => {\n // Locked: Enter is swallowed (no form submit, no caller's \"search now\");\n // every other key is the caller's and the caret's. No list to drive.\n if (locked) {\n if (e.key === \"Enter\") e.preventDefault();\n else onKeyDown?.(e);\n return;\n }\n // An Escape that closes the OPEN list is the list's, and is consumed before\n // the caller sees it. A caller whose Escape means \"close the panel\" (keksdose's\n // address search) otherwise closed the whole panel when the user only meant\n // to dismiss the suggestions — the opposite of what the docs promised.\n if (e.key === \"Escape\" && expanded && takeEscape(e)) return;\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n // Disabled rows are passed over; at either end the highlight stays put.\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n if (!open) setOpen(true);\n else setActive((i) => stepEnabled(results, i, 1));\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n if (!open) setOpen(true);\n // From \"nothing highlighted\", Up goes to the bottom, as the APG has it.\n else setActive((i) => stepEnabled(results, i < 0 ? results.length : i, -1));\n } else if (e.key === \"Enter\") {\n // No row highlighted: the text is the answer, and a form's own submit\n // is left alone. Nor is a row taken by the Enter that confirms an IME\n // composition, which is the IME's (BUG-9).\n if (expanded && activeId && !isImeEnter(e)) {\n e.preventDefault();\n take(results[active]);\n }\n } else if (e.key === \"Tab\") {\n close();\n }\n }}\n className={cn(\n FIELD_BASE,\n hasLabel && FIELD_FLOATING_PAD,\n // Select's `SELECT_SM` box: a fixed 28px, so the caller's line height\n // cannot grow it.\n small && \"h-7 py-0 pe-2 ps-2 text-xs\",\n icon ? (small ? \"ps-7\" : \"ps-8\") : undefined,\n busy && (small ? \"pe-7\" : \"pe-9\"),\n field.isInvalid && FIELD_INVALID,\n inputClassName,\n )}\n />\n {busy && live && (\n // Decorative: the live region below already says \"Loading…\".\n <span\n className={cn(\n \"pointer-events-none absolute top-1/2 flex -translate-y-1/2\",\n small ? \"end-2\" : \"end-2.5\",\n )}\n >\n <Spinner label={null} className={small ? \"h-3.5 w-3.5\" : \"h-4 w-4\"} />\n </span>\n )}\n </div>,\n )}\n </EndHintRow>\n {/* With a \"?\" the label shares the top strip with it, after the field so the \"?\"\n follows the control in the tab order (as on Input and Select). */}\n {hasLabel && hintParts.labelHint !== undefined && (\n <StaticLabelRow hint={hintParts.labelHint}>\n <ComboboxFieldLabel id={labelId} htmlFor={fieldId} className={LABEL_IN_ROW}>\n {label}\n </ComboboxFieldLabel>\n </StaticLabelRow>\n )}\n <FieldCaption parts={hintParts} />\n {field.errorEl}\n {/* The live region, kept mounted so a change IS an announcement: focus stays\n in the field, and without it a reader typed into a geocoder and heard only\n their own letters. The panel's visible line is aria-hidden in favour of\n this, which also carries the row count the eye reads off the list. */}\n <div role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n {!live\n ? null\n : statusLine !== null\n ? statusLine\n : results.length > 0\n ? labels.resultCount(results.length)\n : null}\n </div>\n {expanded &&\n rect &&\n typeof document !== \"undefined\" &&\n createPortal(\n <div\n // Every press inside the list keeps focus in the field — rows, the status\n // line, the scrollbar — or the input's blur would close the list first.\n role=\"presentation\"\n // Portalled out of the form's `dir`; the field's is put back. The list is\n // exactly the field's width, so `left` places it in either direction.\n dir={dir}\n onMouseDown={(e) => e.preventDefault()}\n // The family's suggestion box (DUP-4), as a column: the list scrolls inside\n // it and the status line stays under the rows.\n className={cn(SUGGESTION_LIST_CLASS, \"fixed z-50 flex flex-col overflow-hidden py-0\")}\n // Flipped above, the list hangs from its bottom edge: three rows under a\n // 256 px cap, placed by `top`, floated ~176 px above the field (keksdose K1),\n // and the rows come and go as the user types.\n style={{ ...(above ? { bottom } : { top }), left: rect.left, width: rect.width, maxHeight }}\n >\n {results.length > 0 && (\n <ul\n id={listboxId}\n role=\"listbox\"\n aria-label={ariaLabel}\n aria-labelledby={labelledBy}\n className=\"min-h-0 flex-1 overflow-y-auto py-1\"\n >\n {results.map((o, i) => {\n const startsGroup = o.group != null && o.group !== results[i - 1]?.group;\n return (\n // Keyed by group AND value, as in the core panel: an option may\n // appear once per group.\n <Fragment key={`${o.group ?? \"\"}|${String(o.value)}`}>\n {startsGroup && (\n <li\n role=\"presentation\"\n className=\"px-3 pb-0.5 pt-2 text-caption font-semibold uppercase tracking-wide text-muted first:pt-1\"\n >\n {o.group}\n </li>\n )}\n <li role=\"presentation\">\n <button\n type=\"button\"\n id={optionId(i)}\n role=\"option\"\n // CHOSEN, never \"highlighted\" — the family's rule. This\n // field holds no value, so the only row that can be chosen\n // is the one whose label the text already is.\n aria-selected={fillOnSelect && o.label === value}\n // Listed, announced as unavailable, never taken: `take`\n // refuses it and the arrows pass it over.\n aria-disabled={o.disabled || undefined}\n tabIndex={-1}\n onClick={() => take(o)}\n onMouseEnter={() => {\n if (!o.disabled) setActive(i);\n }}\n className={cn(\n // The family's suggestion row (DUP-4): it hand-rolled its\n // own with a plain `truncate`, so a long address was cut at\n // Large, where Combobox's rows wrap (text size §10.17, T1).\n // A flex row here, for the icon and the two lines.\n suggestionRowClass(i === active && !o.disabled),\n \"flex items-center gap-2\",\n small && \"py-1 text-xs\",\n o.disabled && DISABLED_ROW_CLASS,\n o.group != null && \"ps-6\",\n )}\n >\n {o.icon && (\n <span aria-hidden className=\"shrink-0 text-muted\">\n {o.icon}\n </span>\n )}\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate-until-large text-primary\">\n {o.label}\n </span>\n {o.sublabel && (\n <span\n className={cn(\n \"block truncate-until-large text-placeholder\",\n small ? \"text-caption\" : \"text-xs\",\n )}\n >\n {o.sublabel}\n </span>\n )}\n </span>\n </button>\n </li>\n </Fragment>\n );\n })}\n </ul>\n )}\n {statusLine !== null && (\n // Visible, not live — the region above speaks for it.\n <div\n aria-hidden\n className={cn(\n small ? \"px-3 py-1.5 text-xs\" : \"px-3 py-2 text-sm\",\n failed && !hasStatus ? \"text-danger\" : \"text-muted\",\n results.length > 0 && \"border-t border-subtle text-xs\",\n )}\n >\n {statusLine}\n </div>\n )}\n </div>,\n document.body,\n )}\n </div>\n );\n}\n"],"mappings":";AAkVM,cAwBI,YAxBJ;AAlVN,SAAS,UAAU,OAAO,QAAQ,gBAAgB;AAElD,SAAS,oBAAoB;AAC7B,SAAS,UAAU;AACnB,SAAS,YAAY,oBAAoB,qBAAqB;AAC9D,SAAS,eAAe;AACxB,SAAS,wBAAwB;AACjC,SAAS,YAAY,uBAAuB;AAC5C,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,yBAAyB,oBAAoB;AACtD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AA2KA,SAAS,aAAiD,OAA6B;AAC5F,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,aAAa;AAAA,IACb;AAAA,IACA,eAAe;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IAC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AQ;AAAA,4BACrB;AAAA,4BAEC;AAAA,gCAAE,QACD,oBAAC,UAAK,eAAW,MAAC,WAAU,uBACzB,YAAE,MACL;AAAA,8BAEF,qBAAC,UAAK,WAAU,kBACd;AAAA,oDAAC,UAAK,WAAU,2CACb,YAAE,OACL;AAAA,gCACC,EAAE,YACD;AAAA,kCAAC;AAAA;AAAA,oCACC,WAAW;AAAA,sCACT;AAAA,sCACA,QAAQ,iBAAiB;AAAA,oCAC3B;AAAA,oCAEC,YAAE;AAAA;AAAA,gCACL;AAAA,iCAEJ;AAAA;AAAA;AAAA,wBACF,GACF;AAAA,2BA3Da,GAAG,EAAE,SAAS,EAAE,IAAI,OAAO,EAAE,KAAK,CAAC,EA4DlD;AAAA;AAAA,kBAEJ,CAAC;AAAA;AAAA,cACH;AAAA,cAED,eAAe;AAAA,cAEd;AAAA,gBAAC;AAAA;AAAA,kBACC,eAAW;AAAA,kBACX,WAAW;AAAA,oBACT,QAAQ,wBAAwB;AAAA,oBAChC,UAAU,CAAC,YAAY,gBAAgB;AAAA,oBACvC,QAAQ,SAAS,KAAK;AAAA,kBACxB;AAAA,kBAEC;AAAA;AAAA,cACH;AAAA;AAAA;AAAA,QAEJ;AAAA,QACA,SAAS;AAAA,MACX;AAAA,OACJ;AAAA;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/components/autocomplete.tsx"],"sourcesContent":["import { Fragment, useId, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode, Ref } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { cn } from \"../lib/cn\";\nimport { FIELD_BASE, FIELD_FLOATING_PAD, FIELD_INVALID } from \"./field-base\";\nimport { Spinner } from \"./spinner\";\nimport { useAnchoredPanel } from \"../hooks/use-anchored-panel\";\nimport { takeEscape, useDismissLayer } from \"../hooks/use-dismiss\";\nimport { isImeEnter } from \"../lib/ime\";\nimport { useAnchorDir } from \"./use-anchor-dir\";\nimport {\n ComboboxFieldLabel,\n DISABLED_ROW_CLASS,\n endHintRowProps,\n GROUP_HEADING_STICKY,\n isOptionEnabled,\n stepEnabled,\n SUGGESTION_LIST_CLASS,\n suggestionRowClass,\n useActiveOptionScroll,\n useOptionSource,\n type ComboOption,\n} from \"./combobox-core\";\nimport { DEFAULT_COMBOBOX_LABELS, useKitLabels } from \"../i18n/kit-labels\";\nimport {\n EndHintRow,\n FieldCaption,\n LABEL_IN_ROW,\n LockedReason,\n mergeDescribedBy,\n StaticLabelRow,\n useFieldError,\n useFieldHint,\n useLockReason,\n type DisabledReasonDisplay,\n type FieldHelpProps,\n} from \"./field-parts\";\nimport type { CommitScope } from \"./write-lock\";\n\n/**\n * `value`/`onChange` are the TEXT's, and `onSelect` is \"a suggestion was taken\" —\n * not the DOM's text-selection event — so the input's own spellings of those three\n * are omitted. Everything else reaches the `<input>`, the way it does on {@link Input}.\n */\nexport interface AutocompleteProps<V extends string | number = string>\n extends Omit<\n ComponentPropsWithoutRef<\"input\">,\n \"value\" | \"defaultValue\" | \"onChange\" | \"onSelect\" | \"children\" | \"type\" | \"size\"\n >,\n FieldHelpProps {\n /** What is in the field. Controlled, and never reset by the component: opening,\n * closing and a failed lookup all leave it exactly as typed. */\n value: string;\n /** Every keystroke — and, with `fillOnSelect`, the label of a taken suggestion. */\n onChange: (text: string) => void;\n /** Suggestions the caller already has (e.g. from its own query hook). Narrowed by\n * the text unless `filter={false}`. An option with `disabled: true` is listed but\n * cannot be taken — see {@link ComboOption.disabled}. */\n options?: ComboOption<V>[];\n /** Or: fetch them. Debounced (`debounceMs`), race-safe, only at `minChars` and up,\n * never while the field is idle; a rejection shows `loadErrorLabel` and empties\n * the list rather than leaving the previous text's rows under it. */\n loadOptions?: (query: string) => Promise<ComboOption<V>[]>;\n /** Narrow `options` by label/sublabel substring. Default `true`. Pass `false` for\n * a list a server has already searched and ranked — it is shown as given. */\n filter?: boolean;\n /** External loading flag (a caller-side fetch), OR-ed with `loadOptions`'. */\n loading?: boolean;\n /** Below this many characters nothing is offered or fetched. Default 1: an empty\n * field asks nothing — focusing it is not a search. */\n minChars?: number;\n /** Quiet time before `loadOptions` runs. Default 300 ms — an ordinary typist's\n * inter-key interval is 150–250 ms, so the pickers' 150 fires on nearly every\n * letter, which a rate-limited geocoder cannot afford. */\n debounceMs?: number;\n /**\n * Whether the list MAY show — controlled. Omit (or pass `undefined`) and the field\n * decides: open while focused, until Escape, Tab or a taken row. `false` keeps it\n * shut whatever the user does, and stops `loadOptions` asking — keksdose's address\n * search, with its confirm map up, where it used to pass `minChars={Infinity}`.\n * `true` shows it even unfocused.\n *\n * Even open, the list only APPEARS when it has something to show (rows, or a\n * status line); `aria-expanded` follows what appears, not this flag.\n */\n open?: boolean;\n /** The field wants the list open or shut — focus, typing, ↓/↑ open it; blur,\n * Escape, Tab and taking a row shut it. Called on every change, controlled or not. */\n onOpenChange?: (open: boolean) => void;\n /**\n * `\"sm\"`: the 28px, 12px-type field of {@link Select}'s `size=\"sm\"`, with the icon,\n * spinner and list rows scaled to match — for a card or toolbar whose buttons are\n * small. `\"md\"` (default) is the form field. Unlabelled only, as on `Select`: a\n * floating label needs the tall box, so a labelled field ignores `\"sm\"`.\n *\n * A NUMBER is still the native `size` attribute (the width in characters), passed\n * straight through.\n */\n size?: \"sm\" | \"md\" | number;\n /** A suggestion was taken (click, or Enter on the highlighted row). */\n onSelect?: (option: ComboOption<V>) => void;\n /**\n * Put the taken suggestion's label into the field (`onChange(label)`). Default\n * `true` — the free-text case, where the text IS the value and a suggestion only\n * completes it (an address field). Pass `false` where taking a row is an ACTION\n * and the field is only the search that found it; the text then stays as typed.\n */\n fillOnSelect?: boolean;\n /** A floating label, as on {@link Combobox} — a real `<label for>` on the input.\n * Names the field (`aria-labelledby`) unless an `aria-label` is given. */\n label?: ReactNode;\n /** Leading decoration inside the field (a pin, a magnifier). Decorative: the\n * label names the field. An `<svg>` child is sized by the field — 16px, or 14px\n * at `size=\"sm\"` — so a lucide icon needs no class of its own. */\n icon?: ReactNode;\n /** Required and unanswered — {@link FIELD_INVALID}. */\n invalid?: boolean;\n /** What is wrong with the VALUE, as {@link Input}'s `error`: under the field, on\n * its `aria-describedby`, implies `invalid`. Not a failed lookup — that is\n * `loadErrorLabel`, shown in the list. */\n error?: ReactNode;\n /**\n * Standing advice — {@link Combobox}'s `hint`, so this field reads like every other\n * (keksdose K4): plain TEXT is a caption under the field on the input's\n * `aria-describedby`, before any error; a {@link FieldHint} \"?\" rides the label line,\n * or with no label sits at the field's end edge, outside the box. Not the list's\n * `status` line, which talks about the lookup, not the field.\n *\n * Pass it — even as `undefined` — on a field whose hint comes and goes (0.24): the\n * unlabelled field then keeps its end-hint row whether or not a \"?\" is in it, so the\n * `<input>` is never re-parented, and focus and caret survive the toggle. The rule\n * the rest of the family has had since 0.23 (and the fields since 0.22).\n */\n hint?: ReactNode;\n /**\n * The caller's own line in the list, replacing the automatic one (loading / failed\n * / no results). For what only the caller knows: \"offline\", \"the address service\n * is switched off\", a privacy note, the hint a caller-fetched list needs below its\n * own minimum. While set, the list opens even with no rows. Announced politely.\n */\n status?: ReactNode;\n /** Default: `combobox.noResults` from the {@link UiKitProvider}, else English. */\n emptyLabel?: string;\n /** Default: `combobox.loadError`. */\n loadErrorLabel?: string;\n /** Classes for the `<input>` itself; `className` styles the wrapper. */\n inputClassName?: string;\n /**\n * Why the field cannot be changed — {@link Button}'s `disabledReason`, the Combobox\n * family's write lock (keksdose G2, 0.23), for a field whose pick SAVES: an address\n * search whose taken row writes the address, a lookup that links a record.\n *\n * With a reason the input stays focusable and `aria-disabled`, is `readOnly` (the\n * settled grey FIELD_BASE gives a `[readonly]` field), opens no list and asks no\n * `loadOptions` — whatever `open` says — and nothing reaches `onChange`, `onSelect` or\n * `onOpenChange(true)`. Enter is swallowed, so a locked field does not submit the form\n * around it, and a caller's `onKeyDown` does not hear it; every other key still\n * reaches the caller (an Escape that closes its panel) and the caret. The reason is in\n * the kit {@link Tooltip} and on the input's `aria-describedby`. Wins over `disabled`.\n */\n disabledReason?: ReactNode;\n /**\n * This field COMMITS. Under a locked {@link WriteLockProvider} it is locked the\n * `disabledReason` way with the lock's reason (which wins over its own). A search\n * whose result is only draft state — the form's Save writes it — leaves this off and\n * stays live under the lock. No provider, or an unlocked one: no effect.\n */\n commit?: CommitScope;\n /** Where the reason shows — {@link Button}'s `disabledReasonDisplay`: a line under the\n * field at Large and on a touch screen by default, the tooltip otherwise (DUP-3). */\n disabledReasonDisplay?: DisabledReasonDisplay;\n /** The `<input>`. A React 19 ref prop since 0.34 (MOD-4, refactor audit 2026-10): it was\n * `forwardRef`, cast back to a generic function, with a `displayName` line beside it. */\n ref?: Ref<HTMLInputElement>;\n}\n\n/**\n * An inline, async-capable text field with a suggestion list under it — the\n * WAI-ARIA APG \"editable combobox with list autocomplete\".\n *\n * Two jobs, one control:\n * - **free text** (kastlan's address field): the text is the value, the list only\n * offers completions, and taking one fills the field (`fillOnSelect`, default);\n * - **search-then-act** (keksdose's address search): the text is a query, taking a\n * row calls `onSelect` and nothing is held (`fillOnSelect={false}`).\n *\n * How it differs from its siblings: {@link Combobox} is free text over a STATIC\n * string pool and opens on focus; {@link EntityCombobox} is a trigger holding an id.\n * This one keeps no value of its own, never resets the text, asks nothing below\n * `minChars`, and reports a failed lookup instead of showing stale rows.\n *\n * Focus never leaves the `<input>`: `aria-activedescendant` names the highlighted\n * row, `aria-controls` the list, and a polite live region says what the list now\n * holds. Keyboard: ↓/↑ move (↓ opens) over every row but a `disabled` one, Enter\n * takes the highlighted row (with none,\n * Enter is left to the form), Escape closes, Tab closes and moves on; Home/End stay\n * with the caret. An Escape that closes an open list is consumed and never reaches the\n * caller; with the list closed it does. For every other key a caller's `onKeyDown`\n * runs first and may `preventDefault()` to\n * keep a key for itself.\n *\n * The list is portalled and anchored under the field on every screen size: the\n * field already carries the keyboard, and `useAnchoredPanel` keeps the list clear\n * of it on a phone. There is no full-screen sheet as {@link Combobox} has.\n *\n * Generic over the option value (`ComboOption<V>`); the ref is the `<input>`'s.\n */\nexport function Autocomplete<V extends string | number = string>(props: AutocompleteProps<V>) {\n const {\n ref,\n value,\n onChange,\n options,\n loadOptions,\n filter,\n loading,\n minChars = 1,\n debounceMs = 300,\n onSelect,\n fillOnSelect = true,\n label,\n icon,\n invalid,\n error,\n hint,\n help,\n status,\n emptyLabel,\n loadErrorLabel,\n open: openProp,\n onOpenChange,\n size,\n className,\n inputClassName,\n id,\n disabled,\n disabledReason,\n disabledReasonDisplay,\n commit,\n onKeyDown,\n onFocus,\n onBlur,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...rest\n } = props;\n const generated = useId();\n const fieldId = id ?? generated;\n // Off the GENERATED id: a caller's `id` is theirs to collide with.\n const listboxId = `${generated}-listbox`;\n const labelId = `${generated}-label`;\n const optionId = (index: number) => `${generated}-option-${index}`;\n const fieldRef = useRef<HTMLDivElement>(null);\n const labels = useKitLabels(\"combobox\", DEFAULT_COMBOBOX_LABELS, {\n noResults: emptyLabel,\n loadError: loadErrorLabel,\n });\n const hintParts = useFieldHint(hint, ariaDescribedBy, { help, name: label ?? ariaLabel });\n // A form library's `aria-invalid` paints as well as announces (DUP-8: it only\n // announced, through the spread below).\n const field = useFieldError(error, invalid, hintParts.describedBy, rest[\"aria-invalid\"]);\n\n /** The user's intent: the field is focused and the list has not been dismissed.\n * Whether anything SHOWS is decided below, from what there is to show. */\n const [ownOpen, setOwnOpen] = useState(false);\n // Controlled when the caller passes a boolean. The own state is kept up to date\n // either way, so a caller that controls only SOMETIMES (`open={confirming ? false :\n // undefined}`) hands back a field that is exactly as open as focus says it is.\n const open = openProp ?? ownOpen;\n const setOpen = (next: boolean) => {\n setOwnOpen(next);\n if (next !== open) onOpenChange?.(next);\n };\n const [active, setActive] = useState(-1);\n // The lock: focusable, `readOnly`, no list — see `disabledReason`. Folded into `live`,\n // so a locked field asks nothing and shows nothing even with `open` held true.\n const lock = useLockReason(commit, disabledReason);\n const locked = lock.locked;\n const live = open && !disabled && !locked;\n const { results, busy, failed, tooShort } = useOptionSource<V>({\n options,\n loadOptions,\n loading,\n filter,\n minChars,\n debounceMs,\n query: value,\n active: live,\n });\n\n const hasStatus = status !== undefined && status !== null && status !== false && status !== \"\";\n // The visible line under the rows. Nothing below `minChars` unless the caller has\n // something to say — an empty field opening a box that says \"type more\" is noise.\n const statusLine: ReactNode = hasStatus\n ? status\n : tooShort\n ? null\n : busy && results.length === 0\n ? labels.loading\n : failed\n ? labels.loadError\n : !busy && results.length === 0\n ? labels.noResults\n : null;\n const expanded = live && (results.length > 0 || statusLine !== null);\n // A disabled row is never the keyboard's — not even when a list that changed under\n // the highlight put one there.\n const activeId = expanded && isOptionEnabled(results[active]) ? optionId(active) : undefined;\n useActiveOptionScroll(activeId);\n const { rect, top, bottom, maxHeight, above } = useAnchoredPanel(fieldRef, expanded, { preferredHeight: 256 });\n const dir = useAnchorDir(fieldRef, expanded);\n\n const close = () => {\n setOpen(false);\n setActive(-1);\n };\n // The list is a layer on the kit's Escape stack while it shows (Wave 2, DUP-1).\n useDismissLayer(expanded, close);\n const take = (o: ComboOption<V>) => {\n if (o.disabled || locked) return;\n if (fillOnSelect) onChange(o.label);\n onSelect?.(o);\n close();\n };\n\n const hasLabel = label !== undefined;\n // `size=\"sm\"` is for an UNLABELLED field, as on Select: the floating label needs the\n // tall box. A number is the native attribute.\n const small = size === \"sm\" && !hasLabel;\n const nativeSize = typeof size === \"number\" ? size : undefined;\n // The caller's name wins; else the floating label, by reference so a non-string\n // label still names the field.\n const labelledBy =\n ariaLabel === undefined ? (ariaLabelledBy ?? (hasLabel ? labelId : undefined)) : undefined;\n // While locked the field sits in the reason's Tooltip — in a fragment with a hidden\n // copy of the reason, Button's anatomy; `block` so a full-width field stays full width.\n const withLock = (box: ReactNode) =>\n locked ? (\n <LockedReason lock={lock} display={disabledReasonDisplay} className=\"block\">\n {box}\n </LockedReason>\n ) : (\n box\n );\n\n return (\n // `relative`: the floating label and the live region's `sr-only` both need a\n // local containing block.\n <div className={cn(\"relative\", className)}>\n {/* A real <label for> (lenkbank), and still `aria-labelledby`'s target, so the\n name — and the listbox's, which borrows it — is exactly what it was. */}\n {hasLabel && hintParts.labelHint === undefined && (\n <ComboboxFieldLabel id={labelId} htmlFor={fieldId}>\n {label}\n </ComboboxFieldLabel>\n )}\n {/* `\"hint\" in props`: the family's 0.22 rule (see `endHintRowProps`) — passed at\n all, even as `undefined`, a hint keeps the unlabelled field's end-hint row, so\n a \"?\" coming and going never re-parents the <input> under the caret (0.24, the\n last of the family to get it; the siblings had it in 0.23). */}\n <EndHintRow {...endHintRowProps(\"hint\" in props, hasLabel, hintParts.labelHint)}>\n {withLock(\n <div ref={fieldRef} className={cn(\"relative\", locked && \"cursor-not-allowed\")}>\n {icon && (\n <span\n aria-hidden\n className={cn(\n \"pointer-events-none absolute flex text-muted\",\n small ? \"start-2 [&>svg]:size-3.5\" : \"start-2.5 [&>svg]:size-4\",\n // Labelled, the icon sits on the VALUE's line — the one line box below\n // FIELD_FLOATING_PAD's `pt-4` and the 1px border — not on the middle of\n // the box. Centred on the box it rose into the top strip and sat on the\n // label's first letters, which float at the same start inset. On the\n // value line it is beside what it describes, and the label keeps the\n // start edge every other label in the form's column shares.\n // At Large the label stands above the field and the strip is gone\n // (0.33, §10.17): the value's line is under FIELD_BASE's `py-2`.\n hasLabel\n ? \"top-[calc(1rem+1px)] h-5 items-center large:top-[calc(0.5rem+1px)]\"\n : \"top-1/2 -translate-y-1/2\",\n )}\n >\n {icon}\n </span>\n )}\n <input\n {...rest}\n ref={ref}\n id={fieldId}\n size={nativeSize}\n type=\"text\"\n value={value}\n // Locked: focusable, `readOnly`, `aria-disabled` — see `disabledReason`.\n disabled={locked ? undefined : disabled}\n readOnly={locked || rest.readOnly}\n aria-disabled={locked || rest[\"aria-disabled\"]}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded={expanded}\n // Required by the role, and set while closed too, as on the siblings.\n aria-controls={listboxId}\n aria-activedescendant={activeId}\n aria-label={ariaLabel}\n aria-labelledby={labelledBy}\n aria-invalid={field.isInvalid || rest[\"aria-invalid\"] || undefined}\n aria-describedby={mergeDescribedBy(field.describedBy, locked && lock.reasonId)}\n autoComplete=\"off\"\n onFocus={(e) => {\n onFocus?.(e);\n // A locked field takes focus to say why, and opens nothing.\n if (locked) return;\n // A seeded field (keksdose's `initialQuery`) is looked up as it is\n // focused; an empty one asks nothing, because of `minChars`.\n setOpen(true);\n }}\n onBlur={(e) => {\n onBlur?.(e);\n close();\n }}\n onChange={(e) => {\n if (locked) return;\n onChange(e.target.value);\n setOpen(true);\n setActive(-1);\n }}\n onKeyDown={(e) => {\n // Locked: Enter is swallowed (no form submit, no caller's \"search now\");\n // every other key is the caller's and the caret's. No list to drive.\n if (locked) {\n if (e.key === \"Enter\") e.preventDefault();\n else onKeyDown?.(e);\n return;\n }\n // An Escape that closes the OPEN list is the list's, and is consumed before\n // the caller sees it. A caller whose Escape means \"close the panel\" (keksdose's\n // address search) otherwise closed the whole panel when the user only meant\n // to dismiss the suggestions — the opposite of what the docs promised.\n if (e.key === \"Escape\" && expanded && takeEscape(e)) return;\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n // Disabled rows are passed over; at either end the highlight stays put.\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n if (!open) setOpen(true);\n else setActive((i) => stepEnabled(results, i, 1));\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n if (!open) setOpen(true);\n // From \"nothing highlighted\", Up goes to the bottom, as the APG has it.\n else setActive((i) => stepEnabled(results, i < 0 ? results.length : i, -1));\n } else if (e.key === \"Enter\") {\n // No row highlighted: the text is the answer, and a form's own submit\n // is left alone. Nor is a row taken by the Enter that confirms an IME\n // composition, which is the IME's (BUG-9).\n if (expanded && activeId && !isImeEnter(e)) {\n e.preventDefault();\n take(results[active]);\n }\n } else if (e.key === \"Tab\") {\n close();\n }\n }}\n className={cn(\n FIELD_BASE,\n hasLabel && FIELD_FLOATING_PAD,\n // Select's `SELECT_SM` box: a fixed 28px, so the caller's line height\n // cannot grow it.\n small && \"h-7 py-0 pe-2 ps-2 text-xs\",\n icon ? (small ? \"ps-7\" : \"ps-8\") : undefined,\n busy && (small ? \"pe-7\" : \"pe-9\"),\n field.isInvalid && FIELD_INVALID,\n inputClassName,\n )}\n />\n {busy && live && (\n // Decorative: the live region below already says \"Loading…\".\n <span\n className={cn(\n \"pointer-events-none absolute top-1/2 flex -translate-y-1/2\",\n small ? \"end-2\" : \"end-2.5\",\n )}\n >\n <Spinner label={null} className={small ? \"h-3.5 w-3.5\" : \"h-4 w-4\"} />\n </span>\n )}\n </div>,\n )}\n </EndHintRow>\n {/* With a \"?\" the label shares the top strip with it, after the field so the \"?\"\n follows the control in the tab order (as on Input and Select). */}\n {hasLabel && hintParts.labelHint !== undefined && (\n <StaticLabelRow hint={hintParts.labelHint}>\n <ComboboxFieldLabel id={labelId} htmlFor={fieldId} className={LABEL_IN_ROW}>\n {label}\n </ComboboxFieldLabel>\n </StaticLabelRow>\n )}\n <FieldCaption parts={hintParts} />\n {field.errorEl}\n {/* The live region, kept mounted so a change IS an announcement: focus stays\n in the field, and without it a reader typed into a geocoder and heard only\n their own letters. The panel's visible line is aria-hidden in favour of\n this, which also carries the row count the eye reads off the list. */}\n <div role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n {!live\n ? null\n : statusLine !== null\n ? statusLine\n : results.length > 0\n ? labels.resultCount(results.length)\n : null}\n </div>\n {expanded &&\n rect &&\n typeof document !== \"undefined\" &&\n createPortal(\n <div\n // Every press inside the list keeps focus in the field — rows, the status\n // line, the scrollbar — or the input's blur would close the list first.\n role=\"presentation\"\n // Portalled out of the form's `dir`; the field's is put back. The list is\n // exactly the field's width, so `left` places it in either direction.\n dir={dir}\n onMouseDown={(e) => e.preventDefault()}\n // The family's suggestion box (DUP-4), as a column: the list scrolls inside\n // it and the status line stays under the rows.\n className={cn(SUGGESTION_LIST_CLASS, \"fixed z-50 flex flex-col overflow-hidden py-0\")}\n // Flipped above, the list hangs from its bottom edge: three rows under a\n // 256 px cap, placed by `top`, floated ~176 px above the field (keksdose K1),\n // and the rows come and go as the user types.\n style={{ ...(above ? { bottom } : { top }), left: rect.left, width: rect.width, maxHeight }}\n >\n {results.length > 0 && (\n <ul\n id={listboxId}\n role=\"listbox\"\n aria-label={ariaLabel}\n aria-labelledby={labelledBy}\n className=\"min-h-0 flex-1 overflow-y-auto py-1\"\n >\n {results.map((o, i) => {\n const startsGroup = o.group != null && o.group !== results[i - 1]?.group;\n return (\n // Keyed by group AND value, as in the core panel: an option may\n // appear once per group.\n <Fragment key={`${o.group ?? \"\"}|${String(o.value)}`}>\n {startsGroup && (\n <li\n role=\"presentation\"\n className={cn(\n GROUP_HEADING_STICKY,\n \"px-3 pb-0.5 pt-2 text-caption font-semibold uppercase tracking-wide text-muted first:pt-1\",\n )}\n >\n {o.group}\n </li>\n )}\n <li role=\"presentation\">\n <button\n type=\"button\"\n id={optionId(i)}\n role=\"option\"\n // CHOSEN, never \"highlighted\" — the family's rule. This\n // field holds no value, so the only row that can be chosen\n // is the one whose label the text already is.\n aria-selected={fillOnSelect && o.label === value}\n // Listed, announced as unavailable, never taken: `take`\n // refuses it and the arrows pass it over.\n aria-disabled={o.disabled || undefined}\n tabIndex={-1}\n onClick={() => take(o)}\n onMouseEnter={() => {\n if (!o.disabled) setActive(i);\n }}\n className={cn(\n // The family's suggestion row (DUP-4): it hand-rolled its\n // own with a plain `truncate`, so a long address was cut at\n // Large, where Combobox's rows wrap (text size §10.17, T1).\n // A flex row here, for the icon and the two lines.\n suggestionRowClass(i === active && !o.disabled),\n \"flex items-center gap-2\",\n small && \"py-1 text-xs\",\n o.disabled && DISABLED_ROW_CLASS,\n o.group != null && \"ps-6\",\n )}\n >\n {o.icon && (\n <span aria-hidden className=\"shrink-0 text-muted\">\n {o.icon}\n </span>\n )}\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate-until-large text-primary\">\n {o.label}\n </span>\n {o.sublabel && (\n <span\n className={cn(\n \"block truncate-until-large text-placeholder\",\n small ? \"text-caption\" : \"text-xs\",\n )}\n >\n {o.sublabel}\n </span>\n )}\n </span>\n </button>\n </li>\n </Fragment>\n );\n })}\n </ul>\n )}\n {statusLine !== null && (\n // Visible, not live — the region above speaks for it.\n <div\n aria-hidden\n className={cn(\n small ? \"px-3 py-1.5 text-xs\" : \"px-3 py-2 text-sm\",\n failed && !hasStatus ? \"text-danger\" : \"text-muted\",\n results.length > 0 && \"border-t border-subtle text-xs\",\n )}\n >\n {statusLine}\n </div>\n )}\n </div>,\n document.body,\n )}\n </div>\n );\n}\n"],"mappings":";AAmVM,cAwBI,YAxBJ;AAnVN,SAAS,UAAU,OAAO,QAAQ,gBAAgB;AAElD,SAAS,oBAAoB;AAC7B,SAAS,UAAU;AACnB,SAAS,YAAY,oBAAoB,qBAAqB;AAC9D,SAAS,eAAe;AACxB,SAAS,wBAAwB;AACjC,SAAS,YAAY,uBAAuB;AAC5C,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,yBAAyB,oBAAoB;AACtD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AA2KA,SAAS,aAAiD,OAA6B;AAC5F,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,aAAa;AAAA,IACb;AAAA,IACA,eAAe;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,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KT,mBAAmB,MAAM,UAAU,CAAC,EAAE,QAAQ;AAAA,8BAC9C;AAAA,8BACA,SAAS;AAAA,8BACT,EAAE,YAAY;AAAA,8BACd,EAAE,SAAS,QAAQ;AAAA,4BACrB;AAAA,4BAEC;AAAA,gCAAE,QACD,oBAAC,UAAK,eAAW,MAAC,WAAU,uBACzB,YAAE,MACL;AAAA,8BAEF,qBAAC,UAAK,WAAU,kBACd;AAAA,oDAAC,UAAK,WAAU,2CACb,YAAE,OACL;AAAA,gCACC,EAAE,YACD;AAAA,kCAAC;AAAA;AAAA,oCACC,WAAW;AAAA,sCACT;AAAA,sCACA,QAAQ,iBAAiB;AAAA,oCAC3B;AAAA,oCAEC,YAAE;AAAA;AAAA,gCACL;AAAA,iCAEJ;AAAA;AAAA;AAAA,wBACF,GACF;AAAA,2BA9Da,GAAG,EAAE,SAAS,EAAE,IAAI,OAAO,EAAE,KAAK,CAAC,EA+DlD;AAAA;AAAA,kBAEJ,CAAC;AAAA;AAAA,cACH;AAAA,cAED,eAAe;AAAA,cAEd;AAAA,gBAAC;AAAA;AAAA,kBACC,eAAW;AAAA,kBACX,WAAW;AAAA,oBACT,QAAQ,wBAAwB;AAAA,oBAChC,UAAU,CAAC,YAAY,gBAAgB;AAAA,oBACvC,QAAQ,SAAS,KAAK;AAAA,kBACxB;AAAA,kBAEC;AAAA;AAAA,cACH;AAAA;AAAA;AAAA,QAEJ;AAAA,QACA,SAAS;AAAA,MACX;AAAA,OACJ;AAAA;AAEJ;","names":[]}
@@ -25,7 +25,11 @@ export interface ComboOption<V extends string | number> {
25
25
  * members indented beneath — {@link InlineEntityCombobox} does — this is a genuine
26
26
  * grouping, not decoration: the name appears once per section rather than trailing
27
27
  * every row in small grey type, which is barely legible on a phone (feedback #136).
28
- * Searchable like `sublabel`.
28
+ * The heading stays at the top of the list while its rows scroll beneath it.
29
+ *
30
+ * NOT searched (0.40, kk run 79): a group is where a row is filed, not what it is
31
+ * called — with first-letter groups ("A", "B", … "#"), typing "a" matched every row
32
+ * filed under A. Searching a category's name means putting it in `sublabel`.
29
33
  */
30
34
  group?: string;
31
35
  /**
@@ -209,6 +213,15 @@ export interface ComboboxCore<V extends string | number> {
209
213
  export declare function useComboboxCore<V extends string | number>({ options, minChars, backCloses, ...source }: ComboboxCoreOptions<V>): ComboboxCore<V>;
210
214
  /** The anchored suggestion list's box and rows — one look for {@link Combobox},
211
215
  * {@link InlineEntityCombobox} and {@link Autocomplete}. */
216
+ /**
217
+ * A group's heading in a picker list stays at the top of the list while its rows scroll
218
+ * under it (kk run 79 gap 3): with first-letter groups over two hundred payees, the
219
+ * heading is the one thing that says where in the alphabet the thumb is. Opaque — the
220
+ * list's own `bg-surface` — so the rows pass beneath it rather than through it. Shared
221
+ * by every list that heads groups (the panel and the sheet, `Combobox`, `Autocomplete`,
222
+ * `InlineEntityCombobox`).
223
+ */
224
+ export declare const GROUP_HEADING_STICKY = "sticky top-0 z-10 bg-surface";
212
225
  export declare const SUGGESTION_LIST_CLASS = "max-h-64 overflow-y-auto rounded-md border border-subtle bg-surface py-1 shadow-lg";
213
226
  export declare const suggestionRowClass: (isActive: boolean) => string;
214
227
  /**
@@ -180,6 +180,7 @@ function useComboboxCore({
180
180
  closeToTrigger
181
181
  };
182
182
  }
183
+ const GROUP_HEADING_STICKY = "sticky top-0 z-10 bg-surface";
183
184
  const SUGGESTION_LIST_CLASS = "max-h-64 overflow-y-auto rounded-md border border-subtle bg-surface py-1 shadow-lg";
184
185
  const suggestionRowClass = (isActive) => cn(
185
186
  "block w-full truncate-until-large px-3 py-1.5 text-start text-sm text-primary",
@@ -442,6 +443,7 @@ function ComboboxPanel({
442
443
  {
443
444
  role: "presentation",
444
445
  className: cn(
446
+ GROUP_HEADING_STICKY,
445
447
  "font-semibold uppercase tracking-wide text-muted",
446
448
  isPhone ? "px-4 pb-1 pt-3 text-xs" : "px-3 pb-0.5 pt-2 text-caption first:pt-1"
447
449
  ),
@@ -476,6 +478,7 @@ function ComboboxPanel({
476
478
  onSearchKeyDown: onKeyDown,
477
479
  listboxId,
478
480
  activeId,
481
+ done: multi,
479
482
  children: [
480
483
  toolbar,
481
484
  /* @__PURE__ */ jsxs("div", { className: "relative", children: [
@@ -545,6 +548,7 @@ export {
545
548
  ComboboxFieldLabel,
546
549
  ComboboxPanel,
547
550
  DISABLED_ROW_CLASS,
551
+ GROUP_HEADING_STICKY,
548
552
  SUGGESTION_LIST_CLASS,
549
553
  endHintRowProps,
550
554
  isOptionEnabled,