@cratis/components 0.1.12 → 0.1.14
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/dist/cjs/CommandDialog/CommandDialog.js.map +1 -1
- package/dist/cjs/CommandForm/CommandForm.js +6 -2
- package/dist/cjs/CommandForm/CommandForm.js.map +1 -1
- package/dist/cjs/CommandForm/CommandFormFields.js.map +1 -1
- package/dist/cjs/DataTables/DataTableForObservableQuery.js.map +1 -1
- package/dist/cjs/DataTables/DataTableForQuery.js.map +1 -1
- package/dist/cjs/PivotViewer/PivotViewer.js +57 -378
- package/dist/cjs/PivotViewer/PivotViewer.js.map +1 -1
- package/dist/cjs/PivotViewer/components/PivotCanvas.js +3 -3
- package/dist/cjs/PivotViewer/components/PivotCanvas.js.map +1 -1
- package/dist/cjs/PivotViewer/components/PivotViewerMain.js.map +1 -1
- package/dist/cjs/PivotViewer/components/RangeHistogramFilter.js.map +1 -1
- package/dist/cjs/PivotViewer/components/pivot/buckets.js.map +1 -1
- package/dist/cjs/PivotViewer/components/pivot/sprites.js +1 -1
- package/dist/cjs/PivotViewer/components/pivot/sprites.js.map +1 -1
- package/dist/cjs/PivotViewer/components/pivot/visibility.js.map +1 -1
- package/dist/cjs/PivotViewer/hooks/useAnimationModeTracking.js +37 -0
- package/dist/cjs/PivotViewer/hooks/useAnimationModeTracking.js.map +1 -0
- package/dist/cjs/PivotViewer/hooks/useCardSelection.js +64 -0
- package/dist/cjs/PivotViewer/hooks/useCardSelection.js.map +1 -0
- package/dist/cjs/PivotViewer/hooks/useCurrentFilters.js +52 -0
- package/dist/cjs/PivotViewer/hooks/useCurrentFilters.js.map +1 -0
- package/dist/cjs/PivotViewer/hooks/useDetailPanelClose.js +63 -0
- package/dist/cjs/PivotViewer/hooks/useDetailPanelClose.js.map +1 -0
- package/dist/cjs/PivotViewer/hooks/useFieldExtractors.js +50 -0
- package/dist/cjs/PivotViewer/hooks/useFieldExtractors.js.map +1 -0
- package/dist/cjs/PivotViewer/hooks/usePanning.js.map +1 -1
- package/dist/cjs/PivotViewer/hooks/usePivotEngine.js.map +1 -1
- package/dist/cjs/PivotViewer/hooks/useScrollSync.js +21 -0
- package/dist/cjs/PivotViewer/hooks/useScrollSync.js.map +1 -0
- package/dist/cjs/PivotViewer/hooks/useViewModeScrollHandling.js +42 -0
- package/dist/cjs/PivotViewer/hooks/useViewModeScrollHandling.js.map +1 -0
- package/dist/cjs/PivotViewer/types.js.map +1 -1
- package/dist/cjs/PivotViewer/utils/cardPosition.js +67 -0
- package/dist/cjs/PivotViewer/utils/cardPosition.js.map +1 -0
- package/dist/cjs/PivotViewer/utils/constants.js +4 -0
- package/dist/cjs/PivotViewer/utils/constants.js.map +1 -1
- package/dist/cjs/PivotViewer/utils/idResolution.js +34 -0
- package/dist/cjs/PivotViewer/utils/idResolution.js.map +1 -0
- package/dist/esm/CommandDialog/CommandDialog.d.ts +2 -2
- package/dist/esm/CommandDialog/CommandDialog.d.ts.map +1 -1
- package/dist/esm/CommandDialog/CommandDialog.js.map +1 -1
- package/dist/esm/CommandForm/CommandForm.d.ts +2 -2
- package/dist/esm/CommandForm/CommandForm.d.ts.map +1 -1
- package/dist/esm/CommandForm/CommandForm.js +6 -2
- package/dist/esm/CommandForm/CommandForm.js.map +1 -1
- package/dist/esm/CommandForm/CommandFormFields.d.ts +2 -2
- package/dist/esm/CommandForm/CommandFormFields.d.ts.map +1 -1
- package/dist/esm/CommandForm/CommandFormFields.js.map +1 -1
- package/dist/esm/Common/ErrorBoundary.stories.d.ts +1 -1
- package/dist/esm/Common/ErrorBoundary.stories.js.map +1 -1
- package/dist/esm/Common/FormElement.stories.d.ts +1 -1
- package/dist/esm/Common/FormElement.stories.js.map +1 -1
- package/dist/esm/Common/Page.stories.d.ts +1 -1
- package/dist/esm/Common/Page.stories.js.map +1 -1
- package/dist/esm/DataPage/DataPage.stories.d.ts +1 -1
- package/dist/esm/DataPage/DataPage.stories.js.map +1 -1
- package/dist/esm/DataTables/DataTableForObservableQuery.d.ts +4 -4
- package/dist/esm/DataTables/DataTableForObservableQuery.d.ts.map +1 -1
- package/dist/esm/DataTables/DataTableForObservableQuery.js.map +1 -1
- package/dist/esm/DataTables/DataTableForObservableQuery.stories.d.ts +1 -1
- package/dist/esm/DataTables/DataTableForObservableQuery.stories.js.map +1 -1
- package/dist/esm/DataTables/DataTableForQuery.d.ts +4 -4
- package/dist/esm/DataTables/DataTableForQuery.d.ts.map +1 -1
- package/dist/esm/DataTables/DataTableForQuery.js.map +1 -1
- package/dist/esm/DataTables/DataTableForQuery.stories.d.ts +1 -1
- package/dist/esm/DataTables/DataTableForQuery.stories.js.map +1 -1
- package/dist/esm/Dialogs/ConfirmationDialog.stories.js.map +1 -1
- package/dist/esm/PivotViewer/PivotViewer.d.ts.map +1 -1
- package/dist/esm/PivotViewer/PivotViewer.js +57 -378
- package/dist/esm/PivotViewer/PivotViewer.js.map +1 -1
- package/dist/esm/PivotViewer/components/PivotCanvas.d.ts +2 -2
- package/dist/esm/PivotViewer/components/PivotCanvas.d.ts.map +1 -1
- package/dist/esm/PivotViewer/components/PivotCanvas.js +3 -3
- package/dist/esm/PivotViewer/components/PivotCanvas.js.map +1 -1
- package/dist/esm/PivotViewer/components/PivotViewerMain.js.map +1 -1
- package/dist/esm/PivotViewer/components/RangeHistogramFilter.js.map +1 -1
- package/dist/esm/PivotViewer/components/pivot/buckets.js.map +1 -1
- package/dist/esm/PivotViewer/components/pivot/sprites.js +1 -1
- package/dist/esm/PivotViewer/components/pivot/sprites.js.map +1 -1
- package/dist/esm/PivotViewer/components/pivot/visibility.js.map +1 -1
- package/dist/esm/PivotViewer/engine/pivot.worker.d.ts.map +1 -1
- package/dist/esm/PivotViewer/engine/pivot.worker.js.map +1 -1
- package/dist/esm/PivotViewer/hooks/index.d.ts +7 -0
- package/dist/esm/PivotViewer/hooks/index.d.ts.map +1 -1
- package/dist/esm/PivotViewer/hooks/index.js +7 -0
- package/dist/esm/PivotViewer/hooks/index.js.map +1 -1
- package/dist/esm/PivotViewer/hooks/useAnimationModeTracking.d.ts +2 -0
- package/dist/esm/PivotViewer/hooks/useAnimationModeTracking.d.ts.map +1 -0
- package/dist/esm/PivotViewer/hooks/useAnimationModeTracking.js +35 -0
- package/dist/esm/PivotViewer/hooks/useAnimationModeTracking.js.map +1 -0
- package/dist/esm/PivotViewer/hooks/useCardSelection.d.ts +37 -0
- package/dist/esm/PivotViewer/hooks/useCardSelection.d.ts.map +1 -0
- package/dist/esm/PivotViewer/hooks/useCardSelection.js +62 -0
- package/dist/esm/PivotViewer/hooks/useCardSelection.js.map +1 -0
- package/dist/esm/PivotViewer/hooks/useCurrentFilters.d.ts +5 -0
- package/dist/esm/PivotViewer/hooks/useCurrentFilters.d.ts.map +1 -0
- package/dist/esm/PivotViewer/hooks/useCurrentFilters.js +49 -0
- package/dist/esm/PivotViewer/hooks/useCurrentFilters.js.map +1 -0
- package/dist/esm/PivotViewer/hooks/useDetailPanelClose.d.ts +27 -0
- package/dist/esm/PivotViewer/hooks/useDetailPanelClose.d.ts.map +1 -0
- package/dist/esm/PivotViewer/hooks/useDetailPanelClose.js +61 -0
- package/dist/esm/PivotViewer/hooks/useDetailPanelClose.js.map +1 -0
- package/dist/esm/PivotViewer/hooks/useFieldExtractors.d.ts +7 -0
- package/dist/esm/PivotViewer/hooks/useFieldExtractors.d.ts.map +1 -0
- package/dist/esm/PivotViewer/hooks/useFieldExtractors.js +48 -0
- package/dist/esm/PivotViewer/hooks/useFieldExtractors.js.map +1 -0
- package/dist/esm/PivotViewer/hooks/useFilterPanelDrag.js.map +1 -1
- package/dist/esm/PivotViewer/hooks/usePanning.js.map +1 -1
- package/dist/esm/PivotViewer/hooks/usePivotEngine.js.map +1 -1
- package/dist/esm/PivotViewer/hooks/useScrollSync.d.ts +3 -0
- package/dist/esm/PivotViewer/hooks/useScrollSync.d.ts.map +1 -0
- package/dist/esm/PivotViewer/hooks/useScrollSync.js +19 -0
- package/dist/esm/PivotViewer/hooks/useScrollSync.js.map +1 -0
- package/dist/esm/PivotViewer/hooks/useViewModeScrollHandling.d.ts +16 -0
- package/dist/esm/PivotViewer/hooks/useViewModeScrollHandling.d.ts.map +1 -0
- package/dist/esm/PivotViewer/hooks/useViewModeScrollHandling.js +40 -0
- package/dist/esm/PivotViewer/hooks/useViewModeScrollHandling.js.map +1 -0
- package/dist/esm/PivotViewer/types.js.map +1 -1
- package/dist/esm/PivotViewer/utils/cardPosition.d.ts +18 -0
- package/dist/esm/PivotViewer/utils/cardPosition.d.ts.map +1 -0
- package/dist/esm/PivotViewer/utils/cardPosition.js +63 -0
- package/dist/esm/PivotViewer/utils/cardPosition.js.map +1 -0
- package/dist/esm/PivotViewer/utils/constants.js +3 -1
- package/dist/esm/PivotViewer/utils/constants.js.map +1 -1
- package/dist/esm/PivotViewer/utils/idResolution.d.ts +13 -0
- package/dist/esm/PivotViewer/utils/idResolution.d.ts.map +1 -0
- package/dist/esm/PivotViewer/utils/idResolution.js +31 -0
- package/dist/esm/PivotViewer/utils/idResolution.js.map +1 -0
- package/dist/esm/PivotViewer/utils/index.d.ts +2 -0
- package/dist/esm/PivotViewer/utils/index.d.ts.map +1 -1
- package/dist/esm/PivotViewer/utils/index.js +2 -0
- package/dist/esm/PivotViewer/utils/index.js.map +1 -1
- package/dist/esm/TimeMachine/EventsView.stories.d.ts +1 -1
- package/dist/esm/TimeMachine/EventsView.stories.js.map +1 -1
- package/dist/esm/TimeMachine/Properties.stories.d.ts +1 -1
- package/dist/esm/TimeMachine/Properties.stories.js.map +1 -1
- package/dist/esm/TimeMachine/ReadModelView.stories.d.ts +1 -1
- package/dist/esm/TimeMachine/ReadModelView.stories.js.map +1 -1
- package/dist/esm/TimeMachine/TimeMachine.stories.d.ts +1 -1
- package/dist/esm/TimeMachine/TimeMachine.stories.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/vite.config.js.map +1 -1
- package/dist/esm/vitest.setup.d.ts +2 -0
- package/dist/esm/vitest.setup.d.ts.map +1 -0
- package/dist/esm/vitest.setup.js +8 -0
- package/dist/esm/vitest.setup.js.map +1 -0
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandForm.js","sources":["../../../CommandForm/CommandForm.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 { CommandFormFields, ColumnInfo } from './CommandFormFields';\nimport { Constructor } from '@cratis/fundamentals';\nimport { useCommand, SetCommandValues } from '@cratis/arc.react/commands';\nimport { ICommandResult } from '@cratis/arc/commands';\nimport React, { createContext, useContext, useMemo, useState, useCallback } from 'react';\nimport type { CommandFormFieldProps } from './CommandFormField';\nimport { Panel } from 'primereact/panel';\n\nexport type BeforeExecuteCallback<TCommand> = (values: TCommand) => TCommand;\n\nexport interface CommandFormProps<TCommand extends object> {\n command: Constructor<TCommand>;\n initialValues?: Partial<TCommand>;\n currentValues?: Partial<TCommand> | undefined;\n onFieldValidate?: (command: TCommand, fieldName: string, oldValue: unknown, newValue: unknown) => string | undefined;\n onFieldChange?: (command: TCommand, fieldName: string, oldValue: unknown, newValue: unknown) => void;\n onBeforeExecute?: BeforeExecuteCallback<TCommand>;\n children?: React.ReactNode;\n}\n\ninterface CommandFormContextValue<TCommand> {\n command: Constructor<TCommand>;\n commandInstance: TCommand;\n setCommandValues: SetCommandValues<TCommand>;\n commandResult?: ICommandResult<unknown>;\n setCommandResult: (result: ICommandResult<unknown>) => void;\n getFieldError: (propertyName: string) => string | undefined;\n isValid: boolean;\n setFieldValidity: (fieldName: string, isValid: boolean) => void;\n onFieldValidate?: (command: TCommand, fieldName: string, oldValue: unknown, newValue: unknown) => string | undefined;\n onFieldChange?: (command: TCommand, fieldName: string, oldValue: unknown, newValue: unknown) => void;\n onBeforeExecute?: BeforeExecuteCallback<TCommand>;\n customFieldErrors: Record<string, string>;\n setCustomFieldError: (fieldName: string, error: string | undefined) => void;\n}\n\nconst CommandFormContext = createContext<CommandFormContextValue<any> | undefined>(undefined);\n\nexport const useCommandFormContext = <TCommand,>() => {\n const context = useContext(CommandFormContext);\n if (!context) {\n throw new Error('useCommandFormContext must be used within a CommandForm');\n }\n return context as CommandFormContextValue<TCommand>;\n};\n\n// Hook to get just the command instance for easier access\nexport const useCommandInstance = <TCommand = any>() => {\n const { commandInstance } = useCommandFormContext<any>();\n return commandInstance as TCommand;\n};\n\n// Hook to get setCommandResult for easier access\nexport const useSetCommandResult = () => {\n const { setCommandResult } = useCommandFormContext();\n return setCommandResult;\n};\n\nconst CommandFormFieldsWrapper = (props: { children: React.ReactNode }) => {\n React.Children.forEach(props.children, child => {\n if (React.isValidElement(child)) {\n const component = child.type as any;\n if (component.displayName !== 'CommandFormField') {\n throw new Error(`Only CommandFormField components are allowed as children of CommandForm.Fields. Got: ${component.displayName || component.name || 'Unknown'}`);\n }\n }\n });\n\n return <></>;\n};\n\nCommandFormFieldsWrapper.displayName = 'CommandFormFieldsWrapper';\n\nconst getCommandFormFields = <TCommand,>(props: { children?: React.ReactNode }): { fieldsOrColumns: React.ReactElement[] | ColumnInfo[], otherChildren: React.ReactNode[], initialValuesFromFields: Partial<TCommand> } => {\n if (!props.children) {\n return { fieldsOrColumns: [], otherChildren: [], initialValuesFromFields: {} };\n }\n let fields: React.ReactElement<CommandFormFieldProps<any>>[] = [];\n const columns: ColumnInfo[] = [];\n let hasColumns = false;\n const otherChildren: React.ReactNode[] = [];\n let initialValuesFromFields: Partial<TCommand> = {};\n\n const extractInitialValue = (field: React.ReactElement) => {\n const fieldProps = field.props as any;\n if (fieldProps.currentValue !== undefined && fieldProps.value) {\n const propertyAccessor = fieldProps.value;\n const propertyName = getPropertyNameFromAccessor(propertyAccessor);\n if (propertyName) {\n initialValuesFromFields = { ...initialValuesFromFields, [propertyName]: fieldProps.currentValue } as Partial<TCommand>;\n }\n }\n };\n\n React.Children.toArray(props.children).forEach(child => {\n if (!React.isValidElement(child)) {\n otherChildren.push(child);\n return;\n }\n\n const component = child.type as any;\n\n // Check if child is a CommandFormColumn\n if (component.displayName === 'CommandFormColumn') {\n hasColumns = true;\n const childProps = child.props as { children?: React.ReactNode };\n const columnFields = React.Children.toArray(childProps.children).filter(child => {\n if (React.isValidElement(child)) {\n const comp = child.type as any;\n if (comp.displayName === 'CommandFormField') {\n extractInitialValue(child as React.ReactElement);\n return true;\n }\n }\n return false;\n }) as React.ReactElement[];\n columns.push({ fields: columnFields as React.ReactElement<CommandFormFieldProps<any>>[] });\n }\n // Check if child is a CommandFormField (direct child)\n else if (component.displayName === 'CommandFormField') {\n extractInitialValue(child as React.ReactElement);\n fields.push(child as React.ReactElement<CommandFormFieldProps<any>>);\n }\n // Check if child is Fields wrapper (backwards compatibility)\n else if (component === CommandFormFieldsWrapper || component.displayName === 'CommandFormFieldsWrapper') {\n const childProps = child.props as { children: React.ReactNode };\n const relevantChildren = React.Children.toArray(childProps.children).filter(child => {\n if (React.isValidElement(child)) {\n const component = child.type as any;\n if (component.displayName === 'CommandFormField') {\n extractInitialValue(child as React.ReactElement);\n return true;\n }\n }\n return false;\n }) as React.ReactElement[];\n fields = [...fields, ...(relevantChildren as React.ReactElement<CommandFormFieldProps<any>>[])];\n }\n // Everything else is not a field, keep it as other children\n else {\n otherChildren.push(child);\n }\n });\n\n return { fieldsOrColumns: hasColumns ? columns : fields, otherChildren, initialValuesFromFields };\n};\n\n// Helper function to extract property name from accessor function\nfunction getPropertyNameFromAccessor<T>(accessor: (obj: T) => unknown): string {\n const fnStr = accessor.toString();\n const match = fnStr.match(/\\.([a-zA-Z_$][a-zA-Z0-9_$]*)/);\n return match ? match[1] : '';\n}\n\nconst CommandFormComponent = <TCommand extends object = any>(props: CommandFormProps<TCommand>) => {\n const { fieldsOrColumns, otherChildren, initialValuesFromFields } = useMemo(() => getCommandFormFields<TCommand>(props), [props.children]);\n\n // Extract matching properties from currentValues\n const valuesFromCurrentValues = useMemo(() => {\n if (!props.currentValues) return {};\n\n const tempCommand = new props.command();\n const commandProperties = (tempCommand as any).properties || [];\n const extracted: Partial<TCommand> = {};\n\n commandProperties.forEach((propertyName: string) => {\n if ((props.currentValues as any)[propertyName] !== undefined) {\n (extracted as any)[propertyName] = (props.currentValues as any)[propertyName];\n }\n });\n\n return extracted;\n }, [props.currentValues, props.command]);\n\n // Merge initialValues prop with values extracted from field currentValue props and currentValues\n const mergedInitialValues = useMemo(() => ({\n ...valuesFromCurrentValues,\n ...initialValuesFromFields,\n ...props.initialValues\n }), [valuesFromCurrentValues, initialValuesFromFields, props.initialValues]);\n\n // useCommand returns [instance, setter] for the typed command. Provide generics so commandInstance is TCommand.\n const [commandInstance, setCommandValues] = useCommand<any>(props.command as Constructor<any>, mergedInitialValues as Partial<any>);\n const [commandResult, setCommandResult] = useState<ICommandResult<unknown> | undefined>(undefined);\n const [fieldValidities, setFieldValidities] = useState<Record<string, boolean>>({});\n const [customFieldErrors, setCustomFieldErrors] = useState<Record<string, string>>({});\n\n // Update command values when mergedInitialValues changes (e.g., when data loads asynchronously)\n React.useEffect(() => {\n if (mergedInitialValues && Object.keys(mergedInitialValues).length > 0) {\n setCommandValues(mergedInitialValues as TCommand);\n }\n }, [mergedInitialValues, setCommandValues]);\n\n const isValid = Object.values(fieldValidities).every(valid => valid);\n\n const setFieldValidity = useCallback((fieldName: string, isFieldValid: boolean) => {\n setFieldValidities(prev => ({ ...prev, [fieldName]: isFieldValid }));\n }, []);\n\n const setCustomFieldError = useCallback((fieldName: string, error: string | undefined) => {\n setCustomFieldErrors(prev => {\n if (error === undefined) {\n const newErrors = { ...prev };\n delete newErrors[fieldName];\n return newErrors;\n }\n return { ...prev, [fieldName]: error };\n });\n }, []);\n\n const getFieldError = (propertyName: string): string | undefined => {\n // Check custom field errors first\n if (customFieldErrors[propertyName]) {\n return customFieldErrors[propertyName];\n }\n\n if (!commandResult || !commandResult.validationResults) {\n return undefined;\n }\n\n for (const validationResult of commandResult.validationResults) {\n if (validationResult.members && validationResult.members.includes(propertyName)) {\n return validationResult.message;\n }\n }\n\n return undefined;\n };\n\n const exceptionMessages = commandResult?.exceptionMessages || [];\n const hasColumns = fieldsOrColumns.length > 0 && 'fields' in fieldsOrColumns[0];\n\n return (\n <CommandFormContext.Provider value={{ command: props.command, commandInstance, setCommandValues, commandResult, setCommandResult, getFieldError, isValid, setFieldValidity, onFieldValidate: props.onFieldValidate, onFieldChange: props.onFieldChange, onBeforeExecute: props.onBeforeExecute, customFieldErrors, setCustomFieldError }}>\n <CommandFormFields fields={hasColumns ? undefined : (fieldsOrColumns as React.ReactElement<CommandFormFieldProps<any>>[])} columns={hasColumns ? fieldsOrColumns as ColumnInfo[] : undefined} />\n {exceptionMessages.length > 0 && (\n <div className=\"card flex flex-row gap-3 mt-3\">\n <Panel header=\"The server responded with\" className=\"w-full\">\n <ul>\n {exceptionMessages.map((msg, idx) => (\n <li key={idx}>{msg}</li>\n ))}\n </ul>\n </Panel>\n </div>\n )}\n {otherChildren}\n </CommandFormContext.Provider>\n );\n};\n\nconst CommandFormColumnComponent = (_props: { children: React.ReactNode }) => {\n void _props;\n return <></>;\n};\n\nCommandFormColumnComponent.displayName = 'CommandFormColumn';\n\nCommandFormComponent.Fields = CommandFormFieldsWrapper;\nCommandFormComponent.Column = CommandFormColumnComponent;\n\nexport const CommandForm = CommandFormComponent;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;AAuCA,MAAM,kBAAkB,GAAG,aAAa,CAA2C,SAAS,CAAC;AAEtF,MAAM,qBAAqB,GAAG,MAAgB;AACjD,IAAA,MAAM,OAAO,GAAG,UAAU,CAAC,kBAAkB,CAAC;IAC9C,IAAI,CAAC,OAAO,EAAE;AACV,QAAA,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC;IAC9E;AACA,IAAA,OAAO,OAA4C;AACvD;AAGO,MAAM,kBAAkB,GAAG,MAAqB;AACnD,IAAA,MAAM,EAAE,eAAe,EAAE,GAAG,qBAAqB,EAAO;AACxD,IAAA,OAAO,eAA2B;AACtC;AAGO,M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A,EAAe,GAAG,EAAA,EAAT,GAAG,CAAY,CAC3B,CAAC,EAAA,CACD,EAAA,CACD,EAAA,CACN,CACT,EACA,aAAa,CAAA,EAAA,CACY;AAEtC,CAAC;AAED,MAAM,0BAA0B,GAAG,CAAC,MAAqC,KAAI;AAEzE,IAAA,OAAOA,iBAAK;AAChB,CAAC;AAED,0BAA0B,CAAC,WAAW,GAAG,mBAAmB;AAE5D,oBAAoB,CAAC,MAAM,GAAG,wBAAwB;AACtD,oBAAoB,CAAC,MAAM,GAAG,0BAA0B;AAEjD,MAAM,WAAW,GAAG;;;;"}
|
|
1
|
+
{"version":3,"file":"CommandForm.js","sources":["../../../CommandForm/CommandForm.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 { CommandFormFields, ColumnInfo } from './CommandFormFields';\nimport { Constructor } from '@cratis/fundamentals';\nimport { useCommand, SetCommandValues } from '@cratis/arc.react/commands';\nimport { ICommandResult } from '@cratis/arc/commands';\nimport { Command } from '@cratis/arc/commands';\nimport React, { createContext, useContext, useMemo, useState, useCallback } from 'react';\nimport type { CommandFormFieldProps } from './CommandFormField';\nimport { Panel } from 'primereact/panel';\n\nexport type BeforeExecuteCallback<TCommand> = (values: TCommand) => TCommand;\n\nexport interface CommandFormProps<TCommand extends object> {\n command: Constructor<TCommand>;\n initialValues?: Partial<TCommand>;\n currentValues?: Partial<TCommand> | undefined;\n onFieldValidate?: (command: TCommand, fieldName: string, oldValue: unknown, newValue: unknown) => string | undefined;\n onFieldChange?: (command: TCommand, fieldName: string, oldValue: unknown, newValue: unknown) => void;\n onBeforeExecute?: BeforeExecuteCallback<TCommand>;\n children?: React.ReactNode;\n}\n\ninterface CommandFormContextValue<TCommand> {\n command: Constructor<TCommand>;\n commandInstance: TCommand;\n setCommandValues: SetCommandValues<TCommand>;\n commandResult?: ICommandResult<unknown>;\n setCommandResult: (result: ICommandResult<unknown>) => void;\n getFieldError: (propertyName: string) => string | undefined;\n isValid: boolean;\n setFieldValidity: (fieldName: string, isValid: boolean) => void;\n onFieldValidate?: (command: TCommand, fieldName: string, oldValue: unknown, newValue: unknown) => string | undefined;\n onFieldChange?: (command: TCommand, fieldName: string, oldValue: unknown, newValue: unknown) => void;\n onBeforeExecute?: BeforeExecuteCallback<TCommand>;\n customFieldErrors: Record<string, string>;\n setCustomFieldError: (fieldName: string, error: string | undefined) => void;\n}\n\nconst CommandFormContext = createContext<CommandFormContextValue<unknown> | undefined>(undefined);\n\nexport const useCommandFormContext = <TCommand,>() => {\n const context = useContext(CommandFormContext);\n if (!context) {\n throw new Error('useCommandFormContext must be used within a CommandForm');\n }\n return context as CommandFormContextValue<TCommand>;\n};\n\n// Hook to get just the command instance for easier access\nexport const useCommandInstance = <TCommand = unknown>() => {\n const { commandInstance } = useCommandFormContext<TCommand>();\n return commandInstance as TCommand;\n};\n\n// Hook to get setCommandResult for easier access\nexport const useSetCommandResult = () => {\n const { setCommandResult } = useCommandFormContext();\n return setCommandResult;\n};\n\nconst CommandFormFieldsWrapper = (props: { children: React.ReactNode }) => {\n React.Children.forEach(props.children, child => {\n if (React.isValidElement(child)) {\n const component = child.type as React.ComponentType<unknown>;\n if (component.displayName !== 'CommandFormField') {\n throw new Error(`Only CommandFormField components are allowed as children of CommandForm.Fields. Got: ${component.displayName || component.name || 'Unknown'}`);\n }\n }\n });\n\n return <></>;\n};\n\nCommandFormFieldsWrapper.displayName = 'CommandFormFieldsWrapper';\n\nconst getCommandFormFields = <TCommand,>(props: { children?: React.ReactNode }): { fieldsOrColumns: React.ReactElement[] | ColumnInfo[], otherChildren: React.ReactNode[], initialValuesFromFields: Partial<TCommand> } => {\n if (!props.children) {\n return { fieldsOrColumns: [], otherChildren: [], initialValuesFromFields: {} };\n }\n let fields: React.ReactElement<CommandFormFieldProps<unknown>>[] = [];\n const columns: ColumnInfo[] = [];\n let hasColumns = false;\n const otherChildren: React.ReactNode[] = [];\n let initialValuesFromFields: Partial<TCommand> = {};\n\n const extractInitialValue = (field: React.ReactElement) => {\n const fieldProps = field.props as Record<string, unknown>;\n if (fieldProps.currentValue !== undefined && fieldProps.value) {\n const propertyAccessor = fieldProps.value;\n const propertyName = getPropertyNameFromAccessor(propertyAccessor);\n if (propertyName) {\n initialValuesFromFields = { ...initialValuesFromFields, [propertyName]: fieldProps.currentValue } as Partial<TCommand>;\n }\n }\n };\n\n React.Children.toArray(props.children).forEach(child => {\n if (!React.isValidElement(child)) {\n otherChildren.push(child);\n return;\n }\n\n const component = child.type as React.ComponentType<unknown>;\n\n // Check if child is a CommandFormColumn\n if (component.displayName === 'CommandFormColumn') {\n hasColumns = true;\n const childProps = child.props as { children?: React.ReactNode };\n const columnFields = React.Children.toArray(childProps.children).filter(child => {\n if (React.isValidElement(child)) {\n const comp = child.type as React.ComponentType<unknown>;\n if (comp.displayName === 'CommandFormField') {\n extractInitialValue(child as React.ReactElement);\n return true;\n }\n }\n return false;\n }) as React.ReactElement[];\n columns.push({ fields: columnFields as React.ReactElement<CommandFormFieldProps<unknown>>[] });\n }\n // Check if child is a CommandFormField (direct child)\n else if (component.displayName === 'CommandFormField') {\n extractInitialValue(child as React.ReactElement);\n fields.push(child as React.ReactElement<CommandFormFieldProps<unknown>>);\n }\n // Check if child is Fields wrapper (backwards compatibility)\n else if (component === CommandFormFieldsWrapper || component.displayName === 'CommandFormFieldsWrapper') {\n const childProps = child.props as { children: React.ReactNode };\n const relevantChildren = React.Children.toArray(childProps.children).filter(child => {\n if (React.isValidElement(child)) {\n const component = child.type as React.ComponentType<unknown>;\n if (component.displayName === 'CommandFormField') {\n extractInitialValue(child as React.ReactElement);\n return true;\n }\n }\n return false;\n }) as React.ReactElement[];\n fields = [...fields, ...(relevantChildren as React.ReactElement<CommandFormFieldProps<unknown>>[])];\n }\n // Everything else is not a field, keep it as other children\n else {\n otherChildren.push(child);\n }\n });\n\n return { fieldsOrColumns: hasColumns ? columns : fields, otherChildren, initialValuesFromFields };\n};\n\n// Helper function to extract property name from accessor function\nfunction getPropertyNameFromAccessor<T = unknown>(accessor: ((obj: T) => unknown) | unknown): string {\n if (typeof accessor !== 'function') return '';\n const fnStr = accessor.toString();\n const match = fnStr.match(/\\.([a-zA-Z_$][a-zA-Z0-9_$]*)/);\n return match ? match[1] : '';\n}\n\nconst CommandFormComponent = <TCommand extends object = object>(props: CommandFormProps<TCommand>) => {\n const { fieldsOrColumns, otherChildren, initialValuesFromFields } = useMemo(() => getCommandFormFields<TCommand>(props), [props.children]);\n\n // Extract matching properties from currentValues\n const valuesFromCurrentValues = useMemo(() => {\n if (!props.currentValues) return {};\n\n const tempCommand = new props.command();\n const commandProperties = ((tempCommand as Record<string, unknown>).properties || []) as string[];\n const extracted: Partial<TCommand> = {};\n\n commandProperties.forEach((propertyName: string) => {\n if ((props.currentValues as Record<string, unknown>)[propertyName] !== undefined) {\n (extracted as Record<string, unknown>)[propertyName] = (props.currentValues as Record<string, unknown>)[propertyName];\n }\n });\n\n return extracted;\n }, [props.currentValues, props.command]);\n\n // Merge initialValues prop with values extracted from field currentValue props and currentValues\n const mergedInitialValues = useMemo(() => ({\n ...valuesFromCurrentValues,\n ...initialValuesFromFields,\n ...props.initialValues\n }), [valuesFromCurrentValues, initialValuesFromFields, props.initialValues]);\n\n // useCommand returns [instance, setter] for the typed command. Provide generics so commandInstance is TCommand.\n // Using type assertion through unknown to work around generic constraint mismatch\n const useCommandResult = useCommand(props.command as unknown as Constructor<Command<Partial<TCommand>, object>>, mergedInitialValues);\n const commandInstance = useCommandResult[0] as unknown as TCommand;\n const setCommandValues = useCommandResult[1] as SetCommandValues<TCommand>;\n const [commandResult, setCommandResult] = useState<ICommandResult<unknown> | undefined>(undefined);\n const [fieldValidities, setFieldValidities] = useState<Record<string, boolean>>({});\n const [customFieldErrors, setCustomFieldErrors] = useState<Record<string, string>>({});\n\n // Update command values when mergedInitialValues changes (e.g., when data loads asynchronously)\n React.useEffect(() => {\n if (mergedInitialValues && Object.keys(mergedInitialValues).length > 0) {\n setCommandValues(mergedInitialValues as TCommand);\n }\n }, [mergedInitialValues, setCommandValues]);\n\n const isValid = Object.values(fieldValidities).every(valid => valid);\n\n const setFieldValidity = useCallback((fieldName: string, isFieldValid: boolean) => {\n setFieldValidities(prev => ({ ...prev, [fieldName]: isFieldValid }));\n }, []);\n\n const setCustomFieldError = useCallback((fieldName: string, error: string | undefined) => {\n setCustomFieldErrors(prev => {\n if (error === undefined) {\n const newErrors = { ...prev };\n delete newErrors[fieldName];\n return newErrors;\n }\n return { ...prev, [fieldName]: error };\n });\n }, []);\n\n const getFieldError = (propertyName: string): string | undefined => {\n // Check custom field errors first\n if (customFieldErrors[propertyName]) {\n return customFieldErrors[propertyName];\n }\n\n if (!commandResult || !commandResult.validationResults) {\n return undefined;\n }\n\n for (const validationResult of commandResult.validationResults) {\n if (validationResult.members && validationResult.members.includes(propertyName)) {\n return validationResult.message;\n }\n }\n\n return undefined;\n };\n\n const exceptionMessages = commandResult?.exceptionMessages || [];\n const hasColumns = fieldsOrColumns.length > 0 && 'fields' in fieldsOrColumns[0];\n\n return (\n <CommandFormContext.Provider value={{ command: props.command, commandInstance, setCommandValues, commandResult, setCommandResult, getFieldError, isValid, setFieldValidity, onFieldValidate: props.onFieldValidate, onFieldChange: props.onFieldChange, onBeforeExecute: props.onBeforeExecute, customFieldErrors, setCustomFieldError }}>\n <CommandFormFields fields={hasColumns ? undefined : (fieldsOrColumns as React.ReactElement<CommandFormFieldProps<unknown>>[])} columns={hasColumns ? fieldsOrColumns as ColumnInfo[] : undefined} />\n {exceptionMessages.length > 0 && (\n <div className=\"card flex flex-row gap-3 mt-3\">\n <Panel header=\"The server responded with\" className=\"w-full\">\n <ul>\n {exceptionMessages.map((msg, idx) => (\n <li key={idx}>{msg}</li>\n ))}\n </ul>\n </Panel>\n </div>\n )}\n {otherChildren}\n </CommandFormContext.Provider>\n );\n};\n\nconst CommandFormColumnComponent = (_props: { children: React.ReactNode }) => {\n void _props;\n return <></>;\n};\n\nCommandFormColumnComponent.displayName = 'CommandFormColumn';\n\nCommandFormComponent.Fields = CommandFormFieldsWrapper;\nCommandFormComponent.Column = CommandFormColumnComponent;\n\nexport const CommandForm = CommandFormComponent;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;AAwCA,MAAM,kBAAkB,GAAG,aAAa,CAA+C,SAAS,CAAC;AAE1F,MAAM,qBAAqB,GAAG,MAAgB;AACjD,IAAA,MAAM,OAAO,GAAG,UAAU,CAAC,kBAAkB,CAAC;IAC9C,IAAI,CAAC,OAAO,EAAE;AACV,QAAA,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC;IAC9E;AACA,IAAA,OAAO,OAA4C;AACvD;AAGO,MAAM,kBAAkB,GAAG,MAAyB;AACvD,IAAA,MAAM,EAAE,eAAe,EAAE,GAAG,qBAAqB,EAAY;AAC7D,IAAA,OAAO,eAA2B;AACtC;AAGO,MAAM,mBAAmB,GAAG,MAAK;AACpC,IAAA,MAAM,EAAE,gBAAgB,EAAE,GAAG,qBAAqB,EAAE;AACpD,IAAA,OAAO,gBAAgB;AAC3B;AAEA,MAAM,wBAAwB,GAAG,CAAC,KAAoC,KAAI;IACtE,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,IAAG;AAC3C,QAAA,IAAI,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;AAC7B,YAAA,MAAM,SAAS,GAAG,KAAK,CAAC,IAAoC;AAC5D,YAAA,IAAI,SAAS,CAAC,WAAW,KAAK,kBAAkB,EAAE;AAC9C,gBAAA,MAAM,IAAI,KAAK,CAAC,CAAA,qFAAA,EAAwF,SAAS,CAAC,WAAW,IAAI,SAAS,CAAC,IAAI,IAAI,SAAS,CAAA,CAAE,CAAC;YACnK;QACJ;AACJ,IAAA,CAAC,CAAC;AAEF,IAAA,OAAOA,iBAAK;AAChB,CAAC;AAED,wBAAwB,CAAC,WAAW,GAAG,0BAA0B;AAEjE,MAAM,oBAAoB,G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a,EAAE,gBAAgB,EAAE,aAAa,EAAE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,KAAK,CAAC,eAAe,EAAE,aAAa,EAAE,KAAK,CAAC,aAAa,EAAE,eAAe,EAAE,KAAK,CAAC,eAAe,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,EAAA,QAAA,EAAA,CACpUD,GAAA,CAAC,iBAAiB,EAAA,EAAC,MAAM,EAAE,UAAU,GAAG,SAAS,GAAI,eAAwE,EAAE,OAAO,EAAE,UAAU,GAAG,eAA+B,GAAG,SAAS,EAAA,CAAI,EACnM,iBAAiB,CAAC,MAAM,GAAG,CAAC,KACzBA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,+BAA+B,EAAA,QAAA,EAC1CA,GAAA,CAAC,KAAK,EAAA,EAAC,MAAM,EAAC,2BAA2B,EAAC,SAAS,EAAC,QAAQ,EAAA,QAAA,EACxDA,GAAA,CAAA,IAAA,EAAA,EAAA,QAAA,EACK,iBAAiB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,MAC5BA,GAAA,CAAA,IAAA,EAAA,EAAA,QAAA,EAAe,GAAG,EAAA,EAAT,GAAG,CAAY,CAC3B,CAAC,EAAA,CACD,EAAA,CACD,EAAA,CACN,CACT,EACA,aAAa,CAAA,EAAA,CACY;AAEtC,CAAC;AAED,MAAM,0BAA0B,GAAG,CAAC,MAAqC,KAAI;AAEzE,IAAA,OAAOA,iBAAK;AAChB,CAAC;AAED,0BAA0B,CAAC,WAAW,GAAG,mBAAmB;AAE5D,oBAAoB,CAAC,MAAM,GAAG,wBAAwB;AACtD,oBAAoB,CAAC,MAAM,GAAG,0BAA0B;AAEjD,MAAM,WAAW,GAAG;;;;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { CommandFormFieldProps } from './CommandFormField';
|
|
3
3
|
export interface ColumnInfo {
|
|
4
|
-
fields: React.ReactElement<CommandFormFieldProps<
|
|
4
|
+
fields: React.ReactElement<CommandFormFieldProps<unknown>>[];
|
|
5
5
|
}
|
|
6
6
|
export interface CommandFormFieldsProps {
|
|
7
|
-
fields?: React.ReactElement<CommandFormFieldProps<
|
|
7
|
+
fields?: React.ReactElement<CommandFormFieldProps<unknown>>[];
|
|
8
8
|
columns?: ColumnInfo[];
|
|
9
9
|
}
|
|
10
10
|
export declare const CommandFormFields: (props: CommandFormFieldsProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandFormFields.d.ts","sourceRoot":"","sources":["../../../CommandForm/CommandFormFields.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"CommandFormFields.d.ts","sourceRoot":"","sources":["../../../CommandForm/CommandFormFields.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAGhE,MAAM,WAAW,UAAU;IACvB,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;CAChE;AAED,MAAM,WAAW,sBAAsB;IACnC,MAAM,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;IAC9D,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;CAC1B;AAkFD,eAAO,MAAM,iBAAiB,GAAI,OAAO,sBAAsB,4CA8C9D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandFormFields.js","sources":["../../../CommandForm/CommandFormFields.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 { useCommandFormContext } from './CommandForm';\nimport React from 'react';\nimport { Tooltip } from 'primereact/tooltip';\nimport type { CommandFormFieldProps } from './CommandFormField';\n\nexport interface ColumnInfo {\n fields: React.ReactElement<CommandFormFieldProps<any>>[];\n}\n\nexport interface CommandFormFieldsProps {\n fields?: React.ReactElement<CommandFormFieldProps<any>>[];\n columns?: ColumnInfo[];\n}\n\n// Separate component for each field to prevent re-rendering all fields\nconst CommandFormFieldWrapper = ({ field, index }: { field: React.ReactElement<CommandFormFieldProps<any>>; index: number }) => {\n const context = useCommandFormContext<any>();\n const fieldProps = field.props as CommandFormFieldProps<any>;\n const propertyAccessor = fieldProps.value;\n\n // Get the property name from the accessor function\n const propertyName = propertyAccessor ? getPropertyName(propertyAccessor) : '';\n\n // Get the current value from the command instance\n const currentValue = propertyName ? (context.commandInstance as any)?.[propertyName] : undefined;\n\n // Get the error message for this field, if any\n const errorMessage = propertyName ? context.getFieldError(propertyName) : undefined;\n\n // Get the property descriptor for this field from the command instance\n const propertyDescriptor = propertyName && (context.commandInstance as any)?.propertyDescriptors\n ? (context.commandInstance as any).propertyDescriptors.find((pd: any) => pd.name === propertyName)\n : undefined;\n\n // Clone the field element with the current value and onChange handler\n const clonedField = React.cloneElement(field as React.ReactElement, {\n ...fieldProps,\n currentValue,\n propertyDescriptor,\n fieldName: propertyName,\n onValueChange: (value: unknown) => {\n if (propertyName) {\n const oldValue = currentValue;\n\n // Update the command value\n context.setCommandValues({ [propertyName]: value } as any);\n\n // Call validate() on the command instance and store the result\n if (context.commandInstance && typeof (context.commandInstance as any).validate === 'function') {\n const validationResult = (context.commandInstance as any).validate();\n if (validationResult) {\n context.setCommandResult(validationResult);\n }\n }\n\n // Call custom field validator if provided\n if (context.onFieldValidate) {\n const validationError = context.onFieldValidate(context.commandInstance as any, propertyName, oldValue, value);\n context.setCustomFieldError(propertyName, validationError);\n }\n\n // Call field change callback if provided\n if (context.onFieldChange) {\n context.onFieldChange(context.commandInstance as any, propertyName, oldValue, value);\n }\n }\n fieldProps.onChange?.(value as any);\n },\n required: fieldProps.required ?? true,\n invalid: !!errorMessage\n } as any);\n\n const tooltipId = fieldProps.description ? `tooltip-${propertyName}-${index}` : undefined;\n\n return (\n <div className=\"w-full\">\n <div className=\"p-inputgroup w-full\">\n {fieldProps.description && (\n <Tooltip target={`.${tooltipId}`} content={fieldProps.description} />\n )}\n {fieldProps.icon && (\n <span className={`p-inputgroup-addon ${tooltipId || ''}`}>\n {fieldProps.icon}\n </span>\n )}\n {clonedField}\n </div>\n {errorMessage && (\n <small className=\"p-error block mt-1\">{errorMessage}</small>\n )}\n </div>\n );\n};\n\nexport const CommandFormFields = (props: CommandFormFieldsProps) => {\n const { fields, columns } = props;\n\n // Render columns if provided\n if (columns && columns.length > 0) {\n return (\n <div className=\"card flex flex-column md:flex-row gap-3\">\n {columns.map((column, columnIndex) => (\n <div key={`column-${columnIndex}`} className=\"flex flex-column gap-3 flex-1\">\n {column.fields.map((field, index) => {\n const fieldProps = field.props as CommandFormFieldProps<any>;\n const propertyAccessor = fieldProps.value;\n const propertyName = propertyAccessor ? getPropertyName(propertyAccessor) : `field-${columnIndex}-${index}`;\n\n return (\n <CommandFormFieldWrapper\n key={propertyName}\n field={field}\n index={index}\n />\n );\n })}\n </div>\n ))}\n </div>\n );\n }\n\n // Render fields (single column layout)\n return (\n <div className=\"flex flex-col gap-4 w-full\">\n {(fields || []).map((field, index) => {\n const fieldProps = field.props as CommandFormFieldProps<any>;\n const propertyAccessor = fieldProps.value;\n const propertyName = propertyAccessor ? getPropertyName(propertyAccessor) : `field-${index}`;\n\n return (\n <CommandFormFieldWrapper\n key={propertyName}\n field={field}\n index={index}\n />\n );\n })}\n </div>\n );\n};\n\n// Helper function to extract property name from accessor function\nfunction getPropertyName<T>(accessor: (obj: T) => unknown): string {\n const fnStr = accessor.toString();\n const match = fnStr.match(/\\.([a-zA-Z_$][a-zA-Z0-9_$]*)/);\n return match ? match[1] : '';\n}\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;A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,KAAmC;AAC5D,YAAA,MAAM,gBAAgB,GAAG,UAAU,CAAC,KAAK;AACzC,YAAA,MAAM,YAAY,GAAG,gBAAgB,GAAG,eAAe,CAAC,gBAAgB,CAAC,GAAG,CAAA,MAAA,EAAS,KAAK,EAAE;AAE5F,YAAA,QACIA,GAAA,CAAC,uBAAuB,EAAA,EAEpB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,EAAA,EAFP,YAAY,CAGnB;QAEV,CAAC,CAAC,EAAA,CACA;AAEd;AAGA,SAAS,eAAe,CAAI,QAA6B,EAAA;AACrD,IAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,EAAE;IACjC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,8BAA8B,CAAC;AACzD,IAAA,OAAO,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE;AAChC;;;;"}
|
|
1
|
+
{"version":3,"file":"CommandFormFields.js","sources":["../../../CommandForm/CommandFormFields.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 { useCommandFormContext } from './CommandForm';\nimport React from 'react';\nimport { Tooltip } from 'primereact/tooltip';\nimport type { CommandFormFieldProps } from './CommandFormField';\nimport type { ICommandResult } from '@cratis/arc/commands';\n\nexport interface ColumnInfo {\n fields: React.ReactElement<CommandFormFieldProps<unknown>>[];\n}\n\nexport interface CommandFormFieldsProps {\n fields?: React.ReactElement<CommandFormFieldProps<unknown>>[];\n columns?: ColumnInfo[];\n}\n\n// Separate component for each field to prevent re-rendering all fields\nconst CommandFormFieldWrapper = ({ field, index }: { field: React.ReactElement<CommandFormFieldProps<unknown>>; index: number }) => {\n const context = useCommandFormContext<unknown>();\n const fieldProps = field.props as CommandFormFieldProps<unknown>;\n const propertyAccessor = fieldProps.value;\n\n // Get the property name from the accessor function\n const propertyName = propertyAccessor ? getPropertyName(propertyAccessor) : '';\n\n // Get the current value from the command instance\n const currentValue = propertyName ? (context.commandInstance as Record<string, unknown>)?.[propertyName] : undefined;\n\n // Get the error message for this field, if any\n const errorMessage = propertyName ? context.getFieldError(propertyName) : undefined;\n\n // Get the property descriptor for this field from the command instance\n const propertyDescriptor = propertyName && (context.commandInstance as Record<string, unknown>)?.propertyDescriptors\n ? ((context.commandInstance as Record<string, unknown>).propertyDescriptors as Array<Record<string, unknown>>).find((pd: Record<string, unknown>) => pd.name === propertyName)\n : undefined;\n\n // Clone the field element with the current value and onChange handler\n const clonedField = React.cloneElement(field as React.ReactElement, {\n ...fieldProps,\n currentValue,\n propertyDescriptor,\n fieldName: propertyName,\n onValueChange: (value: unknown) => {\n if (propertyName) {\n const oldValue = currentValue;\n\n // Update the command value\n context.setCommandValues({ [propertyName]: value } as Record<string, unknown>);\n\n // Call validate() on the command instance and store the result\n if (context.commandInstance && typeof (context.commandInstance as Record<string, unknown>).validate === 'function') {\n const validationResult = ((context.commandInstance as Record<string, unknown>).validate as () => ICommandResult<unknown>)();\n if (validationResult) {\n context.setCommandResult(validationResult);\n }\n }\n\n // Call custom field validator if provided\n if (context.onFieldValidate) {\n const validationError = context.onFieldValidate(context.commandInstance as Record<string, unknown>, propertyName, oldValue, value);\n context.setCustomFieldError(propertyName, validationError);\n }\n\n // Call field change callback if provided\n if (context.onFieldChange) {\n context.onFieldChange(context.commandInstance as Record<string, unknown>, propertyName, oldValue, value);\n }\n }\n fieldProps.onChange?.(value as unknown);\n },\n required: fieldProps.required ?? true,\n invalid: !!errorMessage\n } as Record<string, unknown>);\n\n const tooltipId = fieldProps.description ? `tooltip-${propertyName}-${index}` : undefined;\n\n return (\n <div className=\"w-full\">\n <div className=\"p-inputgroup w-full\">\n {fieldProps.description && (\n <Tooltip target={`.${tooltipId}`} content={fieldProps.description} />\n )}\n {fieldProps.icon && (\n <span className={`p-inputgroup-addon ${tooltipId || ''}`}>\n {fieldProps.icon}\n </span>\n )}\n {clonedField}\n </div>\n {errorMessage && (\n <small className=\"p-error block mt-1\">{errorMessage}</small>\n )}\n </div>\n );\n};\n\nexport const CommandFormFields = (props: CommandFormFieldsProps) => {\n const { fields, columns } = props;\n\n // Render columns if provided\n if (columns && columns.length > 0) {\n return (\n <div className=\"card flex flex-column md:flex-row gap-3\">\n {columns.map((column, columnIndex) => (\n <div key={`column-${columnIndex}`} className=\"flex flex-column gap-3 flex-1\">\n {column.fields.map((field, index) => {\n const fieldProps = field.props as CommandFormFieldProps<unknown>;\n const propertyAccessor = fieldProps.value;\n const propertyName = propertyAccessor ? getPropertyName(propertyAccessor) : `field-${columnIndex}-${index}`;\n\n return (\n <CommandFormFieldWrapper\n key={propertyName}\n field={field}\n index={index}\n />\n );\n })}\n </div>\n ))}\n </div>\n );\n }\n\n // Render fields (single column layout)\n return (\n <div className=\"flex flex-col gap-4 w-full\">\n {(fields || []).map((field, index) => {\n const fieldProps = field.props as CommandFormFieldProps<unknown>;\n const propertyAccessor = fieldProps.value;\n const propertyName = propertyAccessor ? getPropertyName(propertyAccessor) : `field-${index}`;\n\n return (\n <CommandFormFieldWrapper\n key={propertyName}\n field={field}\n index={index}\n />\n );\n })}\n </div>\n );\n};\n\n// Helper function to extract property name from accessor function\nfunction getPropertyName<T>(accessor: (obj: T) => unknown): string {\n const fnStr = accessor.toString();\n const match = fnStr.match(/\\.([a-zA-Z_$][a-zA-Z0-9_$]*)/);\n return match ? match[1] : '';\n}\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;AAmBA,MAAM,uBAAuB,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,EAAgF,KAAI;AAC/H,IAAA,MAAM,OAAO,GAAG,qBAAqB,EAAW;AAChD,IAAA,MAAM,UAAU,GAAG,KAAK,CAAC,KAAuC;AAChE,IAAA,MAAM,gBAAgB,GAAG,UAAU,CAAC,KAAK;AAGzC,IAAA,MAAM,YAAY,GAAG,gBAAgB,GAAG,eAAe,CAAC,gBAAgB,CAAC,GAAG,EAAE;AAG9E,IAAA,MAAM,YAAY,GAAG,YA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AAS,eAAe,CAAI,QAA6B,EAAA;AACrD,IAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,EAAE;IACjC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,8BAA8B,CAAC;AACzD,IAAA,OAAO,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE;AAChC;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
declare const _default: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: React.ComponentType<
|
|
4
|
+
component: React.ComponentType<Record<string, never>> | undefined;
|
|
5
5
|
};
|
|
6
6
|
export default _default;
|
|
7
7
|
export declare const Default: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorBoundary.stories.js","sourceRoot":"","sources":["../../../Common/ErrorBoundary.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"ErrorBoundary.stories.js","sourceRoot":"","sources":["../../../Common/ErrorBoundary.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,MAAM,SAAS,GAA4D,IAAgC,CAAC,OAA4E,IAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAuE,CAAC;AAE1R,eAAe,EAAE,KAAK,EAAE,sBAAsB,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAEvE,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAC,SAAS,KAAG,CAAC,CAAC,CAAC,uDAAqC,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
declare const _default: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: React.ComponentType<
|
|
4
|
+
component: React.ComponentType<Record<string, never>> | undefined;
|
|
5
5
|
};
|
|
6
6
|
export default _default;
|
|
7
7
|
export declare const Default: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormElement.stories.js","sourceRoot":"","sources":["../../../Common/FormElement.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"FormElement.stories.js","sourceRoot":"","sources":["../../../Common/FormElement.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,MAAM,SAAS,GAA4D,IAAgC,CAAC,OAA4E,IAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAuE,CAAC;AAE1R,eAAe,EAAE,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAErE,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAC,SAAS,KAAG,CAAC,CAAC,CAAC,uDAAqC,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
declare const _default: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: React.ComponentType<
|
|
4
|
+
component: React.ComponentType<Record<string, never>> | undefined;
|
|
5
5
|
};
|
|
6
6
|
export default _default;
|
|
7
7
|
export declare const Default: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Page.stories.js","sourceRoot":"","sources":["../../../Common/Page.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"Page.stories.js","sourceRoot":"","sources":["../../../Common/Page.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,MAAM,SAAS,GAA4D,IAAgC,CAAC,OAA4E,IAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAuE,CAAC;AAE1R,eAAe,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAE9D,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAC,SAAS,KAAG,CAAC,CAAC,CAAC,uDAAqC,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
declare const _default: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: React.ComponentType<
|
|
4
|
+
component: React.ComponentType<Record<string, never>> | undefined;
|
|
5
5
|
};
|
|
6
6
|
export default _default;
|
|
7
7
|
export declare const Default: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataPage.stories.js","sourceRoot":"","sources":["../../../DataPage/DataPage.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AACnC,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"DataPage.stories.js","sourceRoot":"","sources":["../../../DataPage/DataPage.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AACnC,MAAM,SAAS,GAA4D,IAAgC,CAAC,OAAiE,IAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAA4D,CAAC;AAEpQ,eAAe,EAAE,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAEpE,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAC,SAAS,KAAG,CAAC,CAAC,CAAC,uDAAqC,CAAC,CAAC"}
|
|
@@ -2,16 +2,16 @@ import { DataTableFilterMeta, DataTableSelectionSingleChangeEvent } from 'primer
|
|
|
2
2
|
import { Constructor } from '@cratis/fundamentals';
|
|
3
3
|
import { IObservableQueryFor } from '@cratis/arc/queries';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
|
-
export interface DataTableForObservableQueryProps<TQuery extends IObservableQueryFor<TDataType>, TDataType, TArguments> {
|
|
5
|
+
export interface DataTableForObservableQueryProps<TQuery extends IObservableQueryFor<TDataType, TArguments>, TDataType extends object, TArguments extends object> {
|
|
6
6
|
children?: ReactNode;
|
|
7
7
|
query: Constructor<TQuery>;
|
|
8
8
|
queryArguments?: TArguments;
|
|
9
9
|
emptyMessage: string;
|
|
10
10
|
dataKey?: string | undefined;
|
|
11
|
-
selection?:
|
|
12
|
-
onSelectionChange?(event: DataTableSelectionSingleChangeEvent<
|
|
11
|
+
selection?: TDataType | undefined | null;
|
|
12
|
+
onSelectionChange?(event: DataTableSelectionSingleChangeEvent<TDataType[]>): void;
|
|
13
13
|
globalFilterFields?: string[] | undefined;
|
|
14
14
|
defaultFilters?: DataTableFilterMeta;
|
|
15
15
|
}
|
|
16
|
-
export declare const DataTableForObservableQuery: <TQuery extends IObservableQueryFor<TDataType, TArguments>, TDataType, TArguments extends object>(props: DataTableForObservableQueryProps<TQuery, TDataType, TArguments>) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare const DataTableForObservableQuery: <TQuery extends IObservableQueryFor<TDataType, TArguments>, TDataType extends object, TArguments extends object>(props: DataTableForObservableQueryProps<TQuery, TDataType, TArguments>) => import("react/jsx-runtime").JSX.Element;
|
|
17
17
|
//# sourceMappingURL=DataTableForObservableQuery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTableForObservableQuery.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableForObservableQuery.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAa,mB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BAA2B,GAAI,MAAM,SAAS,mBAAmB,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,SAAS,SAAS,MAAM,EAAE,UAAU,SAAS,MAAM,EAAE,OAAO,gCAAgC,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,4CA4BjO,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTableForObservableQuery.js","sources":["../../../DataTables/DataTableForObservableQuery.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 { DataTable, DataTableFilterMeta, DataTableSelectionSingleChangeEvent } from 'primereact/datatable';\nimport { Constructor } from '@cratis/fundamentals';\nimport { IObservableQueryFor, Paging } from '@cratis/arc/queries';\nimport { useObservableQueryWithPaging } from '@cratis/arc.react/queries';\nimport { ReactNode, useState } from 'react';\n\n \n\n/**\n * Props for the DataTableForQuery component\n */\nexport interface DataTableForObservableQueryProps<TQuery extends IObservableQueryFor<TDataType>, TDataType, TArguments> {\n /**\n * Children to render\n */\n children?: ReactNode;\n\n /**\n * The type of query to use\n */\n query: Constructor<TQuery>;\n\n /**\n * Optional arguments to pass to the query\n */\n queryArguments?: TArguments;\n\n /**\n * The message to show when there is no data\n */\n emptyMessage: string;\n\n /**\n * The key to use for the data\n */\n dataKey?: string | undefined;\n\n /**\n * The current selection.\n */\n selection?:
|
|
1
|
+
{"version":3,"file":"DataTableForObservableQuery.js","sources":["../../../DataTables/DataTableForObservableQuery.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 { DataTable, DataTableFilterMeta, DataTableSelectionSingleChangeEvent } from 'primereact/datatable';\nimport { Constructor } from '@cratis/fundamentals';\nimport { IObservableQueryFor, Paging } from '@cratis/arc/queries';\nimport { useObservableQueryWithPaging } from '@cratis/arc.react/queries';\nimport { ReactNode, useState } from 'react';\n\n \n\n/**\n * Props for the DataTableForQuery component\n */\nexport interface DataTableForObservableQueryProps<TQuery extends IObservableQueryFor<TDataType, TArguments>, TDataType extends object, TArguments extends object> {\n /**\n * Children to render\n */\n children?: ReactNode;\n\n /**\n * The type of query to use\n */\n query: Constructor<TQuery>;\n\n /**\n * Optional arguments to pass to the query\n */\n queryArguments?: TArguments;\n\n /**\n * The message to show when there is no data\n */\n emptyMessage: string;\n\n /**\n * The key to use for the data\n */\n dataKey?: string | undefined;\n\n /**\n * The current selection.\n */\n selection?: TDataType | undefined | null;\n\n /**\n * Callback for when the selection changes\n */\n onSelectionChange?(event: DataTableSelectionSingleChangeEvent<TDataType[]>): void;\n\n /**\n * Fields to use for global filtering\n */\n globalFilterFields?: string[] | undefined;\n\n /**\n * Default filters to use\n */\n defaultFilters?: DataTableFilterMeta;\n}\n\nconst paging = new Paging(0, 20);\n\n/**\n * Represents a DataTable for a query.\n * @param props Props for the component\n * @returns Function to render the DataTableForQuery component\n */\nexport const DataTableForObservableQuery = <TQuery extends IObservableQueryFor<TDataType, TArguments>, TDataType extends object, TArguments extends object>(props: DataTableForObservableQueryProps<TQuery, TDataType, TArguments>) => {\n const [filters, setFilters] = useState<DataTableFilterMeta>(props.defaultFilters ?? {});\n const [result, , setPage] = useObservableQueryWithPaging(props.query, paging, props.queryArguments);\n\n return (\n <DataTable\n value={result.data as unknown as object[]}\n lazy\n rows={paging.pageSize}\n totalRecords={result.paging.totalItems}\n paginator\n alwaysShowPaginator={false}\n first={result.paging.page * paging.pageSize}\n onPage={(e) => setPage(e.page ?? 0)}\n scrollable\n scrollHeight={'flex'}\n selectionMode='single'\n selection={props.selection}\n onSelectionChange={props.onSelectionChange}\n dataKey={props.dataKey}\n filters={filters}\n filterDisplay='menu'\n onFilter={(e) => setFilters(e.filters)}\n globalFilterFields={props.globalFilterFields}\n emptyMessage={props.emptyMessage}>\n {props.children}\n </DataTable>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;AA6DA,MAAM,MAAM,GAAG,IAAI,M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|
3
3
|
title: string;
|
|
4
|
-
component: React.ComponentType<
|
|
4
|
+
component: React.ComponentType<Record<string, never>> | undefined;
|
|
5
5
|
};
|
|
6
6
|
export default _default;
|
|
7
7
|
export declare const Default: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTableForObservableQuery.stories.js","sourceRoot":"","sources":["../../../DataTables/DataTableForObservableQuery.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,KAAK,IAAI,MAAM,+BAA+B,CAAC;AACtD,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"DataTableForObservableQuery.stories.js","sourceRoot":"","sources":["../../../DataTables/DataTableForObservableQuery.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,KAAK,IAAI,MAAM,+BAA+B,CAAC;AACtD,MAAM,SAAS,GAA4D,IAAgC,CAAC,OAA4E,IAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAuE,CAAC;AAE1R,eAAe,EAAE,KAAK,EAAE,wCAAwC,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAEzF,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAC,SAAS,KAAG,CAAC,CAAC,CAAC,uDAAqC,CAAC,CAAC"}
|
|
@@ -2,16 +2,16 @@ import { DataTableFilterMeta, DataTableSelectionSingleChangeEvent } from 'primer
|
|
|
2
2
|
import { Constructor } from '@cratis/fundamentals';
|
|
3
3
|
import { IQueryFor } from '@cratis/arc/queries';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
|
-
export interface DataTableForQueryProps<TQuery extends IQueryFor<TDataType>, TDataType, TArguments> {
|
|
5
|
+
export interface DataTableForQueryProps<TQuery extends IQueryFor<TDataType, TArguments>, TDataType extends object, TArguments extends object> {
|
|
6
6
|
children?: ReactNode;
|
|
7
7
|
query: Constructor<TQuery>;
|
|
8
8
|
queryArguments?: TArguments;
|
|
9
9
|
emptyMessage: string;
|
|
10
10
|
dataKey?: string | undefined;
|
|
11
|
-
selection?:
|
|
12
|
-
onSelectionChange?(event: DataTableSelectionSingleChangeEvent<
|
|
11
|
+
selection?: TDataType | undefined | null;
|
|
12
|
+
onSelectionChange?(event: DataTableSelectionSingleChangeEvent<TDataType[]>): void;
|
|
13
13
|
globalFilterFields?: string[] | undefined;
|
|
14
14
|
defaultFilters?: DataTableFilterMeta;
|
|
15
15
|
}
|
|
16
|
-
export declare const DataTableForQuery: <TQuery extends IQueryFor<TDataType, TArguments>, TDataType, TArguments extends object>(props: DataTableForQueryProps<TQuery, TDataType, TArguments>) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare const DataTableForQuery: <TQuery extends IQueryFor<TDataType, TArguments>, TDataType extends object, TArguments extends object>(props: DataTableForQueryProps<TQuery, TDataType, TArguments>) => import("react/jsx-runtime").JSX.Element;
|
|
17
17
|
//# sourceMappingURL=DataTableForQuery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTableForQuery.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableForQuery.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAa,mBAAmB,EAAE,mCAAmC,EAAE,MAAM,sBAAsB,CAAC;AAC3G,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAU,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAO5C,MAAM,WAAW,sBAAsB,CAAC,MAAM,SAAS,SAAS,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,UAAU;
|
|
1
|
+
{"version":3,"file":"DataTableForQuery.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableForQuery.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAa,mBAAmB,EAAE,mCAAmC,EAAE,MAAM,sBAAsB,CAAC;AAC3G,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAU,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAO5C,MAAM,WAAW,sBAAsB,CAAC,MAAM,SAAS,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,SAAS,SAAS,MAAM,EAAE,UAAU,SAAS,MAAM;IAIxI,QAAQ,CAAC,EAAE,SAAS,CAAC;IAKrB,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAK3B,cAAc,CAAC,EAAE,UAAU,CAAC;IAK5B,YAAY,EAAE,MAAM,CAAC;IAKrB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAK7B,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,CAAC;IAKzC,iBAAiB,CAAC,CAAC,KAAK,EAAE,mCAAmC,CAAC,SAAS,EAAE,CAAC,GAAG,IAAI,CAAC;IAKlF,kBAAkB,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAK1C,cAAc,CAAC,EAAE,mBAAmB,CAAC;CACxC;AASD,eAAO,MAAM,iBAAiB,GAAI,MAAM,SAAS,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,SAAS,SAAS,MAAM,EAAE,UAAU,SAAS,MAAM,EAAE,OAAO,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,4CA4BnM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTableForQuery.js","sources":["../../../DataTables/DataTableForQuery.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 { DataTable, DataTableFilterMeta, DataTableSelectionSingleChangeEvent } from 'primereact/datatable';\nimport { Constructor } from '@cratis/fundamentals';\nimport { IQueryFor, Paging } from '@cratis/arc/queries';\nimport { useQueryWithPaging } from '@cratis/arc.react/queries';\nimport { ReactNode, useState } from 'react';\n\n \n\n/**\n * Props for the DataTableForQuery component\n */\nexport interface DataTableForQueryProps<TQuery extends IQueryFor<TDataType>, TDataType, TArguments> {\n /**\n * Children to render\n */\n children?: ReactNode;\n\n /**\n * The type of query to use\n */\n query: Constructor<TQuery>;\n\n /**\n * Optional Arguments to pass to the query\n */\n queryArguments?: TArguments;\n\n /**\n * The message to show when there is no data\n */\n emptyMessage: string;\n\n /**\n * The key to use for the data\n */\n dataKey?: string | undefined;\n\n /**\n * The current selection.\n */\n selection?:
|
|
1
|
+
{"version":3,"file":"DataTableForQuery.js","sources":["../../../DataTables/DataTableForQuery.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 { DataTable, DataTableFilterMeta, DataTableSelectionSingleChangeEvent } from 'primereact/datatable';\nimport { Constructor } from '@cratis/fundamentals';\nimport { IQueryFor, Paging } from '@cratis/arc/queries';\nimport { useQueryWithPaging } from '@cratis/arc.react/queries';\nimport { ReactNode, useState } from 'react';\n\n \n\n/**\n * Props for the DataTableForQuery component\n */\nexport interface DataTableForQueryProps<TQuery extends IQueryFor<TDataType, TArguments>, TDataType extends object, TArguments extends object> {\n /**\n * Children to render\n */\n children?: ReactNode;\n\n /**\n * The type of query to use\n */\n query: Constructor<TQuery>;\n\n /**\n * Optional Arguments to pass to the query\n */\n queryArguments?: TArguments;\n\n /**\n * The message to show when there is no data\n */\n emptyMessage: string;\n\n /**\n * The key to use for the data\n */\n dataKey?: string | undefined;\n\n /**\n * The current selection.\n */\n selection?: TDataType | undefined | null;\n\n /**\n * Callback for when the selection changes\n */\n onSelectionChange?(event: DataTableSelectionSingleChangeEvent<TDataType[]>): void;\n\n /**\n * Fields to use for global filtering\n */\n globalFilterFields?: string[] | undefined;\n\n /**\n * Default filters to use\n */\n defaultFilters?: DataTableFilterMeta;\n}\n\nconst paging = new Paging(0, 20);\n\n/**\n * Represents a DataTable for a query.\n * @param props Props for the component\n * @returns Function to render the DataTableForQuery component\n */\nexport const DataTableForQuery = <TQuery extends IQueryFor<TDataType, TArguments>, TDataType extends object, TArguments extends object>(props: DataTableForQueryProps<TQuery, TDataType, TArguments>) => {\n const [filters, setFilters] = useState<DataTableFilterMeta>(props.defaultFilters ?? {});\n const [result, , , setPage] = useQueryWithPaging(props.query, paging, props.queryArguments);\n\n return (\n <DataTable\n value={result.data as unknown as object[]}\n lazy\n rows={paging.pageSize}\n totalRecords={result.paging.totalItems}\n paginator\n alwaysShowPaginator={false}\n first={result.paging.page * paging.pageSize}\n onPage={(e) => setPage(e.page ?? 0)}\n scrollable\n scrollHeight={'flex'}\n selectionMode='single'\n selection={props.selection}\n onSelectionChange={props.onSelectionChange}\n dataKey={props.dataKey}\n filters={filters}\n filterDisplay='menu'\n onFilter={(e) => setFilters(e.filters)}\n globalFilterFields={props.globalFilterFields}\n emptyMessage={props.emptyMessage} >\n {props.children}\n </DataTable >\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;AA6DA,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC;AAOzB,MAAM,iBAAiB,GAAG,CAAuG,KAA4D,KAAI;AACpM,IAAA,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAsB,KAAK,CAAC,cAAc,IAAI,EAAE,CAAC;IACvF,MAAM,CAAC,MAAM,MAAM,OAAO,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC;AAE3F,IAAA,QACIA,GAAA,CAAC,SAAS,EAAA,EACN,KAAK,EAAE,MAAM,CAAC,IAA2B,EACzC,IAAI,EAAA,IAAA,EACJ,IAAI,EAAE,MAAM,CAAC,QAAQ,EACrB,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,EACtC,SAAS,EAAA,IAAA,EACT,mBAAmB,EAAE,KAAK,EAC1B,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,QAAQ,EAC3C,MAAM,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EACnC,UAAU,EAAA,IAAA,EACV,YAAY,EAAE,MAAM,EACpB,aAAa,EAAC,QAAQ,EACtB,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,EAC1C,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,OAAO,EAAE,OAAO,EAChB,aAAa,EAAC,MAAM,EACpB,QAAQ,EAAE,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,EACtC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAC5C,YAAY,EAAE,KAAK,CAAC,YAAY,EAAA,QAAA,EAC/B,KAAK,CAAC,QAAQ,EAAA,CACN;AAErB;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
declare const _default: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: React.ComponentType<
|
|
4
|
+
component: React.ComponentType<Record<string, never>> | undefined;
|
|
5
5
|
};
|
|
6
6
|
export default _default;
|
|
7
7
|
export declare const Default: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTableForQuery.stories.js","sourceRoot":"","sources":["../../../DataTables/DataTableForQuery.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAC;AAC5C,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"DataTableForQuery.stories.js","sourceRoot":"","sources":["../../../DataTables/DataTableForQuery.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAC;AAC5C,MAAM,SAAS,GAA4D,IAAgC,CAAC,OAA4E,IAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAuE,CAAC;AAE1R,eAAe,EAAE,KAAK,EAAE,8BAA8B,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAE/E,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAC,SAAS,KAAG,CAAC,CAAC,CAAC,uDAAqC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmationDialog.stories.js","sourceRoot":"","sources":["../../../Dialogs/ConfirmationDialog.stories.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAEnG,MAAM,IAAI,GAAoC;IAC1C,KAAK,EAAE,4BAA4B;IACnC,SAAS,EAAE,kBAAkB;CAChC,CAAC;AAEF,eAAe,IAAI,CAAC;AAGpB,MAAM,aAAa,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,EAAsC,EAAE,EAAE;IAC7E,MAAM,CAAC,UAAU,CAAC,GAAG,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IACtF,OAAO,CACH,iBAAQ,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE,4BAAsB,CAC5D,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAU;IAC1B,IAAI,EAAE;QACF,KAAK,EAAE,mCAAmC;QAC1C,OAAO,EAAE,wDAAwD;KACpE;IACD,MAAM,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"ConfirmationDialog.stories.js","sourceRoot":"","sources":["../../../Dialogs/ConfirmationDialog.stories.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAEnG,MAAM,IAAI,GAAoC;IAC1C,KAAK,EAAE,4BAA4B;IACnC,SAAS,EAAE,kBAAkB;CAChC,CAAC;AAEF,eAAe,IAAI,CAAC;AAGpB,MAAM,aAAa,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,EAAsC,EAAE,EAAE;IAC7E,MAAM,CAAC,UAAU,CAAC,GAAG,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IACtF,OAAO,CACH,iBAAQ,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE,4BAAsB,CAC5D,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAU;IAC1B,IAAI,EAAE;QACF,KAAK,EAAE,mCAAmC;QAC1C,OAAO,EAAE,wDAAwD;KACpE;IACD,MAAM,EAAE,CAAC,IAAwC,EAAE,EAAE,CAAC,CAClD,cAAK,SAAS,EAAC,mBAAmB,YAC9B,KAAC,gBAAgB,IAAC,YAAY,EAAE,kBAAkB,YAC9C,KAAC,aAAa,IAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,GAAI,GAC5C,GACjB,CACT;CACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PivotViewer.d.ts","sourceRoot":"","sources":["../../../PivotViewer/PivotViewer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"PivotViewer.d.ts","sourceRoot":"","sources":["../../../PivotViewer/PivotViewer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAQhD,OAAO,mBAAmB,CAAC;AAe3B,wBAAgB,WAAW,CAAC,KAAK,SAAS,MAAM,EAAE,EAC9C,IAAI,EACJ,UAAU,EACV,OAAO,EACP,mBAAmB,EACnB,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,SAAiB,GACpB,EAAE,gBAAgB,CAAC,KAAK,CAAC,2CA6VzB"}
|