@splpi/estore-shared-components 0.0.6 → 7.0.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.mts CHANGED
@@ -70,10 +70,40 @@ interface LifePlanApplication1Props {
70
70
  }
71
71
  declare const LifePlanApplication1: ({ initialData, onUpdate, }: LifePlanApplication1Props) => react_jsx_runtime.JSX.Element;
72
72
 
73
+ interface IOcrValue {
74
+ firstName?: string;
75
+ middleName?: string;
76
+ lastName?: string;
77
+ birthDate?: string;
78
+ idType?: string;
79
+ idNumber?: string;
80
+ addressLine?: string;
81
+ }
82
+ /** Shape returned by the host app's address parser (e.g. GeoApifyService.parseAddress). */
83
+ interface IParsedAddress {
84
+ lot: string;
85
+ street: string;
86
+ barangay: string;
87
+ district: string;
88
+ city: string;
89
+ province: string;
90
+ zipCode: string;
91
+ barangayCandidates: string[];
92
+ districtCandidates: string[];
93
+ cityCandidates: string[];
94
+ provinceCandidates: string[];
95
+ geoapifyUsed: boolean;
96
+ }
97
+
73
98
  interface LifePlanApplication2Props {
74
99
  onAddressUpdate?: (address: IAddress) => void;
100
+ /**
101
+ * Optional address parser from the host app (e.g. GeoApifyService.parseAddress).
102
+ * When provided, the scanned ID address (OCR) is split into the form fields.
103
+ */
104
+ parseAddress?: (addressLine: string) => Promise<IParsedAddress>;
75
105
  }
76
- declare const LifePlanApplication2: ({ onAddressUpdate, }: LifePlanApplication2Props) => react_jsx_runtime.JSX.Element;
106
+ declare const LifePlanApplication2: ({ onAddressUpdate, parseAddress, }: LifePlanApplication2Props) => react_jsx_runtime.JSX.Element;
77
107
 
78
108
  interface LifePlanApplication3Props {
79
109
  initialData?: IEmployment;
@@ -88,20 +118,58 @@ declare const Beneficiary: ({ onUpdate }: BeneficiaryProps) => react_jsx_runtime
88
118
 
89
119
  declare const HealthDeclaration: () => react_jsx_runtime.JSX.Element;
90
120
 
91
- declare const LifePlanApplicationFormWrapper: ({ openSection, openSectionKey, onValidChange, }: {
121
+ declare const LifePlanApplicationFormWrapper: ({ openSection, openSectionKey, onValidChange, parseAddress, }: {
92
122
  openSection?: string;
93
123
  openSectionKey?: number;
94
124
  onValidChange?: (valid: boolean) => void;
125
+ parseAddress?: (addressLine: string) => Promise<IParsedAddress>;
95
126
  }) => react_jsx_runtime.JSX.Element;
96
127
 
97
- declare const LifePlanApplicationStepWrapper: () => react_jsx_runtime.JSX.Element;
128
+ interface CartItem {
129
+ planDesc: string;
130
+ mode: string;
131
+ planTerm: string;
132
+ quantity: number;
133
+ price: number;
134
+ total: number;
135
+ contractPrice: number;
136
+ ipInstAmt?: number;
137
+ balance?: number;
138
+ }
98
139
 
140
+ type NewSalesCheckoutItem = {
141
+ planDesc: CartItem["planDesc"];
142
+ mode: CartItem["mode"];
143
+ ipInstAmt: number;
144
+ planTerm: CartItem["planTerm"];
145
+ quantity: number;
146
+ };
147
+ type NewSalesCheckoutRequest = {
148
+ items: NewSalesCheckoutItem[];
149
+ application: IApplicationData;
150
+ };
99
151
  type SharedLifePlanApplicationProps = {
100
152
  title?: string;
101
153
  description?: string;
102
154
  onPaymentError?: (error: unknown) => void;
155
+ /**
156
+ * Called on the payment step with the cart items and application data.
157
+ * Must return the checkout URL (e.g. from PayMongoService.createNewSalesCheckout).
158
+ */
159
+ onCheckout?: (request: NewSalesCheckoutRequest) => Promise<string | undefined>;
160
+ /** Optional address parser used to fill the address form from the scanned ID. */
161
+ parseAddress?: (addressLine: string) => Promise<IParsedAddress>;
103
162
  };
104
- declare const SharedLifePlanApplication: ({ title, description, onPaymentError, }: SharedLifePlanApplicationProps) => react_jsx_runtime.JSX.Element;
163
+ declare const SharedLifePlanApplication: ({ title, description, onPaymentError, onCheckout, parseAddress, }: SharedLifePlanApplicationProps) => react_jsx_runtime.JSX.Element;
164
+
165
+ declare const LifePlanApplicationStepWrapper: (props: SharedLifePlanApplicationProps) => react_jsx_runtime.JSX.Element;
166
+
167
+ declare const OCR_STORAGE_KEY = "ocrResult";
168
+ type OcrSection = "personal" | "address";
169
+ /** Returns the saved OCR result if it has not been applied to this section yet. */
170
+ declare const readOcrResult: (section: OcrSection) => IOcrValue | null;
171
+ /** Marks the OCR result as used for this section. Returns true the first time only. */
172
+ declare const markOcrApplied: (section: OcrSection) => boolean;
105
173
 
106
174
  type QuickAction = {
107
175
  /** React Icons icon component */
@@ -185,20 +253,8 @@ interface ReusableProfileProps {
185
253
  }
186
254
  declare function ReusableProfile({ user, colorMode: controlledColorMode, onColorModeChange, initialTwoFactorEnabled, initialQuickNavHrefs, availableNavOptions, maxQuickNavItems, enableLocalStorage, storageKey, onSaveAccount, onChangePassword, onSignOut, onTwoFactorChange, onToast, }: ReusableProfileProps): react_jsx_runtime.JSX.Element;
187
255
 
188
- interface CartItem {
189
- planDesc: string;
190
- mode: string;
191
- planTerm: string;
192
- quantity: number;
193
- price: number;
194
- total: number;
195
- contractPrice: number;
196
- ipInstAmt?: number;
197
- balance?: number;
198
- }
199
-
200
256
  declare const createEmptyApplicationData: () => IApplicationData;
201
257
  declare const loadApplicationDataFromLocalStorage: (storageKey?: string) => IApplicationData | null;
202
258
  declare const saveApplicationDataToLocalStorage: (data: IApplicationData, storageKey?: string) => void;
203
259
 
204
- export { Beneficiary, type BeneficiaryClass, BottomQuickActions, type CartItem, HealthDeclaration, type IAddress, type IApplicationData, type IBeneficiary, type IEmployment, type IHealthDeclaration, type IPersonalInfo, type ITransactionData, LifePlanApplication1, LifePlanApplication2, LifePlanApplication3, LifePlanApplicationFormWrapper, LifePlanApplicationStepWrapper, type NavOptionDef, NotifyInstall, type ProfileUser, type ReusableProfileProps, SharedLifePlanApplication, ReusableProfile as UserProfile, createEmptyApplicationData, loadApplicationDataFromLocalStorage, saveApplicationDataToLocalStorage };
260
+ export { Beneficiary, type BeneficiaryClass, BottomQuickActions, type CartItem, HealthDeclaration, type IAddress, type IApplicationData, type IBeneficiary, type IEmployment, type IHealthDeclaration, type IOcrValue, type IParsedAddress, type IPersonalInfo, type ITransactionData, LifePlanApplication1, LifePlanApplication2, LifePlanApplication3, LifePlanApplicationFormWrapper, LifePlanApplicationStepWrapper, type NavOptionDef, type NewSalesCheckoutItem, type NewSalesCheckoutRequest, NotifyInstall, OCR_STORAGE_KEY, type OcrSection, type ProfileUser, type ReusableProfileProps, SharedLifePlanApplication, type SharedLifePlanApplicationProps, ReusableProfile as UserProfile, createEmptyApplicationData, loadApplicationDataFromLocalStorage, markOcrApplied, readOcrResult, saveApplicationDataToLocalStorage };
package/dist/index.d.ts CHANGED
@@ -70,10 +70,40 @@ interface LifePlanApplication1Props {
70
70
  }
71
71
  declare const LifePlanApplication1: ({ initialData, onUpdate, }: LifePlanApplication1Props) => react_jsx_runtime.JSX.Element;
72
72
 
73
+ interface IOcrValue {
74
+ firstName?: string;
75
+ middleName?: string;
76
+ lastName?: string;
77
+ birthDate?: string;
78
+ idType?: string;
79
+ idNumber?: string;
80
+ addressLine?: string;
81
+ }
82
+ /** Shape returned by the host app's address parser (e.g. GeoApifyService.parseAddress). */
83
+ interface IParsedAddress {
84
+ lot: string;
85
+ street: string;
86
+ barangay: string;
87
+ district: string;
88
+ city: string;
89
+ province: string;
90
+ zipCode: string;
91
+ barangayCandidates: string[];
92
+ districtCandidates: string[];
93
+ cityCandidates: string[];
94
+ provinceCandidates: string[];
95
+ geoapifyUsed: boolean;
96
+ }
97
+
73
98
  interface LifePlanApplication2Props {
74
99
  onAddressUpdate?: (address: IAddress) => void;
100
+ /**
101
+ * Optional address parser from the host app (e.g. GeoApifyService.parseAddress).
102
+ * When provided, the scanned ID address (OCR) is split into the form fields.
103
+ */
104
+ parseAddress?: (addressLine: string) => Promise<IParsedAddress>;
75
105
  }
76
- declare const LifePlanApplication2: ({ onAddressUpdate, }: LifePlanApplication2Props) => react_jsx_runtime.JSX.Element;
106
+ declare const LifePlanApplication2: ({ onAddressUpdate, parseAddress, }: LifePlanApplication2Props) => react_jsx_runtime.JSX.Element;
77
107
 
78
108
  interface LifePlanApplication3Props {
79
109
  initialData?: IEmployment;
@@ -88,20 +118,58 @@ declare const Beneficiary: ({ onUpdate }: BeneficiaryProps) => react_jsx_runtime
88
118
 
89
119
  declare const HealthDeclaration: () => react_jsx_runtime.JSX.Element;
90
120
 
91
- declare const LifePlanApplicationFormWrapper: ({ openSection, openSectionKey, onValidChange, }: {
121
+ declare const LifePlanApplicationFormWrapper: ({ openSection, openSectionKey, onValidChange, parseAddress, }: {
92
122
  openSection?: string;
93
123
  openSectionKey?: number;
94
124
  onValidChange?: (valid: boolean) => void;
125
+ parseAddress?: (addressLine: string) => Promise<IParsedAddress>;
95
126
  }) => react_jsx_runtime.JSX.Element;
96
127
 
97
- declare const LifePlanApplicationStepWrapper: () => react_jsx_runtime.JSX.Element;
128
+ interface CartItem {
129
+ planDesc: string;
130
+ mode: string;
131
+ planTerm: string;
132
+ quantity: number;
133
+ price: number;
134
+ total: number;
135
+ contractPrice: number;
136
+ ipInstAmt?: number;
137
+ balance?: number;
138
+ }
98
139
 
140
+ type NewSalesCheckoutItem = {
141
+ planDesc: CartItem["planDesc"];
142
+ mode: CartItem["mode"];
143
+ ipInstAmt: number;
144
+ planTerm: CartItem["planTerm"];
145
+ quantity: number;
146
+ };
147
+ type NewSalesCheckoutRequest = {
148
+ items: NewSalesCheckoutItem[];
149
+ application: IApplicationData;
150
+ };
99
151
  type SharedLifePlanApplicationProps = {
100
152
  title?: string;
101
153
  description?: string;
102
154
  onPaymentError?: (error: unknown) => void;
155
+ /**
156
+ * Called on the payment step with the cart items and application data.
157
+ * Must return the checkout URL (e.g. from PayMongoService.createNewSalesCheckout).
158
+ */
159
+ onCheckout?: (request: NewSalesCheckoutRequest) => Promise<string | undefined>;
160
+ /** Optional address parser used to fill the address form from the scanned ID. */
161
+ parseAddress?: (addressLine: string) => Promise<IParsedAddress>;
103
162
  };
104
- declare const SharedLifePlanApplication: ({ title, description, onPaymentError, }: SharedLifePlanApplicationProps) => react_jsx_runtime.JSX.Element;
163
+ declare const SharedLifePlanApplication: ({ title, description, onPaymentError, onCheckout, parseAddress, }: SharedLifePlanApplicationProps) => react_jsx_runtime.JSX.Element;
164
+
165
+ declare const LifePlanApplicationStepWrapper: (props: SharedLifePlanApplicationProps) => react_jsx_runtime.JSX.Element;
166
+
167
+ declare const OCR_STORAGE_KEY = "ocrResult";
168
+ type OcrSection = "personal" | "address";
169
+ /** Returns the saved OCR result if it has not been applied to this section yet. */
170
+ declare const readOcrResult: (section: OcrSection) => IOcrValue | null;
171
+ /** Marks the OCR result as used for this section. Returns true the first time only. */
172
+ declare const markOcrApplied: (section: OcrSection) => boolean;
105
173
 
106
174
  type QuickAction = {
107
175
  /** React Icons icon component */
@@ -185,20 +253,8 @@ interface ReusableProfileProps {
185
253
  }
186
254
  declare function ReusableProfile({ user, colorMode: controlledColorMode, onColorModeChange, initialTwoFactorEnabled, initialQuickNavHrefs, availableNavOptions, maxQuickNavItems, enableLocalStorage, storageKey, onSaveAccount, onChangePassword, onSignOut, onTwoFactorChange, onToast, }: ReusableProfileProps): react_jsx_runtime.JSX.Element;
187
255
 
188
- interface CartItem {
189
- planDesc: string;
190
- mode: string;
191
- planTerm: string;
192
- quantity: number;
193
- price: number;
194
- total: number;
195
- contractPrice: number;
196
- ipInstAmt?: number;
197
- balance?: number;
198
- }
199
-
200
256
  declare const createEmptyApplicationData: () => IApplicationData;
201
257
  declare const loadApplicationDataFromLocalStorage: (storageKey?: string) => IApplicationData | null;
202
258
  declare const saveApplicationDataToLocalStorage: (data: IApplicationData, storageKey?: string) => void;
203
259
 
204
- export { Beneficiary, type BeneficiaryClass, BottomQuickActions, type CartItem, HealthDeclaration, type IAddress, type IApplicationData, type IBeneficiary, type IEmployment, type IHealthDeclaration, type IPersonalInfo, type ITransactionData, LifePlanApplication1, LifePlanApplication2, LifePlanApplication3, LifePlanApplicationFormWrapper, LifePlanApplicationStepWrapper, type NavOptionDef, NotifyInstall, type ProfileUser, type ReusableProfileProps, SharedLifePlanApplication, ReusableProfile as UserProfile, createEmptyApplicationData, loadApplicationDataFromLocalStorage, saveApplicationDataToLocalStorage };
260
+ export { Beneficiary, type BeneficiaryClass, BottomQuickActions, type CartItem, HealthDeclaration, type IAddress, type IApplicationData, type IBeneficiary, type IEmployment, type IHealthDeclaration, type IOcrValue, type IParsedAddress, type IPersonalInfo, type ITransactionData, LifePlanApplication1, LifePlanApplication2, LifePlanApplication3, LifePlanApplicationFormWrapper, LifePlanApplicationStepWrapper, type NavOptionDef, type NewSalesCheckoutItem, type NewSalesCheckoutRequest, NotifyInstall, OCR_STORAGE_KEY, type OcrSection, type ProfileUser, type ReusableProfileProps, SharedLifePlanApplication, type SharedLifePlanApplicationProps, ReusableProfile as UserProfile, createEmptyApplicationData, loadApplicationDataFromLocalStorage, markOcrApplied, readOcrResult, saveApplicationDataToLocalStorage };