@diagonal-hq/pages 0.6.0 → 0.6.2
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/dist/index.d.ts +39 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4556,6 +4556,11 @@ export type SdkDisplayFormatOptions = {
|
|
|
4556
4556
|
durationUnit?: 'milliseconds' | 'seconds' | 'minutes' | 'hours';
|
|
4557
4557
|
};
|
|
4558
4558
|
|
|
4559
|
+
export type SdkDisplayPriceOptions = {
|
|
4560
|
+
/** Use a short suffix or a long billing phrase. Defaults to `short`. */
|
|
4561
|
+
style?: 'short' | 'long';
|
|
4562
|
+
};
|
|
4563
|
+
|
|
4559
4564
|
export type SdkRecordInput<TRecord extends ResourceRecord = ResourceRecord> =
|
|
4560
4565
|
| TRecord
|
|
4561
4566
|
| { fields?: TRecord | null }
|
|
@@ -4599,6 +4604,29 @@ export type SdkDisplayUtils = {
|
|
|
4599
4604
|
options?: SdkDisplayFormatOptions
|
|
4600
4605
|
) => string | null;
|
|
4601
4606
|
|
|
4607
|
+
/**
|
|
4608
|
+
* Format money with its billing recurrence for string contexts such as template
|
|
4609
|
+
* literals and `<option>` labels. Pass the recurrence select field handle so an
|
|
4610
|
+
* unknown value can use its option label, or its raw value if no label exists.
|
|
4611
|
+
* Uses the existing money formatter. The default style is `short`.
|
|
4612
|
+
* `one_time`, nullish, and empty recurrence values return the amount alone.
|
|
4613
|
+
* Invalid money, malformed fields, and invalid styles return `null` and report
|
|
4614
|
+
* the standard SDK diagnostic.
|
|
4615
|
+
*
|
|
4616
|
+
* @example
|
|
4617
|
+
* const recurrence = prices.fields.recurrence;
|
|
4618
|
+
* const amount = { amount: 5000, currency: 'USD' };
|
|
4619
|
+
* Sdk.utils.display.price(recurrence, 'monthly', amount); // '$50.00/mo'
|
|
4620
|
+
* Sdk.utils.display.price(recurrence, 'monthly', amount, { style: 'long' }); // '$50.00 per month'
|
|
4621
|
+
* Sdk.utils.display.price(recurrence, 'weekly', amount); // '$50.00 (Weekly)' with an option label
|
|
4622
|
+
*/
|
|
4623
|
+
price: (
|
|
4624
|
+
field: SdkResourceField | null | undefined,
|
|
4625
|
+
recurrence: any,
|
|
4626
|
+
amount: any,
|
|
4627
|
+
options?: SdkDisplayPriceOptions
|
|
4628
|
+
) => string | null;
|
|
4629
|
+
|
|
4602
4630
|
/**
|
|
4603
4631
|
* Build initials from the first `count` whitespace-delimited name parts.
|
|
4604
4632
|
* `count` defaults to `2`. Nullish/blank names or an invalid count return `''`
|
|
@@ -4716,11 +4744,17 @@ export type SdkUtils = Omit<TaskUtils, 'workspace' | 'workflow' | 'tiptap'> & {
|
|
|
4716
4744
|
* @remarks
|
|
4717
4745
|
* `format` delegates date, time, money, number, phone, and location rendering to the
|
|
4718
4746
|
* existing SDK formatters so their current locale and timezone behavior remains consistent.
|
|
4747
|
+
* Use `price` for billing recurrence wording in template literals and `<option>` labels.
|
|
4719
4748
|
* Nullish or malformed values return `null` with the standard SDK diagnostic;
|
|
4720
4749
|
* `fieldValue` returns `null`.
|
|
4721
4750
|
*
|
|
4722
4751
|
* @example
|
|
4723
4752
|
* const status = Sdk.utils.display.format(tasks.fields.status, task.status);
|
|
4753
|
+
* const recurrence = prices.fields.recurrence;
|
|
4754
|
+
* const amount = { amount: 5000, currency: 'USD' };
|
|
4755
|
+
* Sdk.utils.display.price(recurrence, 'monthly', amount); // '$50.00/mo'
|
|
4756
|
+
* Sdk.utils.display.price(recurrence, 'monthly', amount, { style: 'long' }); // '$50.00 per month'
|
|
4757
|
+
* Sdk.utils.display.price(recurrence, 'weekly', amount); // '$50.00 (Weekly)' with an option label
|
|
4724
4758
|
*/
|
|
4725
4759
|
display: SdkDisplayUtils;
|
|
4726
4760
|
};
|
|
@@ -6933,7 +6967,7 @@ export type SdkHooks = {
|
|
|
6933
6967
|
*/
|
|
6934
6968
|
useRecord<
|
|
6935
6969
|
TReference extends SdkResourceQueryReference<'show'>,
|
|
6936
|
-
const TRelations extends readonly SdkReferenceRelationPath<
|
|
6970
|
+
const TRelations extends readonly SdkReferenceRelationPath<TReference>[] = readonly []
|
|
6937
6971
|
>(
|
|
6938
6972
|
resource: TReference,
|
|
6939
6973
|
recordId: string | null | undefined,
|
|
@@ -7024,7 +7058,7 @@ export type SdkHooks = {
|
|
|
7024
7058
|
*/
|
|
7025
7059
|
useRecords<
|
|
7026
7060
|
TReference extends SdkResourceQueryReference<'search'>,
|
|
7027
|
-
const TRelations extends readonly SdkReferenceRelationPath<
|
|
7061
|
+
const TRelations extends readonly SdkReferenceRelationPath<TReference>[] = readonly []
|
|
7028
7062
|
>(
|
|
7029
7063
|
resource: TReference,
|
|
7030
7064
|
options?: SdkUseRecordsOptions<TRelations, NoInfer<SdkReferenceRecord<TReference, TRelations>>>
|
|
@@ -7102,7 +7136,7 @@ export type SdkHooks = {
|
|
|
7102
7136
|
*/
|
|
7103
7137
|
useInfiniteRecords<
|
|
7104
7138
|
TReference extends SdkResourceQueryReference<'search'>,
|
|
7105
|
-
const TRelations extends readonly SdkReferenceRelationPath<
|
|
7139
|
+
const TRelations extends readonly SdkReferenceRelationPath<TReference>[] = readonly []
|
|
7106
7140
|
>(
|
|
7107
7141
|
resource: TReference,
|
|
7108
7142
|
options?: SdkUseInfiniteRecordsOptions<TRelations>
|
|
@@ -15345,6 +15379,8 @@ export declare const workspace: SdkInternal.FilePageSdk["workspace"];
|
|
|
15345
15379
|
|
|
15346
15380
|
export type DisplayFormatOptions = SdkInternal.SdkDisplayFormatOptions;
|
|
15347
15381
|
|
|
15382
|
+
export type DisplayPriceOptions = SdkInternal.SdkDisplayPriceOptions;
|
|
15383
|
+
|
|
15348
15384
|
export type FieldSelector<TKey extends string = string> = SdkInternal.SdkFieldSelector<TKey>;
|
|
15349
15385
|
|
|
15350
15386
|
export type RecordInput<TRecord extends SdkInternal.ResourceRecord = SdkInternal.ResourceRecord> = SdkInternal.SdkRecordInput<TRecord>;
|