@cratis/scene.components 4.8.0 → 4.10.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.
Files changed (61) hide show
  1. package/cratisComponentsDescriptors.ts +53 -1
  2. package/cratisComponentsPackage.ts +23 -0
  3. package/dist/cjs/cratisComponentsDescriptors.js +150 -0
  4. package/dist/cjs/cratisComponentsDescriptors.js.map +1 -1
  5. package/dist/cjs/cratisComponentsPackage.js +40 -2
  6. package/dist/cjs/cratisComponentsPackage.js.map +1 -1
  7. package/dist/cjs/forms/CommandFieldPropertyEditor.js +28 -0
  8. package/dist/cjs/forms/CommandFieldPropertyEditor.js.map +1 -0
  9. package/dist/cjs/forms/CommandFormDesigner.js +20 -0
  10. package/dist/cjs/forms/CommandFormDesigner.js.map +1 -0
  11. package/dist/cjs/forms/CommandFormRuntime.js +11 -4
  12. package/dist/cjs/forms/CommandFormRuntime.js.map +1 -1
  13. package/dist/cjs/forms/ExplicitCommandField.js +13 -7
  14. package/dist/cjs/forms/ExplicitCommandField.js.map +1 -1
  15. package/dist/cjs/forms/SceneCommandForm.js +10 -3
  16. package/dist/cjs/forms/SceneCommandForm.js.map +1 -1
  17. package/dist/cjs/forms/commandInputs.js +8 -2
  18. package/dist/cjs/forms/commandInputs.js.map +1 -1
  19. package/dist/cjs/forms/generateCommandFieldsAction.js +58 -0
  20. package/dist/cjs/forms/generateCommandFieldsAction.js.map +1 -0
  21. package/dist/esm/cratisComponentsDescriptors.d.ts.map +1 -1
  22. package/dist/esm/cratisComponentsDescriptors.js +151 -1
  23. package/dist/esm/cratisComponentsDescriptors.js.map +1 -1
  24. package/dist/esm/cratisComponentsPackage.d.ts.map +1 -1
  25. package/dist/esm/cratisComponentsPackage.js +40 -2
  26. package/dist/esm/cratisComponentsPackage.js.map +1 -1
  27. package/dist/esm/forms/CommandFieldPropertyEditor.d.ts +3 -0
  28. package/dist/esm/forms/CommandFieldPropertyEditor.d.ts.map +1 -0
  29. package/dist/esm/forms/CommandFieldPropertyEditor.js +26 -0
  30. package/dist/esm/forms/CommandFieldPropertyEditor.js.map +1 -0
  31. package/dist/esm/forms/CommandFormDesigner.d.ts +3 -0
  32. package/dist/esm/forms/CommandFormDesigner.d.ts.map +1 -0
  33. package/dist/esm/forms/CommandFormDesigner.js +18 -0
  34. package/dist/esm/forms/CommandFormDesigner.js.map +1 -0
  35. package/dist/esm/forms/CommandFormRuntime.d.ts +2 -1
  36. package/dist/esm/forms/CommandFormRuntime.d.ts.map +1 -1
  37. package/dist/esm/forms/CommandFormRuntime.js +11 -4
  38. package/dist/esm/forms/CommandFormRuntime.js.map +1 -1
  39. package/dist/esm/forms/ExplicitCommandField.d.ts.map +1 -1
  40. package/dist/esm/forms/ExplicitCommandField.js +13 -7
  41. package/dist/esm/forms/ExplicitCommandField.js.map +1 -1
  42. package/dist/esm/forms/SceneCommandForm.d.ts.map +1 -1
  43. package/dist/esm/forms/SceneCommandForm.js +11 -4
  44. package/dist/esm/forms/SceneCommandForm.js.map +1 -1
  45. package/dist/esm/forms/commandInputs.d.ts +2 -0
  46. package/dist/esm/forms/commandInputs.d.ts.map +1 -1
  47. package/dist/esm/forms/commandInputs.js +9 -3
  48. package/dist/esm/forms/commandInputs.js.map +1 -1
  49. package/dist/esm/forms/generateCommandFieldsAction.d.ts +3 -0
  50. package/dist/esm/forms/generateCommandFieldsAction.d.ts.map +1 -0
  51. package/dist/esm/forms/generateCommandFieldsAction.js +56 -0
  52. package/dist/esm/forms/generateCommandFieldsAction.js.map +1 -0
  53. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  54. package/forms/CommandFieldPropertyEditor.tsx +16 -0
  55. package/forms/CommandFormDesigner.tsx +14 -0
  56. package/forms/CommandFormRuntime.tsx +5 -2
  57. package/forms/ExplicitCommandField.tsx +4 -2
  58. package/forms/SceneCommandForm.tsx +5 -3
  59. package/forms/commandInputs.ts +7 -3
  60. package/forms/generateCommandFieldsAction.ts +46 -0
  61. package/package.json +7 -7
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandFormDesigner.js","sources":["../../../forms/CommandFormDesigner.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DesignTimeComponentProps } from '@cratis/scene.react';\n\n/**\n * Generic package-side command form designer. It reads only the shared design-time context and submits Scene edits.\n */\nexport function CommandFormDesigner({ context }: DesignTimeComponentProps) {\n const canGenerate = context.capabilities['commandForm.generateFields'] === true && context.permissions.edit !== false;\n return <button type='button' disabled={!canGenerate} onClick={() => context.submitAction('Cratis.Components.commandForm.generateFields', [])}>\n Generate fields\n </button>;\n}\n"],"names":["CommandFormDesigner","context","canGenerate","capabilities","permissions","edit","_jsx","button","type","disabled","onClick","submitAction"],"mappings":";;AAAA;AACA;AAIA;;AAEC,IACM,SAASA,mBAAAA,CAAoB,EAAEC,OAAO,EAA4B,EAAA;IACrE,MAAMC,WAAAA,GAAcD,OAAAA,CAAQE,YAAY,CAAC,4BAAA,CAA6B,KAAK,IAAA,IAAQF,OAAAA,CAAQG,WAAW,CAACC,IAAI,KAAK,KAAA;AAChH,IAAA,qBAAOC,GAAA,CAACC,QAAAA,EAAAA;QAAOC,IAAAA,EAAK,QAAA;AAASC,QAAAA,QAAAA,EAAU,CAACP,WAAAA;AAAaQ,QAAAA,OAAAA,EAAS,IAAMT,OAAAA,CAAQU,YAAY,CAAC,gDAAgD,EAAE,CAAA;AAAG,QAAA,QAAA,EAAA;;AAGlJ;;"}
@@ -5,7 +5,8 @@ interface CommandFormRuntimeProps {
5
5
  inputs?: CommandInput[];
6
6
  exclude?: string[];
7
7
  submitLabel: string;
8
+ columns?: number;
8
9
  }
9
- export default function CommandFormRuntime({ command, inputs, exclude, submitLabel }: CommandFormRuntimeProps): import("react").JSX.Element;
10
+ export default function CommandFormRuntime({ command, inputs, exclude, submitLabel, columns }: CommandFormRuntimeProps): import("react").JSX.Element;
10
11
  export {};
11
12
  //# sourceMappingURL=CommandFormRuntime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CommandFormRuntime.d.ts","sourceRoot":"","sources":["../../../forms/CommandFormRuntime.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAIpD,UAAU,uBAAuB;IAC7B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACvB;AA4CD,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,uBAAuB,+BAS5G"}
1
+ {"version":3,"file":"CommandFormRuntime.d.ts","sourceRoot":"","sources":["../../../forms/CommandFormRuntime.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAIpD,UAAU,uBAAuB;IAC7B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AA4CD,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,OAAW,EAAE,EAAE,uBAAuB,+BAWzH"}
@@ -45,7 +45,7 @@ const NativeAutoCommandForm = AutoCommandForm;
45
45
  }
46
46
  return undefined;
47
47
  }
48
- /** Private lazy entry point: importing the Scene registry must not import Arc. */ function CommandFormRuntime({ command, inputs, exclude, submitLabel }) {
48
+ /** Private lazy entry point: importing the Scene registry must not import Arc. */ function CommandFormRuntime({ command, inputs, exclude, submitLabel, columns = 1 }) {
49
49
  const error = capability(command, inputs, exclude);
50
50
  if (error) return /*#__PURE__*/ jsx("div", {
51
51
  role: "alert",
@@ -56,9 +56,16 @@ const NativeAutoCommandForm = AutoCommandForm;
56
56
  command: command,
57
57
  showTitles: false,
58
58
  children: [
59
- inputs.map((input)=>/*#__PURE__*/ jsx(ExplicitCommandField, {
60
- input: input
61
- }, input.property)),
59
+ /*#__PURE__*/ jsx("div", {
60
+ style: {
61
+ display: 'grid',
62
+ gridTemplateColumns: `repeat(${Math.max(1, columns)}, minmax(0, 1fr))`,
63
+ gap: '1rem'
64
+ },
65
+ children: inputs.map((input)=>/*#__PURE__*/ jsx(ExplicitCommandField, {
66
+ input: input
67
+ }, input.property))
68
+ }),
62
69
  /*#__PURE__*/ jsx(CommandFormSubmit, {
63
70
  label: submitLabel
64
71
  })
@@ -1 +1 @@
1
- {"version":3,"file":"CommandFormRuntime.js","sources":["../../../forms/CommandFormRuntime.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { ComponentType, ReactNode } from 'react';\nimport { AutoCommandForm } from '@cratis/components/CommandForm';\nimport { CommandForm } from '@cratis/arc.react/commands';\nimport { Guid } from '@cratis/fundamentals';\nimport type { BoundConstructor } from '../bindings';\nimport type { CommandInput } from './commandInputs';\nimport { CommandFormSubmit } from './CommandFormSubmit';\nimport { ExplicitCommandField } from './ExplicitCommandField';\n\ninterface CommandFormRuntimeProps {\n command: BoundConstructor;\n inputs?: CommandInput[];\n exclude?: string[];\n submitLabel: string;\n}\n\n// Runtime bindings erase the proxy's keys; the optional footer is a Components >=4.13 contract.\nconst NativeAutoCommandForm = AutoCommandForm as unknown as ComponentType<{\n command: BoundConstructor;\n exclude?: string[];\n footer?: ReactNode;\n}>;\n\ntype Descriptor = { name: string; type: unknown; isOptional: boolean };\n\n/** Verify the whole command before mounting any native form: partial forms must never execute. */\nfunction capability(command: BoundConstructor, inputs?: CommandInput[], exclude?: string[]): string | undefined {\n let descriptors: unknown;\n try { descriptors = (new command() as { propertyDescriptors?: unknown }).propertyDescriptors; }\n catch { return 'Unable to inspect command proxy'; }\n if (!Array.isArray(descriptors)) return 'Command proxy has no property descriptors';\n const byName = new Map<string, Descriptor>();\n for (const descriptor of descriptors) {\n if (!descriptor || typeof descriptor.name !== 'string' || !descriptor.name ||\n typeof descriptor.isOptional !== 'boolean' || byName.has(descriptor.name)) return 'Ambiguous or invalid command property descriptors';\n byName.set(descriptor.name, descriptor);\n }\n if (inputs) {\n for (const input of inputs) {\n const descriptor = byName.get(input.property);\n if (!descriptor) return `Unknown command property '${input.property}'`;\n if (descriptor.type !== (input.type === 'guid' ? Guid : String)) return `Command property '${input.property}' type does not match '${input.type}'`;\n }\n for (const descriptor of byName.values()) {\n if (!descriptor.isOptional && !inputs.some(input => input.property === descriptor.name)) return `Required command property '${descriptor.name}' has no input`;\n }\n } else {\n for (const descriptor of byName.values()) {\n if (!descriptor.isOptional && (exclude?.includes(descriptor.name) ||\n ![String, Number, Boolean, Date].includes(descriptor.type as typeof String))) {\n return `Required command property '${descriptor.name}' has no supported automatic field; declare inputs`;\n }\n }\n }\n return undefined;\n}\n\n/** Private lazy entry point: importing the Scene registry must not import Arc. */\nexport default function CommandFormRuntime({ command, inputs, exclude, submitLabel }: CommandFormRuntimeProps) {\n const error = capability(command, inputs, exclude);\n if (error) return <div role='alert'>{error}</div>;\n // The registry's never-argument constructor is erased; Arc creates this checked proxy with no args.\n if (inputs) return <CommandForm command={command as unknown as new () => object} showTitles={false}>\n {inputs.map(input => <ExplicitCommandField key={input.property} input={input} />)}\n <CommandFormSubmit label={submitLabel} />\n </CommandForm>;\n return <NativeAutoCommandForm command={command} exclude={exclude} footer={<CommandFormSubmit label={submitLabel} />} />;\n}\n"],"names":["NativeAutoCommandForm","AutoCommandForm","capability","command","inputs","exclude","descriptors","propertyDescriptors","Array","isArray","byName","Map","descriptor","name","isOptional","has","set","input","get","property","type","Guid","String","values","some","includes","Number","Boolean","Date","undefined","CommandFormRuntime","submitLabel","error","_jsx","div","role","_jsxs","CommandForm","showTitles","map","ExplicitCommandField","CommandFormSubmit","label","footer"],"mappings":";;;;;;;AAAA;AACA;AAkBA;AACA,MAAMA,qBAAAA,GAAwBC,eAAAA;AAQ9B,mGACA,SAASC,UAAAA,CAAWC,OAAyB,EAAEC,MAAuB,EAAEC,OAAkB,EAAA;IACtF,IAAIC,WAAAA;IACJ,IAAI;QAAEA,WAAAA,GAAe,IAAIH,OAAAA,EAAAA,CAAgDI,mBAAmB;AAAE,IAAA,CAAA,CAC9F,OAAM;QAAE,OAAO,iCAAA;AAAmC,IAAA;AAClD,IAAA,IAAI,CAACC,KAAAA,CAAMC,OAAO,CAACH,cAAc,OAAO,2CAAA;AACxC,IAAA,MAAMI,SAAS,IAAIC,GAAAA,EAAAA;IACnB,KAAK,MAAMC,cAAcN,WAAAA,CAAa;QAClC,IAAI,CAACM,cAAc,OAAOA,UAAAA,CAAWC,IAAI,KAAK,QAAA,IAAY,CAACD,UAAAA,CAAWC,IAAI,IACtE,OAAOD,UAAAA,CAAWE,UAAU,KAAK,SAAA,IAAaJ,MAAAA,CAAOK,GAAG,CAACH,UAAAA,CAAWC,IAAI,CAAA,EAAG,OAAO,mDAAA;AACtFH,QAAAA,MAAAA,CAAOM,GAAG,CAACJ,UAAAA,CAAWC,IAAI,EAAED,UAAAA,CAAAA;AAChC,IAAA;AACA,IAAA,IAAIR,MAAAA,EAAQ;QACR,KAAK,MAAMa,SAASb,MAAAA,CAAQ;AACxB,YAAA,MAAMQ,UAAAA,GAAaF,MAAAA,CAAOQ,GAAG,CAACD,MAAME,QAAQ,CAAA;YAC5C,IAAI,CAACP,UAAAA,EAAY,OAAO,CAAC,0BAA0B,EAAEK,KAAAA,CAAME,QAAQ,CAAC,CAAC,CAAC;YACtE,IAAIP,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,GAAA,CAACC,KAAAA,EAAAA;QAAIC,IAAAA,EAAK,OAAA;AAASH,QAAAA,QAAAA,EAAAA;;;IAErC,IAAI5B,MAAAA,EAAQ,qBAAOgC,IAAA,CAACC,WAAAA,EAAAA;QAAYlC,OAAAA,EAASA,OAAAA;QAAwCmC,UAAAA,EAAY,KAAA;;AACxFlC,YAAAA,MAAAA,CAAOmC,GAAG,CAACtB,CAAAA,KAAAA,iBAASgB,GAAA,CAACO,oBAAAA,EAAAA;oBAA0CvB,KAAAA,EAAOA;AAAvBA,iBAAAA,EAAAA,KAAAA,CAAME,QAAQ,CAAA,CAAA;0BAC9Dc,GAAA,CAACQ,iBAAAA,EAAAA;gBAAkBC,KAAAA,EAAOX;;;;AAE9B,IAAA,qBAAOE,GAAA,CAACjC,qBAAAA,EAAAA;QAAsBG,OAAAA,EAASA,OAAAA;QAASE,OAAAA,EAASA,OAAAA;AAASsC,QAAAA,MAAAA,gBAAQV,GAAA,CAACQ,iBAAAA,EAAAA;YAAkBC,KAAAA,EAAOX;;;AACxG;;"}
1
+ {"version":3,"file":"CommandFormRuntime.js","sources":["../../../forms/CommandFormRuntime.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { ComponentType, ReactNode } from 'react';\nimport { AutoCommandForm } from '@cratis/components/CommandForm';\nimport { CommandForm } from '@cratis/arc.react/commands';\nimport { Guid } from '@cratis/fundamentals';\nimport type { BoundConstructor } from '../bindings';\nimport type { CommandInput } from './commandInputs';\nimport { CommandFormSubmit } from './CommandFormSubmit';\nimport { ExplicitCommandField } from './ExplicitCommandField';\n\ninterface CommandFormRuntimeProps {\n command: BoundConstructor;\n inputs?: CommandInput[];\n exclude?: string[];\n submitLabel: string;\n columns?: number;\n}\n\n// Runtime bindings erase the proxy's keys; the optional footer is a Components >=4.13 contract.\nconst NativeAutoCommandForm = AutoCommandForm as unknown as ComponentType<{\n command: BoundConstructor;\n exclude?: string[];\n footer?: ReactNode;\n}>;\n\ntype Descriptor = { name: string; type: unknown; isOptional: boolean };\n\n/** Verify the whole command before mounting any native form: partial forms must never execute. */\nfunction capability(command: BoundConstructor, inputs?: CommandInput[], exclude?: string[]): string | undefined {\n let descriptors: unknown;\n try { descriptors = (new command() as { propertyDescriptors?: unknown }).propertyDescriptors; }\n catch { return 'Unable to inspect command proxy'; }\n if (!Array.isArray(descriptors)) return 'Command proxy has no property descriptors';\n const byName = new Map<string, Descriptor>();\n for (const descriptor of descriptors) {\n if (!descriptor || typeof descriptor.name !== 'string' || !descriptor.name ||\n typeof descriptor.isOptional !== 'boolean' || byName.has(descriptor.name)) return 'Ambiguous or invalid command property descriptors';\n byName.set(descriptor.name, descriptor);\n }\n if (inputs) {\n for (const input of inputs) {\n const descriptor = byName.get(input.property);\n if (!descriptor) return `Unknown command property '${input.property}'`;\n if (descriptor.type !== (input.type === 'guid' ? Guid : String)) return `Command property '${input.property}' type does not match '${input.type}'`;\n }\n for (const descriptor of byName.values()) {\n if (!descriptor.isOptional && !inputs.some(input => input.property === descriptor.name)) return `Required command property '${descriptor.name}' has no input`;\n }\n } else {\n for (const descriptor of byName.values()) {\n if (!descriptor.isOptional && (exclude?.includes(descriptor.name) ||\n ![String, Number, Boolean, Date].includes(descriptor.type as typeof String))) {\n return `Required command property '${descriptor.name}' has no supported automatic field; declare inputs`;\n }\n }\n }\n return undefined;\n}\n\n/** Private lazy entry point: importing the Scene registry must not import Arc. */\nexport default function CommandFormRuntime({ command, inputs, exclude, submitLabel, columns = 1 }: CommandFormRuntimeProps) {\n const error = capability(command, inputs, exclude);\n if (error) return <div role='alert'>{error}</div>;\n // The registry's never-argument constructor is erased; Arc creates this checked proxy with no args.\n if (inputs) return <CommandForm command={command as unknown as new () => object} showTitles={false}>\n <div style={{ display: 'grid', gridTemplateColumns: `repeat(${Math.max(1, columns)}, minmax(0, 1fr))`, gap: '1rem' }}>\n {inputs.map(input => <ExplicitCommandField key={input.property} input={input} />)}\n </div>\n <CommandFormSubmit label={submitLabel} />\n </CommandForm>;\n return <NativeAutoCommandForm command={command} exclude={exclude} footer={<CommandFormSubmit label={submitLabel} />} />;\n}\n"],"names":["NativeAutoCommandForm","AutoCommandForm","capability","command","inputs","exclude","descriptors","propertyDescriptors","Array","isArray","byName","Map","descriptor","name","isOptional","has","set","input","get","property","type","Guid","String","values","some","includes","Number","Boolean","Date","undefined","CommandFormRuntime","submitLabel","columns","error","_jsx","div","role","_jsxs","CommandForm","showTitles","style","display","gridTemplateColumns","Math","max","gap","map","ExplicitCommandField","CommandFormSubmit","label","footer"],"mappings":";;;;;;;AAAA;AACA;AAmBA;AACA,MAAMA,qBAAAA,GAAwBC,eAAAA;AAQ9B,mGACA,SAASC,UAAAA,CAAWC,OAAyB,EAAEC,MAAuB,EAAEC,OAAkB,EAAA;IACtF,IAAIC,WAAAA;IACJ,IAAI;QAAEA,WAAAA,GAAe,IAAIH,OAAAA,EAAAA,CAAgDI,mBAAmB;AAAE,IAAA,CAAA,CAC9F,OAAM;QAAE,OAAO,iCAAA;AAAmC,IAAA;AAClD,IAAA,IAAI,CAACC,KAAAA,CAAMC,OAAO,CAACH,cAAc,OAAO,2CAAA;AACxC,IAAA,MAAMI,SAAS,IAAIC,GAAAA,EAAAA;IACnB,KAAK,MAAMC,cAAcN,WAAAA,CAAa;QAClC,IAAI,CAACM,cAAc,OAAOA,UAAAA,CAAWC,IAAI,KAAK,QAAA,IAAY,CAACD,UAAAA,CAAWC,IAAI,IACtE,OAAOD,UAAAA,CAAWE,UAAU,KAAK,SAAA,IAAaJ,MAAAA,CAAOK,GAAG,CAACH,UAAAA,CAAWC,IAAI,CAAA,EAAG,OAAO,mDAAA;AACtFH,QAAAA,MAAAA,CAAOM,GAAG,CAACJ,UAAAA,CAAWC,IAAI,EAAED,UAAAA,CAAAA;AAChC,IAAA;AACA,IAAA,IAAIR,MAAAA,EAAQ;QACR,KAAK,MAAMa,SAASb,MAAAA,CAAQ;AACxB,YAAA,MAAMQ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,YAAY,EAAE,MAAM,iBAAiB,CAAC;AA4EpD,wBAAgB,oBAAoB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,YAAY,CAAA;CAAE,+BAGtE"}
1
+ {"version":3,"file":"ExplicitCommandField.d.ts","sourceRoot":"","sources":["../../../forms/ExplicitCommandField.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AA4EpD,wBAAgB,oBAAoB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,YAAY,CAAA;CAAE,+BAKtE"}
@@ -93,13 +93,19 @@ const NativeTextField = asCommandFormField(TextControl, {
93
93
  defaultValue: ''
94
94
  });
95
95
  /** Opaque child is self-bound by Arc's native runtime binding, with an exact fieldName. */ function ExplicitCommandField({ input }) {
96
- return /*#__PURE__*/ jsx(NativeTextField, {
97
- fieldName: input.property,
98
- value: (command)=>command[input.property],
99
- property: input.property,
100
- guid: input.type === 'guid',
101
- label: input.label,
102
- title: input.label
96
+ return /*#__PURE__*/ jsx("div", {
97
+ style: {
98
+ gridColumn: input.column === undefined ? undefined : `${input.column}`,
99
+ width: input.width
100
+ },
101
+ children: /*#__PURE__*/ jsx(NativeTextField, {
102
+ fieldName: input.property,
103
+ value: (command)=>command[input.property],
104
+ property: input.property,
105
+ guid: input.type === 'guid',
106
+ label: input.label,
107
+ title: input.label
108
+ })
103
109
  });
104
110
  }
105
111
 
@@ -1 +1 @@
1
- {"version":3,"file":"ExplicitCommandField.js","sources":["../../../forms/ExplicitCommandField.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useId, useLayoutEffect, useRef, useState } from 'react';\nimport { asCommandFormField, useCommandFormContext } from '@cratis/arc.react/commands';\nimport { Guid } from '@cratis/fundamentals';\nimport type { CommandInput } from './commandInputs';\n\ninterface TextProps {\n value: unknown;\n onChange: (value: unknown) => void;\n onBlur?: () => void;\n invalid: boolean;\n required: boolean;\n errors: string[];\n label: string;\n property: string;\n guid: boolean;\n}\n\nfunction TextControl({ value, onChange, onBlur, invalid, required, errors, label, property, guid }: TextProps) {\n const id = useId();\n const context = useCommandFormContext();\n const { setCustomFieldError } = context;\n // Keep the latest native getter: the context snapshot can be stale when another field sets an\n // error and this field unmounts in the same event.\n const contextRef = useRef(context);\n contextRef.current = context;\n // The draft is intentionally independent of the typed proxy value: malformed text must never\n // reappear as a stale previously valid Guid in the command's serialized payload.\n const [draft, setDraft] = useState(() => value instanceof Guid && !value.equals(Guid.empty) ? value.toString() : '');\n const draftRef = useRef(draft);\n const ownedError = useRef<string | undefined>(undefined);\n const updateError = (error: string | undefined) => {\n const current = contextRef.current.getFieldError(property);\n // Do not replace or erase another producer's error for this field.\n if (ownedError.current !== undefined && current !== ownedError.current) {\n ownedError.current = undefined;\n return;\n }\n if (ownedError.current === undefined && Object.hasOwn(contextRef.current.customFieldErrors, property)) return;\n if (error === undefined && ownedError.current === undefined) return;\n ownedError.current = error;\n setCustomFieldError(property, error);\n };\n // A label/required change must recalculate the message without disposing the field's error.\n // Only a different field/type or an actual unmount relinquishes ownership.\n useLayoutEffect(() => () => {\n if (ownedError.current !== undefined && contextRef.current.getFieldError(property) === ownedError.current) {\n contextRef.current.setCustomFieldError(property, undefined);\n }\n ownedError.current = undefined;\n }, [property, guid]);\n useLayoutEffect(() => {\n if (guid) {\n const current = draftRef.current || (value instanceof Guid && !value.equals(Guid.empty) ? value.toString() : '');\n updateError(!current ? required ? `${label} is required` : undefined :\n !Guid.isGuid(current) ? `${label} must be a valid GUID` : undefined);\n }\n }, [guid, required, property, label, setCustomFieldError]);\n const text = guid ? draft : typeof value === 'string' ? value : '';\n return <div>\n <label htmlFor={id}>{label}</label>\n <input id={id} name={property} type='text' required={required} value={text}\n aria-invalid={invalid} aria-describedby={errors.length ? `${id}-error` : undefined}\n onBlur={onBlur} onChange={event => {\n const next = event.currentTarget.value;\n if (!guid) { onChange(next); return; }\n draftRef.current = next;\n setDraft(next);\n const error = !next ? required ? `${label} is required` : undefined : !Guid.isGuid(next) ? `${label} must be a valid GUID` : undefined;\n // A malformed draft clears the previously typed value, not just its display.\n onChange(error || !next ? undefined : Guid.parse(next));\n updateError(error);\n }} />\n {errors.length > 0 && <div id={`${id}-error`} role='alert'>{errors[0]}</div>}\n </div>;\n}\n\nconst NativeTextField = asCommandFormField<TextProps>(TextControl, { defaultValue: '' });\n\n/** Opaque child is self-bound by Arc's native runtime binding, with an exact fieldName. */\nexport function ExplicitCommandField({ input }: { input: CommandInput }) {\n return <NativeTextField fieldName={input.property} value={(command: Record<string, unknown>) => command[input.property]}\n property={input.property} guid={input.type === 'guid'} label={input.label} title={input.label} />;\n}\n"],"names":["TextControl","value","onChange","onBlur","invalid","required","errors","label","property","guid","id","useId","context","useCommandFormContext","setCustomFieldError","contextRef","useRef","current","draft","setDraft","useState","Guid","equals","empty","toString","draftRef","ownedError","undefined","updateError","error","getFieldError","Object","hasOwn","customFieldErrors","useLayoutEffect","isGuid","text","_jsxs","div","_jsx","htmlFor","input","name","type","aria-invalid","aria-describedby","length","event","next","currentTarget","parse","role","NativeTextField","asCommandFormField","defaultValue","ExplicitCommandField","fieldName","command","title"],"mappings":";;;;;AAoBA,SAASA,YAAY,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,IAAI,EAAa,EAAA;AACzG,IAAA,MAAMC,EAAAA,GAAKC,KAAAA,EAAAA;AACX,IAAA,MAAMC,OAAAA,GAAUC,qBAAAA,EAAAA;IAChB,MAAM,EAAEC,mBAAmB,EAAE,GAAGF,OAAAA;;;AAGhC,IAAA,MAAMG,aAAaC,MAAAA,CAAOJ,OAAAA,CAAAA;AAC1BG,IAAAA,UAAAA,CAAWE,OAAO,GAAGL,OAAAA;;;AAGrB,IAAA,MAAM,CAACM,KAAAA,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AAqB,EAAEd,KAAK,EAA2B,EAAA;AACnE,IAAA,qBAAOF,GAAA,CAACa,eAAAA,EAAAA;AAAgBI,QAAAA,SAAAA,EAAWf,MAAMjC,QAAQ;AAAEP,QAAAA,KAAAA,EAAO,CAACwD,OAAAA,GAAqCA,OAAO,CAAChB,KAAAA,CAAMjC,QAAQ,CAAC;AACnHA,QAAAA,QAAAA,EAAUiC,MAAMjC,QAAQ;QAAEC,IAAAA,EAAMgC,KAAAA,CAAME,IAAI,KAAK,MAAA;AAAQpC,QAAAA,KAAAA,EAAOkC,MAAMlC,KAAK;AAAEmD,QAAAA,KAAAA,EAAOjB,MAAMlC;;AAChG;;"}
1
+ {"version":3,"file":"ExplicitCommandField.js","sources":["../../../forms/ExplicitCommandField.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useId, useLayoutEffect, useRef, useState } from 'react';\nimport { asCommandFormField, useCommandFormContext } from '@cratis/arc.react/commands';\nimport { Guid } from '@cratis/fundamentals';\nimport type { CommandInput } from './commandInputs';\n\ninterface TextProps {\n value: unknown;\n onChange: (value: unknown) => void;\n onBlur?: () => void;\n invalid: boolean;\n required: boolean;\n errors: string[];\n label: string;\n property: string;\n guid: boolean;\n}\n\nfunction TextControl({ value, onChange, onBlur, invalid, required, errors, label, property, guid }: TextProps) {\n const id = useId();\n const context = useCommandFormContext();\n const { setCustomFieldError } = context;\n // Keep the latest native getter: the context snapshot can be stale when another field sets an\n // error and this field unmounts in the same event.\n const contextRef = useRef(context);\n contextRef.current = context;\n // The draft is intentionally independent of the typed proxy value: malformed text must never\n // reappear as a stale previously valid Guid in the command's serialized payload.\n const [draft, setDraft] = useState(() => value instanceof Guid && !value.equals(Guid.empty) ? value.toString() : '');\n const draftRef = useRef(draft);\n const ownedError = useRef<string | undefined>(undefined);\n const updateError = (error: string | undefined) => {\n const current = contextRef.current.getFieldError(property);\n // Do not replace or erase another producer's error for this field.\n if (ownedError.current !== undefined && current !== ownedError.current) {\n ownedError.current = undefined;\n return;\n }\n if (ownedError.current === undefined && Object.hasOwn(contextRef.current.customFieldErrors, property)) return;\n if (error === undefined && ownedError.current === undefined) return;\n ownedError.current = error;\n setCustomFieldError(property, error);\n };\n // A label/required change must recalculate the message without disposing the field's error.\n // Only a different field/type or an actual unmount relinquishes ownership.\n useLayoutEffect(() => () => {\n if (ownedError.current !== undefined && contextRef.current.getFieldError(property) === ownedError.current) {\n contextRef.current.setCustomFieldError(property, undefined);\n }\n ownedError.current = undefined;\n }, [property, guid]);\n useLayoutEffect(() => {\n if (guid) {\n const current = draftRef.current || (value instanceof Guid && !value.equals(Guid.empty) ? value.toString() : '');\n updateError(!current ? required ? `${label} is required` : undefined :\n !Guid.isGuid(current) ? `${label} must be a valid GUID` : undefined);\n }\n }, [guid, required, property, label, setCustomFieldError]);\n const text = guid ? draft : typeof value === 'string' ? value : '';\n return <div>\n <label htmlFor={id}>{label}</label>\n <input id={id} name={property} type='text' required={required} value={text}\n aria-invalid={invalid} aria-describedby={errors.length ? `${id}-error` : undefined}\n onBlur={onBlur} onChange={event => {\n const next = event.currentTarget.value;\n if (!guid) { onChange(next); return; }\n draftRef.current = next;\n setDraft(next);\n const error = !next ? required ? `${label} is required` : undefined : !Guid.isGuid(next) ? `${label} must be a valid GUID` : undefined;\n // A malformed draft clears the previously typed value, not just its display.\n onChange(error || !next ? undefined : Guid.parse(next));\n updateError(error);\n }} />\n {errors.length > 0 && <div id={`${id}-error`} role='alert'>{errors[0]}</div>}\n </div>;\n}\n\nconst NativeTextField = asCommandFormField<TextProps>(TextControl, { defaultValue: '' });\n\n/** Opaque child is self-bound by Arc's native runtime binding, with an exact fieldName. */\nexport function ExplicitCommandField({ input }: { input: CommandInput }) {\n return <div style={{ gridColumn: input.column === undefined ? undefined : `${input.column}`, width: input.width }}>\n <NativeTextField fieldName={input.property} value={(command: Record<string, unknown>) => command[input.property]}\n property={input.property} guid={input.type === 'guid'} label={input.label} title={input.label} />\n </div>;\n}\n"],"names":["TextControl","value","onChange","onBlur","invalid","required","errors","label","property","guid","id","useId","context","useCommandFormContext","setCustomFieldError","contextRef","useRef","current","draft","setDraft","useState","Guid","equals","empty","toString","draftRef","ownedError","undefined","updateError","error","getFieldError","Object","hasOwn","customFieldErrors","useLayoutEffect","isGuid","text","_jsxs","div","_jsx","htmlFor","input","name","type","aria-invalid","aria-describedby","length","event","next","currentTarget","parse","role","NativeTextField","asCommandFormField","defaultValue","ExplicitCommandField","style","gridColumn","column","width","fieldName","command","title"],"mappings":";;;;;AAoBA,SAASA,YAAY,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,IAAI,EAAa,EAAA;AACzG,IAAA,MAAMC,EAAAA,GAAKC,KAAAA,EAAAA;AACX,IAAA,MAAMC,OAAAA,GAAUC,qBAAAA,EAAAA;IAChB,MAAM,EAAEC,mBAAmB,EAAE,GAAGF,OAAAA;;;AAGhC,IAAA,MAAMG,aAAaC,MAAAA,CAAOJ,OAAAA,CAAAA;AAC1BG,IAAAA,UAAAA,CAAWE,OAAO,GAAGL,OAAAA;;;AAGrB,IAAA,MAAM,CAACM,KAAAA,EAAOC,QAAAA,CAAS,GAAGC,QAAAA,CAAS,IAAMnB,KAAAA,YAAiBoB,IAAAA,IAAQ,CAACpB,KAAAA,CAAMqB,MAAM,CAACD,IAAAA,CAAKE,KAAK,CAAA,GAAItB,KAAAA,CAAMuB,QAAQ,EAAA,GAAK,EAAA,CAAA;AACjH,IAAA,MAAMC,WAAWT,MAAAA,CAAOE,KAAAA,CAAAA;AACxB,IAAA,MAAMQ,aAAaV,MAAAA,CAA2BW,SAAAA,CAAAA;AAC9C,IAAA,MAAMC,cAAc,CAACC,KAAAA,GAAAA;AACjB,QAAA,MAAMZ,OAAAA,GAAUF,UAAAA,CAAWE,OAAO,CAACa,aAAa,CAACtB,QAAA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pB,KAAAA,CAAMjC,QAAQ,CAAC;AAC5GA,YAAAA,QAAAA,EAAUiC,MAAMjC,QAAQ;YAAEC,IAAAA,EAAMgC,KAAAA,CAAME,IAAI,KAAK,MAAA;AAAQpC,YAAAA,KAAAA,EAAOkC,MAAMlC,KAAK;AAAEuD,YAAAA,KAAAA,EAAOrB,MAAMlC;;;AAEpG;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SceneCommandForm.d.ts","sourceRoot":"","sources":["../../../forms/SceneCommandForm.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAyB/D,wBAAgB,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,+BAkBrE"}
1
+ {"version":3,"file":"SceneCommandForm.d.ts","sourceRoot":"","sources":["../../../forms/SceneCommandForm.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAyB/D,wBAAgB,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,+BAoBrE"}
@@ -4,7 +4,7 @@ import { BindingKind } from '../bindings/BindingKind.js';
4
4
  import { resolveElementBinding } from '../bindings/resolveElementBinding.js';
5
5
  import { MissingBinding } from '../bindings/MissingBinding.js';
6
6
  import { ArcRuntimeBoundary } from '../bindings/ArcRuntimeBoundary.js';
7
- import { stringProperty, stringArrayProperty } from '../properties.js';
7
+ import { unionProperty, numberProperty, stringProperty, stringArrayProperty } from '../properties.js';
8
8
  import { commandInputs } from './commandInputs.js';
9
9
 
10
10
  const CommandFormRuntime = /*#__PURE__*/ lazy(()=>import('./CommandFormRuntime.js'));
@@ -30,8 +30,12 @@ function commandKey(command) {
30
30
  kind: BindingKind.Command,
31
31
  name: name
32
32
  });
33
- const inputs = Object.hasOwn(element.properties, 'inputs') ? commandInputs(element.properties) : undefined;
34
- if (Object.hasOwn(element.properties, 'inputs') && !inputs) return /*#__PURE__*/ jsx("div", {
33
+ const mode = unionProperty(element.properties, 'mode', [
34
+ 'auto',
35
+ 'manual'
36
+ ]) ?? (Object.hasOwn(element.properties, 'inputs') ? 'manual' : 'auto');
37
+ const inputs = mode === 'manual' ? commandInputs(element.properties) : undefined;
38
+ if (mode === 'manual' && !inputs) return /*#__PURE__*/ jsx("div", {
35
39
  role: "alert",
36
40
  children: "Invalid command form inputs declaration"
37
41
  });
@@ -40,7 +44,10 @@ function commandKey(command) {
40
44
  command: target,
41
45
  inputs: inputs,
42
46
  exclude: stringArrayProperty(element.properties, 'exclude'),
43
- submitLabel: stringProperty(element.properties, 'submitLabel') ?? 'Submit'
47
+ submitLabel: stringProperty(element.properties, 'submitLabel') ?? 'Submit',
48
+ ...numberProperty(element.properties, 'columns') === undefined ? {} : {
49
+ columns: numberProperty(element.properties, 'columns')
50
+ }
44
51
  }, commandKey(target))
45
52
  });
46
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SceneCommandForm.js","sources":["../../../forms/SceneCommandForm.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { lazy } from 'react';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { ArcRuntimeBoundary, BindingKind, MissingBinding, resolveElementBinding } from '../bindings';\nimport type { BoundConstructor } from '../bindings';\nimport { stringArrayProperty, stringProperty } from '../properties';\nimport { commandInputs } from './commandInputs';\n\nconst CommandFormRuntime = lazy(() => import('./CommandFormRuntime'));\n\n// Arc's useCommand constructs the proxy only on mount. Key by the actual registered class,\n// not its Scene name (which may be re-registered with a different route or roles).\nconst commandKeys = new WeakMap<BoundConstructor, number>();\nlet nextCommandKey = 0;\nfunction commandKey(command: BoundConstructor): number {\n let key = commandKeys.get(command);\n if (key === undefined) {\n key = ++nextCommandKey;\n commandKeys.set(command, key);\n }\n return key;\n}\n\n/**\n * Auto mode follows supported native proxy descriptors; opt-in inputs bind exactly named fields\n * inside a single native Arc form. Neither mode consumes the content slot.\n */\nexport function SceneCommandForm({ element }: RegisteredComponentProps) {\n const { name, target } = resolveElementBinding(element, BindingKind.Command);\n if (!target) return <MissingBinding element={element} kind={BindingKind.Command} name={name} />;\n\n const inputs = Object.hasOwn(element.properties, 'inputs') ? commandInputs(element.properties) : undefined;\n if (Object.hasOwn(element.properties, 'inputs') && !inputs) return <div role='alert'>Invalid command form inputs declaration</div>;\n\n return (\n <ArcRuntimeBoundary>\n <CommandFormRuntime\n key={commandKey(target)}\n command={target}\n inputs={inputs}\n exclude={stringArrayProperty(element.properties, 'exclude')}\n submitLabel={stringProperty(element.properties, 'submitLabel') ?? 'Submit'}\n />\n </ArcRuntimeBoundary>\n );\n}\n"],"names":["CommandFormRuntime","lazy","commandKeys","WeakMap","nextCommandKey","commandKey","command","key","get","undefined","set","SceneCommandForm","element","name","target","resolveElementBinding","BindingKind","Command","_jsx","MissingBinding","kind","inputs","Object","hasOwn","properties","commandInputs","div","role","ArcRuntimeBoundary","exclude","stringArrayProperty","submitLabel","stringProperty"],"mappings":";;;;;;;;;AAUA,MAAMA,kBAAAA,iBAAqBC,IAAAA,CAAK,IAAM,OAAO,yBAAA,CAAA,CAAA;AAE7C;AACA;AACA,MAAMC,cAAc,IAAIC,OAAAA,EAAAA;AACxB,IAAIC,cAAAA,GAAiB,CAAA;AACrB,SAASC,WAAWC,OAAyB,EAAA;IACzC,IAAIC,GAAAA,GAAML,WAAAA,CAAYM,GAAG,CAACF,OAAAA,CAAAA;AAC1B,IAAA,IAAIC,QAAQE,SAAAA,EAAW;AACnBF,QAAAA,GAAAA,GAAM,EAAEH,cAAAA;QACRF,WAAAA,CAAYQ,GAAG,CAACJ,OAAAA,EAASC,GAAAA,CAAAA;AAC7B,IAAA;IACA,OAAOA,GAAAA;AACX;AAEA;;;AAGC,IACM,SAASI,gBAAAA,CAAiB,EAAEC,OAAO,EAA4B,EAAA;IAClE,MAAM,EAAEC,IAAI,EAAEC,MAAM,EAAE,GAAGC,qBAAAA,CAAsBH,OAAAA,EAASI,WAAAA,CAAYC,OAAO,CAAA;IAC3E,IAAI,CAACH,MAAAA,EAAQ,qBAAOI,GAAA,CAACC,cAAAA,EAAAA;QAAeP,OAAAA,EAASA,OAAAA;AAASQ,QAAAA,IAAAA,EAAMJ,YAAYC,OAAO;QAAEJ,IAAAA,EAAMA;;IAEvF,MAAMQ,MAAAA,GAASC,MAAAA,CAAOC,MAAM,CAACX,OAAAA,CAAQY,UAAU,EAAE,QAAA,CAAA,GAAYC,aAAAA,CAAcb,OAAAA,CAAQY,UAAU,CAAA,GAAIf,SAAAA;IACjG,IAAIa,MAAAA,CAAOC,MAAM,CAACX,OAAAA,CAAQY,UAAU,EAAE,QAAA,CAAA,IAAa,CAACH,MAAAA,EAAQ,qBAAOH,GAAA,CAACQ,KAAAA,EAAAA;QAAIC,IAAAA,EAAK,OAAA;AAAQ,QAAA,QAAA,EAAA;;AAErF,IAAA,qBACIT,GAAA,CAACU,kBAAAA,EAAAA;AACG,QAAA,QAAA,gBAAAV,GAAA,CAAClB,kBAAAA,EAAAA;YAEGM,OAAAA,EAASQ,MAAAA;YACTO,MAAAA,EAAQA,MAAAA;YACRQ,OAAAA,EAASC,mBAAAA,CAAoBlB,OAAAA,CAAQY,UAAU,EAAE,SAAA,CAAA;AACjDO,YAAAA,WAAAA,EAAaC,cAAAA,CAAepB,OAAAA,CAAQY,UAAU,EAAE,aAAA,CAAA,IAAkB;WAJ7DnB,UAAAA,CAAWS,MAAAA,CAAAA;;AAQhC;;"}
1
+ {"version":3,"file":"SceneCommandForm.js","sources":["../../../forms/SceneCommandForm.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { lazy } from 'react';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { ArcRuntimeBoundary, BindingKind, MissingBinding, resolveElementBinding } from '../bindings';\nimport type { BoundConstructor } from '../bindings';\nimport { numberProperty, stringArrayProperty, stringProperty, unionProperty } from '../properties';\nimport { commandInputs } from './commandInputs';\n\nconst CommandFormRuntime = lazy(() => import('./CommandFormRuntime'));\n\n// Arc's useCommand constructs the proxy only on mount. Key by the actual registered class,\n// not its Scene name (which may be re-registered with a different route or roles).\nconst commandKeys = new WeakMap<BoundConstructor, number>();\nlet nextCommandKey = 0;\nfunction commandKey(command: BoundConstructor): number {\n let key = commandKeys.get(command);\n if (key === undefined) {\n key = ++nextCommandKey;\n commandKeys.set(command, key);\n }\n return key;\n}\n\n/**\n * Auto mode follows supported native proxy descriptors; opt-in inputs bind exactly named fields\n * inside a single native Arc form. Neither mode consumes the content slot.\n */\nexport function SceneCommandForm({ element }: RegisteredComponentProps) {\n const { name, target } = resolveElementBinding(element, BindingKind.Command);\n if (!target) return <MissingBinding element={element} kind={BindingKind.Command} name={name} />;\n\n const mode = unionProperty(element.properties, 'mode', ['auto', 'manual'] as const) ?? (Object.hasOwn(element.properties, 'inputs') ? 'manual' : 'auto');\n const inputs = mode === 'manual' ? commandInputs(element.properties) : undefined;\n if (mode === 'manual' && !inputs) return <div role='alert'>Invalid command form inputs declaration</div>;\n\n return (\n <ArcRuntimeBoundary>\n <CommandFormRuntime\n key={commandKey(target)}\n command={target}\n inputs={inputs}\n exclude={stringArrayProperty(element.properties, 'exclude')}\n submitLabel={stringProperty(element.properties, 'submitLabel') ?? 'Submit'}\n {...(numberProperty(element.properties, 'columns') === undefined ? {} : { columns: numberProperty(element.properties, 'columns') })}\n />\n </ArcRuntimeBoundary>\n );\n}\n"],"names":["CommandFormRuntime","lazy","commandKeys","WeakMap","nextCommandKey","commandKey","command","key","get","undefined","set","SceneCommandForm","element","name","target","resolveElementBinding","BindingKind","Command","_jsx","MissingBinding","kind","mode","unionProperty","properties","Object","hasOwn","inputs","commandInputs","div","role","ArcRuntimeBoundary","exclude","stringArrayProperty","submitLabel","stringProperty","numberProperty","columns"],"mappings":";;;;;;;;;AAUA,MAAMA,kBAAAA,iBAAqBC,IAAAA,CAAK,IAAM,OAAO,yB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CAACY,kBAAAA,EAAAA;AACG,QAAA,QAAA,gBAAAZ,GAAA,CAAClB,kBAAAA,EAAAA;YAEGM,OAAAA,EAASQ,MAAAA;YACTY,MAAAA,EAAQA,MAAAA;YACRK,OAAAA,EAASC,mBAAAA,CAAoBpB,OAAAA,CAAQW,UAAU,EAAE,SAAA,CAAA;AACjDU,YAAAA,WAAAA,EAAaC,cAAAA,CAAetB,OAAAA,CAAQW,UAAU,EAAE,aAAA,CAAA,IAAkB,QAAA;AACjE,YAAA,GAAIY,eAAevB,OAAAA,CAAQW,UAAU,EAAE,SAAA,CAAA,KAAed,SAAAA,GAAY,EAAC,GAAI;gBAAE2B,OAAAA,EAASD,cAAAA,CAAevB,OAAAA,CAAQW,UAAU,EAAE,SAAA;;WALjHlB,UAAAA,CAAWS,MAAAA,CAAAA;;AAShC;;"}
@@ -2,6 +2,8 @@ export interface CommandInput {
2
2
  property: string;
3
3
  type: 'string' | 'guid';
4
4
  label: string;
5
+ column?: number;
6
+ width?: string;
5
7
  }
6
8
  export declare function commandInputs(properties: Record<string, unknown>): CommandInput[] | undefined;
7
9
  //# sourceMappingURL=commandInputs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"commandInputs.d.ts","sourceRoot":"","sources":["../../../forms/commandInputs.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,YAAY;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACjB;AAGD,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY,EAAE,GAAG,SAAS,CAe7F"}
1
+ {"version":3,"file":"commandInputs.d.ts","sourceRoot":"","sources":["../../../forms/commandInputs.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,YAAY;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAGD,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY,EAAE,GAAG,SAAS,CAiB7F"}
@@ -1,4 +1,4 @@
1
- import { arrayProperty, objectProperty, stringProperty } from '../properties.js';
1
+ import { arrayProperty, objectProperty, stringProperty, numberProperty } from '../properties.js';
2
2
 
3
3
  // Copyright (c) Cratis. All rights reserved.
4
4
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
@@ -14,16 +14,22 @@ import { arrayProperty, objectProperty, stringProperty } from '../properties.js'
14
14
  if (!input || Object.keys(input).some((key)=>![
15
15
  'property',
16
16
  'type',
17
- 'label'
17
+ 'label',
18
+ 'column',
19
+ 'width'
18
20
  ].includes(key))) return undefined;
19
21
  const property = stringProperty(input, 'property');
20
22
  const label = stringProperty(input, 'label');
21
23
  if (!property?.trim() || !label?.trim() || input.type !== 'string' && input.type !== 'guid' || seen.has(property)) return undefined;
22
24
  seen.add(property);
25
+ const column = numberProperty(input, 'column');
26
+ const width = stringProperty(input, 'width');
23
27
  inputs.push({
24
28
  property,
25
29
  type: input.type,
26
- label
30
+ label,
31
+ column,
32
+ width
27
33
  });
28
34
  }
29
35
  return inputs;
@@ -1 +1 @@
1
- {"version":3,"file":"commandInputs.js","sources":["../../../forms/commandInputs.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { arrayProperty, objectProperty, stringProperty } from '../properties';\n\n/** Exact, case-sensitive names from a generated command's propertyDescriptors. */\nexport interface CommandInput {\n property: string;\n type: 'string' | 'guid';\n label: string;\n}\n\n/** An absent declaration selects legacy auto mode; a present but invalid declaration never does. */\nexport function commandInputs(properties: Record<string, unknown>): CommandInput[] | undefined {\n const values = arrayProperty(properties, 'inputs');\n if (!values?.length) return undefined;\n const inputs: CommandInput[] = [];\n const seen = new Set<string>();\n for (const value of values) {\n const input = objectProperty({ value }, 'value');\n if (!input || Object.keys(input).some(key => !['property', 'type', 'label'].includes(key))) return undefined;\n const property = stringProperty(input, 'property');\n const label = stringProperty(input, 'label');\n if (!property?.trim() || !label?.trim() || (input.type !== 'string' && input.type !== 'guid') || seen.has(property)) return undefined;\n seen.add(property);\n inputs.push({ property, type: input.type, label });\n }\n return inputs;\n}\n"],"names":["commandInputs","properties","values","arrayProperty","length","undefined","inputs","seen","Set","value","input","objectProperty","Object","keys","some","key","includes","property","stringProperty","label","trim","type","has","add","push"],"mappings":";;AAAA;AACA;AAWA,qGACO,SAASA,aAAAA,CAAcC,UAAmC,EAAA;IAC7D,MAAMC,MAAAA,GAASC,cAAcF,UAAAA,EAAY,QAAA,CAAA;IACzC,IAAI,CAACC,MAAAA,EAAQE,MAAAA,EAAQ,OAAOC,SAAAA;AAC5B,IAAA,MAAMC,SAAyB,EAAE;AACjC,IAAA,MAAMC,OAAO,IAAIC,GAAAA,EAAAA;IACjB,KAAK,MAAMC,SAASP,MAAAA,CAAQ;AACxB,QAAA,MAAMQ,QAAQC,cAAAA,CAAe;AAAEF,YAAAA;SAAM,EAAG,OAAA,CAAA;QACxC,IAAI,CAACC,KAAAA,IAASE,MAAAA,CAAOC,IAAI,CAACH,OAAOI,IAAI,CAACC,CAAAA,GAAAA,GAAO,CAAC;AAAC,gBAAA,UAAA;AAAY,gBAAA,MAAA;AAAQ,gBAAA;aAAQ,CAACC,QAAQ,CAACD,GAAAA,CAAAA,CAAAA,EAAO,OAAOV,SAAAA;QACnG,MAAMY,QAAAA,GAAWC,eAAeR,KAAAA,EAAO,UAAA,CAAA;QACvC,MAAMS,KAAAA,GAAQD,eAAeR,KAAAA,EAAO,OAAA,CAAA;AACpC,QAAA,IAAI,CAACO,QAAAA,EAAUG,IAAAA,EAAAA,IAAU,CAACD,KAAAA,EAAOC,IAAAA,EAAAA,IAAWV,MAAMW,IAAI,KAAK,QAAA,IAAYX,KAAAA,CAAMW,IAAI,KAAK,MAAA,IAAWd,KAAKe,GAAG,CAACL,WAAW,OAAOZ,SAAAA;AAC5HE,QAAAA,IAAAA,CAAKgB,GAAG,CAACN,QAAAA,CAAAA;AACTX,QAAAA,MAAAA,CAAOkB,IAAI,CAAC;AAAEP,YAAAA,QAAAA;AAAUI,YAAAA,IAAAA,EAAMX,MAAMW,IAAI;AAAEF,YAAAA;AAAM,SAAA,CAAA;AACpD,IAAA;IACA,OAAOb,MAAAA;AACX;;"}
1
+ {"version":3,"file":"commandInputs.js","sources":["../../../forms/commandInputs.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { arrayProperty, numberProperty, objectProperty, stringProperty } from '../properties';\n\n/** Exact, case-sensitive names from a generated command's propertyDescriptors. */\nexport interface CommandInput {\n property: string;\n type: 'string' | 'guid';\n label: string;\n column?: number;\n width?: string;\n}\n\n/** An absent declaration selects legacy auto mode; a present but invalid declaration never does. */\nexport function commandInputs(properties: Record<string, unknown>): CommandInput[] | undefined {\n const values = arrayProperty(properties, 'inputs');\n if (!values?.length) return undefined;\n const inputs: CommandInput[] = [];\n const seen = new Set<string>();\n for (const value of values) {\n const input = objectProperty({ value }, 'value');\n if (!input || Object.keys(input).some(key => !['property', 'type', 'label', 'column', 'width'].includes(key))) return undefined;\n const property = stringProperty(input, 'property');\n const label = stringProperty(input, 'label');\n if (!property?.trim() || !label?.trim() || (input.type !== 'string' && input.type !== 'guid') || seen.has(property)) return undefined;\n seen.add(property);\n const column = numberProperty(input, 'column');\n const width = stringProperty(input, 'width');\n inputs.push({ property, type: input.type, label, column, width });\n }\n return inputs;\n}\n"],"names":["commandInputs","properties","values","arrayProperty","length","undefined","inputs","seen","Set","value","input","objectProperty","Object","keys","some","key","includes","property","stringProperty","label","trim","type","has","add","column","numberProperty","width","push"],"mappings":";;AAAA;AACA;AA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MAAMW,IAAI;AAAEF,YAAAA,KAAAA;AAAOK,YAAAA,MAAAA;AAAQE,YAAAA;AAAM,SAAA,CAAA;AACnE,IAAA;IACA,OAAOpB,MAAAA;AACX;;"}
@@ -0,0 +1,3 @@
1
+ import { DesignTimeAction } from '@cratis/scene.react';
2
+ export declare const generateCommandFieldsAction: DesignTimeAction;
3
+ //# sourceMappingURL=generateCommandFieldsAction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateCommandFieldsAction.d.ts","sourceRoot":"","sources":["../../../forms/generateCommandFieldsAction.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAmD,MAAM,qBAAqB,CAAC;AAGxG,eAAO,MAAM,2BAA2B,EAAE,gBAWzC,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { DesignTimeActionPlacement, SceneEditKind } from '@cratis/scene.model';
2
+
3
+ // Copyright (c) Cratis. All rights reserved.
4
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
+ const generateCommandFieldsAction = {
6
+ descriptor: {
7
+ id: 'Cratis.Components.commandForm.generateFields',
8
+ label: 'Generate fields',
9
+ placement: DesignTimeActionPlacement.Toolbar,
10
+ availability: 'commandForm.canGenerateFields',
11
+ description: 'Creates a deterministic editable field layout from the selected command metadata.'
12
+ },
13
+ isVisible: (context)=>context.element.componentName.endsWith(':commandForm'),
14
+ isEnabled: (context)=>Array.isArray(context.commandMetadata?.properties) && !Array.isArray(context.element.properties.inputs),
15
+ execute: (context)=>generateCommandFields(context)
16
+ };
17
+ function generateCommandFields(context) {
18
+ const properties = context.commandMetadata?.properties ?? [];
19
+ if (!properties.length) return {
20
+ edits: [],
21
+ diagnostics: [
22
+ 'No command metadata was supplied.'
23
+ ]
24
+ };
25
+ if (Array.isArray(context.element.properties.inputs)) {
26
+ return {
27
+ edits: [],
28
+ diagnostics: [
29
+ 'The form already has authored fields; Generate fields will not overwrite them.'
30
+ ]
31
+ };
32
+ }
33
+ return {
34
+ diagnostics: [],
35
+ edits: [
36
+ {
37
+ kind: SceneEditKind.SetProperty,
38
+ nodeId: context.element.id,
39
+ path: 'inputs',
40
+ value: properties.map((property, index)=>({
41
+ property: property.name,
42
+ type: property.type === 'Guid' || property.type === 'guid' ? 'guid' : 'string',
43
+ label: property.label ?? humanize(property.name),
44
+ column: index % 2 + 1,
45
+ width: '1fr'
46
+ }))
47
+ }
48
+ ]
49
+ };
50
+ }
51
+ function humanize(name) {
52
+ return name.replace(/([a-z0-9])([A-Z])/g, '$1 $2').replace(/^./, (value)=>value.toUpperCase());
53
+ }
54
+
55
+ export { generateCommandFieldsAction };
56
+ //# sourceMappingURL=generateCommandFieldsAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateCommandFieldsAction.js","sources":["../../../forms/generateCommandFieldsAction.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DesignTimeAction, DesignTimeActionContext, DesignTimeActionResult } from '@cratis/scene.react';\nimport { DesignTimeActionPlacement, SceneEditKind } from '@cratis/scene.model';\n\nexport const generateCommandFieldsAction: DesignTimeAction = {\n descriptor: {\n id: 'Cratis.Components.commandForm.generateFields',\n label: 'Generate fields',\n placement: DesignTimeActionPlacement.Toolbar,\n availability: 'commandForm.canGenerateFields',\n description: 'Creates a deterministic editable field layout from the selected command metadata.',\n },\n isVisible: context => context.element.componentName.endsWith(':commandForm'),\n isEnabled: context => Array.isArray(context.commandMetadata?.properties) && !Array.isArray(context.element.properties.inputs),\n execute: context => generateCommandFields(context),\n};\n\nfunction generateCommandFields(context: DesignTimeActionContext): DesignTimeActionResult {\n const properties = context.commandMetadata?.properties ?? [];\n if (!properties.length) return { edits: [], diagnostics: ['No command metadata was supplied.'] };\n if (Array.isArray(context.element.properties.inputs)) {\n return { edits: [], diagnostics: ['The form already has authored fields; Generate fields will not overwrite them.'] };\n }\n\n return {\n diagnostics: [],\n edits: [{\n kind: SceneEditKind.SetProperty,\n nodeId: context.element.id,\n path: 'inputs',\n value: properties.map((property, index) => ({\n property: property.name,\n type: property.type === 'Guid' || property.type === 'guid' ? 'guid' : 'string',\n label: property.label ?? humanize(property.name),\n column: (index % 2) + 1,\n width: '1fr',\n })),\n }],\n };\n}\n\nfunction humanize(name: string): string {\n return name.replace(/([a-z0-9])([A-Z])/g, '$1 $2').replace(/^./, value => value.toUpperCase());\n}\n"],"names":["generateCommandFieldsAction","descriptor","id","label","placement","DesignTimeActionPlacement","Toolbar","availability","description","isVisible","context","element","componentName","endsWith","isEnabled","Array","isArray","commandMetadata","properties","inputs","execute","generateCommandFields","length","edits","diagnostics","kind","SceneEditKind","SetProperty","nodeId","path","value","map","property","index","name","type","humanize","column","width","replace","toUpperCase"],"mappings":";;AAAA;AACA;MAKaA,2BAAAA,GAAgD;IACzDC,UAAAA,EAAY;QACRC,EAAAA,EAAI,8CAAA;QACJC,KAAAA,EAAO,iBAAA;AACPC,QAAAA,SAAAA,EAAWC,0BAA0BC,OAAO;QAC5CC,YAAAA,EAAc,+BAAA;QACdC,WAAAA,EAAa;AACjB,KAAA;IACAC,SAAAA,EAAWC,CAAAA,UAAWA,OAAAA,CAAQC,OAAO,CAACC,aAAa,CAACC,QAAQ,CAAC,cAAA,CAAA;AAC7DC,IAAAA,SAAAA,EAAWJ,CAAAA,OAAAA,GAAWK,KAAAA,CAAMC,OAAO,CAACN,OAAAA,CAAQO,eAAe,EAAEC,UAAAA,CAAAA,IAAe,CAACH,KAAAA,CAAMC,OAAO,CAACN,OAAAA,CAAQC,OAAO,CAACO,UAAU,CAACC,MAAM,CAAA;IAC5HC,OAAAA,EAASV,CAAAA,UAAWW,qBAAAA,CAAsBX,OAAAA;AAC9C;AAEA,SAASW,sBAAsBX,OAAgC,EAAA;AAC3D,IAAA,MAAMQ,UAAAA,GAAaR,OAAAA,CAAQO,eAAe,EAAEC,cAAc,EAAE;AAC5D,IAAA,IAAI,CAACA,UAAAA,CAAWI,MAAM,EAAE,OAAO;A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