@bunnyapp/components 1.6.0-beta.14 → 1.6.0-beta.16
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 +42 -0
- package/dist/cjs/index.js +2521 -2191
- package/dist/cjs/types/src/components/BunnyProvider.d.ts +0 -2
- package/dist/cjs/types/src/components/Checkout/Checkout.d.ts +1 -1
- package/dist/cjs/types/src/components/Checkout/QuoteCheckout.d.ts +4 -4
- package/dist/cjs/types/src/components/QuoteProvider/fragments/quoteFieldsFragment.d.ts +65 -0
- package/dist/cjs/types/src/components/QuoteProvider/fragments/quoteFragment.d.ts +16 -112
- package/dist/cjs/types/src/components/QuoteProvider/hooks/useFeatureQuantities.d.ts +12 -0
- package/dist/cjs/types/src/components/QuoteProvider/hooks/useQuoteQuantities.d.ts +0 -5
- package/dist/cjs/types/src/components/QuoteProvider/mutations/quoteChangeUpdate.d.ts +16 -0
- package/dist/cjs/types/src/components/QuoteProvider/utils/getQuantityFromQuoteChange.d.ts +11 -0
- package/dist/cjs/types/src/components/QuoteProvider/utils/quoteChangeCanBeEdited.d.ts +4 -0
- package/dist/cjs/types/src/components/Subscriptions/Subscriptions.d.ts +1 -5
- package/dist/cjs/types/src/components/Subscriptions/SubscriptionsListContainer.d.ts +0 -4
- package/dist/cjs/types/src/components/Subscriptions/Upgrade/PlanPicker/PlanPicker.d.ts +1 -2
- package/dist/cjs/types/src/components/Subscriptions/Upgrade/PlanPicker/checkoutBar/PlanPickerCheckoutBar.d.ts +19 -0
- package/dist/cjs/types/src/components/Subscriptions/Upgrade/PlanPicker/planPickerDesktop/planManagerUtils.d.ts +5 -2
- package/dist/cjs/types/src/components/Subscriptions/quantityChangeDrawer/QuantityChangeGridRow.d.ts +1 -5
- package/dist/cjs/types/src/components/Subscriptions/quantityChangeDrawer/QuantityDrawer.d.ts +1 -4
- package/dist/cjs/types/src/components/Subscriptions/quantityChangeDrawer/QuoteChangeSummarySection.d.ts +11 -6
- package/dist/cjs/types/src/components/Subscriptions/quantityChangeDrawer/context/quoteIdContext.d.ts +5 -0
- package/dist/{esm/types/src/components/Subscriptions/quantityChangeDrawer/fragments/QuantityDrawerQuoteFragment.d.ts → cjs/types/src/components/Subscriptions/quantityChangeDrawer/fragments/QuantityDrawer_QuoteFragment.d.ts} +4 -0
- package/dist/cjs/types/src/components/Subscriptions/quantityChangeDrawer/hooks/useQuoteQueryData.d.ts +3 -3
- package/dist/cjs/types/src/components/Subscriptions/quantityChangeDrawer/hooks/useSetQuoteQueryData.d.ts +2 -2
- package/dist/cjs/types/src/components/Subscriptions/quantityChangeDrawer/quantityChangeDrawerDesktop/QuantityChangeDrawerDesktop.d.ts +1 -6
- package/dist/{esm/types/src/components/Subscriptions/quantityChangeDrawer → cjs/types/src/components/Subscriptions/quantityChangeDrawer/quantityInput}/QuantityInput.d.ts +2 -9
- package/dist/cjs/types/src/components/Subscriptions/quantityChangeDrawer/quantityInput/fragments/QuantityInput_QuoteFragment.d.ts +27 -0
- package/dist/cjs/types/src/components/Subscriptions/quantityChangeDrawer/utils/utils.d.ts +3 -2
- package/dist/cjs/types/src/components/Subscriptions/subscriptionsList/SubscriptionChargeTotal.d.ts +3 -3
- package/dist/cjs/types/src/components/Subscriptions/subscriptionsList/subscriptionCardHeader/components/SubscriptionCardActions.d.ts +21 -0
- package/dist/cjs/types/src/components/Subscriptions/subscriptionsList/subscriptionCardHeader/queries/getPriceListChangeOptions.d.ts +9 -0
- package/dist/cjs/types/src/components/Subscriptions/subscriptionsList/utils/filterSubscriptionCharges.d.ts +2 -0
- package/dist/cjs/types/src/components/Subscriptions/subscriptionsList/utils/sortSubscriptionCharges.d.ts +2 -0
- package/dist/cjs/types/src/graphql/queries/getPriceListChangeOptions.d.ts +3 -4
- package/dist/cjs/types/src/hooks/useAllErrorFormats.d.ts +1 -0
- package/dist/cjs/types/src/hooks/useCreateQueryClient.d.ts +2 -0
- package/dist/cjs/types/src/types/SubscriptionCharge.d.ts +39 -0
- package/dist/cjs/types/src/utils/QueryKeyFactory.d.ts +91 -0
- package/dist/cjs/types/src/utils/chargeUtils.d.ts +5 -2
- package/dist/cjs/types/src/utils/createStateContext.d.ts +11 -0
- package/dist/cjs/types/src/utils/pricePickerUtils.d.ts +1 -1
- package/dist/esm/index.js +2564 -2234
- package/dist/esm/types/src/components/BunnyProvider.d.ts +0 -2
- package/dist/esm/types/src/components/Checkout/Checkout.d.ts +1 -1
- package/dist/esm/types/src/components/Checkout/QuoteCheckout.d.ts +4 -4
- package/dist/esm/types/src/components/QuoteProvider/fragments/quoteFieldsFragment.d.ts +65 -0
- package/dist/esm/types/src/components/QuoteProvider/fragments/quoteFragment.d.ts +16 -112
- package/dist/esm/types/src/components/QuoteProvider/hooks/useFeatureQuantities.d.ts +12 -0
- package/dist/esm/types/src/components/QuoteProvider/hooks/useQuoteQuantities.d.ts +0 -5
- package/dist/esm/types/src/components/QuoteProvider/mutations/quoteChangeUpdate.d.ts +16 -0
- package/dist/esm/types/src/components/QuoteProvider/utils/getQuantityFromQuoteChange.d.ts +11 -0
- package/dist/esm/types/src/components/QuoteProvider/utils/quoteChangeCanBeEdited.d.ts +4 -0
- package/dist/esm/types/src/components/Subscriptions/Subscriptions.d.ts +1 -5
- package/dist/esm/types/src/components/Subscriptions/SubscriptionsListContainer.d.ts +0 -4
- package/dist/esm/types/src/components/Subscriptions/Upgrade/PlanPicker/PlanPicker.d.ts +1 -2
- package/dist/esm/types/src/components/Subscriptions/Upgrade/PlanPicker/checkoutBar/PlanPickerCheckoutBar.d.ts +19 -0
- package/dist/esm/types/src/components/Subscriptions/Upgrade/PlanPicker/planPickerDesktop/planManagerUtils.d.ts +5 -2
- package/dist/esm/types/src/components/Subscriptions/quantityChangeDrawer/QuantityChangeGridRow.d.ts +1 -5
- package/dist/esm/types/src/components/Subscriptions/quantityChangeDrawer/QuantityDrawer.d.ts +1 -4
- package/dist/esm/types/src/components/Subscriptions/quantityChangeDrawer/QuoteChangeSummarySection.d.ts +11 -6
- package/dist/esm/types/src/components/Subscriptions/quantityChangeDrawer/context/quoteIdContext.d.ts +5 -0
- package/dist/{cjs/types/src/components/Subscriptions/quantityChangeDrawer/fragments/QuantityDrawerQuoteFragment.d.ts → esm/types/src/components/Subscriptions/quantityChangeDrawer/fragments/QuantityDrawer_QuoteFragment.d.ts} +4 -0
- package/dist/esm/types/src/components/Subscriptions/quantityChangeDrawer/hooks/useQuoteQueryData.d.ts +3 -3
- package/dist/esm/types/src/components/Subscriptions/quantityChangeDrawer/hooks/useSetQuoteQueryData.d.ts +2 -2
- package/dist/esm/types/src/components/Subscriptions/quantityChangeDrawer/quantityChangeDrawerDesktop/QuantityChangeDrawerDesktop.d.ts +1 -6
- package/dist/{cjs/types/src/components/Subscriptions/quantityChangeDrawer → esm/types/src/components/Subscriptions/quantityChangeDrawer/quantityInput}/QuantityInput.d.ts +2 -9
- package/dist/esm/types/src/components/Subscriptions/quantityChangeDrawer/quantityInput/fragments/QuantityInput_QuoteFragment.d.ts +27 -0
- package/dist/esm/types/src/components/Subscriptions/quantityChangeDrawer/utils/utils.d.ts +3 -2
- package/dist/esm/types/src/components/Subscriptions/subscriptionsList/SubscriptionChargeTotal.d.ts +3 -3
- package/dist/esm/types/src/components/Subscriptions/subscriptionsList/subscriptionCardHeader/components/SubscriptionCardActions.d.ts +21 -0
- package/dist/esm/types/src/components/Subscriptions/subscriptionsList/subscriptionCardHeader/queries/getPriceListChangeOptions.d.ts +9 -0
- package/dist/esm/types/src/components/Subscriptions/subscriptionsList/utils/filterSubscriptionCharges.d.ts +2 -0
- package/dist/esm/types/src/components/Subscriptions/subscriptionsList/utils/sortSubscriptionCharges.d.ts +2 -0
- package/dist/esm/types/src/graphql/queries/getPriceListChangeOptions.d.ts +3 -4
- package/dist/esm/types/src/hooks/useAllErrorFormats.d.ts +1 -0
- package/dist/esm/types/src/hooks/useCreateQueryClient.d.ts +2 -0
- package/dist/esm/types/src/types/SubscriptionCharge.d.ts +39 -0
- package/dist/esm/types/src/utils/QueryKeyFactory.d.ts +91 -0
- package/dist/esm/types/src/utils/chargeUtils.d.ts +5 -2
- package/dist/esm/types/src/utils/createStateContext.d.ts +11 -0
- package/dist/esm/types/src/utils/pricePickerUtils.d.ts +1 -1
- package/package.json +1 -1
- package/dist/cjs/types/src/components/QuoteProvider/mutations/quoteChargeUpdate.d.ts +0 -23
- package/dist/cjs/types/src/components/Subscriptions/subscriptionsList/SubscriptionCardActions.d.ts +0 -9
- package/dist/cjs/types/src/graphql/queries/getFeatureUsage.d.ts +0 -7
- package/dist/cjs/types/src/hooks/usePriceListChangeOptions.d.ts +0 -9
- package/dist/cjs/types/src/utils/GraphQLClient.d.ts +0 -2
- package/dist/esm/types/src/components/QuoteProvider/mutations/quoteChargeUpdate.d.ts +0 -23
- package/dist/esm/types/src/components/Subscriptions/subscriptionsList/SubscriptionCardActions.d.ts +0 -9
- package/dist/esm/types/src/graphql/queries/getFeatureUsage.d.ts +0 -7
- package/dist/esm/types/src/hooks/usePriceListChangeOptions.d.ts +0 -9
- package/dist/esm/types/src/utils/GraphQLClient.d.ts +0 -2
- /package/dist/cjs/types/src/components/Subscriptions/quantityChangeDrawer/{queries → mutations}/quoteChargeCreate.d.ts +0 -0
- /package/dist/cjs/types/src/components/Subscriptions/quantityChangeDrawer/{queries → mutations}/quoteChargeUpdate.d.ts +0 -0
- /package/dist/cjs/types/src/components/Subscriptions/quantityChangeDrawer/{queries → mutations}/quoteSubscriptionUpdate.d.ts +0 -0
- /package/dist/cjs/types/src/components/Subscriptions/subscriptionsList/{SubscriptionCardHeader.d.ts → subscriptionCardHeader/SubscriptionCardHeader.d.ts} +0 -0
- /package/dist/esm/types/src/components/Subscriptions/quantityChangeDrawer/{queries → mutations}/quoteChargeCreate.d.ts +0 -0
- /package/dist/esm/types/src/components/Subscriptions/quantityChangeDrawer/{queries → mutations}/quoteChargeUpdate.d.ts +0 -0
- /package/dist/esm/types/src/components/Subscriptions/quantityChangeDrawer/{queries → mutations}/quoteSubscriptionUpdate.d.ts +0 -0
- /package/dist/esm/types/src/components/Subscriptions/subscriptionsList/{SubscriptionCardHeader.d.ts → subscriptionCardHeader/SubscriptionCardHeader.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -104,6 +104,48 @@ npm run codegen
|
|
|
104
104
|
npx gql-tada doctor
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
+
### Development best practices
|
|
108
|
+
|
|
109
|
+
**Updating the React Query cache with typed data**
|
|
110
|
+
|
|
111
|
+
Sometimes you want to update the React Query cache directly instead of running another query.
|
|
112
|
+
To keep this safe, you should make sure the data you write into the cache is **strongly typed** and matches what your components expect.
|
|
113
|
+
One simple pattern is to create small hooks that accept a GraphQL fragment, and use that fragment to type the data you store in the cache.
|
|
114
|
+
|
|
115
|
+
Below is a minimal, generic example using a `FruitFragment` and a `useSetFruitQueryData` hook:
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
const FruitFragment = graphql(`
|
|
119
|
+
fragment FruitFragment on Fruit {
|
|
120
|
+
id
|
|
121
|
+
name
|
|
122
|
+
}
|
|
123
|
+
`);
|
|
124
|
+
|
|
125
|
+
export const useSetFruitQueryData = () => {
|
|
126
|
+
const queryClient = useQueryClient();
|
|
127
|
+
|
|
128
|
+
const setFruitQueryData = (
|
|
129
|
+
fruitId: string,
|
|
130
|
+
maskedFruit: FragmentOf<typeof FruitFragment> | null
|
|
131
|
+
) => {
|
|
132
|
+
queryClient.setQueryData(['fruit', fruitId], maskedFruit);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
return { setFruitQueryData };
|
|
136
|
+
};
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Using this hook, the data you write to the cache is constrained by the `FragmentOf<typeof FruitFragment>` type:
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
const { setFruitQueryData } = useSetFruitQueryData();
|
|
143
|
+
|
|
144
|
+
setFruitQueryData('123', { id: '123', name: 'Apple' });
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
For a more complete example in the codebase, see the `useSetQuoteQueryData` hook in the `quantityChangeDrawer` module.
|
|
148
|
+
|
|
107
149
|
### Deprecating @bunnyapp/common
|
|
108
150
|
|
|
109
151
|
We are gradually deprecating `@bunnyapp/common` and moving types and enums locally to this repository. When something is moved from `@bunnyapp/common`, follow this pattern:
|