@colixsystems/widget-sdk 0.344.0 → 0.346.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -3
- package/dist/contract.cjs +12 -6
- package/dist/contract.js +12 -6
- package/dist/hooks.js +13 -10
- package/dist/index.d.ts +4 -0
- package/dist/popover-view.js +19 -3
- package/package.json +1 -1
- package/src/contract.js +12 -6
package/README.md
CHANGED
|
@@ -75,8 +75,8 @@ The data layer lives in **four separate domain-client packages**, each instantia
|
|
|
75
75
|
| **DIRECTORY** | `useInvites(query)` (optional: query) | `{ invites, loading, error, refetch, resend, revoke }` | `directory.invites.*` — `users.write:*` + the SystemAcl `users.write` capability (the whole invite surface, list included). `query` is `{ status?, q?, app_user_id?, limit?, offset? }` with `status` ∈ `pending \| accepted \| revoked \| expired \| not_sent \| open \| all` (endpoint default `all`; `open` = `pending`, `not_sent` or `expired`); `q` matches the invite's name or email, `app_user_id` returns the invites reserving that user id. `resend(inviteId)` sends the invitation — the first send of a `not_sent` one included. |
|
|
76
76
|
| **DIRECTORY** | `useBankIdLink()` | `{ linked, available, status, qr, message, startLink, refresh, cancel, unlink, refetchStatus, … }` | `directory.bankid.*` — no scope (JWT-gated self-service). While `pending`, render `qr` in an `<Image>` (`bankid-order-not-shown` otherwise). |
|
|
77
77
|
| **FILESTORE** (`ctx.filestore`) | `usePdfExport({ spaceType, folderId })` (optional: spaceType, folderId) | `{ openPdf, opening, canOpenPdf, exportToPdf, exporting, error, lastExported }` | `ctx.filestore.files.renderPdf` + `ctx.device.pdfViewer`, `ctx.filestore.files.exportPdf` — `files.write:*`. `openPdf(html, { fileName? })` renders the HTML to a PDF server-side and OPENS it (web: PDF tab; native: print / share sheet) without saving. `exportToPdf(html, { fileName?, folderId? })` renders it and saves it as a file (`application/pdf`). Same server-side renderer on web + native. |
|
|
78
|
-
| **PAYMENTS** (`ctx.payments`) | `useAccessPlans()` | `{ plans, loading, error, purchaseAvailable, purchase, cancel, refresh }` | `ctx.payments.{listAccessPlans,purchaseAccessPlan,cancelAccessPlan}` — `payments.charge:appUser`. Plans selling access to restricted pages; `purchase(planId)` names only the plan, the server sets price and group. `purchaseAvailable` is `false` in an iOS / Android build (digital goods need store billing): show a visible not-available state. |
|
|
79
|
-
| **PAYMENTS** (`ctx.payments`) | `useAppSubscription()` | `{ subscription, loading, error, cancel, refresh }` | `ctx.payments.{getAppSubscription,cancelAppSubscription}` — `payments.charge:appUser`. The signed-in user's subscription to a paid app (`{ active, renews, access_ends_at }`); `cancel()` stops it renewing, and access runs to `access_ends_at`. |
|
|
78
|
+
| **PAYMENTS** (`ctx.payments`) | `useAccessPlans()` | `{ plans, loading, error, purchaseAvailable, purchase, cancel, refresh }` | `ctx.payments.{listAccessPlans,purchaseAccessPlan,cancelAccessPlan}` — `payments.charge:appUser`. Plans selling access to restricted pages; `purchase(planId)` names only the plan, the server sets price and group. A held plan's `member_since` is when the user became a member (first paid charge, else when access was granted). `purchaseAvailable` is `false` in an iOS / Android build (digital goods need store billing): show a visible not-available state. |
|
|
79
|
+
| **PAYMENTS** (`ctx.payments`) | `useAppSubscription()` | `{ subscription, loading, error, cancel, refresh }` | `ctx.payments.{getAppSubscription,cancelAppSubscription}` — `payments.charge:appUser`. The signed-in user's subscription to a paid app (`{ active, renews, access_ends_at, member_since }`); `cancel()` stops it renewing, and access runs to `access_ends_at`. `member_since` is when they became a subscriber. |
|
|
80
80
|
| **PAYMENTS** (`ctx.payments`) | `usePayments()` | `{ requestPayment, getPayment, requestGuestPayment, getGuestPayment }` | `ctx.payments.*` — `payments.charge:appUser`; guest checkout (`requestGuestPayment`, a visitor with no account buying physical goods for an order they created) also `payments.charge:guest`. `requestPayment` requires `kind` (`"physical"` \| `"service"` \| `"digital"`): what is sold. A call without it is a publish-blocking `payment-kind-required` finding. A `"digital"` charge is refused in an iOS or Android build (`DIGITAL_SALE_NEEDS_STORE_BILLING`). Selling an order (goods, a booking, a ticket)? Create its row first and pass `order: { table_id, record_id }`, in a table with a payment-status column: only the payment marks the order paid, so never write a paid status yourself (a `payment-status-written` finding). The server refuses an order it cannot settle with `ORDER_NOT_FOUND`, `ORDER_NOT_PAYABLE` or `ORDER_ALREADY_PAID`, none retryable. Rejects with `PaymentError { code, message, retryable }`; when `retryable` is `false` show `message` and drop the retry. Charges are accepted ONLY in the currency the workspace sells in — omit `currency` and the platform applies it (a disagreeing literal is a publish-blocking `payment-currency` finding). |
|
|
81
81
|
| **NOTIFICATIONS** (`ctx.notifications`) | `useSendNotification()` | `{ send, sending, error }` | `ctx.notifications.send` — `notifications.send:appUser`. `send({ recipient_user_id, title, body, link?, payload? })` notifies one app user in the same workspace; call from an event handler (never render); rejects with `NotificationError`. |
|
|
82
82
|
| **NOTIFICATIONS** (`ctx.notifications`) | `useRecordMutes(tableId)` | `{ isMuted, loading, error, refetch }` | `ctx.notifications.mutes` — no scope. Which records of one table the signed-in user has muted, in one request for a whole list; `isMuted(recordId)` turns false when a timed mute lapses, and a `useRecordMute` write shows at once. |
|
|
@@ -91,7 +91,23 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
91
91
|
|
|
92
92
|
## Status
|
|
93
93
|
|
|
94
|
-
`v0.
|
|
94
|
+
`v0.346.0` — pre-publish. The package surface (types, function names, export paths) is the v1 contract; runtime behaviour for some hooks is stubbed (each hook documents what's wired and what isn't). It is **not yet published to npm**.
|
|
95
|
+
|
|
96
|
+
### What's new in 0.346.0 (contract 1.283.0)
|
|
97
|
+
|
|
98
|
+
**A `<Popover>` can open a dialog of its own.** The `close` a popover hands its children now takes what to run next: `close(then)` closes the popover and runs `then` once it has left the screen. Open a dialog, a `<Modal>` or an `<EmojiPicker>` from a button inside the popover that way. iOS cannot show a dialog while another is still leaving the screen, so one opened in the same press that closed the popover never appeared there. The new `onDismiss` prop runs at the same moment after every close, the backdrop and Escape included. `<Menu>` already runs a picked item's `onPress` this way. Additive.
|
|
99
|
+
|
|
100
|
+
```jsx
|
|
101
|
+
<Popover trigger={trigger}>
|
|
102
|
+
{({ close }) => (
|
|
103
|
+
<Button title={t("more", "More")} onPress={() => close(() => setPickerOpen(true))} />
|
|
104
|
+
)}
|
|
105
|
+
</Popover>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### What's new in 0.345.0 (contract 1.282.0)
|
|
109
|
+
|
|
110
|
+
**A member's start date.** Each plan from `useAccessPlans()` and the `subscription` from `useAppSubscription()` now carry `member_since`: when the signed-in user became a member, as an ISO time (their first paid charge, else when access was granted: the same date the workspace owner sees in Members), or null when they hold none. Show "Member since" from it with `useI18n().formatDate(plan.member_since)`; never keep a join date in a table of your own, which nothing fills when someone pays. When the user holds several live grants for one plan it is the earliest. The injected payments client returns it from `listAccessPlans()` and `getAppSubscription()` (`@colixsystems/payments-client` 0.8.0). Additive.
|
|
95
111
|
|
|
96
112
|
### What's new in 0.344.0 (contract 1.281.0)
|
|
97
113
|
|
package/dist/contract.cjs
CHANGED
|
@@ -2521,7 +2521,7 @@ const HOOKS = [
|
|
|
2521
2521
|
signature: "useAccessPlans()",
|
|
2522
2522
|
returnShape: {
|
|
2523
2523
|
plans:
|
|
2524
|
-
"Array<{ id, name, price_cents, currency, billing: \"one_time\" | \"monthly\", owned, renews, access_ends_at, purchase_available }> // owned: the user holds it; renews: a held monthly plan will charge again; access_ends_at: end of held access without a renewal (null for one-time); purchase_available: this plan can be bought here — false in an iOS/Android build for a plan the workspace does not sell in-app, and for a plan the user holds that is no longer on sale (listed so they can still cancel it)",
|
|
2524
|
+
"Array<{ id, name, price_cents, currency, billing: \"one_time\" | \"monthly\", owned, renews, access_ends_at, member_since, purchase_available }> // owned: the user holds it; renews: a held monthly plan will charge again; access_ends_at: end of held access without a renewal (null for one-time); member_since: the member's start date, their first paid charge, else when access was granted (null when not held; show it with useI18n().formatDate); purchase_available: this plan can be bought here — false in an iOS/Android build for a plan the workspace does not sell in-app, and for a plan the user holds that is no longer on sale (listed so they can still cancel it)",
|
|
2525
2525
|
loading: "boolean",
|
|
2526
2526
|
error: "PaymentError | null",
|
|
2527
2527
|
purchaseAvailable:
|
|
@@ -2545,11 +2545,11 @@ const HOOKS = [
|
|
|
2545
2545
|
signature: "useAppSubscription()",
|
|
2546
2546
|
returnShape: {
|
|
2547
2547
|
subscription:
|
|
2548
|
-
"{ active, renews, access_ends_at } | null // the signed-in user's subscription to the app itself (a paid app): active = they hold paid access now; renews = a subscription will charge again (false once cancelled, or when bought in the App Store / Google Play); access_ends_at = when access ends without a renewal (null while it has no end, or when not held)",
|
|
2548
|
+
"{ active, renews, access_ends_at, member_since } | null // the signed-in user's subscription to the app itself (a paid app): active = they hold paid access now; renews = a subscription will charge again (false once cancelled, or when bought in the App Store / Google Play); access_ends_at = when access ends without a renewal (null while it has no end, or when not held); member_since = the subscriber's start date, their first paid charge, else when access was granted (null when not held)",
|
|
2549
2549
|
loading: "boolean",
|
|
2550
2550
|
error: "PaymentError | null",
|
|
2551
2551
|
cancel:
|
|
2552
|
-
"() => Promise<{ active, renews: false, access_ends_at }> // stop it renewing; access runs to access_ends_at, nothing is refunded — offer it whenever renews is true",
|
|
2552
|
+
"() => Promise<{ active, renews: false, access_ends_at, member_since }> // stop it renewing; access runs to access_ends_at, nothing is refunded — offer it whenever renews is true",
|
|
2553
2553
|
refresh: "() => Promise<void>",
|
|
2554
2554
|
},
|
|
2555
2555
|
requiredContextSlice: ["payments.getAppSubscription", "payments.cancelAppSubscription"],
|
|
@@ -4077,7 +4077,7 @@ const PRIMITIVES = [
|
|
|
4077
4077
|
{
|
|
4078
4078
|
name: "Popover",
|
|
4079
4079
|
description:
|
|
4080
|
-
'Themed popover: free content beside a trigger. `<Popover trigger={<Button variant="secondary" title={t("filters", "Filters")} />} accessibilityLabel={t("filters", "Filters")}>{({ close }) => <View style={{ gap: theme.spacing.sm }}>…<Button title={t("apply", "Apply")} onPress={() => { apply(); close(); }} /></View>}</Popover>`. Use it by default for a small panel that belongs to one control and should open next to it — quick filters, a small colour-swatch or photo picker that opens at its button, a short detail card (an emoji choice is `<EmojiPicker>`; a long or full-screen option list is a `<Modal>`). It opens beside the trigger on a wide screen and as a bottom sheet on a phone, is drawn over the screen so no card or list clips it, and closes on the backdrop press, the Escape key on web and the Android back button. `children` is the content, or a function given `{ close }`. To open or close it from your own code, pass `visible` with `onVisibleChange`. Other props: `trigger` (ONE pressable element; its own `onPress` still runs first), `placement` ("bottom" default | "top"; it flips at the screen edge), `accessibilityLabel`, `closeAccessibilityLabel`, `testID`. A list of actions is `<Menu>`; a form with a title and Save / Cancel is `<Modal>`. Its panel follows the theme (Design > Components > Dropdown menus), and components inside it read a theme inked for that panel. When the request needs what a popover cannot do — a panel that stays open while the user works elsewhere on the page, or one pinned to a spot that is not a pressable control — build your own in the app\'s look.',
|
|
4080
|
+
'Themed popover: free content beside a trigger. `<Popover trigger={<Button variant="secondary" title={t("filters", "Filters")} />} accessibilityLabel={t("filters", "Filters")}>{({ close }) => <View style={{ gap: theme.spacing.sm }}>…<Button title={t("apply", "Apply")} onPress={() => { apply(); close(); }} /></View>}</Popover>`. Use it by default for a small panel that belongs to one control and should open next to it — quick filters, a small colour-swatch or photo picker that opens at its button, a short detail card (an emoji choice is `<EmojiPicker>`; a long or full-screen option list is a `<Modal>`). It opens beside the trigger on a wide screen and as a bottom sheet on a phone, is drawn over the screen so no card or list clips it, and closes on the backdrop press, the Escape key on web and the Android back button. `children` is the content, or a function given `{ close }`. To open or close it from your own code, pass `visible` with `onVisibleChange`. A dialog or `<EmojiPicker>` opened from inside it waits until the popover has left the screen: call `close(() => setPickerOpen(true))`, or open it in `onDismiss`, which runs then too; opened in the same press that closes it, it fails to show on iOS. Other props: `trigger` (ONE pressable element; its own `onPress` still runs first), `placement` ("bottom" default | "top"; it flips at the screen edge), `accessibilityLabel`, `closeAccessibilityLabel`, `onDismiss`, `testID`. A list of actions is `<Menu>`; a form with a title and Save / Cancel is `<Modal>`. Its panel follows the theme (Design > Components > Dropdown menus), and components inside it read a theme inked for that panel. When the request needs what a popover cannot do — a panel that stays open while the user works elsewhere on the page, or one pinned to a spot that is not a pressable control — build your own in the app\'s look.',
|
|
4081
4081
|
rnComponent: null,
|
|
4082
4082
|
docsUrl: null,
|
|
4083
4083
|
},
|
|
@@ -4699,7 +4699,7 @@ const WIDGET_CONTEXT_SHAPE = {
|
|
|
4699
4699
|
},
|
|
4700
4700
|
payments: {
|
|
4701
4701
|
description:
|
|
4702
|
-
"Injected @colixsystems/payments-client instance (REQ-BILL-07-WIDGETPAY). { requestPayment(body) -> Promise<{ id, status }>, getPayment(id) -> Promise<payment>, requestGuestPayment(body) -> Promise<{ id, status }>, getGuestPayment(id) -> Promise<payment>, listAccessPlans() -> Promise<{ data, meta }>, purchaseAccessPlan({ plan_id, return_path? }) -> Promise<{ plan_id, status }>, cancelAccessPlan(planId) -> Promise<{ plan_id, renews, access_ends_at }>, getAppSubscription() -> Promise<{ active, renews, access_ends_at }>, cancelAppSubscription() -> Promise<{ active, renews, access_ends_at }> }; wire is snake_case (amount_cents, return_path, order). Backs usePayments(), useAccessPlans() and useAppSubscription(); requires the payments.charge:appUser scope, and guest checkout (requestGuestPayment, a visitor with no account buying physical goods) also payments.charge:guest. The host opens hosted Checkout itself — same-tab on web, in-app browser on native (or auto-confirms under the mock provider); the charge settles to the workspace owner.",
|
|
4702
|
+
"Injected @colixsystems/payments-client instance (REQ-BILL-07-WIDGETPAY). { requestPayment(body) -> Promise<{ id, status }>, getPayment(id) -> Promise<payment>, requestGuestPayment(body) -> Promise<{ id, status }>, getGuestPayment(id) -> Promise<payment>, listAccessPlans() -> Promise<{ data, meta }>, purchaseAccessPlan({ plan_id, return_path? }) -> Promise<{ plan_id, status }>, cancelAccessPlan(planId) -> Promise<{ plan_id, renews, access_ends_at }>, getAppSubscription() -> Promise<{ active, renews, access_ends_at, member_since }>, cancelAppSubscription() -> Promise<{ active, renews, access_ends_at, member_since }> }; wire is snake_case (amount_cents, return_path, order). Backs usePayments(), useAccessPlans() and useAppSubscription(); requires the payments.charge:appUser scope, and guest checkout (requestGuestPayment, a visitor with no account buying physical goods) also payments.charge:guest. The host opens hosted Checkout itself — same-tab on web, in-app browser on native (or auto-confirms under the mock provider); the charge settles to the workspace owner.",
|
|
4703
4703
|
required: true,
|
|
4704
4704
|
fields: {
|
|
4705
4705
|
requestPayment: "function",
|
|
@@ -7153,7 +7153,13 @@ const CONTRACT = deepFreeze({
|
|
|
7153
7153
|
// locale (date-fns format(d, "dd/MM/yyyy"), toLocaleDateString("en-GB"),
|
|
7154
7154
|
// a hand-built getDate()/getMonth() string) is the `date-shown-fixed-format`
|
|
7155
7155
|
// warning; the widget agent's publish gate blocks on it.
|
|
7156
|
-
|
|
7156
|
+
// 1.282.0: additive (sc-18485) — useAccessPlans() plans and
|
|
7157
|
+
// useAppSubscription() subscription carry member_since, the member's start
|
|
7158
|
+
// date: first paid charge, else when access was granted (null when not held).
|
|
7159
|
+
// 1.283.0: additive (sc-17852) — `<Popover onDismiss>` and the children's
|
|
7160
|
+
// `close(then)` run once the closed popover has left the screen, so a
|
|
7161
|
+
// dialog it opens presents on iOS.
|
|
7162
|
+
version: "1.283.0",
|
|
7157
7163
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7158
7164
|
hooks: HOOKS,
|
|
7159
7165
|
primitives: PRIMITIVES,
|
package/dist/contract.js
CHANGED
|
@@ -2516,7 +2516,7 @@ const HOOKS = [
|
|
|
2516
2516
|
signature: "useAccessPlans()",
|
|
2517
2517
|
returnShape: {
|
|
2518
2518
|
plans:
|
|
2519
|
-
"Array<{ id, name, price_cents, currency, billing: \"one_time\" | \"monthly\", owned, renews, access_ends_at, purchase_available }> // owned: the user holds it; renews: a held monthly plan will charge again; access_ends_at: end of held access without a renewal (null for one-time); purchase_available: this plan can be bought here — false in an iOS/Android build for a plan the workspace does not sell in-app, and for a plan the user holds that is no longer on sale (listed so they can still cancel it)",
|
|
2519
|
+
"Array<{ id, name, price_cents, currency, billing: \"one_time\" | \"monthly\", owned, renews, access_ends_at, member_since, purchase_available }> // owned: the user holds it; renews: a held monthly plan will charge again; access_ends_at: end of held access without a renewal (null for one-time); member_since: the member's start date, their first paid charge, else when access was granted (null when not held; show it with useI18n().formatDate); purchase_available: this plan can be bought here — false in an iOS/Android build for a plan the workspace does not sell in-app, and for a plan the user holds that is no longer on sale (listed so they can still cancel it)",
|
|
2520
2520
|
loading: "boolean",
|
|
2521
2521
|
error: "PaymentError | null",
|
|
2522
2522
|
purchaseAvailable:
|
|
@@ -2540,11 +2540,11 @@ const HOOKS = [
|
|
|
2540
2540
|
signature: "useAppSubscription()",
|
|
2541
2541
|
returnShape: {
|
|
2542
2542
|
subscription:
|
|
2543
|
-
"{ active, renews, access_ends_at } | null // the signed-in user's subscription to the app itself (a paid app): active = they hold paid access now; renews = a subscription will charge again (false once cancelled, or when bought in the App Store / Google Play); access_ends_at = when access ends without a renewal (null while it has no end, or when not held)",
|
|
2543
|
+
"{ active, renews, access_ends_at, member_since } | null // the signed-in user's subscription to the app itself (a paid app): active = they hold paid access now; renews = a subscription will charge again (false once cancelled, or when bought in the App Store / Google Play); access_ends_at = when access ends without a renewal (null while it has no end, or when not held); member_since = the subscriber's start date, their first paid charge, else when access was granted (null when not held)",
|
|
2544
2544
|
loading: "boolean",
|
|
2545
2545
|
error: "PaymentError | null",
|
|
2546
2546
|
cancel:
|
|
2547
|
-
"() => Promise<{ active, renews: false, access_ends_at }> // stop it renewing; access runs to access_ends_at, nothing is refunded — offer it whenever renews is true",
|
|
2547
|
+
"() => Promise<{ active, renews: false, access_ends_at, member_since }> // stop it renewing; access runs to access_ends_at, nothing is refunded — offer it whenever renews is true",
|
|
2548
2548
|
refresh: "() => Promise<void>",
|
|
2549
2549
|
},
|
|
2550
2550
|
requiredContextSlice: ["payments.getAppSubscription", "payments.cancelAppSubscription"],
|
|
@@ -4072,7 +4072,7 @@ const PRIMITIVES = [
|
|
|
4072
4072
|
{
|
|
4073
4073
|
name: "Popover",
|
|
4074
4074
|
description:
|
|
4075
|
-
'Themed popover: free content beside a trigger. `<Popover trigger={<Button variant="secondary" title={t("filters", "Filters")} />} accessibilityLabel={t("filters", "Filters")}>{({ close }) => <View style={{ gap: theme.spacing.sm }}>…<Button title={t("apply", "Apply")} onPress={() => { apply(); close(); }} /></View>}</Popover>`. Use it by default for a small panel that belongs to one control and should open next to it — quick filters, a small colour-swatch or photo picker that opens at its button, a short detail card (an emoji choice is `<EmojiPicker>`; a long or full-screen option list is a `<Modal>`). It opens beside the trigger on a wide screen and as a bottom sheet on a phone, is drawn over the screen so no card or list clips it, and closes on the backdrop press, the Escape key on web and the Android back button. `children` is the content, or a function given `{ close }`. To open or close it from your own code, pass `visible` with `onVisibleChange`. Other props: `trigger` (ONE pressable element; its own `onPress` still runs first), `placement` ("bottom" default | "top"; it flips at the screen edge), `accessibilityLabel`, `closeAccessibilityLabel`, `testID`. A list of actions is `<Menu>`; a form with a title and Save / Cancel is `<Modal>`. Its panel follows the theme (Design > Components > Dropdown menus), and components inside it read a theme inked for that panel. When the request needs what a popover cannot do — a panel that stays open while the user works elsewhere on the page, or one pinned to a spot that is not a pressable control — build your own in the app\'s look.',
|
|
4075
|
+
'Themed popover: free content beside a trigger. `<Popover trigger={<Button variant="secondary" title={t("filters", "Filters")} />} accessibilityLabel={t("filters", "Filters")}>{({ close }) => <View style={{ gap: theme.spacing.sm }}>…<Button title={t("apply", "Apply")} onPress={() => { apply(); close(); }} /></View>}</Popover>`. Use it by default for a small panel that belongs to one control and should open next to it — quick filters, a small colour-swatch or photo picker that opens at its button, a short detail card (an emoji choice is `<EmojiPicker>`; a long or full-screen option list is a `<Modal>`). It opens beside the trigger on a wide screen and as a bottom sheet on a phone, is drawn over the screen so no card or list clips it, and closes on the backdrop press, the Escape key on web and the Android back button. `children` is the content, or a function given `{ close }`. To open or close it from your own code, pass `visible` with `onVisibleChange`. A dialog or `<EmojiPicker>` opened from inside it waits until the popover has left the screen: call `close(() => setPickerOpen(true))`, or open it in `onDismiss`, which runs then too; opened in the same press that closes it, it fails to show on iOS. Other props: `trigger` (ONE pressable element; its own `onPress` still runs first), `placement` ("bottom" default | "top"; it flips at the screen edge), `accessibilityLabel`, `closeAccessibilityLabel`, `onDismiss`, `testID`. A list of actions is `<Menu>`; a form with a title and Save / Cancel is `<Modal>`. Its panel follows the theme (Design > Components > Dropdown menus), and components inside it read a theme inked for that panel. When the request needs what a popover cannot do — a panel that stays open while the user works elsewhere on the page, or one pinned to a spot that is not a pressable control — build your own in the app\'s look.',
|
|
4076
4076
|
rnComponent: null,
|
|
4077
4077
|
docsUrl: null,
|
|
4078
4078
|
},
|
|
@@ -4694,7 +4694,7 @@ const WIDGET_CONTEXT_SHAPE = {
|
|
|
4694
4694
|
},
|
|
4695
4695
|
payments: {
|
|
4696
4696
|
description:
|
|
4697
|
-
"Injected @colixsystems/payments-client instance (REQ-BILL-07-WIDGETPAY). { requestPayment(body) -> Promise<{ id, status }>, getPayment(id) -> Promise<payment>, requestGuestPayment(body) -> Promise<{ id, status }>, getGuestPayment(id) -> Promise<payment>, listAccessPlans() -> Promise<{ data, meta }>, purchaseAccessPlan({ plan_id, return_path? }) -> Promise<{ plan_id, status }>, cancelAccessPlan(planId) -> Promise<{ plan_id, renews, access_ends_at }>, getAppSubscription() -> Promise<{ active, renews, access_ends_at }>, cancelAppSubscription() -> Promise<{ active, renews, access_ends_at }> }; wire is snake_case (amount_cents, return_path, order). Backs usePayments(), useAccessPlans() and useAppSubscription(); requires the payments.charge:appUser scope, and guest checkout (requestGuestPayment, a visitor with no account buying physical goods) also payments.charge:guest. The host opens hosted Checkout itself — same-tab on web, in-app browser on native (or auto-confirms under the mock provider); the charge settles to the workspace owner.",
|
|
4697
|
+
"Injected @colixsystems/payments-client instance (REQ-BILL-07-WIDGETPAY). { requestPayment(body) -> Promise<{ id, status }>, getPayment(id) -> Promise<payment>, requestGuestPayment(body) -> Promise<{ id, status }>, getGuestPayment(id) -> Promise<payment>, listAccessPlans() -> Promise<{ data, meta }>, purchaseAccessPlan({ plan_id, return_path? }) -> Promise<{ plan_id, status }>, cancelAccessPlan(planId) -> Promise<{ plan_id, renews, access_ends_at }>, getAppSubscription() -> Promise<{ active, renews, access_ends_at, member_since }>, cancelAppSubscription() -> Promise<{ active, renews, access_ends_at, member_since }> }; wire is snake_case (amount_cents, return_path, order). Backs usePayments(), useAccessPlans() and useAppSubscription(); requires the payments.charge:appUser scope, and guest checkout (requestGuestPayment, a visitor with no account buying physical goods) also payments.charge:guest. The host opens hosted Checkout itself — same-tab on web, in-app browser on native (or auto-confirms under the mock provider); the charge settles to the workspace owner.",
|
|
4698
4698
|
required: true,
|
|
4699
4699
|
fields: {
|
|
4700
4700
|
requestPayment: "function",
|
|
@@ -7148,7 +7148,13 @@ const CONTRACT = deepFreeze({
|
|
|
7148
7148
|
// locale (date-fns format(d, "dd/MM/yyyy"), toLocaleDateString("en-GB"),
|
|
7149
7149
|
// a hand-built getDate()/getMonth() string) is the `date-shown-fixed-format`
|
|
7150
7150
|
// warning; the widget agent's publish gate blocks on it.
|
|
7151
|
-
|
|
7151
|
+
// 1.282.0: additive (sc-18485) — useAccessPlans() plans and
|
|
7152
|
+
// useAppSubscription() subscription carry member_since, the member's start
|
|
7153
|
+
// date: first paid charge, else when access was granted (null when not held).
|
|
7154
|
+
// 1.283.0: additive (sc-17852) — `<Popover onDismiss>` and the children's
|
|
7155
|
+
// `close(then)` run once the closed popover has left the screen, so a
|
|
7156
|
+
// dialog it opens presents on iOS.
|
|
7157
|
+
version: "1.283.0",
|
|
7152
7158
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7153
7159
|
hooks: HOOKS,
|
|
7154
7160
|
primitives: PRIMITIVES,
|
package/dist/hooks.js
CHANGED
|
@@ -7504,11 +7504,13 @@ export function usePayments() {
|
|
|
7504
7504
|
* `{ plans, loading, error, purchaseAvailable, purchase, cancel, refresh }`:
|
|
7505
7505
|
*
|
|
7506
7506
|
* plans → [{ id, name, price_cents, currency, billing, owned, renews,
|
|
7507
|
-
* access_ends_at, purchase_available }] — `billing` is
|
|
7508
|
-
* "monthly"; `owned` is true once the user holds the plan;
|
|
7509
|
-
* a held monthly plan will charge again; `access_ends_at`
|
|
7510
|
-
* access ends without a renewal (null for one-time access);
|
|
7511
|
-
* `
|
|
7507
|
+
* access_ends_at, member_since, purchase_available }] — `billing` is
|
|
7508
|
+
* "one_time" or "monthly"; `owned` is true once the user holds the plan;
|
|
7509
|
+
* `renews` while a held monthly plan will charge again; `access_ends_at`
|
|
7510
|
+
* is when held access ends without a renewal (null for one-time access);
|
|
7511
|
+
* `member_since` is the member's start date, their first paid charge,
|
|
7512
|
+
* else when access was granted (null when not held); `purchase_available` is whether this plan can be
|
|
7513
|
+
* bought here.
|
|
7512
7514
|
* Render the price with `useWorkspaceCurrency().formatMoney(price_cents)`.
|
|
7513
7515
|
* purchaseAvailable → false where no plan can be bought here: page access is
|
|
7514
7516
|
* a digital good, and an iOS / Android build sells only the plans the
|
|
@@ -7575,11 +7577,12 @@ function _accessPlansState(res) {
|
|
|
7575
7577
|
* sc-15342 — the signed-in app user's own subscription to the app itself (a
|
|
7576
7578
|
* paid app), and the control to stop it renewing.
|
|
7577
7579
|
*
|
|
7578
|
-
* subscription → { active, renews, access_ends_at }. `active`:
|
|
7579
|
-
* access to the app now; `renews`: a subscription will
|
|
7580
|
-
* `access_ends_at`: when access ends without a renewal (null
|
|
7581
|
-
* no end, or when not held)
|
|
7582
|
-
*
|
|
7580
|
+
* subscription → { active, renews, access_ends_at, member_since }. `active`:
|
|
7581
|
+
* they hold paid access to the app now; `renews`: a subscription will
|
|
7582
|
+
* charge again; `access_ends_at`: when access ends without a renewal (null
|
|
7583
|
+
* while it has no end, or when not held); `member_since`: their first
|
|
7584
|
+
* paid charge, else when access was granted (null when not held).
|
|
7585
|
+
* cancel() → Promise<{ active, renews: false, access_ends_at, member_since }> — stop the
|
|
7583
7586
|
* subscription renewing. Access continues until `access_ends_at`, then
|
|
7584
7587
|
* ends; nothing is refunded. Offer it whenever `renews` is true. Access
|
|
7585
7588
|
* bought in the App Store or Google Play is cancelled in the store, so it
|
package/dist/index.d.ts
CHANGED
|
@@ -1713,6 +1713,8 @@ export interface AccessPlan {
|
|
|
1713
1713
|
renews: boolean;
|
|
1714
1714
|
/** ISO time held access ends without a renewal; null for one-time access. */
|
|
1715
1715
|
access_ends_at: string | null;
|
|
1716
|
+
/** ISO time they became a member: first paid charge, else when access was granted; null when not held. */
|
|
1717
|
+
member_since: string | null;
|
|
1716
1718
|
/**
|
|
1717
1719
|
* Whether this plan can be bought here: false in a store build that does not
|
|
1718
1720
|
* sell it in-app, and for a plan the user holds that is no longer on sale
|
|
@@ -1758,6 +1760,8 @@ export interface AppSubscription {
|
|
|
1758
1760
|
renews: boolean;
|
|
1759
1761
|
/** ISO time access ends without a renewal; null while it has no end, or when not held. */
|
|
1760
1762
|
access_ends_at: string | null;
|
|
1763
|
+
/** ISO time they became a subscriber: first paid charge, else when access was granted; null when not held. */
|
|
1764
|
+
member_since: string | null;
|
|
1761
1765
|
}
|
|
1762
1766
|
|
|
1763
1767
|
export interface AppSubscriptionApi {
|
package/dist/popover-view.js
CHANGED
|
@@ -191,12 +191,15 @@ export function makePopover(rn, Overlay) {
|
|
|
191
191
|
*
|
|
192
192
|
* @param {object} props
|
|
193
193
|
* @param {any} props.trigger — the pressable element that opens it.
|
|
194
|
-
* @param {any|((api: {close: () => void}) => any)} props.children
|
|
194
|
+
* @param {any|((api: {close: (then?: () => void) => void}) => any)} props.children
|
|
195
|
+
* — `close(then)` runs `then` once the popover has left the screen.
|
|
195
196
|
* @param {boolean} [props.visible] — set it to control the popover.
|
|
196
197
|
* @param {(visible: boolean) => void} [props.onVisibleChange]
|
|
197
198
|
* @param {"bottom"|"top"} [props.placement] — default "bottom"; flips.
|
|
198
199
|
* @param {string} [props.accessibilityLabel] — names the panel.
|
|
199
200
|
* @param {string} [props.closeAccessibilityLabel] — the sheet backdrop's name.
|
|
201
|
+
* @param {() => void} [props.onDismiss] — runs once a closed popover has
|
|
202
|
+
* left the screen, so a dialog it opens presents on every host.
|
|
200
203
|
* @param {string} [props.testID] — on the panel.
|
|
201
204
|
*/
|
|
202
205
|
function Popover({
|
|
@@ -207,6 +210,7 @@ export function makePopover(rn, Overlay) {
|
|
|
207
210
|
placement = "bottom",
|
|
208
211
|
accessibilityLabel,
|
|
209
212
|
closeAccessibilityLabel,
|
|
213
|
+
onDismiss,
|
|
210
214
|
testID,
|
|
211
215
|
}) {
|
|
212
216
|
const theme = useHostTheme() || DEFAULT_THEME_TOKENS;
|
|
@@ -218,7 +222,18 @@ export function makePopover(rn, Overlay) {
|
|
|
218
222
|
if (!controlled) setOwnOpen(next);
|
|
219
223
|
if (typeof onVisibleChange === "function") onVisibleChange(next);
|
|
220
224
|
};
|
|
221
|
-
|
|
225
|
+
// What `close(then)` asked to run once the popover has left the screen.
|
|
226
|
+
const afterClose = React.useRef(null);
|
|
227
|
+
const close = (then) => {
|
|
228
|
+
afterClose.current = typeof then === "function" ? then : null;
|
|
229
|
+
setOpen(false);
|
|
230
|
+
};
|
|
231
|
+
const dismissed = () => {
|
|
232
|
+
const run = afterClose.current;
|
|
233
|
+
afterClose.current = null;
|
|
234
|
+
if (run) run();
|
|
235
|
+
if (typeof onDismiss === "function") onDismiss();
|
|
236
|
+
};
|
|
222
237
|
const spacing = theme.spacing || DEFAULT_THEME_TOKENS.spacing;
|
|
223
238
|
|
|
224
239
|
return h(
|
|
@@ -233,7 +248,8 @@ export function makePopover(rn, Overlay) {
|
|
|
233
248
|
AnchoredSurface,
|
|
234
249
|
{
|
|
235
250
|
visible: open,
|
|
236
|
-
onRequestClose: close,
|
|
251
|
+
onRequestClose: () => close(),
|
|
252
|
+
onDismiss: dismissed,
|
|
237
253
|
anchorRef,
|
|
238
254
|
placement,
|
|
239
255
|
padding: spacing.md,
|
package/package.json
CHANGED
package/src/contract.js
CHANGED
|
@@ -2516,7 +2516,7 @@ const HOOKS = [
|
|
|
2516
2516
|
signature: "useAccessPlans()",
|
|
2517
2517
|
returnShape: {
|
|
2518
2518
|
plans:
|
|
2519
|
-
"Array<{ id, name, price_cents, currency, billing: \"one_time\" | \"monthly\", owned, renews, access_ends_at, purchase_available }> // owned: the user holds it; renews: a held monthly plan will charge again; access_ends_at: end of held access without a renewal (null for one-time); purchase_available: this plan can be bought here — false in an iOS/Android build for a plan the workspace does not sell in-app, and for a plan the user holds that is no longer on sale (listed so they can still cancel it)",
|
|
2519
|
+
"Array<{ id, name, price_cents, currency, billing: \"one_time\" | \"monthly\", owned, renews, access_ends_at, member_since, purchase_available }> // owned: the user holds it; renews: a held monthly plan will charge again; access_ends_at: end of held access without a renewal (null for one-time); member_since: the member's start date, their first paid charge, else when access was granted (null when not held; show it with useI18n().formatDate); purchase_available: this plan can be bought here — false in an iOS/Android build for a plan the workspace does not sell in-app, and for a plan the user holds that is no longer on sale (listed so they can still cancel it)",
|
|
2520
2520
|
loading: "boolean",
|
|
2521
2521
|
error: "PaymentError | null",
|
|
2522
2522
|
purchaseAvailable:
|
|
@@ -2540,11 +2540,11 @@ const HOOKS = [
|
|
|
2540
2540
|
signature: "useAppSubscription()",
|
|
2541
2541
|
returnShape: {
|
|
2542
2542
|
subscription:
|
|
2543
|
-
"{ active, renews, access_ends_at } | null // the signed-in user's subscription to the app itself (a paid app): active = they hold paid access now; renews = a subscription will charge again (false once cancelled, or when bought in the App Store / Google Play); access_ends_at = when access ends without a renewal (null while it has no end, or when not held)",
|
|
2543
|
+
"{ active, renews, access_ends_at, member_since } | null // the signed-in user's subscription to the app itself (a paid app): active = they hold paid access now; renews = a subscription will charge again (false once cancelled, or when bought in the App Store / Google Play); access_ends_at = when access ends without a renewal (null while it has no end, or when not held); member_since = the subscriber's start date, their first paid charge, else when access was granted (null when not held)",
|
|
2544
2544
|
loading: "boolean",
|
|
2545
2545
|
error: "PaymentError | null",
|
|
2546
2546
|
cancel:
|
|
2547
|
-
"() => Promise<{ active, renews: false, access_ends_at }> // stop it renewing; access runs to access_ends_at, nothing is refunded — offer it whenever renews is true",
|
|
2547
|
+
"() => Promise<{ active, renews: false, access_ends_at, member_since }> // stop it renewing; access runs to access_ends_at, nothing is refunded — offer it whenever renews is true",
|
|
2548
2548
|
refresh: "() => Promise<void>",
|
|
2549
2549
|
},
|
|
2550
2550
|
requiredContextSlice: ["payments.getAppSubscription", "payments.cancelAppSubscription"],
|
|
@@ -4072,7 +4072,7 @@ const PRIMITIVES = [
|
|
|
4072
4072
|
{
|
|
4073
4073
|
name: "Popover",
|
|
4074
4074
|
description:
|
|
4075
|
-
'Themed popover: free content beside a trigger. `<Popover trigger={<Button variant="secondary" title={t("filters", "Filters")} />} accessibilityLabel={t("filters", "Filters")}>{({ close }) => <View style={{ gap: theme.spacing.sm }}>…<Button title={t("apply", "Apply")} onPress={() => { apply(); close(); }} /></View>}</Popover>`. Use it by default for a small panel that belongs to one control and should open next to it — quick filters, a small colour-swatch or photo picker that opens at its button, a short detail card (an emoji choice is `<EmojiPicker>`; a long or full-screen option list is a `<Modal>`). It opens beside the trigger on a wide screen and as a bottom sheet on a phone, is drawn over the screen so no card or list clips it, and closes on the backdrop press, the Escape key on web and the Android back button. `children` is the content, or a function given `{ close }`. To open or close it from your own code, pass `visible` with `onVisibleChange`. Other props: `trigger` (ONE pressable element; its own `onPress` still runs first), `placement` ("bottom" default | "top"; it flips at the screen edge), `accessibilityLabel`, `closeAccessibilityLabel`, `testID`. A list of actions is `<Menu>`; a form with a title and Save / Cancel is `<Modal>`. Its panel follows the theme (Design > Components > Dropdown menus), and components inside it read a theme inked for that panel. When the request needs what a popover cannot do — a panel that stays open while the user works elsewhere on the page, or one pinned to a spot that is not a pressable control — build your own in the app\'s look.',
|
|
4075
|
+
'Themed popover: free content beside a trigger. `<Popover trigger={<Button variant="secondary" title={t("filters", "Filters")} />} accessibilityLabel={t("filters", "Filters")}>{({ close }) => <View style={{ gap: theme.spacing.sm }}>…<Button title={t("apply", "Apply")} onPress={() => { apply(); close(); }} /></View>}</Popover>`. Use it by default for a small panel that belongs to one control and should open next to it — quick filters, a small colour-swatch or photo picker that opens at its button, a short detail card (an emoji choice is `<EmojiPicker>`; a long or full-screen option list is a `<Modal>`). It opens beside the trigger on a wide screen and as a bottom sheet on a phone, is drawn over the screen so no card or list clips it, and closes on the backdrop press, the Escape key on web and the Android back button. `children` is the content, or a function given `{ close }`. To open or close it from your own code, pass `visible` with `onVisibleChange`. A dialog or `<EmojiPicker>` opened from inside it waits until the popover has left the screen: call `close(() => setPickerOpen(true))`, or open it in `onDismiss`, which runs then too; opened in the same press that closes it, it fails to show on iOS. Other props: `trigger` (ONE pressable element; its own `onPress` still runs first), `placement` ("bottom" default | "top"; it flips at the screen edge), `accessibilityLabel`, `closeAccessibilityLabel`, `onDismiss`, `testID`. A list of actions is `<Menu>`; a form with a title and Save / Cancel is `<Modal>`. Its panel follows the theme (Design > Components > Dropdown menus), and components inside it read a theme inked for that panel. When the request needs what a popover cannot do — a panel that stays open while the user works elsewhere on the page, or one pinned to a spot that is not a pressable control — build your own in the app\'s look.',
|
|
4076
4076
|
rnComponent: null,
|
|
4077
4077
|
docsUrl: null,
|
|
4078
4078
|
},
|
|
@@ -4694,7 +4694,7 @@ const WIDGET_CONTEXT_SHAPE = {
|
|
|
4694
4694
|
},
|
|
4695
4695
|
payments: {
|
|
4696
4696
|
description:
|
|
4697
|
-
"Injected @colixsystems/payments-client instance (REQ-BILL-07-WIDGETPAY). { requestPayment(body) -> Promise<{ id, status }>, getPayment(id) -> Promise<payment>, requestGuestPayment(body) -> Promise<{ id, status }>, getGuestPayment(id) -> Promise<payment>, listAccessPlans() -> Promise<{ data, meta }>, purchaseAccessPlan({ plan_id, return_path? }) -> Promise<{ plan_id, status }>, cancelAccessPlan(planId) -> Promise<{ plan_id, renews, access_ends_at }>, getAppSubscription() -> Promise<{ active, renews, access_ends_at }>, cancelAppSubscription() -> Promise<{ active, renews, access_ends_at }> }; wire is snake_case (amount_cents, return_path, order). Backs usePayments(), useAccessPlans() and useAppSubscription(); requires the payments.charge:appUser scope, and guest checkout (requestGuestPayment, a visitor with no account buying physical goods) also payments.charge:guest. The host opens hosted Checkout itself — same-tab on web, in-app browser on native (or auto-confirms under the mock provider); the charge settles to the workspace owner.",
|
|
4697
|
+
"Injected @colixsystems/payments-client instance (REQ-BILL-07-WIDGETPAY). { requestPayment(body) -> Promise<{ id, status }>, getPayment(id) -> Promise<payment>, requestGuestPayment(body) -> Promise<{ id, status }>, getGuestPayment(id) -> Promise<payment>, listAccessPlans() -> Promise<{ data, meta }>, purchaseAccessPlan({ plan_id, return_path? }) -> Promise<{ plan_id, status }>, cancelAccessPlan(planId) -> Promise<{ plan_id, renews, access_ends_at }>, getAppSubscription() -> Promise<{ active, renews, access_ends_at, member_since }>, cancelAppSubscription() -> Promise<{ active, renews, access_ends_at, member_since }> }; wire is snake_case (amount_cents, return_path, order). Backs usePayments(), useAccessPlans() and useAppSubscription(); requires the payments.charge:appUser scope, and guest checkout (requestGuestPayment, a visitor with no account buying physical goods) also payments.charge:guest. The host opens hosted Checkout itself — same-tab on web, in-app browser on native (or auto-confirms under the mock provider); the charge settles to the workspace owner.",
|
|
4698
4698
|
required: true,
|
|
4699
4699
|
fields: {
|
|
4700
4700
|
requestPayment: "function",
|
|
@@ -7148,7 +7148,13 @@ const CONTRACT = deepFreeze({
|
|
|
7148
7148
|
// locale (date-fns format(d, "dd/MM/yyyy"), toLocaleDateString("en-GB"),
|
|
7149
7149
|
// a hand-built getDate()/getMonth() string) is the `date-shown-fixed-format`
|
|
7150
7150
|
// warning; the widget agent's publish gate blocks on it.
|
|
7151
|
-
|
|
7151
|
+
// 1.282.0: additive (sc-18485) — useAccessPlans() plans and
|
|
7152
|
+
// useAppSubscription() subscription carry member_since, the member's start
|
|
7153
|
+
// date: first paid charge, else when access was granted (null when not held).
|
|
7154
|
+
// 1.283.0: additive (sc-17852) — `<Popover onDismiss>` and the children's
|
|
7155
|
+
// `close(then)` run once the closed popover has left the screen, so a
|
|
7156
|
+
// dialog it opens presents on iOS.
|
|
7157
|
+
version: "1.283.0",
|
|
7152
7158
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
7153
7159
|
hooks: HOOKS,
|
|
7154
7160
|
primitives: PRIMITIVES,
|