@wix/auto-patterns 1.15.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +16 -4
- package/dist/cjs/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
- package/dist/cjs/components/AutoPatternsCollectionPageContent/SkeletonCollection.js +34 -0
- package/dist/cjs/components/AutoPatternsCollectionPageContent/SkeletonCollection.js.map +1 -0
- package/dist/cjs/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +1 -0
- package/dist/cjs/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/SkeletonEntity.js +198 -0
- package/dist/cjs/components/AutoPatternsEntityPage/SkeletonEntity.js.map +1 -0
- package/dist/cjs/components/AutoPatternsRoute/AutoPatternsPage.js +13 -3
- package/dist/cjs/components/AutoPatternsRoute/AutoPatternsPage.js.map +1 -1
- package/dist/cjs/hooks/useBaseTableFeatures.js +7 -2
- package/dist/cjs/hooks/useBaseTableFeatures.js.map +1 -1
- package/dist/cjs/hooks/useCollectionPageOnRowClickActions.js +49 -0
- package/dist/cjs/hooks/useCollectionPageOnRowClickActions.js.map +1 -0
- package/dist/cjs/providers/PatternsWizardOverridesContext.js +1 -1
- package/dist/cjs/providers/PatternsWizardOverridesContext.js.map +1 -1
- package/dist/cjs/providers/SchemaContext.js +4 -3
- package/dist/cjs/providers/SchemaContext.js.map +1 -1
- package/dist/cjs/types/CollectionPageConfig.js.map +1 -1
- package/dist/cjs/types/actions/collectionPageActions.js.map +1 -1
- package/dist/docs/action_cell.md +214 -0
- package/dist/docs/app_config_structure.md +355 -0
- package/dist/docs/auto-patterns-guide.md +2447 -0
- package/dist/docs/bulk_actions.md +266 -0
- package/dist/docs/collection_page.md +54 -0
- package/dist/docs/collection_page_actions.md +343 -0
- package/dist/docs/custom_overrides.md +511 -0
- package/dist/docs/entity_page.md +104 -0
- package/dist/docs/entity_page_actions.md +92 -0
- package/dist/docs/index.md +76 -0
- package/dist/docs/installation.md +55 -0
- package/dist/docs/introduction.md +74 -0
- package/dist/docs/pages_configuration.md +129 -0
- package/dist/docs/recipe-bulk-operations.md +1352 -0
- package/dist/docs/recipe-crud-operations.md +786 -0
- package/dist/docs/recipe-customization.md +1702 -0
- package/dist/docs/recipe-first-dashboard.md +794 -0
- package/dist/docs/sdk_and_schema.md +215 -0
- package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +7 -1
- package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
- package/dist/esm/components/AutoPatternsCollectionPageContent/SkeletonCollection.js +21 -0
- package/dist/esm/components/AutoPatternsCollectionPageContent/SkeletonCollection.js.map +1 -0
- package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +3 -1
- package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js +91 -0
- package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js.map +1 -0
- package/dist/esm/components/AutoPatternsRoute/AutoPatternsPage.js +5 -1
- package/dist/esm/components/AutoPatternsRoute/AutoPatternsPage.js.map +1 -1
- package/dist/esm/hooks/useBaseTableFeatures.js +6 -1
- package/dist/esm/hooks/useBaseTableFeatures.js.map +1 -1
- package/dist/esm/hooks/useCollectionPageOnRowClickActions.js +45 -0
- package/dist/esm/hooks/useCollectionPageOnRowClickActions.js.map +1 -0
- package/dist/esm/providers/PatternsWizardOverridesContext.js.map +1 -1
- package/dist/esm/providers/SchemaContext.js +3 -2
- package/dist/esm/providers/SchemaContext.js.map +1 -1
- package/dist/esm/types/CollectionPageConfig.js.map +1 -1
- package/dist/esm/types/actions/collectionPageActions.js.map +1 -1
- package/dist/types/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsCollectionPageContent/SkeletonCollection.d.ts +5 -0
- package/dist/types/components/AutoPatternsCollectionPageContent/SkeletonCollection.d.ts.map +1 -0
- package/dist/types/components/AutoPatternsEntityPage/SkeletonEntity.d.ts +7 -0
- package/dist/types/components/AutoPatternsEntityPage/SkeletonEntity.d.ts.map +1 -0
- package/dist/types/components/AutoPatternsRoute/AutoPatternsPage.d.ts.map +1 -1
- package/dist/types/hooks/useBaseTableFeatures.d.ts +1 -1
- package/dist/types/hooks/useBaseTableFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useCollectionPageOnRowClickActions.d.ts +7 -0
- package/dist/types/hooks/useCollectionPageOnRowClickActions.d.ts.map +1 -0
- package/dist/types/hooks/useTableFeatures.d.ts +1 -1
- package/dist/types/hooks/useTableGridSwitchFeatures.d.ts +1 -1
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts +2 -2
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts.map +1 -1
- package/dist/types/providers/SchemaContext.d.ts +2 -1
- package/dist/types/providers/SchemaContext.d.ts.map +1 -1
- package/dist/types/types/CollectionPageConfig.d.ts +2 -1
- package/dist/types/types/CollectionPageConfig.d.ts.map +1 -1
- package/dist/types/types/actions/collectionPageActions.d.ts +8 -0
- package/dist/types/types/actions/collectionPageActions.d.ts.map +1 -1
- package/package.json +21 -16
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
## SDK Utilities
|
|
2
|
+
|
|
3
|
+
The `sdk` parameter provides access to Auto Patterns utilities and context. Available in custom actions across all action types (ActionCell, BulkActions, CollectionPage actions, and EntityPage Actions).
|
|
4
|
+
|
|
5
|
+
### Key SDK Utilities
|
|
6
|
+
The only functions exist in sdk are:
|
|
7
|
+
|
|
8
|
+
• **closeModal** - `closeModal(): void`
|
|
9
|
+
- Closes the currently open modal
|
|
10
|
+
- Example: `sdk.closeModal()` after saving or canceling
|
|
11
|
+
|
|
12
|
+
• **getOptimisticActions** - `getOptimisticActions(collectionId): OptimisticActions`
|
|
13
|
+
- Provides optimistic UI updates for immediate user feedback
|
|
14
|
+
- Supports create, update, delete operations with automatic rollback on failure
|
|
15
|
+
- Example: `sdk.getOptimisticActions(sdk.collectionId).updateOne(item, { ... })`
|
|
16
|
+
|
|
17
|
+
• **getSchema** - `getSchema(collectionId): SchemaConfig | undefined`
|
|
18
|
+
- Access to collection schema information (fields, types, validation)
|
|
19
|
+
- Useful for dynamic operations based on collection structure
|
|
20
|
+
- Example: `const schema = sdk.getSchema(sdk.collectionId)`
|
|
21
|
+
|
|
22
|
+
• **collectionId** - `string`
|
|
23
|
+
- Current collection context identifier
|
|
24
|
+
- Available in all action contexts for referencing the active collection
|
|
25
|
+
- Example: `sdk.collectionId` to get the current collection ID
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## OptimisticActions
|
|
30
|
+
|
|
31
|
+
Provides immediate UI updates with automatic server synchronization and error recovery.
|
|
32
|
+
|
|
33
|
+
### Usage Rules
|
|
34
|
+
|
|
35
|
+
**Use OptimisticActions for:**
|
|
36
|
+
- Data modification operations (create, update, delete)
|
|
37
|
+
- Operations requiring immediate visual feedback
|
|
38
|
+
|
|
39
|
+
**Do NOT use for:**
|
|
40
|
+
- Read-only operations
|
|
41
|
+
- Operations requiring server confirmation first
|
|
42
|
+
|
|
43
|
+
### Core Pattern
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
// Get instances from SDK (see SDK Utilities section)
|
|
47
|
+
const optimisticActions = sdk.getOptimisticActions(sdk.collectionId);
|
|
48
|
+
const schema = sdk.getSchema(sdk.collectionId);
|
|
49
|
+
|
|
50
|
+
optimisticActions.operation(items, {
|
|
51
|
+
submit: async (items) => schema.actions.serverMethod(items),
|
|
52
|
+
successToast: 'Success message',
|
|
53
|
+
errorToast: (err, {retry}) => ({ text: 'Error message', action: { text: 'Retry', onClick: retry }})
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Available Operations
|
|
58
|
+
|
|
59
|
+
#### Create Operations
|
|
60
|
+
- `createOne(item: T, params: OptimisticParams<T>): void`
|
|
61
|
+
- `createMany(items: T[], params: OptimisticParams<T>): void`
|
|
62
|
+
|
|
63
|
+
#### Update Operations
|
|
64
|
+
- `updateOne(item: T, params: OptimisticParams<T>): void`
|
|
65
|
+
- `updateMany(items: T[], params: OptimisticParams<T>): void`
|
|
66
|
+
- `updateAll(transformFn: (item: T) => Partial<T>, params: OptimisticParams<T>): void`
|
|
67
|
+
|
|
68
|
+
#### Delete Operations
|
|
69
|
+
- `deleteOne(item: T, params: OptimisticParams<T> & { showUndoToast: true }): void`
|
|
70
|
+
- `deleteMany(items: T[], params: OptimisticParams<T> & { showUndoToast: true }): void`
|
|
71
|
+
- `deleteAll(params: OptimisticParams<T> & { showUndoToast: true }): void`
|
|
72
|
+
|
|
73
|
+
### Type Definitions
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
interface OptimisticParams<T> {
|
|
77
|
+
submit: (items: T[]) => Promise<any>;
|
|
78
|
+
successToast: string | ToastConfig;
|
|
79
|
+
errorToast: (error: Error, actions: { retry: () => void }) => ToastConfig | string;
|
|
80
|
+
showUndoToast?: boolean; // Required: true for delete operations
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
interface ToastConfig {
|
|
84
|
+
text: string;
|
|
85
|
+
action?: { text: string; onClick: () => void };
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Validation Requirements
|
|
90
|
+
|
|
91
|
+
**Before using optimistic actions:**
|
|
92
|
+
- Verify `sdk.getOptimisticActions(collectionId)` returns valid instance
|
|
93
|
+
- Verify `sdk.getSchema(collectionId)` returns valid schema
|
|
94
|
+
- For delete operations: `showUndoToast: true` is mandatory
|
|
95
|
+
- All `submit` functions must return a Promise
|
|
96
|
+
|
|
97
|
+
**SDK Parameter:** Available in custom actions and modals. See SDK Utilities section for complete interface.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## SchemaConfig Usage
|
|
102
|
+
|
|
103
|
+
SchemaConfig provides complete collection metadata and server actions. Essential for dynamic operations and accessing collection structure information.
|
|
104
|
+
|
|
105
|
+
### Key Properties
|
|
106
|
+
|
|
107
|
+
• **id** - `string`
|
|
108
|
+
- Collection identifier (e.g., "WixPets")
|
|
109
|
+
- Example: `schema.id === "WixPets"`
|
|
110
|
+
|
|
111
|
+
• **idField** - `string`
|
|
112
|
+
- Primary key field name (usually "_id")
|
|
113
|
+
- Required for all update/delete operations
|
|
114
|
+
- Example: `const id = item[schema.idField]`
|
|
115
|
+
|
|
116
|
+
• **displayField** - `string`
|
|
117
|
+
- Main field for displaying items (name, title, etc.)
|
|
118
|
+
- Used in UI components for item identification
|
|
119
|
+
- Example: `const label = item[schema.displayField]`
|
|
120
|
+
|
|
121
|
+
• **fields** - `Record<string, Field | undefined>`
|
|
122
|
+
- Complete field definitions with types and metadata
|
|
123
|
+
- Useful for dynamic form generation or validation
|
|
124
|
+
- Example: `schema.fields.name.type === 'TEXT'`
|
|
125
|
+
|
|
126
|
+
• **actions** - Server operation functions
|
|
127
|
+
- Pre-configured API calls for CRUD operations
|
|
128
|
+
- Use with optimistic actions for best UX
|
|
129
|
+
- Example: `await schema.actions.update(item)`
|
|
130
|
+
|
|
131
|
+
### Available Schema Actions
|
|
132
|
+
|
|
133
|
+
- schema.actions.create(item) // Create single item
|
|
134
|
+
- schema.actions.update(item) // Update single item
|
|
135
|
+
- schema.actions.delete(itemId) // Delete by ID
|
|
136
|
+
- schema.actions.bulkUpdate(updates) // Update multiple items
|
|
137
|
+
- schema.actions.bulkDelete(itemIds) // Delete multiple items
|
|
138
|
+
|
|
139
|
+
### Schema Validation Checklist
|
|
140
|
+
|
|
141
|
+
Before using schema in operations:
|
|
142
|
+
|
|
143
|
+
✓ Check if schema exists: `if (!schema) return;`
|
|
144
|
+
✓ Verify required fields exist on items
|
|
145
|
+
✓ Use `schema.idField` for ID operations
|
|
146
|
+
✓ Use `schema.displayField` for UI display
|
|
147
|
+
✓ Use `schema.actions` for server operations
|
|
148
|
+
|
|
149
|
+
### Common Usage Patterns
|
|
150
|
+
|
|
151
|
+
- **ActionCell**: Use `schema.actions.update()` or `schema.actions.delete()` for single item operations
|
|
152
|
+
- **BulkActions**: Use `schema.actions.bulkUpdate()` or `schema.actions.bulkDelete()` for multiple items
|
|
153
|
+
- **Dynamic UI**: Use `schema.fields` to build forms or validate data
|
|
154
|
+
- **Error Messages**: Use `schema.displayField` to create meaningful user feedback
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Filters Configuration Notes
|
|
159
|
+
|
|
160
|
+
To configure filters in a `collectionPage`, add a `filters` property inside the page's component configuration object. Each filter must reference a valid field by its `fieldId`, and the supported types are:
|
|
161
|
+
|
|
162
|
+
* `numberConfig`: used with fields of type `NUMBER`
|
|
163
|
+
* `dateConfig`: used with fields of type `DATETIME`
|
|
164
|
+
* `booleanConfig`: used with fields of type `BOOLEAN`
|
|
165
|
+
* `enumConfig`: used with fields of type `ARRAY` or `ARRAY_STRING`
|
|
166
|
+
|
|
167
|
+
### Enum Configuration Implementation
|
|
168
|
+
|
|
169
|
+
When implementing enum filters, you must ask the user to provide the possible option values. Never invent or assume enum values. Here's how to properly handle enumConfig:
|
|
170
|
+
|
|
171
|
+
#### Example: User-Provided Enum Implementation
|
|
172
|
+
|
|
173
|
+
1. First, collect the possible values from the user:
|
|
174
|
+
```
|
|
175
|
+
User requests: "I need a filter for pet types."
|
|
176
|
+
You ask: "What are the possible values for pet types that should be available in the filter?"
|
|
177
|
+
User responds: "dog, cat, bird, rabbit, fish"
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
2. Then, create the `enumConfig` structure:
|
|
181
|
+
```json
|
|
182
|
+
"enumConfig": {
|
|
183
|
+
"options": [
|
|
184
|
+
{ "value": "dog", "label": "Dog" },
|
|
185
|
+
{ "value": "cat", "label": "Cat" },
|
|
186
|
+
{ "value": "bird", "label": "Bird" },
|
|
187
|
+
{ "value": "rabbit", "label": "Rabbit" },
|
|
188
|
+
{ "value": "fish", "label": "Fish" }
|
|
189
|
+
],
|
|
190
|
+
"selectionMode": "multiple",
|
|
191
|
+
"optionType": "checkbox"
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Notice how the `label` is derived from the `value` by capitalizing the first letter. The user's exact values become the `value` property.
|
|
196
|
+
|
|
197
|
+
### Grouping Filters with Section Title
|
|
198
|
+
|
|
199
|
+
* Filters can be grouped by sections using the `sectionTitle` property.
|
|
200
|
+
* If multiple filter items share the same `sectionTitle`, they will be displayed together in a grouped section in the UI.
|
|
201
|
+
* Filters without a `sectionTitle` will appear in a default section or be displayed individually.
|
|
202
|
+
* Grouping helps maintain clarity, especially when dealing with multiple filter options.
|
|
203
|
+
|
|
204
|
+
### Key Guidelines
|
|
205
|
+
|
|
206
|
+
* **openByDefault**: Automatically expands the filter accordion when the filters panel is opened.
|
|
207
|
+
* **tagLabel**: Specifies the label displayed in a Tag component on the table or grid once the filter is active. For example, if the tagLabel is "Age", the filter display might show: `Age: 7`.
|
|
208
|
+
* **maxInlineFilters**: Limits the number of filters shown inline in the table toolbar. Others are accessible via the panel. Default is 0.
|
|
209
|
+
* **dateConfig.mode**:
|
|
210
|
+
|
|
211
|
+
* `ONLY_PREDEFINED`: user can select only from preset options
|
|
212
|
+
* `ONLY_CUSTOM`: user must select a custom date range manually (no presets)
|
|
213
|
+
* `COMBINE`: both options available
|
|
214
|
+
* **dateConfig.presets** must be omitted if mode is `ONLY_CUSTOM`.
|
|
215
|
+
* **dateConfig.includeTime**: Controls whether time selection is also enabled alongside date (default is `true`).
|
package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js
CHANGED
|
@@ -3,6 +3,7 @@ import { AutoPatternsTable } from '../AutoPatternsTable';
|
|
|
3
3
|
import { AutoPatternsGrid } from '../AutoPatternsGrid';
|
|
4
4
|
import { AutoPatternsTableGridSwitch } from '../AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch';
|
|
5
5
|
import { SchemaProvider } from '../../providers';
|
|
6
|
+
import { SkeletonCollection } from './SkeletonCollection';
|
|
6
7
|
export const AutoPatternsCollectionPageContent = _ref => {
|
|
7
8
|
let {
|
|
8
9
|
configuration
|
|
@@ -21,6 +22,7 @@ export const AutoPatternsCollectionPageContent = _ref => {
|
|
|
21
22
|
}
|
|
22
23
|
const tableConfig = (_layout$find = layout.find(item => item.type === 'Table')) == null ? void 0 : _layout$find.table;
|
|
23
24
|
const gridConfig = (_layout$find2 = layout.find(item => item.type === 'Grid')) == null ? void 0 : _layout$find2.grid;
|
|
25
|
+
let componentType = 'Table';
|
|
24
26
|
let componentToRender = null;
|
|
25
27
|
if (tableConfig && gridConfig) {
|
|
26
28
|
const config = {
|
|
@@ -40,6 +42,7 @@ export const AutoPatternsCollectionPageContent = _ref => {
|
|
|
40
42
|
configuration: config
|
|
41
43
|
});
|
|
42
44
|
} else if (gridConfig) {
|
|
45
|
+
componentType = 'Grid';
|
|
43
46
|
const config = {
|
|
44
47
|
...sharedConfig,
|
|
45
48
|
...gridConfig
|
|
@@ -50,7 +53,10 @@ export const AutoPatternsCollectionPageContent = _ref => {
|
|
|
50
53
|
}
|
|
51
54
|
return componentToRender ? /*#__PURE__*/React.createElement(SchemaProvider, {
|
|
52
55
|
key: `${sharedConfig.collection.collectionId}-${index}`,
|
|
53
|
-
collection: sharedConfig.collection
|
|
56
|
+
collection: sharedConfig.collection,
|
|
57
|
+
skeleton: /*#__PURE__*/React.createElement(SkeletonCollection, {
|
|
58
|
+
componentType: componentType
|
|
59
|
+
})
|
|
54
60
|
}, componentToRender) : null;
|
|
55
61
|
}).filter(Boolean));
|
|
56
62
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","AutoPatternsTable","AutoPatternsGrid","AutoPatternsTableGridSwitch","SchemaProvider","AutoPatternsCollectionPageContent","_ref","configuration","components","createElement","Fragment","map","component","index","_layout$find","_layout$find2","layout","sharedConfig","length","tableConfig","find","item","type","table","gridConfig","grid","componentToRender","config","key","collection","collectionId","filter","Boolean"],"sources":["../../../../src/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.tsx"],"sourcesContent":["import React from 'react';\nimport { AutoPatternsTable } from '../AutoPatternsTable';\nimport { CollectionPageConfig } from '../../types';\nimport { AutoPatternsGrid } from '../AutoPatternsGrid';\nimport { AutoPatternsTableGridSwitch } from '../AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch';\nimport { SchemaProvider } from '../../providers';\n\nexport interface AutoPatternsCollectionPageContentProps {\n configuration: CollectionPageConfig;\n}\n\nexport const AutoPatternsCollectionPageContent = ({\n configuration,\n}: AutoPatternsCollectionPageContentProps) => {\n const { components } = configuration;\n return (\n <>\n {components\n .map((component, index) => {\n const { layout, ...sharedConfig } = component;\n\n if (!layout?.length) {\n return null;\n }\n\n const tableConfig = layout.find(\n (item) => item.type === 'Table',\n )?.table;\n const gridConfig = layout.find((item) => item.type === 'Grid')?.grid;\n\n let componentToRender = null;\n\n if (tableConfig && gridConfig) {\n const config = {\n ...sharedConfig,\n ...tableConfig,\n ...gridConfig,\n };\n componentToRender = (\n <AutoPatternsTableGridSwitch configuration={config} />\n );\n } else if (tableConfig) {\n const config = { ...sharedConfig, ...tableConfig };\n componentToRender = <AutoPatternsTable configuration={config} />;\n } else if (gridConfig) {\n const config = { ...sharedConfig, ...gridConfig };\n componentToRender = <AutoPatternsGrid configuration={config} />;\n }\n\n return componentToRender ? (\n <SchemaProvider\n key={`${sharedConfig.collection.collectionId}-${index}`}\n collection={sharedConfig.collection}\n >\n {componentToRender}\n </SchemaProvider>\n ) : null;\n })\n .filter(Boolean)}\n </>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,sBAAsB;AAExD,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,2BAA2B,QAAQ,4DAA4D;AACxG,SAASC,cAAc,QAAQ,iBAAiB;
|
|
1
|
+
{"version":3,"names":["React","AutoPatternsTable","AutoPatternsGrid","AutoPatternsTableGridSwitch","SchemaProvider","SkeletonCollection","AutoPatternsCollectionPageContent","_ref","configuration","components","createElement","Fragment","map","component","index","_layout$find","_layout$find2","layout","sharedConfig","length","tableConfig","find","item","type","table","gridConfig","grid","componentType","componentToRender","config","key","collection","collectionId","skeleton","filter","Boolean"],"sources":["../../../../src/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.tsx"],"sourcesContent":["import React from 'react';\nimport { AutoPatternsTable } from '../AutoPatternsTable';\nimport { CollectionPageConfig } from '../../types';\nimport { AutoPatternsGrid } from '../AutoPatternsGrid';\nimport { AutoPatternsTableGridSwitch } from '../AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch';\nimport { SchemaProvider } from '../../providers';\nimport { SkeletonCollection } from './SkeletonCollection';\n\nexport interface AutoPatternsCollectionPageContentProps {\n configuration: CollectionPageConfig;\n}\n\nexport const AutoPatternsCollectionPageContent = ({\n configuration,\n}: AutoPatternsCollectionPageContentProps) => {\n const { components } = configuration;\n return (\n <>\n {components\n .map((component, index) => {\n const { layout, ...sharedConfig } = component;\n\n if (!layout?.length) {\n return null;\n }\n\n const tableConfig = layout.find(\n (item) => item.type === 'Table',\n )?.table;\n const gridConfig = layout.find((item) => item.type === 'Grid')?.grid;\n let componentType: 'Table' | 'Grid' = 'Table';\n\n let componentToRender = null;\n\n if (tableConfig && gridConfig) {\n const config = {\n ...sharedConfig,\n ...tableConfig,\n ...gridConfig,\n };\n componentToRender = (\n <AutoPatternsTableGridSwitch configuration={config} />\n );\n } else if (tableConfig) {\n const config = { ...sharedConfig, ...tableConfig };\n componentToRender = <AutoPatternsTable configuration={config} />;\n } else if (gridConfig) {\n componentType = 'Grid';\n const config = { ...sharedConfig, ...gridConfig };\n componentToRender = <AutoPatternsGrid configuration={config} />;\n }\n\n return componentToRender ? (\n <SchemaProvider\n key={`${sharedConfig.collection.collectionId}-${index}`}\n collection={sharedConfig.collection}\n skeleton={<SkeletonCollection componentType={componentType} />}\n >\n {componentToRender}\n </SchemaProvider>\n ) : null;\n })\n .filter(Boolean)}\n </>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,sBAAsB;AAExD,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,2BAA2B,QAAQ,4DAA4D;AACxG,SAASC,cAAc,QAAQ,iBAAiB;AAChD,SAASC,kBAAkB,QAAQ,sBAAsB;AAMzD,OAAO,MAAMC,iCAAiC,GAAGC,IAAA,IAEH;EAAA,IAFI;IAChDC;EACsC,CAAC,GAAAD,IAAA;EACvC,MAAM;IAAEE;EAAW,CAAC,GAAGD,aAAa;EACpC,oBACER,KAAA,CAAAU,aAAA,CAAAV,KAAA,CAAAW,QAAA,QACGF,UAAU,CACRG,GAAG,CAAC,CAACC,SAAS,EAAEC,KAAK,KAAK;IAAA,IAAAC,YAAA,EAAAC,aAAA;IACzB,MAAM;MAAEC,MAAM;MAAE,GAAGC;IAAa,CAAC,GAAGL,SAAS;IAE7C,IAAI,EAACI,MAAM,YAANA,MAAM,CAAEE,MAAM,GAAE;MACnB,OAAO,IAAI;IACb;IAEA,MAAMC,WAAW,IAAAL,YAAA,GAAGE,MAAM,CAACI,IAAI,CAC5BC,IAAI,IAAKA,IAAI,CAACC,IAAI,KAAK,OAC1B,CAAC,qBAFmBR,YAAA,CAEjBS,KAAK;IACR,MAAMC,UAAU,IAAAT,aAAA,GAAGC,MAAM,CAACI,IAAI,CAAEC,IAAI,IAAKA,IAAI,CAACC,IAAI,KAAK,MAAM,CAAC,qBAA3CP,aAAA,CAA6CU,IAAI;IACpE,IAAIC,aAA+B,GAAG,OAAO;IAE7C,IAAIC,iBAAiB,GAAG,IAAI;IAE5B,IAAIR,WAAW,IAAIK,UAAU,EAAE;MAC7B,MAAMI,MAAM,GAAG;QACb,GAAGX,YAAY;QACf,GAAGE,WAAW;QACd,GAAGK;MACL,CAAC;MACDG,iBAAiB,gBACf5B,KAAA,CAAAU,aAAA,CAACP,2BAA2B;QAACK,aAAa,EAAEqB;MAAO,CAAE,CACtD;IACH,CAAC,MAAM,IAAIT,WAAW,EAAE;MACtB,MAAMS,MAAM,GAAG;QAAE,GAAGX,YAAY;QAAE,GAAGE;MAAY,CAAC;MAClDQ,iBAAiB,gBAAG5B,KAAA,CAAAU,aAAA,CAACT,iBAAiB;QAACO,aAAa,EAAEqB;MAAO,CAAE,CAAC;IAClE,CAAC,MAAM,IAAIJ,UAAU,EAAE;MACrBE,aAAa,GAAG,MAAM;MACtB,MAAME,MAAM,GAAG;QAAE,GAAGX,YAAY;QAAE,GAAGO;MAAW,CAAC;MACjDG,iBAAiB,gBAAG5B,KAAA,CAAAU,aAAA,CAACR,gBAAgB;QAACM,aAAa,EAAEqB;MAAO,CAAE,CAAC;IACjE;IAEA,OAAOD,iBAAiB,gBACtB5B,KAAA,CAAAU,aAAA,CAACN,cAAc;MACb0B,GAAG,EAAE,GAAGZ,YAAY,CAACa,UAAU,CAACC,YAAY,IAAIlB,KAAK,EAAG;MACxDiB,UAAU,EAAEb,YAAY,CAACa,UAAW;MACpCE,QAAQ,eAAEjC,KAAA,CAAAU,aAAA,CAACL,kBAAkB;QAACsB,aAAa,EAAEA;MAAc,CAAE;IAAE,GAE9DC,iBACa,CAAC,GACf,IAAI;EACV,CAAC,CAAC,CACDM,MAAM,CAACC,OAAO,CACjB,CAAC;AAEP,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { TableGridSwitch, useTableGridSwitchCollection } from '@wix/patterns';
|
|
3
|
+
export const SkeletonCollection = _ref => {
|
|
4
|
+
let {
|
|
5
|
+
componentType
|
|
6
|
+
} = _ref;
|
|
7
|
+
const state = useTableGridSwitchCollection({
|
|
8
|
+
queryName: '',
|
|
9
|
+
fetchData: async () => new Promise(() => {}),
|
|
10
|
+
limit: 50
|
|
11
|
+
});
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
state.viewType = componentType === 'Table' ? 'table' : 'grid';
|
|
14
|
+
}, [componentType, state]);
|
|
15
|
+
return /*#__PURE__*/React.createElement(TableGridSwitch, {
|
|
16
|
+
state: state,
|
|
17
|
+
columns: [],
|
|
18
|
+
dataHook: `auto-patterns-${componentType.toLowerCase()}`
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=SkeletonCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useEffect","TableGridSwitch","useTableGridSwitchCollection","SkeletonCollection","_ref","componentType","state","queryName","fetchData","Promise","limit","viewType","createElement","columns","dataHook","toLowerCase"],"sources":["../../../../src/components/AutoPatternsCollectionPageContent/SkeletonCollection.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { TableGridSwitch, useTableGridSwitchCollection } from '@wix/patterns';\n\nexport const SkeletonCollection = ({\n componentType,\n}: {\n componentType: 'Table' | 'Grid';\n}) => {\n const state = useTableGridSwitchCollection<{}>({\n queryName: '',\n fetchData: async () => new Promise(() => {}),\n limit: 50,\n });\n\n useEffect(() => {\n state.viewType = componentType === 'Table' ? 'table' : 'grid';\n }, [componentType, state]);\n\n return (\n <TableGridSwitch\n state={state}\n columns={[]}\n dataHook={`auto-patterns-${componentType.toLowerCase()}`}\n />\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,SAASC,eAAe,EAAEC,4BAA4B,QAAQ,eAAe;AAE7E,OAAO,MAAMC,kBAAkB,GAAGC,IAAA,IAI5B;EAAA,IAJ6B;IACjCC;EAGF,CAAC,GAAAD,IAAA;EACC,MAAME,KAAK,GAAGJ,4BAA4B,CAAK;IAC7CK,SAAS,EAAE,EAAE;IACbC,SAAS,EAAE,MAAAA,CAAA,KAAY,IAAIC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5CC,KAAK,EAAE;EACT,CAAC,CAAC;EAEFV,SAAS,CAAC,MAAM;IACdM,KAAK,CAACK,QAAQ,GAAGN,aAAa,KAAK,OAAO,GAAG,OAAO,GAAG,MAAM;EAC/D,CAAC,EAAE,CAACA,aAAa,EAAEC,KAAK,CAAC,CAAC;EAE1B,oBACEP,KAAA,CAAAa,aAAA,CAACX,eAAe;IACdK,KAAK,EAAEA,KAAM;IACbO,OAAO,EAAE,EAAG;IACZC,QAAQ,EAAE,iBAAiBT,aAAa,CAACU,WAAW,CAAC,CAAC;EAAG,CAC1D,CAAC;AAEN,CAAC","ignoreList":[]}
|
|
@@ -187,7 +187,9 @@ export const AutoPatternsEntityPage = _ref3 => {
|
|
|
187
187
|
moreActions: resolvedMoreActions.length > 0 ? /*#__PURE__*/React.createElement(MoreActions, {
|
|
188
188
|
items: resolvedMoreActions
|
|
189
189
|
}) : undefined
|
|
190
|
-
}), /*#__PURE__*/React.createElement(EntityPage.Content, null, /*#__PURE__*/React.createElement(EntityPage.MainContent,
|
|
190
|
+
}), /*#__PURE__*/React.createElement(EntityPage.Content, null, /*#__PURE__*/React.createElement(EntityPage.MainContent, {
|
|
191
|
+
dataHook: "entity-page-main-content"
|
|
192
|
+
}, pageLayout == null || (_pageLayout$main = pageLayout.main) == null ? void 0 : _pageLayout$main.map((layout, layoutIndex) => /*#__PURE__*/React.createElement(RenderLayoutCard, {
|
|
191
193
|
key: `main-section-card-${layoutIndex}`,
|
|
192
194
|
layout: layout,
|
|
193
195
|
sectionId: "main",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useMemo","useRef","EntityPage","useEntity","useEntityPage","useEntityPageContext","MoreActions","useForm","Card","Cell","Layout","useParams","useSchema","FormFieldInput","useEntityPageHeaderTexts","useNavigation","usePatternsWizardOverridesContext","useEntityPageMoreActions","useActionsSDK","RenderLayoutContent","_ref","_content$container$ch","_overrides$components","content","level","sectionId","cardIndex","contentIndex","setInputRef","schema","overrides","pageState","type","field","fieldId","fields","createElement","span","key","inputRef","ref","container","children","length","map","child","index","component","componentId","Component","components","form","entity","RenderLayoutCard","_ref2","_layout$card$subtitle","layout","minHeight","Header","title","card","text","subtitle","Divider","Content","AutoPatternsEntityPage","_ref3","_pageLayout$main","_pageLayout$sidebar","configuration","pageLayout","parentPageId","route","moreActions","collectionId","mode","params","entityId","id","isCreateMode","inputRefs","input","current","validate","invalidFieldId","Object","keys","find","_inputRefs$current$fi","invalid","_inputRefs$current$in","focus","Error","getParentPagePath","parentPath","state","onSave","formValues","getValues","baseEntity","updatedEntity","newEntity","actions","update","create","fetch","undefined","get","config","entityDisplayName","displayField","sdk","resolvedMoreActions","dataHook","items","MainContent","main","layoutIndex","sidebar","AdditionalContent"],"sources":["../../../../src/components/AutoPatternsEntityPage/AutoPatternsEntityPage.tsx"],"sourcesContent":["import React, { useMemo, useRef } from 'react';\nimport { CardLayout, EntityPageConfig, LayoutContent } from '../../types';\nimport {\n EntityPage,\n EntityPageState,\n useEntity,\n useEntityPage,\n useEntityPageContext,\n MoreActions,\n} from '@wix/patterns';\nimport { useForm } from '@wix/patterns/form';\nimport { Card, Cell, Layout } from '@wix/design-system';\nimport { useParams } from 'react-router-dom';\nimport { useSchema } from '../../providers/SchemaContext';\nimport { BaseInputRef } from './Fields/types';\nimport { FormFieldInput } from './Fields/FormFieldInput';\nimport { useEntityPageHeaderTexts, useNavigation } from '../../hooks';\nimport { usePatternsWizardOverridesContext } from '../../providers';\nimport { useEntityPageMoreActions } from '../../hooks/useEntityPageMoreActions';\nimport { useActionsSDK } from '../../hooks/useActionsSDK';\n\nconst RenderLayoutContent: React.FC<{\n content: LayoutContent;\n level: number;\n sectionId: string;\n cardIndex: number;\n contentIndex: number;\n setInputRef: (id: string, input: BaseInputRef) => void;\n}> = ({ content, level, sectionId, cardIndex, contentIndex, setInputRef }) => {\n const schema = useSchema();\n const overrides = usePatternsWizardOverridesContext();\n const pageState = useEntityPageContext();\n\n switch (content.type) {\n case 'field':\n if (!content.field.fieldId) {\n return null;\n }\n\n const field = schema.fields[content.field.fieldId];\n\n if (!field) {\n return null;\n }\n\n return (\n <Cell span={content.field.span}>\n <FormFieldInput\n key={content.field.fieldId}\n field={field}\n inputRef={(ref) => setInputRef(content.field.fieldId, ref)}\n />\n </Cell>\n );\n\n case 'container':\n if (!content.container.children?.length) {\n return null;\n }\n\n return (\n <Cell span={content.container.span}>\n <Layout>\n {content.container.children.map((child, index) => (\n <RenderLayoutContent\n key={`${sectionId}-card-${cardIndex}-content-${contentIndex}-level-${level}-child-${index}`}\n content={child}\n level={level + 1}\n sectionId={sectionId}\n cardIndex={cardIndex}\n contentIndex={index}\n setInputRef={setInputRef}\n />\n ))}\n </Layout>\n </Cell>\n );\n\n case 'component':\n if (!content.component.componentId) {\n return null;\n }\n\n const Component = overrides?.components?.[content.component.componentId];\n\n if (!Component) {\n return null;\n }\n\n return (\n <Cell span={content.component.span}>\n <Component\n form={pageState.form as any}\n entity={pageState.entity as any as Record<string, any>}\n />\n </Cell>\n );\n\n default:\n return null;\n }\n};\n\nconst RenderLayoutCard: React.FC<{\n layout: CardLayout;\n sectionId: string;\n cardIndex: number;\n setInputRef: (id: string, input: BaseInputRef) => void;\n}> = ({ layout, sectionId, cardIndex, setInputRef }) => {\n switch (layout.type) {\n case 'card':\n return (\n <EntityPage.Card minHeight=\"50px\">\n <Card.Header\n title={layout.card.title.text}\n subtitle={layout.card.subtitle?.text}\n />\n <Card.Divider />\n <Card.Content>\n <Layout>\n {layout.card.children.map((child, index: number) => (\n <RenderLayoutContent\n key={`${sectionId}-card-${cardIndex}-content-${index}`}\n content={child}\n level={0}\n sectionId={sectionId}\n cardIndex={cardIndex}\n contentIndex={index}\n setInputRef={setInputRef}\n />\n ))}\n </Layout>\n </Card.Content>\n </EntityPage.Card>\n );\n default:\n return null;\n }\n};\n\nexport interface AutoPatternsEntityPageProps {\n configuration: EntityPageConfig;\n}\n\nexport const AutoPatternsEntityPage: React.FC<AutoPatternsEntityPageProps> = ({\n configuration,\n}) => {\n const {\n layout: pageLayout,\n parentPageId,\n route,\n moreActions,\n collectionId,\n } = configuration;\n\n const form = useForm<any>({\n mode: 'onChange',\n });\n const params = useParams();\n const entityId = params[route.params.id];\n const schema = useSchema();\n const isCreateMode = !entityId;\n\n const inputRefs = useRef<{ [fieldId: string]: BaseInputRef }>({});\n\n const setInputRef = (id: string, input: BaseInputRef) => {\n inputRefs.current[id] = input;\n };\n\n const validate = () => {\n const invalidFieldId = Object.keys(inputRefs.current).find((fieldId) => {\n return inputRefs.current[fieldId]?.invalid;\n });\n\n if (invalidFieldId) {\n inputRefs.current[invalidFieldId]?.focus?.();\n throw new Error('Invalid form');\n }\n };\n const { getParentPagePath } = useNavigation();\n\n const parentPath = useMemo(\n () => getParentPagePath(parentPageId),\n [parentPageId, getParentPagePath],\n );\n\n const state: EntityPageState<any> = useEntityPage<any, any>({\n parentPath,\n form,\n onSave: async () => {\n validate();\n\n const formValues = form.getValues();\n const baseEntity = state.entity || {};\n const updatedEntity = {\n ...baseEntity,\n ...formValues,\n };\n\n const newEntity = entityId\n ? await schema.actions.update(updatedEntity)\n : await schema.actions.create(updatedEntity);\n\n return { updatedEntity: newEntity };\n },\n fetch: async () => {\n if (!entityId) {\n return { entity: undefined };\n }\n const entity = await schema.actions.get(entityId);\n return { entity };\n },\n });\n\n const entity = useEntity(state);\n\n const { title, subtitle } = useEntityPageHeaderTexts({\n config: configuration,\n isCreateMode,\n entityDisplayName: entity?.[schema.displayField],\n });\n\n const sdk = useActionsSDK({\n collectionId,\n });\n\n const resolvedMoreActions = useEntityPageMoreActions(\n moreActions,\n entity,\n sdk,\n form,\n );\n\n return (\n <EntityPage state={state} dataHook=\"auto-patterns-entity-page\">\n <EntityPage.Header\n title={title}\n subtitle={subtitle}\n moreActions={\n resolvedMoreActions.length > 0 ? (\n <MoreActions items={resolvedMoreActions} />\n ) : undefined\n }\n />\n <EntityPage.Content>\n <EntityPage.MainContent>\n {pageLayout?.main?.map((layout, layoutIndex) => (\n <RenderLayoutCard\n key={`main-section-card-${layoutIndex}`}\n layout={layout}\n sectionId=\"main\"\n cardIndex={layoutIndex}\n setInputRef={setInputRef}\n />\n ))}\n </EntityPage.MainContent>\n {pageLayout?.sidebar ? (\n <EntityPage.AdditionalContent>\n {pageLayout.sidebar?.map((layout, layoutIndex) => (\n <RenderLayoutCard\n key={`sidebar-section-card-${layoutIndex}`}\n layout={layout}\n sectionId=\"sidebar\"\n cardIndex={layoutIndex}\n setInputRef={setInputRef}\n />\n ))}\n </EntityPage.AdditionalContent>\n ) : null}\n </EntityPage.Content>\n </EntityPage>\n );\n};\n\n/*\n Key structure explanation:\n\n Main cards: main-section-card-{layoutIndex}\n Sidebar cards: sidebar-section-card-{layoutIndex}\n\n Layout content:\n {sectionId}-card-{cardIndex}-content-{contentIndex}\n\n Nested children:\n {sectionId}-card-{cardIndex}-content-{parentContentIndex}-level-{level}-child-{childIndex}\n\n This ensures uniqueness across all levels and sections.\n*/\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAE9C,SACEC,UAAU,EAEVC,SAAS,EACTC,aAAa,EACbC,oBAAoB,EACpBC,WAAW,QACN,eAAe;AACtB,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,IAAI,EAAEC,IAAI,EAAEC,MAAM,QAAQ,oBAAoB;AACvD,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,SAAS,QAAQ,+BAA+B;AAEzD,SAASC,cAAc,QAAQ,yBAAyB;AACxD,SAASC,wBAAwB,EAAEC,aAAa,QAAQ,aAAa;AACrE,SAASC,iCAAiC,QAAQ,iBAAiB;AACnE,SAASC,wBAAwB,QAAQ,sCAAsC;AAC/E,SAASC,aAAa,QAAQ,2BAA2B;AAEzD,MAAMC,mBAOJ,GAAGC,IAAA,IAAyE;EAAA,IAAAC,qB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WAAW,EACTuC,mBAAmB,CAACrE,MAAM,GAAG,CAAC,gBAC5B5C,KAAA,CAAAqC,aAAA,CAAC9B,WAAW;MAAC4G,KAAK,EAAEF;IAAoB,CAAE,CAAC,GACzCN;EACL,CACF,CAAC,eACF3G,KAAA,CAAAqC,aAAA,CAAClC,UAAU,CAAC8D,OAAO,qBACjBjE,KAAA,CAAAqC,aAAA,CAAClC,UAAU,CAACiH,WAAW,QACpB7C,UAAU,aAAAH,gBAAA,GAAVG,UAAU,CAAE8C,IAAI,qBAAhBjD,gBAAA,CAAkBvB,GAAG,CAAC,CAACY,MAAM,EAAE6D,WAAW,kBACzCtH,KAAA,CAAAqC,aAAA,CAACiB,gBAAgB;IACff,GAAG,EAAE,qBAAqB+E,WAAW,EAAG;IACxC7D,MAAM,EAAEA,MAAO;IACf/B,SAAS,EAAC,MAAM;IAChBC,SAAS,EAAE2F,WAAY;IACvBzF,WAAW,EAAEA;EAAY,CAC1B,CACF,CACqB,CAAC,EACxB0C,UAAU,YAAVA,UAAU,CAAEgD,OAAO,gBAClBvH,KAAA,CAAAqC,aAAA,CAAClC,UAAU,CAACqH,iBAAiB,SAAAnD,mBAAA,GAC1BE,UAAU,CAACgD,OAAO,qBAAlBlD,mBAAA,CAAoBxB,GAAG,CAAC,CAACY,MAAM,EAAE6D,WAAW,kBAC3CtH,KAAA,CAAAqC,aAAA,CAACiB,gBAAgB;IACff,GAAG,EAAE,wBAAwB+E,WAAW,EAAG;IAC3C7D,MAAM,EAAEA,MAAO;IACf/B,SAAS,EAAC,SAAS;IACnBC,SAAS,EAAE2F,WAAY;IACvBzF,WAAW,EAAEA;EAAY,CAC1B,CACF,CAC2B,CAAC,GAC7B,IACc,CACV,CAAC;AAEjB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","useMemo","useRef","EntityPage","useEntity","useEntityPage","useEntityPageContext","MoreActions","useForm","Card","Cell","Layout","useParams","useSchema","FormFieldInput","useEntityPageHeaderTexts","useNavigation","usePatternsWizardOverridesContext","useEntityPageMoreActions","useActionsSDK","RenderLayoutContent","_ref","_content$container$ch","_overrides$components","content","level","sectionId","cardIndex","contentIndex","setInputRef","schema","overrides","pageState","type","field","fieldId","fields","createElement","span","key","inputRef","ref","container","children","length","map","child","index","component","componentId","Component","components","form","entity","RenderLayoutCard","_ref2","_layout$card$subtitle","layout","minHeight","Header","title","card","text","subtitle","Divider","Content","AutoPatternsEntityPage","_ref3","_pageLayout$main","_pageLayout$sidebar","configuration","pageLayout","parentPageId","route","moreActions","collectionId","mode","params","entityId","id","isCreateMode","inputRefs","input","current","validate","invalidFieldId","Object","keys","find","_inputRefs$current$fi","invalid","_inputRefs$current$in","focus","Error","getParentPagePath","parentPath","state","onSave","formValues","getValues","baseEntity","updatedEntity","newEntity","actions","update","create","fetch","undefined","get","config","entityDisplayName","displayField","sdk","resolvedMoreActions","dataHook","items","MainContent","main","layoutIndex","sidebar","AdditionalContent"],"sources":["../../../../src/components/AutoPatternsEntityPage/AutoPatternsEntityPage.tsx"],"sourcesContent":["import React, { useMemo, useRef } from 'react';\nimport { CardLayout, EntityPageConfig, LayoutContent } from '../../types';\nimport {\n EntityPage,\n EntityPageState,\n useEntity,\n useEntityPage,\n useEntityPageContext,\n MoreActions,\n} from '@wix/patterns';\nimport { useForm } from '@wix/patterns/form';\nimport { Card, Cell, Layout } from '@wix/design-system';\nimport { useParams } from 'react-router-dom';\nimport { useSchema } from '../../providers/SchemaContext';\nimport { BaseInputRef } from './Fields/types';\nimport { FormFieldInput } from './Fields/FormFieldInput';\nimport { useEntityPageHeaderTexts, useNavigation } from '../../hooks';\nimport { usePatternsWizardOverridesContext } from '../../providers';\nimport { useEntityPageMoreActions } from '../../hooks/useEntityPageMoreActions';\nimport { useActionsSDK } from '../../hooks/useActionsSDK';\n\nconst RenderLayoutContent: React.FC<{\n content: LayoutContent;\n level: number;\n sectionId: string;\n cardIndex: number;\n contentIndex: number;\n setInputRef: (id: string, input: BaseInputRef) => void;\n}> = ({ content, level, sectionId, cardIndex, contentIndex, setInputRef }) => {\n const schema = useSchema();\n const overrides = usePatternsWizardOverridesContext();\n const pageState = useEntityPageContext();\n\n switch (content.type) {\n case 'field':\n if (!content.field.fieldId) {\n return null;\n }\n\n const field = schema.fields[content.field.fieldId];\n\n if (!field) {\n return null;\n }\n\n return (\n <Cell span={content.field.span}>\n <FormFieldInput\n key={content.field.fieldId}\n field={field}\n inputRef={(ref) => setInputRef(content.field.fieldId, ref)}\n />\n </Cell>\n );\n\n case 'container':\n if (!content.container.children?.length) {\n return null;\n }\n\n return (\n <Cell span={content.container.span}>\n <Layout>\n {content.container.children.map((child, index) => (\n <RenderLayoutContent\n key={`${sectionId}-card-${cardIndex}-content-${contentIndex}-level-${level}-child-${index}`}\n content={child}\n level={level + 1}\n sectionId={sectionId}\n cardIndex={cardIndex}\n contentIndex={index}\n setInputRef={setInputRef}\n />\n ))}\n </Layout>\n </Cell>\n );\n\n case 'component':\n if (!content.component.componentId) {\n return null;\n }\n\n const Component = overrides?.components?.[content.component.componentId];\n\n if (!Component) {\n return null;\n }\n\n return (\n <Cell span={content.component.span}>\n <Component\n form={pageState.form as any}\n entity={pageState.entity as any as Record<string, any>}\n />\n </Cell>\n );\n\n default:\n return null;\n }\n};\n\nconst RenderLayoutCard: React.FC<{\n layout: CardLayout;\n sectionId: string;\n cardIndex: number;\n setInputRef: (id: string, input: BaseInputRef) => void;\n}> = ({ layout, sectionId, cardIndex, setInputRef }) => {\n switch (layout.type) {\n case 'card':\n return (\n <EntityPage.Card minHeight=\"50px\">\n <Card.Header\n title={layout.card.title.text}\n subtitle={layout.card.subtitle?.text}\n />\n <Card.Divider />\n <Card.Content>\n <Layout>\n {layout.card.children.map((child, index: number) => (\n <RenderLayoutContent\n key={`${sectionId}-card-${cardIndex}-content-${index}`}\n content={child}\n level={0}\n sectionId={sectionId}\n cardIndex={cardIndex}\n contentIndex={index}\n setInputRef={setInputRef}\n />\n ))}\n </Layout>\n </Card.Content>\n </EntityPage.Card>\n );\n default:\n return null;\n }\n};\n\nexport interface AutoPatternsEntityPageProps {\n configuration: EntityPageConfig;\n}\n\nexport const AutoPatternsEntityPage: React.FC<AutoPatternsEntityPageProps> = ({\n configuration,\n}) => {\n const {\n layout: pageLayout,\n parentPageId,\n route,\n moreActions,\n collectionId,\n } = configuration;\n\n const form = useForm<any>({\n mode: 'onChange',\n });\n const params = useParams();\n const entityId = params[route.params.id];\n const schema = useSchema();\n const isCreateMode = !entityId;\n\n const inputRefs = useRef<{ [fieldId: string]: BaseInputRef }>({});\n\n const setInputRef = (id: string, input: BaseInputRef) => {\n inputRefs.current[id] = input;\n };\n\n const validate = () => {\n const invalidFieldId = Object.keys(inputRefs.current).find((fieldId) => {\n return inputRefs.current[fieldId]?.invalid;\n });\n\n if (invalidFieldId) {\n inputRefs.current[invalidFieldId]?.focus?.();\n throw new Error('Invalid form');\n }\n };\n const { getParentPagePath } = useNavigation();\n\n const parentPath = useMemo(\n () => getParentPagePath(parentPageId),\n [parentPageId, getParentPagePath],\n );\n\n const state: EntityPageState<any> = useEntityPage<any, any>({\n parentPath,\n form,\n onSave: async () => {\n validate();\n\n const formValues = form.getValues();\n const baseEntity = state.entity || {};\n const updatedEntity = {\n ...baseEntity,\n ...formValues,\n };\n\n const newEntity = entityId\n ? await schema.actions.update(updatedEntity)\n : await schema.actions.create(updatedEntity);\n\n return { updatedEntity: newEntity };\n },\n fetch: async () => {\n if (!entityId) {\n return { entity: undefined };\n }\n const entity = await schema.actions.get(entityId);\n return { entity };\n },\n });\n\n const entity = useEntity(state);\n\n const { title, subtitle } = useEntityPageHeaderTexts({\n config: configuration,\n isCreateMode,\n entityDisplayName: entity?.[schema.displayField],\n });\n\n const sdk = useActionsSDK({\n collectionId,\n });\n\n const resolvedMoreActions = useEntityPageMoreActions(\n moreActions,\n entity,\n sdk,\n form,\n );\n\n return (\n <EntityPage state={state} dataHook=\"auto-patterns-entity-page\">\n <EntityPage.Header\n title={title}\n subtitle={subtitle}\n moreActions={\n resolvedMoreActions.length > 0 ? (\n <MoreActions items={resolvedMoreActions} />\n ) : undefined\n }\n />\n <EntityPage.Content>\n <EntityPage.MainContent dataHook=\"entity-page-main-content\">\n {pageLayout?.main?.map((layout, layoutIndex) => (\n <RenderLayoutCard\n key={`main-section-card-${layoutIndex}`}\n layout={layout}\n sectionId=\"main\"\n cardIndex={layoutIndex}\n setInputRef={setInputRef}\n />\n ))}\n </EntityPage.MainContent>\n {pageLayout?.sidebar ? (\n <EntityPage.AdditionalContent>\n {pageLayout.sidebar?.map((layout, layoutIndex) => (\n <RenderLayoutCard\n key={`sidebar-section-card-${layoutIndex}`}\n layout={layout}\n sectionId=\"sidebar\"\n cardIndex={layoutIndex}\n setInputRef={setInputRef}\n />\n ))}\n </EntityPage.AdditionalContent>\n ) : null}\n </EntityPage.Content>\n </EntityPage>\n );\n};\n\n/*\n Key structure explanation:\n\n Main cards: main-section-card-{layoutIndex}\n Sidebar cards: sidebar-section-card-{layoutIndex}\n\n Layout content:\n {sectionId}-card-{cardIndex}-content-{contentIndex}\n\n Nested children:\n {sectionId}-card-{cardIndex}-content-{parentContentIndex}-level-{level}-child-{childIndex}\n\n This ensures uniqueness across all levels and sections.\n*/\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAE9C,SACEC,UAAU,EAEVC,SAAS,EACTC,aAAa,EACbC,oBAAoB,EACpBC,WAAW,QACN,eAAe;AACtB,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,IAAI,EAAEC,IAAI,EAAEC,MAAM,QAAQ,oBAAoB;AACvD,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,SAAS,QAAQ,+BAA+B;AAEzD,SAASC,cAAc,QAAQ,yBAAyB;AACxD,SAASC,wBAAwB,EAAEC,aAAa,QAAQ,aAAa;AACrE,SAASC,iCAAiC,Q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C;AAEjB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { EntityPage, useEntityPage } from '@wix/patterns';
|
|
2
|
+
import { useForm } from '../../exports/form';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Card, Cell, Layout } from '@wix/design-system';
|
|
5
|
+
const RenderLayoutContent = _ref => {
|
|
6
|
+
var _content$container$ch;
|
|
7
|
+
let {
|
|
8
|
+
content,
|
|
9
|
+
level,
|
|
10
|
+
sectionId,
|
|
11
|
+
cardIndex,
|
|
12
|
+
contentIndex
|
|
13
|
+
} = _ref;
|
|
14
|
+
switch (content.type) {
|
|
15
|
+
case 'container':
|
|
16
|
+
if (!((_content$container$ch = content.container.children) != null && _content$container$ch.length)) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return /*#__PURE__*/React.createElement(Cell, {
|
|
20
|
+
span: content.container.span
|
|
21
|
+
}, /*#__PURE__*/React.createElement(Layout, null, content.container.children.map((child, index) => /*#__PURE__*/React.createElement(RenderLayoutContent, {
|
|
22
|
+
key: `${sectionId}-card-${cardIndex}-content-${contentIndex}-level-${level}-child-${index}`,
|
|
23
|
+
content: child,
|
|
24
|
+
level: level + 1,
|
|
25
|
+
sectionId: sectionId,
|
|
26
|
+
cardIndex: cardIndex,
|
|
27
|
+
contentIndex: index
|
|
28
|
+
}))));
|
|
29
|
+
default:
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const RenderLayoutCard = _ref2 => {
|
|
34
|
+
var _layout$card$subtitle;
|
|
35
|
+
let {
|
|
36
|
+
layout,
|
|
37
|
+
sectionId,
|
|
38
|
+
cardIndex
|
|
39
|
+
} = _ref2;
|
|
40
|
+
switch (layout.type) {
|
|
41
|
+
case 'card':
|
|
42
|
+
return /*#__PURE__*/React.createElement(EntityPage.Card, {
|
|
43
|
+
minHeight: "50px"
|
|
44
|
+
}, /*#__PURE__*/React.createElement(Card.Header, {
|
|
45
|
+
title: layout.card.title.text,
|
|
46
|
+
subtitle: (_layout$card$subtitle = layout.card.subtitle) == null ? void 0 : _layout$card$subtitle.text
|
|
47
|
+
}), /*#__PURE__*/React.createElement(Card.Divider, null), /*#__PURE__*/React.createElement(Card.Content, null, /*#__PURE__*/React.createElement(Layout, null, layout.card.children.map((child, index) => /*#__PURE__*/React.createElement(RenderLayoutContent, {
|
|
48
|
+
key: `${sectionId}-card-${cardIndex}-content-${index}`,
|
|
49
|
+
content: child,
|
|
50
|
+
level: 0,
|
|
51
|
+
sectionId: sectionId,
|
|
52
|
+
cardIndex: cardIndex,
|
|
53
|
+
contentIndex: index
|
|
54
|
+
})))));
|
|
55
|
+
default:
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
export const SkeletonEntity = _ref3 => {
|
|
60
|
+
var _entityPage$layout, _entityPage$layout2, _entityPage$layout$si;
|
|
61
|
+
let {
|
|
62
|
+
entityPage
|
|
63
|
+
} = _ref3;
|
|
64
|
+
const form = useForm();
|
|
65
|
+
const state = useEntityPage({
|
|
66
|
+
parentPath: '',
|
|
67
|
+
form,
|
|
68
|
+
onSave: async () => ({
|
|
69
|
+
updatedEntity: {}
|
|
70
|
+
}),
|
|
71
|
+
fetch: async () => new Promise(() => {})
|
|
72
|
+
});
|
|
73
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EntityPage, {
|
|
74
|
+
state: state
|
|
75
|
+
}, /*#__PURE__*/React.createElement(EntityPage.Header, {
|
|
76
|
+
title: {
|
|
77
|
+
text: ''
|
|
78
|
+
}
|
|
79
|
+
}), /*#__PURE__*/React.createElement(EntityPage.Content, null, /*#__PURE__*/React.createElement(EntityPage.MainContent, null, (_entityPage$layout = entityPage.layout) == null || (_entityPage$layout = _entityPage$layout.main) == null ? void 0 : _entityPage$layout.map((layout, layoutIndex) => /*#__PURE__*/React.createElement(RenderLayoutCard, {
|
|
80
|
+
key: `main-section-card-${layoutIndex}`,
|
|
81
|
+
layout: layout,
|
|
82
|
+
sectionId: "main",
|
|
83
|
+
cardIndex: layoutIndex
|
|
84
|
+
}))), (_entityPage$layout2 = entityPage.layout) != null && _entityPage$layout2.sidebar ? /*#__PURE__*/React.createElement(EntityPage.AdditionalContent, null, (_entityPage$layout$si = entityPage.layout.sidebar) == null ? void 0 : _entityPage$layout$si.map((layout, layoutIndex) => /*#__PURE__*/React.createElement(RenderLayoutCard, {
|
|
85
|
+
key: `sidebar-section-card-${layoutIndex}`,
|
|
86
|
+
layout: layout,
|
|
87
|
+
sectionId: "sidebar",
|
|
88
|
+
cardIndex: layoutIndex
|
|
89
|
+
}))) : null)));
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=SkeletonEntity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["EntityPage","useEntityPage","useForm","React","Card","Cell","Layout","RenderLayoutContent","_ref","_content$container$ch","content","level","sectionId","cardIndex","contentIndex","type","container","children","length","createElement","span","map","child","index","key","RenderLayoutCard","_ref2","_layout$card$subtitle","layout","minHeight","Header","title","card","text","subtitle","Divider","Content","SkeletonEntity","_ref3","_entityPage$layout","_entityPage$layout2","_entityPage$layout$si","entityPage","form","state","parentPath","onSave","updatedEntity","fetch","Promise","Fragment","MainContent","main","layoutIndex","sidebar","AdditionalContent"],"sources":["../../../../src/components/AutoPatternsEntityPage/SkeletonEntity.tsx"],"sourcesContent":["import { EntityPage, EntityPageState, useEntityPage } from '@wix/patterns';\nimport { useForm } from '../../exports/form';\nimport React from 'react';\nimport { EntityPageConfig, CardLayout, LayoutContent } from '../../types';\n\nexport interface SkeletonEntityProps {\n entityPage: EntityPageConfig;\n}\nimport { Card, Cell, Layout } from '@wix/design-system';\n\nconst RenderLayoutContent: React.FC<{\n content: LayoutContent;\n level: number;\n sectionId: string;\n cardIndex: number;\n contentIndex: number;\n}> = ({ content, level, sectionId, cardIndex, contentIndex }) => {\n switch (content.type) {\n case 'container':\n if (!content.container.children?.length) {\n return null;\n }\n\n return (\n <Cell span={content.container.span}>\n <Layout>\n {content.container.children.map((child, index) => (\n <RenderLayoutContent\n key={`${sectionId}-card-${cardIndex}-content-${contentIndex}-level-${level}-child-${index}`}\n content={child}\n level={level + 1}\n sectionId={sectionId}\n cardIndex={cardIndex}\n contentIndex={index}\n />\n ))}\n </Layout>\n </Cell>\n );\n\n default:\n return null;\n }\n};\n\nconst RenderLayoutCard: React.FC<{\n layout: CardLayout;\n sectionId: string;\n cardIndex: number;\n}> = ({ layout, sectionId, cardIndex }) => {\n switch (layout.type) {\n case 'card':\n return (\n <EntityPage.Card minHeight=\"50px\">\n <Card.Header\n title={layout.card.title.text}\n subtitle={layout.card.subtitle?.text}\n />\n <Card.Divider />\n <Card.Content>\n <Layout>\n {layout.card.children.map((child, index: number) => (\n <RenderLayoutContent\n key={`${sectionId}-card-${cardIndex}-content-${index}`}\n content={child}\n level={0}\n sectionId={sectionId}\n cardIndex={cardIndex}\n contentIndex={index}\n />\n ))}\n </Layout>\n </Card.Content>\n </EntityPage.Card>\n );\n default:\n return null;\n }\n};\n\nexport const SkeletonEntity = ({ entityPage }: SkeletonEntityProps) => {\n const form = useForm();\n\n const state: EntityPageState<any> = useEntityPage<any, any>({\n parentPath: '',\n form,\n onSave: async () => ({ updatedEntity: {} }),\n fetch: async () => new Promise(() => {}),\n });\n\n return (\n <>\n <EntityPage state={state}>\n <EntityPage.Header title={{ text: '' }} />\n <EntityPage.Content>\n <EntityPage.MainContent>\n {entityPage.layout?.main?.map((layout, layoutIndex) => (\n <RenderLayoutCard\n key={`main-section-card-${layoutIndex}`}\n layout={layout}\n sectionId=\"main\"\n cardIndex={layoutIndex}\n />\n ))}\n </EntityPage.MainContent>\n {entityPage.layout?.sidebar ? (\n <EntityPage.AdditionalContent>\n {entityPage.layout.sidebar?.map((layout, layoutIndex) => (\n <RenderLayoutCard\n key={`sidebar-section-card-${layoutIndex}`}\n layout={layout}\n sectionId=\"sidebar\"\n cardIndex={layoutIndex}\n />\n ))}\n </EntityPage.AdditionalContent>\n ) : null}\n </EntityPage.Content>\n </EntityPage>\n </>\n );\n};\n"],"mappings":"AAAA,SAASA,UAAU,EAAmBC,aAAa,QAAQ,eAAe;AAC1E,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,OAAOC,KAAK,MAAM,OAAO;AAMzB,SAASC,IAAI,EAAEC,IAAI,EAAEC,MAAM,QAAQ,oBAAoB;AAEvD,MAAMC,mBAMJ,GAAGC,IAAA,IAA4D;EAAA,IAAAC,qBAAA;EAAA,IAA3D;IAAEC,OAAO;IAAEC,KAAK;IAAEC,SAAS;IAAEC,SAAS;IAAEC;EAAa,CAAC,GAAAN,IAAA;EAC1D,QAAQE,OAAO,CAACK,IAAI;IAClB,KAAK,WAAW;MACd,IAAI,GAAAN,qBAAA,GAACC,OAAO,CAACM,SAAS,CAACC,QAAQ,aAA1BR,qBAAA,CAA4BS,MAAM,GAAE;QACvC,OAAO,IAAI;MACb;MAEA,oBACEf,KAAA,CAAAgB,aAAA,CAACd,IAAI;QAACe,IAAI,EAAEV,OAAO,CAACM,SAAS,CAACI;MAAK,gBACjCjB,KAAA,CAAAgB,aAAA,CAACb,MAAM,QACJI,OAAO,CAACM,SAAS,CAACC,QAAQ,CAACI,GAAG,CAAC,CAACC,KAAK,EAAEC,KAAK,kBAC3CpB,KAAA,CAAAgB,aAAA,CAACZ,mBAAmB;QAClBiB,GAAG,EAAE,GAAGZ,SAAS,SAASC,SAAS,YAAYC,YAAY,UAAUH,KAAK,UAAUY,KAAK,EAAG;QAC5Fb,OAAO,EAAEY,KAAM;QACfX,KAAK,EAAEA,KAAK,GAAG,CAAE;QACjBC,SAAS,EAAEA,SAAU;QACrBC,SAAS,EAAEA,SAAU;QACrBC,YAAY,EAAES;MAAM,CACrB,CACF,CACK,CACJ,CAAC;IAGX;MACE,OAAO,IAAI;EACf;AACF,CAA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DlD,KAAA,CAAAgB,aAAA,CAACM,gBAAgB;IACfD,GAAG,EAAE,wBAAwB6B,WAAW,EAAG;IAC3CzB,MAAM,EAAEA,MAAO;IACfhB,SAAS,EAAC,SAAS;IACnBC,SAAS,EAAEwC;EAAY,CACxB,CACF,CAC2B,CAAC,GAC7B,IACc,CACV,CACZ,CAAC;AAEP,CAAC","ignoreList":[]}
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { AutoPatternsCollectionPage } from '../AutoPatternsCollectionPage';
|
|
3
3
|
import { AutoPatternsEntityPage } from '../AutoPatternsEntityPage';
|
|
4
4
|
import { SchemaProvider } from '../../providers/SchemaContext';
|
|
5
|
+
import { SkeletonEntity } from '../AutoPatternsEntityPage/SkeletonEntity';
|
|
5
6
|
export const AutoPatternsPage = _ref => {
|
|
6
7
|
let {
|
|
7
8
|
pageConfig
|
|
@@ -22,7 +23,10 @@ export const AutoPatternsPage = _ref => {
|
|
|
22
23
|
case 'entityPage':
|
|
23
24
|
if (entityPage) {
|
|
24
25
|
return /*#__PURE__*/React.createElement(SchemaProvider, {
|
|
25
|
-
collection: entityPage
|
|
26
|
+
collection: entityPage,
|
|
27
|
+
skeleton: /*#__PURE__*/React.createElement(SkeletonEntity, {
|
|
28
|
+
entityPage: entityPage
|
|
29
|
+
})
|
|
26
30
|
}, /*#__PURE__*/React.createElement(AutoPatternsEntityPage, {
|
|
27
31
|
configuration: entityPage
|
|
28
32
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","AutoPatternsCollectionPage","AutoPatternsEntityPage","SchemaProvider","AutoPatternsPage","_ref","pageConfig","type","collectionPage","entityPage","createElement","configuration","collection"],"sources":["../../../../src/components/AutoPatternsRoute/AutoPatternsPage.tsx"],"sourcesContent":["import React from 'react';\nimport { PageConfig } from '../../types';\nimport { AutoPatternsCollectionPage } from '../AutoPatternsCollectionPage';\nimport { AutoPatternsEntityPage } from '../AutoPatternsEntityPage';\nimport { SchemaProvider } from '../../providers/SchemaContext';\n\nexport interface AutoPatternsPageProps {\n pageConfig: PageConfig;\n}\n\nexport const AutoPatternsPage = ({ pageConfig }: AutoPatternsPageProps) => {\n const { type, collectionPage, entityPage } = pageConfig;\n\n switch (type) {\n case 'collectionPage':\n if (collectionPage) {\n return <AutoPatternsCollectionPage configuration={collectionPage} />;\n }\n break;\n case 'entityPage':\n if (entityPage) {\n return (\n <SchemaProvider
|
|
1
|
+
{"version":3,"names":["React","AutoPatternsCollectionPage","AutoPatternsEntityPage","SchemaProvider","SkeletonEntity","AutoPatternsPage","_ref","pageConfig","type","collectionPage","entityPage","createElement","configuration","collection","skeleton"],"sources":["../../../../src/components/AutoPatternsRoute/AutoPatternsPage.tsx"],"sourcesContent":["import React from 'react';\nimport { PageConfig } from '../../types';\nimport { AutoPatternsCollectionPage } from '../AutoPatternsCollectionPage';\nimport { AutoPatternsEntityPage } from '../AutoPatternsEntityPage';\nimport { SchemaProvider } from '../../providers/SchemaContext';\nimport { SkeletonEntity } from '../AutoPatternsEntityPage/SkeletonEntity';\n\nexport interface AutoPatternsPageProps {\n pageConfig: PageConfig;\n}\n\nexport const AutoPatternsPage = ({ pageConfig }: AutoPatternsPageProps) => {\n const { type, collectionPage, entityPage } = pageConfig;\n\n switch (type) {\n case 'collectionPage':\n if (collectionPage) {\n return <AutoPatternsCollectionPage configuration={collectionPage} />;\n }\n break;\n case 'entityPage':\n if (entityPage) {\n return (\n <SchemaProvider\n collection={entityPage}\n skeleton={<SkeletonEntity entityPage={entityPage} />}\n >\n <AutoPatternsEntityPage configuration={entityPage} />\n </SchemaProvider>\n );\n }\n break;\n default:\n break;\n }\n\n return null;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,0BAA0B,QAAQ,+BAA+B;AAC1E,SAASC,sBAAsB,QAAQ,2BAA2B;AAClE,SAASC,cAAc,QAAQ,+BAA+B;AAC9D,SAASC,cAAc,QAAQ,0CAA0C;AAMzE,OAAO,MAAMC,gBAAgB,GAAGC,IAAA,IAA2C;EAAA,IAA1C;IAAEC;EAAkC,CAAC,GAAAD,IAAA;EACpE,MAAM;IAAEE,IAAI;IAAEC,cAAc;IAAEC;EAAW,CAAC,GAAGH,UAAU;EAEvD,QAAQC,IAAI;IACV,KAAK,gBAAgB;MACnB,IAAIC,cAAc,EAAE;QAClB,oBAAOT,KAAA,CAAAW,aAAA,CAACV,0BAA0B;UAACW,aAAa,EAAEH;QAAe,CAAE,CAAC;MACtE;MACA;IACF,KAAK,YAAY;MACf,IAAIC,UAAU,EAAE;QACd,oBACEV,KAAA,CAAAW,aAAA,CAACR,cAAc;UACbU,UAAU,EAAEH,UAAW;UACvBI,QAAQ,eAAEd,KAAA,CAAAW,aAAA,CAACP,cAAc;YAACM,UAAU,EAAEA;UAAW,CAAE;QAAE,gBAErDV,KAAA,CAAAW,aAAA,CAACT,sBAAsB;UAACU,aAAa,EAAEF;QAAW,CAAE,CACtC,CAAC;MAErB;MACA;IACF;MACE;EACJ;EAEA,OAAO,IAAI;AACb,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import { useColumns } from './useColumns';
|
|
3
3
|
import { CustomColumns } from '@wix/patterns';
|
|
4
|
+
import { useCollectionPageOnRowClickActions } from './useCollectionPageOnRowClickActions';
|
|
4
5
|
import { useNavigation } from './useNavigationUtils';
|
|
5
6
|
export const useBaseTableFeatures = configuration => {
|
|
6
7
|
var _configuration$custom;
|
|
@@ -10,7 +11,11 @@ export const useBaseTableFeatures = configuration => {
|
|
|
10
11
|
const columns = useColumns(configuration.columns);
|
|
11
12
|
const visibleFieldIds = useMemo(() => configuration.columns.map(column => column.id), [configuration]);
|
|
12
13
|
const entityPageId = configuration.entityPageId;
|
|
13
|
-
const
|
|
14
|
+
const onRowClickOverride = useCollectionPageOnRowClickActions({
|
|
15
|
+
collectionPageOnRowClickActions: configuration.onRowClick,
|
|
16
|
+
collectionId: configuration.collection.collectionId
|
|
17
|
+
});
|
|
18
|
+
const onRowClick = configuration.onRowClick ? onRowClickOverride : item => navigateToEntityPage({
|
|
14
19
|
item,
|
|
15
20
|
entityPageId
|
|
16
21
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useMemo","useColumns","CustomColumns","useNavigation","useBaseTableFeatures","configuration","_configuration$custom","navigateToEntityPage","columns","visibleFieldIds","map","column","id","entityPageId","onRowClick","item","stickyColumns","stickySelectionColumn","customColumns","enabled","createElement","undefined"],"sources":["../../../src/hooks/useBaseTableFeatures.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { TableConfig } from '../types';\nimport { useColumns } from './useColumns';\nimport { CustomColumns } from '@wix/patterns';\nimport { useNavigation } from './useNavigationUtils';\n\nexport const useBaseTableFeatures = (configuration: TableConfig) => {\n const { navigateToEntityPage } = useNavigation();\n
|
|
1
|
+
{"version":3,"names":["React","useMemo","useColumns","CustomColumns","useCollectionPageOnRowClickActions","useNavigation","useBaseTableFeatures","configuration","_configuration$custom","navigateToEntityPage","columns","visibleFieldIds","map","column","id","entityPageId","onRowClickOverride","collectionPageOnRowClickActions","onRowClick","collectionId","collection","item","stickyColumns","stickySelectionColumn","customColumns","enabled","createElement","undefined"],"sources":["../../../src/hooks/useBaseTableFeatures.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { TableConfig } from '../types';\nimport { useColumns } from './useColumns';\nimport { CustomColumns } from '@wix/patterns';\nimport { useCollectionPageOnRowClickActions } from './useCollectionPageOnRowClickActions';\nimport { useNavigation } from './useNavigationUtils';\n\nexport const useBaseTableFeatures = (configuration: TableConfig) => {\n const { navigateToEntityPage } = useNavigation();\n const columns = useColumns(configuration.columns);\n const visibleFieldIds = useMemo(\n () => configuration.columns.map((column) => column.id),\n [configuration],\n );\n\n const entityPageId = configuration.entityPageId;\n\n const onRowClickOverride = useCollectionPageOnRowClickActions({\n collectionPageOnRowClickActions: configuration.onRowClick,\n collectionId: configuration.collection.collectionId,\n });\n\n const onRowClick = configuration.onRowClick\n ? onRowClickOverride\n : (item: any) =>\n navigateToEntityPage({\n item,\n entityPageId,\n });\n\n const stickyColumns = configuration.stickyColumns;\n const stickySelectionColumn = !!stickyColumns; // Sticky selection column is true if stickyColumns is positive number\n\n return {\n columns,\n visibleFieldIds,\n onRowClick,\n customColumns: configuration.customColumns?.enabled ? (\n <CustomColumns />\n ) : undefined,\n stickyColumns,\n stickySelectionColumn,\n };\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AAEtC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,aAAa,QAAQ,eAAe;AAC7C,SAASC,kCAAkC,QAAQ,sCAAsC;AACzF,SAASC,aAAa,QAAQ,sBAAsB;AAEpD,OAAO,MAAMC,oBAAoB,GAAIC,aAA0B,IAAK;EAAA,IAAAC,qBAAA;EAClE,MAAM;IAAEC;EAAqB,CAAC,GAAGJ,aAAa,CAAC,CAAC;EAChD,MAAMK,OAAO,GAAGR,UAAU,CAACK,aAAa,CAACG,OAAO,CAAC;EACjD,MAAMC,eAAe,GAAGV,OAAO,CAC7B,MAAMM,aAAa,CAACG,OAAO,CAACE,GAAG,CAAEC,MAAM,IAAKA,MAAM,CAACC,EAAE,CAAC,EACtD,CAACP,aAAa,CAChB,CAAC;EAED,MAAMQ,YAAY,GAAGR,aAAa,CAACQ,YAAY;EAE/C,MAAMC,kBAAkB,GAAGZ,kCAAkC,CAAC;IAC5Da,+BAA+B,EAAEV,aAAa,CAACW,UAAU;IACzDC,YAAY,EAAEZ,aAAa,CAACa,UAAU,CAACD;EACzC,CAAC,CAAC;EAEF,MAAMD,UAAU,GAAGX,aAAa,CAACW,UAAU,GACvCF,kBAAkB,GACjBK,IAAS,IACRZ,oBAAoB,CAAC;IACnBY,IAAI;IACJN;EACF,CAAC,CAAC;EAER,MAAMO,aAAa,GAAGf,aAAa,CAACe,aAAa;EACjD,MAAMC,qBAAqB,GAAG,CAAC,CAACD,aAAa,CAAC,CAAC;;EAE/C,OAAO;IACLZ,OAAO;IACPC,eAAe;IACfO,UAAU;IACVM,aAAa,EAAE,CAAAhB,qBAAA,GAAAD,aAAa,CAACiB,aAAa,aAA3BhB,qBAAA,CAA6BiB,OAAO,gBACjDzB,KAAA,CAAA0B,aAAA,CAACvB,aAAa,MAAE,CAAC,GACfwB,SAAS;IACbL,aAAa;IACbC;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { customAction, resolveAction } from '../utils/actions';
|
|
3
|
+
import { useActionsSDK } from './useActionsSDK';
|
|
4
|
+
export const useCollectionPageOnRowClickActions = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
collectionPageOnRowClickActions,
|
|
7
|
+
collectionId
|
|
8
|
+
} = _ref;
|
|
9
|
+
const sdk = useActionsSDK({
|
|
10
|
+
collectionId
|
|
11
|
+
});
|
|
12
|
+
const buildCollectionPageActions = useCallback((item, index) => {
|
|
13
|
+
if (!collectionPageOnRowClickActions) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const buildAction = actionConfig => {
|
|
17
|
+
let actionToResolve = null;
|
|
18
|
+
const baseParams = {
|
|
19
|
+
actionParams: {
|
|
20
|
+
item,
|
|
21
|
+
index
|
|
22
|
+
},
|
|
23
|
+
sdk
|
|
24
|
+
};
|
|
25
|
+
switch (actionConfig.type) {
|
|
26
|
+
case 'custom':
|
|
27
|
+
actionToResolve = customAction({
|
|
28
|
+
action: actionConfig,
|
|
29
|
+
...baseParams
|
|
30
|
+
});
|
|
31
|
+
break;
|
|
32
|
+
default:
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
if (!actionToResolve) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const resolvedAction = resolveAction(actionConfig, actionToResolve);
|
|
39
|
+
return resolvedAction.onClick == null ? void 0 : resolvedAction.onClick();
|
|
40
|
+
};
|
|
41
|
+
return buildAction(collectionPageOnRowClickActions);
|
|
42
|
+
}, [collectionPageOnRowClickActions, sdk]);
|
|
43
|
+
return buildCollectionPageActions;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=useCollectionPageOnRowClickActions.js.map
|