@netlisian/softconfig 0.0.4 → 0.0.5

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.
@@ -105,11 +105,8 @@ type BuilderComponentConfig = {
105
105
  _map?: {
106
106
  from: string | string[];
107
107
  to: string | string[];
108
- transform?: (inputs: any, props: DefaultComponentProps) => any;
109
- graphState?: {
110
- nodes: any[];
111
- edges: any[];
112
- };
108
+ transform?: (inputs: any[], props: DefaultComponentProps) => any;
109
+ [key: string]: any;
113
110
  }[];
114
111
  [key: string]: any;
115
112
  };
@@ -129,6 +126,7 @@ type SoftSubComponent = {
129
126
  }[];
130
127
  type SoftComponent = {
131
128
  fields: Fields;
129
+ fieldSettings?: Record<string, any>;
132
130
  defaultProps: DefaultComponentProps;
133
131
  components: SoftSubComponent;
134
132
  slots: {
@@ -140,6 +138,7 @@ type VersionedSoftComponent = {
140
138
  versions: {
141
139
  [version: string]: {
142
140
  fields: Fields;
141
+ fieldSettings?: Record<string, any>;
143
142
  defaultProps: DefaultComponentProps;
144
143
  components: SoftSubComponent;
145
144
  slots: {
@@ -105,11 +105,8 @@ type BuilderComponentConfig = {
105
105
  _map?: {
106
106
  from: string | string[];
107
107
  to: string | string[];
108
- transform?: (inputs: any, props: DefaultComponentProps) => any;
109
- graphState?: {
110
- nodes: any[];
111
- edges: any[];
112
- };
108
+ transform?: (inputs: any[], props: DefaultComponentProps) => any;
109
+ [key: string]: any;
113
110
  }[];
114
111
  [key: string]: any;
115
112
  };
@@ -129,6 +126,7 @@ type SoftSubComponent = {
129
126
  }[];
130
127
  type SoftComponent = {
131
128
  fields: Fields;
129
+ fieldSettings?: Record<string, any>;
132
130
  defaultProps: DefaultComponentProps;
133
131
  components: SoftSubComponent;
134
132
  slots: {
@@ -140,6 +138,7 @@ type VersionedSoftComponent = {
140
138
  versions: {
141
139
  [version: string]: {
142
140
  fields: Fields;
141
+ fieldSettings?: Record<string, any>;
143
142
  defaultProps: DefaultComponentProps;
144
143
  components: SoftSubComponent;
145
144
  slots: {
@@ -924,6 +924,7 @@ var softComponentFromAppState = (appState, configComponents) => {
924
924
  acc[slot] = { type: "slot", label: slot };
925
925
  return acc;
926
926
  }, {})),
927
+ fieldSettings: field_settings,
927
928
  defaultProps,
928
929
  components,
929
930
  slots
@@ -1078,6 +1079,7 @@ var import_uuid = require("uuid");
1078
1079
  var import_jsx_runtime5 = require("react/jsx-runtime");
1079
1080
  function SoftRender({
1080
1081
  softComponentFields,
1082
+ softComponentFieldSettings,
1081
1083
  softSubComponent,
1082
1084
  configComponents,
1083
1085
  props,
@@ -1118,9 +1120,16 @@ function SoftRender({
1118
1120
  subComponent.map.forEach(({ from, to, transform }) => {
1119
1121
  const fromPaths = Array.isArray(from) ? from : from ? [from] : [];
1120
1122
  const toPaths = Array.isArray(to) ? to : to ? [to] : [];
1121
- const inputValues = fromPaths.map(
1122
- (f) => getFieldSettingsByPath(props || {}, f)
1123
- );
1123
+ const inputValues = fromPaths.map((f) => {
1124
+ const setting = getFieldSettingsByPath(
1125
+ softComponentFieldSettings || {},
1126
+ f
1127
+ );
1128
+ if (setting && Object.prototype.hasOwnProperty.call(setting, "defaultValue")) {
1129
+ return setting.defaultValue;
1130
+ }
1131
+ return getFieldSettingsByPath(props || {}, f);
1132
+ });
1124
1133
  const cacheKey = JSON.stringify(inputValues);
1125
1134
  let result = mapCacheRef.current.get(cacheKey);
1126
1135
  if (!result) {
@@ -1224,6 +1233,7 @@ var createVersionedComponentConfig = (componentName, version, allVersions, confi
1224
1233
  SoftRender,
1225
1234
  {
1226
1235
  softComponentFields: versionedComponent.fields,
1236
+ softComponentFieldSettings: versionedComponent.fieldSettings,
1227
1237
  softSubComponent: versionedComponent.components,
1228
1238
  configComponents: softConfig.components,
1229
1239
  props
@@ -874,6 +874,7 @@ var softComponentFromAppState = (appState, configComponents) => {
874
874
  acc[slot] = { type: "slot", label: slot };
875
875
  return acc;
876
876
  }, {})),
877
+ fieldSettings: field_settings,
877
878
  defaultProps,
878
879
  components,
879
880
  slots
@@ -1028,6 +1029,7 @@ import { v4 as uuidv4 } from "uuid";
1028
1029
  import { Fragment as Fragment2, jsx as jsx5 } from "react/jsx-runtime";
1029
1030
  function SoftRender({
1030
1031
  softComponentFields,
1032
+ softComponentFieldSettings,
1031
1033
  softSubComponent,
1032
1034
  configComponents,
1033
1035
  props,
@@ -1068,9 +1070,16 @@ function SoftRender({
1068
1070
  subComponent.map.forEach(({ from, to, transform }) => {
1069
1071
  const fromPaths = Array.isArray(from) ? from : from ? [from] : [];
1070
1072
  const toPaths = Array.isArray(to) ? to : to ? [to] : [];
1071
- const inputValues = fromPaths.map(
1072
- (f) => getFieldSettingsByPath(props || {}, f)
1073
- );
1073
+ const inputValues = fromPaths.map((f) => {
1074
+ const setting = getFieldSettingsByPath(
1075
+ softComponentFieldSettings || {},
1076
+ f
1077
+ );
1078
+ if (setting && Object.prototype.hasOwnProperty.call(setting, "defaultValue")) {
1079
+ return setting.defaultValue;
1080
+ }
1081
+ return getFieldSettingsByPath(props || {}, f);
1082
+ });
1074
1083
  const cacheKey = JSON.stringify(inputValues);
1075
1084
  let result = mapCacheRef.current.get(cacheKey);
1076
1085
  if (!result) {
@@ -1174,6 +1183,7 @@ var createVersionedComponentConfig = (componentName, version, allVersions, confi
1174
1183
  SoftRender,
1175
1184
  {
1176
1185
  softComponentFields: versionedComponent.fields,
1186
+ softComponentFieldSettings: versionedComponent.fieldSettings,
1177
1187
  softSubComponent: versionedComponent.components,
1178
1188
  configComponents: softConfig.components,
1179
1189
  props
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlisian/softconfig",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -22,7 +22,16 @@
22
22
  "./dist/index.css": "./dist/index.css",
23
23
  "./puck/index.css": "./dist/puck/index.css"
24
24
  },
25
+ "scripts": {
26
+ "build": "tsup src/index.tsx src/puck/index.tsx --format esm,cjs --dts --out-dir dist --external react --external react-dom",
27
+ "dev": "tsup src/index.tsx src/puck/index.tsx --format esm,cjs --watch --dts --out-dir dist --external react --external react-dom",
28
+ "lint": "eslint \"src/**/*.ts*\"",
29
+ "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
30
+ "size": "size-limit"
31
+ },
25
32
  "devDependencies": {
33
+ "@netlisian/eslint-config": "workspace:*",
34
+ "@netlisian/tsconfig": "workspace:*",
26
35
  "@size-limit/esbuild": "^11.1.6",
27
36
  "@size-limit/esbuild-why": "^11.1.6",
28
37
  "@size-limit/file": "^11.1.6",
@@ -35,9 +44,7 @@
35
44
  "size-limit": "^11.1.6",
36
45
  "tsup": "^8.0.2",
37
46
  "typescript": "5.9.3",
38
- "typescript-plugin-css-modules": "^5.1.0",
39
- "@netlisian/eslint-config": "0.0.0",
40
- "@netlisian/tsconfig": "0.0.1"
47
+ "typescript-plugin-css-modules": "^5.1.0"
41
48
  },
42
49
  "dependencies": {
43
50
  "classnames": "^2.5.1",
@@ -51,12 +58,5 @@
51
58
  },
52
59
  "publishConfig": {
53
60
  "access": "public"
54
- },
55
- "scripts": {
56
- "build": "tsup src/index.tsx src/puck/index.tsx --format esm,cjs --dts --out-dir dist --external react --external react-dom",
57
- "dev": "tsup src/index.tsx src/puck/index.tsx --format esm,cjs --watch --dts --out-dir dist --external react --external react-dom",
58
- "lint": "eslint \"src/**/*.ts*\"",
59
- "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
60
- "size": "size-limit"
61
61
  }
62
62
  }