@netlisian/softconfig 0.0.3 → 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.
@@ -1,6 +1,6 @@
1
1
  import * as zustand from 'zustand';
2
2
  import { StoreApi } from 'zustand';
3
- import { History, AppState, PuckApi, ComponentConfig, ComponentData, DefaultComponentProps, Field, Fields, Config, Data } from '@measured/puck';
3
+ import { History, AppState, PuckApi, ComponentConfig, ComponentData, DefaultComponentProps, Field, Config, Fields, Data } from '@measured/puck';
4
4
  import * as react from 'react';
5
5
  import react__default, { ReactNode, ReactElement } from 'react';
6
6
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -105,14 +105,12 @@ 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
  };
113
+ type BuilderConfig = Config<any, BuilderRootConfig>;
116
114
 
117
115
  type SoftSubComponent = {
118
116
  type: string;
@@ -128,6 +126,7 @@ type SoftSubComponent = {
128
126
  }[];
129
127
  type SoftComponent = {
130
128
  fields: Fields;
129
+ fieldSettings?: Record<string, any>;
131
130
  defaultProps: DefaultComponentProps;
132
131
  components: SoftSubComponent;
133
132
  slots: {
@@ -139,6 +138,7 @@ type VersionedSoftComponent = {
139
138
  versions: {
140
139
  [version: string]: {
141
140
  fields: Fields;
141
+ fieldSettings?: Record<string, any>;
142
142
  defaultProps: DefaultComponentProps;
143
143
  components: SoftSubComponent;
144
144
  slots: {
@@ -343,4 +343,10 @@ declare const confirm: (message: string) => Promise<boolean>;
343
343
  */
344
344
  declare const resolveSoftConfig: (data: Data, softComponents: SoftComponents, config: Config) => Data;
345
345
 
346
- export { ActionBarOverride as ActionBar, type AppStore, type AppStoreApi, ComponentItem, Header, type SoftComponent, type SoftComponents, SoftConfigProvider, confirm, createSoftConfigStore, createUseSoftConfig, notify, resolveSoftConfig, setConfirmHandler, setNotificationHandler, useBuild, useCancel, useComplete, useDecompose, useDemolish, useInspect, useRemodel, useSetDefaultVersion, useSoftConfig };
346
+ declare const Modal: ({ children, onClose, isOpen, }: {
347
+ children: ReactNode;
348
+ onClose: () => void;
349
+ isOpen: boolean;
350
+ }) => react_jsx_runtime.JSX.Element;
351
+
352
+ export { ActionBarOverride as ActionBar, type AppStore, type AppStoreApi, type BuilderComponentConfig, type BuilderConfig, type BuilderRootConfig, ComponentItem, Header, Modal, type Overrides, type SoftComponent, type SoftComponents, SoftConfigProvider, confirm, createSoftConfigStore, createUseSoftConfig, notify, resolveSoftConfig, setConfirmHandler, setNotificationHandler, useBuild, useCancel, useComplete, useDecompose, useDemolish, useInspect, useRemodel, useSetDefaultVersion, useSoftConfig };
@@ -1,6 +1,6 @@
1
1
  import * as zustand from 'zustand';
2
2
  import { StoreApi } from 'zustand';
3
- import { History, AppState, PuckApi, ComponentConfig, ComponentData, DefaultComponentProps, Field, Fields, Config, Data } from '@measured/puck';
3
+ import { History, AppState, PuckApi, ComponentConfig, ComponentData, DefaultComponentProps, Field, Config, Fields, Data } from '@measured/puck';
4
4
  import * as react from 'react';
5
5
  import react__default, { ReactNode, ReactElement } from 'react';
6
6
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -105,14 +105,12 @@ 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
  };
113
+ type BuilderConfig = Config<any, BuilderRootConfig>;
116
114
 
117
115
  type SoftSubComponent = {
118
116
  type: string;
@@ -128,6 +126,7 @@ type SoftSubComponent = {
128
126
  }[];
129
127
  type SoftComponent = {
130
128
  fields: Fields;
129
+ fieldSettings?: Record<string, any>;
131
130
  defaultProps: DefaultComponentProps;
132
131
  components: SoftSubComponent;
133
132
  slots: {
@@ -139,6 +138,7 @@ type VersionedSoftComponent = {
139
138
  versions: {
140
139
  [version: string]: {
141
140
  fields: Fields;
141
+ fieldSettings?: Record<string, any>;
142
142
  defaultProps: DefaultComponentProps;
143
143
  components: SoftSubComponent;
144
144
  slots: {
@@ -343,4 +343,10 @@ declare const confirm: (message: string) => Promise<boolean>;
343
343
  */
344
344
  declare const resolveSoftConfig: (data: Data, softComponents: SoftComponents, config: Config) => Data;
345
345
 
346
- export { ActionBarOverride as ActionBar, type AppStore, type AppStoreApi, ComponentItem, Header, type SoftComponent, type SoftComponents, SoftConfigProvider, confirm, createSoftConfigStore, createUseSoftConfig, notify, resolveSoftConfig, setConfirmHandler, setNotificationHandler, useBuild, useCancel, useComplete, useDecompose, useDemolish, useInspect, useRemodel, useSetDefaultVersion, useSoftConfig };
346
+ declare const Modal: ({ children, onClose, isOpen, }: {
347
+ children: ReactNode;
348
+ onClose: () => void;
349
+ isOpen: boolean;
350
+ }) => react_jsx_runtime.JSX.Element;
351
+
352
+ export { ActionBarOverride as ActionBar, type AppStore, type AppStoreApi, type BuilderComponentConfig, type BuilderConfig, type BuilderRootConfig, ComponentItem, Header, Modal, type Overrides, type SoftComponent, type SoftComponents, SoftConfigProvider, confirm, createSoftConfigStore, createUseSoftConfig, notify, resolveSoftConfig, setConfirmHandler, setNotificationHandler, useBuild, useCancel, useComplete, useDecompose, useDemolish, useInspect, useRemodel, useSetDefaultVersion, useSoftConfig };
@@ -83,6 +83,7 @@ __export(puck_exports, {
83
83
  ActionBar: () => ActionBarOverride,
84
84
  ComponentItem: () => ComponentItem,
85
85
  Header: () => Header,
86
+ Modal: () => Modal,
86
87
  SoftConfigProvider: () => SoftConfigProvider,
87
88
  confirm: () => confirm,
88
89
  createSoftConfigStore: () => createSoftConfigStore,
@@ -923,6 +924,7 @@ var softComponentFromAppState = (appState, configComponents) => {
923
924
  acc[slot] = { type: "slot", label: slot };
924
925
  return acc;
925
926
  }, {})),
927
+ fieldSettings: field_settings,
926
928
  defaultProps,
927
929
  components,
928
930
  slots
@@ -1077,6 +1079,7 @@ var import_uuid = require("uuid");
1077
1079
  var import_jsx_runtime5 = require("react/jsx-runtime");
1078
1080
  function SoftRender({
1079
1081
  softComponentFields,
1082
+ softComponentFieldSettings,
1080
1083
  softSubComponent,
1081
1084
  configComponents,
1082
1085
  props,
@@ -1117,9 +1120,16 @@ function SoftRender({
1117
1120
  subComponent.map.forEach(({ from, to, transform }) => {
1118
1121
  const fromPaths = Array.isArray(from) ? from : from ? [from] : [];
1119
1122
  const toPaths = Array.isArray(to) ? to : to ? [to] : [];
1120
- const inputValues = fromPaths.map(
1121
- (f) => getFieldSettingsByPath(props || {}, f)
1122
- );
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
+ });
1123
1133
  const cacheKey = JSON.stringify(inputValues);
1124
1134
  let result = mapCacheRef.current.get(cacheKey);
1125
1135
  if (!result) {
@@ -1223,6 +1233,7 @@ var createVersionedComponentConfig = (componentName, version, allVersions, confi
1223
1233
  SoftRender,
1224
1234
  {
1225
1235
  softComponentFields: versionedComponent.fields,
1236
+ softComponentFieldSettings: versionedComponent.fieldSettings,
1226
1237
  softSubComponent: versionedComponent.components,
1227
1238
  configComponents: softConfig.components,
1228
1239
  props
@@ -2828,6 +2839,7 @@ var resolveSoftConfig = (data, softComponents, config) => {
2828
2839
  ActionBar,
2829
2840
  ComponentItem,
2830
2841
  Header,
2842
+ Modal,
2831
2843
  SoftConfigProvider,
2832
2844
  confirm,
2833
2845
  createSoftConfigStore,
@@ -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
@@ -2778,6 +2788,7 @@ export {
2778
2788
  ActionBarOverride as ActionBar,
2779
2789
  ComponentItem,
2780
2790
  Header,
2791
+ Modal,
2781
2792
  SoftConfigProvider,
2782
2793
  confirm,
2783
2794
  createSoftConfigStore,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlisian/softconfig",
3
- "version": "0.0.3",
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.0"
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
  }