@bluecircuit/offer-calculator 2.0.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/LICENSE +674 -0
- package/README.md +473 -0
- package/dist/calculator.css +385 -0
- package/dist/index.css +305 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.mts +74 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.js +1084 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1062 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types.d.mts +64 -0
- package/dist/types.d.ts +64 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/types.mjs +3 -0
- package/dist/types.mjs.map +1 -0
- package/package.json +86 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { CalculatorConfig, ConditionTier, DefectAdjustment, CalculationResult, UseOfferCalculatorResult, ValidationError } from './types.mjs';
|
|
3
|
+
export { CalculationBreakdown, CalculatorHandlers, CalculatorState, DeviceInfo } from './types.mjs';
|
|
4
|
+
|
|
5
|
+
interface OfferCalculatorProps {
|
|
6
|
+
config: CalculatorConfig;
|
|
7
|
+
showBreakdown?: boolean;
|
|
8
|
+
className?: string;
|
|
9
|
+
formFieldPrefix?: string;
|
|
10
|
+
}
|
|
11
|
+
declare function OfferCalculator({ config, showBreakdown, className, formFieldPrefix, }: OfferCalculatorProps): react_jsx_runtime.JSX.Element;
|
|
12
|
+
declare function CalculatorErrorBoundary({ error, reset, }: {
|
|
13
|
+
error: Error;
|
|
14
|
+
reset?: () => void;
|
|
15
|
+
}): react_jsx_runtime.JSX.Element;
|
|
16
|
+
|
|
17
|
+
interface ConditionTabsProps {
|
|
18
|
+
conditions: ConditionTier[];
|
|
19
|
+
selectedConditionId: string;
|
|
20
|
+
onSelectCondition: (conditionId: string) => void;
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
declare function ConditionTabs({ conditions, selectedConditionId, onSelectCondition, className, }: ConditionTabsProps): react_jsx_runtime.JSX.Element;
|
|
24
|
+
declare function CompactConditionSelector({ conditions, selectedConditionId, onSelectCondition, className, }: ConditionTabsProps): react_jsx_runtime.JSX.Element;
|
|
25
|
+
|
|
26
|
+
interface DefectCheckboxProps {
|
|
27
|
+
defect: DefectAdjustment;
|
|
28
|
+
isSelected: boolean;
|
|
29
|
+
onToggle: (defectId: string) => void;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
className?: string;
|
|
32
|
+
}
|
|
33
|
+
declare function DefectCheckbox({ defect, isSelected, onToggle, disabled, className, }: DefectCheckboxProps): react_jsx_runtime.JSX.Element;
|
|
34
|
+
declare function DefectCheckboxList({ defects, selectedDefectIds, onToggle, disabled, groupByCategory, className, }: {
|
|
35
|
+
defects: DefectAdjustment[];
|
|
36
|
+
selectedDefectIds: Set<string>;
|
|
37
|
+
onToggle: (defectId: string) => void;
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
groupByCategory?: boolean;
|
|
40
|
+
className?: string;
|
|
41
|
+
}): react_jsx_runtime.JSX.Element;
|
|
42
|
+
|
|
43
|
+
interface PriceDisplayProps {
|
|
44
|
+
result: CalculationResult;
|
|
45
|
+
currency?: string;
|
|
46
|
+
locale?: string;
|
|
47
|
+
showBreakdown?: boolean;
|
|
48
|
+
className?: string;
|
|
49
|
+
}
|
|
50
|
+
declare function PriceDisplay({ result, currency, locale, showBreakdown, className, }: PriceDisplayProps): react_jsx_runtime.JSX.Element;
|
|
51
|
+
declare function CompactPriceDisplay({ result, currency, locale, className, }: Omit<PriceDisplayProps, 'showBreakdown'>): react_jsx_runtime.JSX.Element;
|
|
52
|
+
|
|
53
|
+
declare function useOfferCalculator(config: CalculatorConfig): UseOfferCalculatorResult;
|
|
54
|
+
declare function useDefectCheckbox(defectId: string, isSelected: boolean, onToggle: (defectId: string) => void): {
|
|
55
|
+
checked: boolean;
|
|
56
|
+
handleChange: () => void;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
declare function calculateOffer(basePrice: number, conditionMultiplier: number, selectedDefects: DefectAdjustment[], minimumOffer?: number): CalculationResult;
|
|
60
|
+
declare function formatCurrency(price: number, currency?: string, locale?: string): string;
|
|
61
|
+
declare function calculateEffectiveDiscount(selectedDefects: DefectAdjustment[]): number;
|
|
62
|
+
|
|
63
|
+
declare function normalizeConfig(raw: any): CalculatorConfig;
|
|
64
|
+
declare function validateConfig(config: CalculatorConfig): ValidationError[];
|
|
65
|
+
declare function hasErrors(errors: ValidationError[]): boolean;
|
|
66
|
+
declare function formatValidationErrors(errors: ValidationError[]): string;
|
|
67
|
+
|
|
68
|
+
declare function fetchCalculatorConfig(deviceId: string): Promise<CalculatorConfig>;
|
|
69
|
+
declare function getMockCalculatorConfig(deviceId: string): CalculatorConfig;
|
|
70
|
+
declare function revalidateCalculatorConfig(deviceId: string): Promise<void>;
|
|
71
|
+
|
|
72
|
+
declare const VERSION = "2.0.0";
|
|
73
|
+
|
|
74
|
+
export { CalculationResult, CalculatorConfig, CalculatorErrorBoundary, CompactConditionSelector, CompactPriceDisplay, ConditionTabs, ConditionTier, DefectAdjustment, DefectCheckbox, DefectCheckboxList, OfferCalculator, PriceDisplay, UseOfferCalculatorResult, VERSION, ValidationError, calculateEffectiveDiscount, calculateOffer, fetchCalculatorConfig, formatCurrency, formatValidationErrors, getMockCalculatorConfig, hasErrors, normalizeConfig, revalidateCalculatorConfig, useDefectCheckbox, useOfferCalculator, validateConfig };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { CalculatorConfig, ConditionTier, DefectAdjustment, CalculationResult, UseOfferCalculatorResult, ValidationError } from './types.js';
|
|
3
|
+
export { CalculationBreakdown, CalculatorHandlers, CalculatorState, DeviceInfo } from './types.js';
|
|
4
|
+
|
|
5
|
+
interface OfferCalculatorProps {
|
|
6
|
+
config: CalculatorConfig;
|
|
7
|
+
showBreakdown?: boolean;
|
|
8
|
+
className?: string;
|
|
9
|
+
formFieldPrefix?: string;
|
|
10
|
+
}
|
|
11
|
+
declare function OfferCalculator({ config, showBreakdown, className, formFieldPrefix, }: OfferCalculatorProps): react_jsx_runtime.JSX.Element;
|
|
12
|
+
declare function CalculatorErrorBoundary({ error, reset, }: {
|
|
13
|
+
error: Error;
|
|
14
|
+
reset?: () => void;
|
|
15
|
+
}): react_jsx_runtime.JSX.Element;
|
|
16
|
+
|
|
17
|
+
interface ConditionTabsProps {
|
|
18
|
+
conditions: ConditionTier[];
|
|
19
|
+
selectedConditionId: string;
|
|
20
|
+
onSelectCondition: (conditionId: string) => void;
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
declare function ConditionTabs({ conditions, selectedConditionId, onSelectCondition, className, }: ConditionTabsProps): react_jsx_runtime.JSX.Element;
|
|
24
|
+
declare function CompactConditionSelector({ conditions, selectedConditionId, onSelectCondition, className, }: ConditionTabsProps): react_jsx_runtime.JSX.Element;
|
|
25
|
+
|
|
26
|
+
interface DefectCheckboxProps {
|
|
27
|
+
defect: DefectAdjustment;
|
|
28
|
+
isSelected: boolean;
|
|
29
|
+
onToggle: (defectId: string) => void;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
className?: string;
|
|
32
|
+
}
|
|
33
|
+
declare function DefectCheckbox({ defect, isSelected, onToggle, disabled, className, }: DefectCheckboxProps): react_jsx_runtime.JSX.Element;
|
|
34
|
+
declare function DefectCheckboxList({ defects, selectedDefectIds, onToggle, disabled, groupByCategory, className, }: {
|
|
35
|
+
defects: DefectAdjustment[];
|
|
36
|
+
selectedDefectIds: Set<string>;
|
|
37
|
+
onToggle: (defectId: string) => void;
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
groupByCategory?: boolean;
|
|
40
|
+
className?: string;
|
|
41
|
+
}): react_jsx_runtime.JSX.Element;
|
|
42
|
+
|
|
43
|
+
interface PriceDisplayProps {
|
|
44
|
+
result: CalculationResult;
|
|
45
|
+
currency?: string;
|
|
46
|
+
locale?: string;
|
|
47
|
+
showBreakdown?: boolean;
|
|
48
|
+
className?: string;
|
|
49
|
+
}
|
|
50
|
+
declare function PriceDisplay({ result, currency, locale, showBreakdown, className, }: PriceDisplayProps): react_jsx_runtime.JSX.Element;
|
|
51
|
+
declare function CompactPriceDisplay({ result, currency, locale, className, }: Omit<PriceDisplayProps, 'showBreakdown'>): react_jsx_runtime.JSX.Element;
|
|
52
|
+
|
|
53
|
+
declare function useOfferCalculator(config: CalculatorConfig): UseOfferCalculatorResult;
|
|
54
|
+
declare function useDefectCheckbox(defectId: string, isSelected: boolean, onToggle: (defectId: string) => void): {
|
|
55
|
+
checked: boolean;
|
|
56
|
+
handleChange: () => void;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
declare function calculateOffer(basePrice: number, conditionMultiplier: number, selectedDefects: DefectAdjustment[], minimumOffer?: number): CalculationResult;
|
|
60
|
+
declare function formatCurrency(price: number, currency?: string, locale?: string): string;
|
|
61
|
+
declare function calculateEffectiveDiscount(selectedDefects: DefectAdjustment[]): number;
|
|
62
|
+
|
|
63
|
+
declare function normalizeConfig(raw: any): CalculatorConfig;
|
|
64
|
+
declare function validateConfig(config: CalculatorConfig): ValidationError[];
|
|
65
|
+
declare function hasErrors(errors: ValidationError[]): boolean;
|
|
66
|
+
declare function formatValidationErrors(errors: ValidationError[]): string;
|
|
67
|
+
|
|
68
|
+
declare function fetchCalculatorConfig(deviceId: string): Promise<CalculatorConfig>;
|
|
69
|
+
declare function getMockCalculatorConfig(deviceId: string): CalculatorConfig;
|
|
70
|
+
declare function revalidateCalculatorConfig(deviceId: string): Promise<void>;
|
|
71
|
+
|
|
72
|
+
declare const VERSION = "2.0.0";
|
|
73
|
+
|
|
74
|
+
export { CalculationResult, CalculatorConfig, CalculatorErrorBoundary, CompactConditionSelector, CompactPriceDisplay, ConditionTabs, ConditionTier, DefectAdjustment, DefectCheckbox, DefectCheckboxList, OfferCalculator, PriceDisplay, UseOfferCalculatorResult, VERSION, ValidationError, calculateEffectiveDiscount, calculateOffer, fetchCalculatorConfig, formatCurrency, formatValidationErrors, getMockCalculatorConfig, hasErrors, normalizeConfig, revalidateCalculatorConfig, useDefectCheckbox, useOfferCalculator, validateConfig };
|