@shipengine/elements 1.3.0 → 1.3.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.
@@ -382,6 +382,10 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
382
382
  weightGroup: string;
383
383
  today: string;
384
384
  };
385
+ /**
386
+ * `onBeforeLabelCreate` is an async/sync callback function that will be invoked before every
387
+ * label purchase.
388
+ */
385
389
  hints: {
386
390
  contentDescription: string;
387
391
  };
@@ -407,7 +411,10 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
407
411
  };
408
412
  requirements: {
409
413
  noWarehouse: string;
410
- noCarrier: string;
414
+ noCarrier: string; /**
415
+ * `onLoad` is an async/sync callback provided by the host application that is invoked after the
416
+ * element is loaded. (This may be useful to grab the shipmentId of a one-off label)
417
+ */
411
418
  noWarehouseOrCarrier: string;
412
419
  };
413
420
  shipToAddressFormFields: string;
@@ -441,6 +448,14 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
441
448
  fundingAndCarrierConnection: string;
442
449
  };
443
450
  warehouse: {
451
+ /**
452
+ * # Purchase Label Component Props
453
+ *
454
+ * These are the shared props that will be passed into the `<PurchaseLabel.Element />`, and work
455
+ * for either shipment-based or sales order-based label purchasing.
456
+ *
457
+ * @see {@link PurchaseLabel.Element | This prop types usage in `<PurchaseLabel.Element />`}
458
+ */
444
459
  title: string;
445
460
  subtitle: string;
446
461
  inlineMessage: string;
@@ -449,7 +464,9 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
449
464
  title: string;
450
465
  subtitle: string;
451
466
  action: string;
452
- };
467
+ }; /**
468
+ * `features` is a set of feature flags you would like to enable or disable in this component.
469
+ */
453
470
  termsAndAgreementLinkText: {
454
471
  aHR0cHM6Ly9teWRobC5leHByZXNzLmRobC91cy9lbi9sZWdhbC90ZXJtcy1hbmQtY29uZGl0aW9ucy5odG1s: string;
455
472
  "aHR0cHM6Ly93d3cuc3RhbXBzLmNvbS9wcml2YWN5LXBvbGljeQ==": string;
@@ -552,6 +569,14 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
552
569
  minimumPurchaseAmount: string;
553
570
  other: string;
554
571
  };
572
+ /**
573
+ *`getPreferredRates is an async/sync optional callback function that will be invoked each time rates are caculated.
574
+ * This is an optional callback function that returns an array of ShipEngine rates. The rates from this response will
575
+ * be spliced into the normal get rates response the Elements makes internally. If a service code matches a service
576
+ * code on a rate returned from getPreferredRates, the rate returned from getPreferredRates will not be shown in the
577
+ * rate form. These preferred rates will be displayed with a set of UI enhancements that incude a dynamic cost savings
578
+ * flag and green checkmark when the rate is selected.
579
+ */
555
580
  fundAndPurchase: {
556
581
  finalBalance: string;
557
582
  insufficientFunds: string;
@@ -565,11 +590,6 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
565
590
  unableToFindBalance: string;
566
591
  };
567
592
  currentBalance: string;
568
- /**
569
- * `onAddressValidation` is an async/sync callback function that will be invoked on each Address
570
- * validation request. For example, whenever you update the `Ship To Address` or
571
- * `Ship From Address` for a given shipment.
572
- */
573
593
  maximumBalanceAmount: string;
574
594
  };
575
595
  "list-carriers": {
@@ -632,7 +652,14 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
632
652
  confirm: string;
633
653
  addressNotValidated: string;
634
654
  modified: string;
635
- title: string;
655
+ title: string; /**
656
+ *`getPreferredRates is an async/sync optional callback function that will be invoked each time rates are caculated.
657
+ * This is an optional callback function that returns an array of ShipEngine rates. The rates from this response will
658
+ * be spliced into the normal get rates response the Elements makes internally. If a service code matches a service
659
+ * code on a rate returned from getPreferredRates, the rate returned from getPreferredRates will not be shown in the
660
+ * rate form. These preferred rates will be displayed with a set of UI enhancements that incude a dynamic cost savings
661
+ * flag and green checkmark when the rate is selected.
662
+ */
636
663
  originalAddress: string;
637
664
  matchedAddress: string;
638
665
  unableToValidate: string;
@@ -680,13 +707,13 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
680
707
  adultSignature: string;
681
708
  delivery: string;
682
709
  deliveryMailed: string;
710
+ directSignature: string;
711
+ none: string;
712
+ signature: string;
683
713
  /**
684
714
  * `onChangeShipmentFormMode` is an async/sync callback function that will be invoked each time
685
715
  * the user toggles the `Shipment Form Mode` between `Browse Rates` and `Selected Rate`.
686
716
  */
687
- directSignature: string;
688
- none: string;
689
- signature: string;
690
717
  verbalConfirmation: string;
691
718
  };
692
719
  customs: {
@@ -826,44 +853,6 @@ export declare const Element: ({ resources, ...props }: ElementProps & {
826
853
  tooManyCharacters: string;
827
854
  };
828
855
  shippingPresets: {
829
- /**
830
- * # Registered Purchase Label Element
831
- *
832
- * @param ElementProps The props necessary to render the `<PurchaseLabel.Element />` for shipment
833
- * based or sales order based label purchasing.
834
- *
835
- * @example
836
- * The `<Component />` is the source JSX that is rendered when you make use of the `PurchaseLabel`
837
- * Element directly.
838
- * ```tsx
839
- * <PurchaseLabel.Element
840
- * key={currentSalesOrderId}
841
- * printLabelLayout='4x6'
842
- * shippingPresets={presets}
843
- * onShipmentUpdated={(shipment) => console.log('Shipment Updated', shipment)}
844
- * onRateSaved={(
845
- * shipment: SE.SalesOrderShipment,
846
- * rate?: SE.Rate,
847
- * rateOptions?: SE.Rate[]
848
- * ) => console.log('Rate Saved', shipment, rate, rateOptions)}
849
- * onRatesCalculated={() => console.log('Rates Calculated')}
850
- * onBeforeLabelCreate={onBeforeLabelPurchase}
851
- * onLabelCreateSuccess={onLabelPurchaseSuccess}
852
- * onLabelCreateFailure={(rate) => console.log('Label Purchase Failed', rate)}
853
- * warehouseId={defaultWarehouseId}
854
- * />
855
- * ```
856
- *
857
- * <br />
858
- *
859
- * - Once a label has been purchased using this Element, you can take the `shipmentId` for the
860
- * associated shipment and pass it into the `<ViewShipment.Element />` Element in order to view
861
- * the shipment details.
862
- *
863
- * @see {@link PurchaseLabel.PurchaseLabelCommonProps | The **Common props** used in `<PurchaseLabel.Element />`}
864
- *
865
- * @see {@link ViewShipment.Element | The next step in the label purchase workflow `<ViewShipment.Element />`}
866
- */
867
856
  apply: string;
868
857
  platform: string;
869
858
  user: string;
@@ -1,11 +1,35 @@
1
1
  /**
2
2
  * @internal
3
3
  *
4
- * # Date Utils - getDaysInMonth
4
+ * # Date Utils - Formats a date to the current locale
5
5
  *
6
6
  * @category Utilities
7
7
  */
8
8
  export declare const formatDate: (date: string, locale?: string) => string;
9
+ /**
10
+ * @internal
11
+ * Get the locale data for a given locale string.
12
+ * @param locale string i.e. "en-US"
13
+ * @returns locale data
14
+ */
15
+ export declare const findDateLocale: (locale?: string) => Locale;
16
+ /**
17
+ * @internal
18
+ * Given a date and a locale, format the date to the locale's date format.
19
+ * @param date
20
+ * @param locale string i.e. "en-US"
21
+ * @param dateFormat string. See https://date-fns.org/v3.3.1/docs/format
22
+ * @returns formatted date string
23
+ */
24
+ export declare const formatByDateAndLocale: (date: Date, locale?: string, dateFormat?: string) => string;
25
+ /**
26
+ * @internal
27
+ * Parse a string in the CURRENT locale into a Date object.
28
+ * @param date string
29
+ * @param locale
30
+ * @returns date
31
+ */
32
+ export declare const parseLocaleDate: (date: string, locale?: string, dateFormat?: string) => Date;
9
33
  /**
10
34
  * @internal
11
35
  *
@@ -17,7 +41,24 @@ export declare const formatDateDDMMYY: (date: string, locale?: string) => string
17
41
  /**
18
42
  * @internal
19
43
  *
20
- * # Date Utils - getDaysInMonth
44
+ * # Date Utils - formatDateDDMMYYYY
45
+ *
46
+ * @category Utilities
47
+ */
48
+ export declare const formatDateDDMMYYYY: (date: string, locale?: string) => string;
49
+ /**
50
+ * @internal
51
+ *
52
+ * Get the date format in the current locale i.e., "MM/DD/YYYY"
53
+ *
54
+ * @category Utilities
55
+ * @returns Date format as string
56
+ */
57
+ export declare const getlocaleDateStringFormat: (locale?: string) => string;
58
+ /**
59
+ * @internal
60
+ *
61
+ * # Date Utils - Get the date a number of days after a given date
21
62
  *
22
63
  * @category Utilities
23
64
  */
@@ -25,7 +66,7 @@ export declare const daysAfter: (days: number, date?: Date) => Date;
25
66
  /**
26
67
  * @internal
27
68
  *
28
- * # Date Utils - getDaysInMonth
69
+ * # Date Utils - Get a cutoff date for a given date or the current date
29
70
  *
30
71
  * @category Utilities
31
72
  */
@@ -33,7 +74,7 @@ export declare const nextDayCutoff: (cutoff: number, date?: Date) => Date;
33
74
  /**
34
75
  * @internal
35
76
  *
36
- * # Date Utils - getDaysInMonth
77
+ * # Date Utils - get the most recent date from a list of dates
37
78
  *
38
79
  * @category Utilities
39
80
  */
@@ -41,7 +82,7 @@ export declare const mostRecent: (...dates: Date[]) => Date;
41
82
  /**
42
83
  * @internal
43
84
  *
44
- * # Date Utils - getDaysInMonth
85
+ * # Date Utils - Given a date, return a new date with the time set to 00:00:00
45
86
  *
46
87
  * @category Utilities
47
88
  */
@@ -1,16 +0,0 @@
1
- export declare const LOCALE: string;
2
- /**
3
- * Parse a string in the CURRENT locale into a Date object.
4
- * current locale is determined by navigator.language for now
5
- * @param dateString
6
- */
7
- export declare const parseLocaleDate: (dateString: string | null) => Date | null;
8
- export declare const parseUSADate: (dateString: string) => Date | null;
9
- /**
10
- *
11
- * Format a date into a string in the CURRENT locale.
12
- * current locale is determined by navigator.language for now
13
- * @param date
14
- */
15
- export declare const formatLocaleDate: (date: Date | null) => string | null;
16
- export declare const formatUSADate: (date: Date | null) => string | null;