ov-configurator 1.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/README.md +170 -0
- package/dist/calculator.d.ts +60 -0
- package/dist/configurator.d.ts +11 -0
- package/dist/index.d.ts +3 -0
- package/dist/ov-configurator.cjs +30 -0
- package/dist/ov-configurator.iife.js +30 -0
- package/dist/ov-configurator.js +1784 -0
- package/dist/types.d.ts +63 -0
- package/package.json +40 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export interface DataSource extends Record<string, DataSource | number | string | boolean> {
|
|
2
|
+
}
|
|
3
|
+
export type CalculateFunction<TData = unknown> = (values: Record<string, string>, data: TData) => unknown;
|
|
4
|
+
export interface SectionInput {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
export interface FieldOptions<TData = unknown> {
|
|
9
|
+
selector: string;
|
|
10
|
+
animated?: boolean;
|
|
11
|
+
duration?: number;
|
|
12
|
+
dots?: number;
|
|
13
|
+
dataKey?: string;
|
|
14
|
+
calculateFunction?: CalculateFunction<TData>;
|
|
15
|
+
attribute?: boolean;
|
|
16
|
+
animation?: string[];
|
|
17
|
+
animatedNode?: 'parent' | 'self' | 'closest';
|
|
18
|
+
animatedNodeSelector?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface SectionOptions {
|
|
21
|
+
title?: string;
|
|
22
|
+
type: string;
|
|
23
|
+
inputs: SectionInput[] | ((data: unknown) => SectionInput[]);
|
|
24
|
+
className?: string;
|
|
25
|
+
checked?: boolean;
|
|
26
|
+
inputType?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface CalculatorOptions<TData = unknown> {
|
|
29
|
+
id: string;
|
|
30
|
+
editableFields?: FieldOptions<TData>[];
|
|
31
|
+
data?: TData | null;
|
|
32
|
+
parentSelector?: string;
|
|
33
|
+
prefix?: string;
|
|
34
|
+
stylePrefix?: string;
|
|
35
|
+
dataAttributePrefix?: string;
|
|
36
|
+
sectionsOptions?: SectionOptions[];
|
|
37
|
+
}
|
|
38
|
+
/** Minimal interface exposed to external code that receives a calculator instance */
|
|
39
|
+
export interface ICalculatorInstance {
|
|
40
|
+
getValue(key: string): unknown;
|
|
41
|
+
getValues(): Record<string, string>;
|
|
42
|
+
refresh(): void;
|
|
43
|
+
}
|
|
44
|
+
export interface ConfiguratorSection {
|
|
45
|
+
key: string;
|
|
46
|
+
title: string;
|
|
47
|
+
path: string;
|
|
48
|
+
postfix?: string;
|
|
49
|
+
inputs?: SectionInput[];
|
|
50
|
+
selectorDisplay?: (selected: string, sectionData: unknown) => string;
|
|
51
|
+
labelMapping?: Record<string, string>;
|
|
52
|
+
}
|
|
53
|
+
export interface ConfiguratorField {
|
|
54
|
+
selector: string;
|
|
55
|
+
attribute?: boolean;
|
|
56
|
+
get: (values: Record<string, string>, item: unknown, id: string, calculator: ICalculatorInstance) => unknown;
|
|
57
|
+
}
|
|
58
|
+
export interface ConfiguratorOptions {
|
|
59
|
+
oldPricePercent: number;
|
|
60
|
+
getPrice: (values: Record<string, string>, item: unknown, id: string) => number;
|
|
61
|
+
sections: ConfiguratorSection[];
|
|
62
|
+
fields?: ConfiguratorField[];
|
|
63
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ov-configurator",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Universal frontend product configurator module",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/ov-configurator.cjs",
|
|
7
|
+
"module": "./dist/ov-configurator.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/ov-configurator.js",
|
|
12
|
+
"require": "./dist/ov-configurator.cjs",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./iife": "./dist/ov-configurator.iife.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"start:dev": "vite --config vite.dev.config.ts",
|
|
22
|
+
"build": "vite build",
|
|
23
|
+
"typecheck": "tsc --noEmit",
|
|
24
|
+
"preview": "vite preview"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@babel/core": "^7.29.0",
|
|
28
|
+
"@babel/preset-env": "^7.29.2",
|
|
29
|
+
"@rollup/plugin-babel": "^7.0.0",
|
|
30
|
+
"@tailwindcss/vite": "^4.2.2",
|
|
31
|
+
"@types/node": "^25.6.0",
|
|
32
|
+
"tailwindcss": "^4.2.2",
|
|
33
|
+
"typescript": "~6.0.2",
|
|
34
|
+
"vite": "^8.0.4",
|
|
35
|
+
"vite-plugin-dts": "^4.5.4"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"jsonpath-plus": "^10.4.0"
|
|
39
|
+
}
|
|
40
|
+
}
|