@wix/auto-patterns 1.20.0 → 1.22.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/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js +109 -0
- package/dist/cjs/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js.map +1 -0
- package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +5 -14
- package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
- package/dist/cjs/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +19 -68
- package/dist/cjs/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
- package/dist/cjs/components/AutoPatternsEntityPage/Fields/ImageInput.js +5 -4
- package/dist/cjs/components/AutoPatternsEntityPage/Fields/ImageInput.js.map +1 -1
- package/dist/cjs/components/AutoPatternsTable/AutoPatternsTable.js +3 -1
- package/dist/cjs/components/AutoPatternsTable/AutoPatternsTable.js.map +1 -1
- package/dist/cjs/hooks/useActionCell.js +10 -2
- package/dist/cjs/hooks/useActionCell.js.map +1 -1
- package/dist/cjs/hooks/useBaseTableFeatures.js +4 -3
- package/dist/cjs/hooks/useBaseTableFeatures.js.map +1 -1
- package/dist/cjs/hooks/useTableFeatures.js +3 -1
- package/dist/cjs/hooks/useTableFeatures.js.map +1 -1
- package/dist/cjs/hooks/useTableGridSwitchFeatures.js +4 -2
- package/dist/cjs/hooks/useTableGridSwitchFeatures.js.map +1 -1
- package/dist/cjs/providers/PatternsWizardOverridesContext.js.map +1 -1
- package/dist/cjs/types/CollectionPageConfig.js.map +1 -1
- package/dist/cjs/types/actions/actionCell.js.map +1 -1
- package/dist/docs/action_cell.md +13 -3
- package/dist/docs/app_config_structure.md +8 -2
- package/dist/docs/auto-patterns-guide.md +202 -14
- package/dist/docs/custom_overrides.md +181 -9
- package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js +72 -0
- package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js.map +1 -0
- package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +1 -3
- package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
- package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +17 -48
- package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/ImageInput.js +4 -3
- package/dist/esm/components/AutoPatternsEntityPage/Fields/ImageInput.js.map +1 -1
- package/dist/esm/components/AutoPatternsTable/AutoPatternsTable.js +2 -0
- package/dist/esm/components/AutoPatternsTable/AutoPatternsTable.js.map +1 -1
- package/dist/esm/hooks/useActionCell.js +10 -2
- package/dist/esm/hooks/useActionCell.js.map +1 -1
- package/dist/esm/hooks/useBaseTableFeatures.js +3 -2
- package/dist/esm/hooks/useBaseTableFeatures.js.map +1 -1
- package/dist/esm/hooks/useTableFeatures.js +3 -1
- package/dist/esm/hooks/useTableFeatures.js.map +1 -1
- package/dist/esm/hooks/useTableGridSwitchFeatures.js +4 -2
- package/dist/esm/hooks/useTableGridSwitchFeatures.js.map +1 -1
- package/dist/esm/providers/PatternsWizardOverridesContext.js.map +1 -1
- package/dist/esm/types/CollectionPageConfig.js.map +1 -1
- package/dist/esm/types/actions/actionCell.js.map +1 -1
- package/dist/types/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.d.ts +7 -0
- package/dist/types/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.d.ts.map +1 -0
- package/dist/types/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsEntityPage/Fields/ImageInput.d.ts.map +1 -1
- package/dist/types/components/AutoPatternsTable/AutoPatternsTable.d.ts.map +1 -1
- package/dist/types/hooks/useActionCell.d.ts.map +1 -1
- package/dist/types/hooks/useBaseTableFeatures.d.ts +1 -0
- package/dist/types/hooks/useBaseTableFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useTableFeatures.d.ts +1 -0
- package/dist/types/hooks/useTableFeatures.d.ts.map +1 -1
- package/dist/types/hooks/useTableGridSwitchFeatures.d.ts +1 -0
- package/dist/types/hooks/useTableGridSwitchFeatures.d.ts.map +1 -1
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts +1 -1
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts.map +1 -1
- package/dist/types/types/CollectionPageConfig.d.ts +8 -1
- package/dist/types/types/CollectionPageConfig.d.ts.map +1 -1
- package/dist/types/types/actions/actionCell.d.ts +1 -0
- package/dist/types/types/actions/actionCell.d.ts.map +1 -1
- package/package.json +13 -13
|
@@ -28,6 +28,10 @@ your-page/
|
|
|
28
28
|
│ ├── index.tsx // Exports useColumns hook
|
|
29
29
|
│ ├── name.ts
|
|
30
30
|
│ └── date.ts
|
|
31
|
+
├── slots/ // Custom slot components for collection pages
|
|
32
|
+
│ ├── index.tsx // Exports useSlots hook
|
|
33
|
+
│ ├── TopBannerComponent.tsx
|
|
34
|
+
│ └── BottomStatsComponent.tsx
|
|
31
35
|
├── customComponents/ // Custom entity page components
|
|
32
36
|
│ ├── index.tsx // Exports useComponents hook
|
|
33
37
|
│ ├── CustomNameField.tsx
|
|
@@ -35,16 +39,12 @@ your-page/
|
|
|
35
39
|
├── modals/ // Custom modals
|
|
36
40
|
│ ├── index.tsx // Exports useModals hook
|
|
37
41
|
│ └── myCustomModal.tsx
|
|
38
|
-
|
|
42
|
+
├── customDataSources/ // Custom data sources
|
|
39
43
|
│ ├── index.tsx // Exports useCustomDataSources hook
|
|
40
44
|
│ └── myCustomDataSource.ts
|
|
41
|
-
|
|
42
|
-
│ ├── index.tsx
|
|
43
|
-
│ └── groupByType.ts
|
|
44
|
-
└── customComponents/ // Custom entity page components
|
|
45
|
+
└── sections/ // Section renderers
|
|
45
46
|
├── index.tsx
|
|
46
|
-
|
|
47
|
-
└── InfoCard.tsx
|
|
47
|
+
└── groupByType.ts
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
### Using Override Hooks in Your Page
|
|
@@ -54,6 +54,7 @@ In your page component, use the hook-based approach to access React context and
|
|
|
54
54
|
```tsx
|
|
55
55
|
import { useActions } from '../components/actions';
|
|
56
56
|
import { useColumns } from '../components/columns';
|
|
57
|
+
import { useSlots } from '../components/slots';
|
|
57
58
|
import { useSections } from '../components/sections';
|
|
58
59
|
import { useComponents } from '../components/customComponents';
|
|
59
60
|
import { useModals } from '../components/modals';
|
|
@@ -62,13 +63,14 @@ import { useCustomDataSources } from '../components/customDataSources';
|
|
|
62
63
|
export default function YourPage() {
|
|
63
64
|
const actions = useActions();
|
|
64
65
|
const columns = useColumns();
|
|
66
|
+
const slots = useSlots();
|
|
65
67
|
const sections = useSections();
|
|
66
68
|
const components = useComponents();
|
|
67
69
|
const modals = useModals();
|
|
68
70
|
const customDataSources = useCustomDataSources();
|
|
69
71
|
|
|
70
72
|
return (
|
|
71
|
-
<PatternsWizardOverridesProvider value={{ actions, columns, sections, components, modals, customDataSources }}>
|
|
73
|
+
<PatternsWizardOverridesProvider value={{ actions, columns, slots, sections, components, modals, customDataSources }}>
|
|
72
74
|
<AutoPatternsApp configuration={config} />
|
|
73
75
|
</PatternsWizardOverridesProvider>
|
|
74
76
|
);
|
|
@@ -77,12 +79,13 @@ export default function YourPage() {
|
|
|
77
79
|
|
|
78
80
|
### Important: Updating Hook Index Files
|
|
79
81
|
|
|
80
|
-
**When adding any new implementation (action, modal, column, section or component), you MUST update the corresponding hook in the `index.tsx` file to include your new implementation.** The main page component uses these hooks, so they serve as the central export point for each type of override.
|
|
82
|
+
**When adding any new implementation (action, modal, column, slot, section or component), you MUST update the corresponding hook in the `index.tsx` file to include your new implementation.** The main page component uses these hooks, so they serve as the central export point for each type of override.
|
|
81
83
|
|
|
82
84
|
For example:
|
|
83
85
|
- Adding a new action → Update `../components/actions/index.tsx` to include the new action in the `useActions` hook
|
|
84
86
|
- Adding a new modal → Update `../components/modals/index.tsx` to include the new modal in the `useModals` hook
|
|
85
87
|
- Adding a new column override → Update `../components/columns/index.tsx` to include the new column in the `useColumns` hook
|
|
88
|
+
- Adding a new slot component → Update `../components/slots/index.tsx` to include the new slot in the `useSlots` hook
|
|
86
89
|
- Adding a new section renderer → Update `../components/sections/index.tsx` to include the new section in the `useSections` hook
|
|
87
90
|
- Adding a new custom component → Update `../components/customComponents/index.tsx` to include the new component in the `useComponents` hook
|
|
88
91
|
- Adding a new custom data source → Update `../components/customDataSources/index.tsx` to include the new data source in the `useCustomDataSources` hook
|
|
@@ -812,6 +815,10 @@ interface Section {
|
|
|
812
815
|
prefixIcon?: React.ReactElement;
|
|
813
816
|
onClick: () => void;
|
|
814
817
|
};
|
|
818
|
+
badge?: {
|
|
819
|
+
visible: boolean;
|
|
820
|
+
skin?: 'light' | 'danger' | 'neutralLight';
|
|
821
|
+
};
|
|
815
822
|
}
|
|
816
823
|
```
|
|
817
824
|
|
|
@@ -819,6 +826,7 @@ The section renderer receives an item and returns:
|
|
|
819
826
|
- **id**: A unique identifier for the section (items with the same id are grouped together)
|
|
820
827
|
- **title**: The text displayed in the section header
|
|
821
828
|
- **primaryAction** (optional): An action button displayed in the section header
|
|
829
|
+
- **badge** (optional): A badge configuration displayed in the section header
|
|
822
830
|
|
|
823
831
|
#### Example: Section Renderer Implementation
|
|
824
832
|
|
|
@@ -844,6 +852,10 @@ export function groupByType(item: any): Section {
|
|
|
844
852
|
console.log(`Showing all ${petType}s`);
|
|
845
853
|
},
|
|
846
854
|
},
|
|
855
|
+
badge: {
|
|
856
|
+
visible: true,
|
|
857
|
+
skin: 'light',
|
|
858
|
+
},
|
|
847
859
|
};
|
|
848
860
|
}
|
|
849
861
|
```
|
|
@@ -866,16 +878,20 @@ export function groupByAgeAndVaccination(item: any): Section {
|
|
|
866
878
|
|
|
867
879
|
let sectionId: string;
|
|
868
880
|
let sectionTitle: string;
|
|
881
|
+
let badgeSkin: 'light' | 'danger' | 'neutralLight' = 'light';
|
|
869
882
|
|
|
870
883
|
if (age < 1) {
|
|
871
884
|
sectionId = 'puppies';
|
|
872
885
|
sectionTitle = 'Puppies (Under 1 year)';
|
|
886
|
+
badgeSkin = 'neutralLight';
|
|
873
887
|
} else if (age >= 1 && age <= 5) {
|
|
874
888
|
sectionId = isVaccinated ? 'young-vaccinated' : 'young-unvaccinated';
|
|
875
889
|
sectionTitle = `Young Adults (1-5 years) - ${isVaccinated ? 'Vaccinated' : 'Not Vaccinated'}`;
|
|
890
|
+
badgeSkin = isVaccinated ? 'light' : 'danger';
|
|
876
891
|
} else {
|
|
877
892
|
sectionId = 'seniors';
|
|
878
893
|
sectionTitle = 'Senior Pets (5+ years)';
|
|
894
|
+
badgeSkin = 'light';
|
|
879
895
|
}
|
|
880
896
|
|
|
881
897
|
return {
|
|
@@ -888,6 +904,10 @@ export function groupByAgeAndVaccination(item: any): Section {
|
|
|
888
904
|
// Show special care information for puppies
|
|
889
905
|
},
|
|
890
906
|
} : undefined,
|
|
907
|
+
badge: {
|
|
908
|
+
visible: true,
|
|
909
|
+
skin: badgeSkin,
|
|
910
|
+
},
|
|
891
911
|
};
|
|
892
912
|
}
|
|
893
913
|
```
|
|
@@ -915,3 +935,155 @@ import * as actions from './components/actions';
|
|
|
915
935
|
|
|
916
936
|
|
|
917
937
|
By implementing sections, you can significantly improve the user experience when dealing with large datasets by providing logical groupings that make information easier to find and understand.
|
|
938
|
+
|
|
939
|
+
## Slots
|
|
940
|
+
|
|
941
|
+
Slots allow you to inject custom React components into collection pages at specific points in the component hierarchy. Unlike other overrides that modify existing functionality, slots enable you to add entirely custom UI elements anywhere within the collection page components array.
|
|
942
|
+
|
|
943
|
+
Slots are useful for:
|
|
944
|
+
- Adding custom banners or announcements above or below the table/grid
|
|
945
|
+
- Inserting analytics widgets or dashboards
|
|
946
|
+
- Adding custom promotional content
|
|
947
|
+
- Implementing page-specific functionality that doesn't fit into standard patterns
|
|
948
|
+
|
|
949
|
+
### Configuration Structure
|
|
950
|
+
|
|
951
|
+
Slots are configured in the collection page configuration using the `CustomComponentConfig` structure:
|
|
952
|
+
|
|
953
|
+
```json
|
|
954
|
+
{
|
|
955
|
+
"type": "custom",
|
|
956
|
+
"id": "myCustomSlot"
|
|
957
|
+
}
|
|
958
|
+
```
|
|
959
|
+
|
|
960
|
+
**Key Properties:**
|
|
961
|
+
- `type`: Must be set to `"custom"` to identify this as a slot component
|
|
962
|
+
- `id`: A unique identifier that maps to your slot component implementation
|
|
963
|
+
|
|
964
|
+
### Component Positioning
|
|
965
|
+
|
|
966
|
+
Slot components can be positioned anywhere within the `components` array of a collection page. They will be rendered in the exact order specified in the configuration:
|
|
967
|
+
|
|
968
|
+
```json
|
|
969
|
+
{
|
|
970
|
+
"type": "collectionPage",
|
|
971
|
+
"collectionPage": {
|
|
972
|
+
"components": [
|
|
973
|
+
{
|
|
974
|
+
"type": "custom",
|
|
975
|
+
"id": "topBanner"
|
|
976
|
+
},
|
|
977
|
+
{
|
|
978
|
+
"type": "collection",
|
|
979
|
+
"collection": {
|
|
980
|
+
"collectionId": "MyCollection"
|
|
981
|
+
},
|
|
982
|
+
"layout": [...]
|
|
983
|
+
},
|
|
984
|
+
{
|
|
985
|
+
"type": "custom",
|
|
986
|
+
"id": "bottomStats"
|
|
987
|
+
}
|
|
988
|
+
]
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
```
|
|
992
|
+
|
|
993
|
+
This configuration will render:
|
|
994
|
+
1. The custom `topBanner` component at the top
|
|
995
|
+
2. The main collection component (table/grid) in the middle
|
|
996
|
+
3. The custom `bottomStats` component at the bottom
|
|
997
|
+
|
|
998
|
+
### Implementation Structure
|
|
999
|
+
|
|
1000
|
+
#### Creating Slot Components
|
|
1001
|
+
|
|
1002
|
+
Slot components are standard React functional components that take no props:
|
|
1003
|
+
|
|
1004
|
+
```tsx
|
|
1005
|
+
import React from 'react';
|
|
1006
|
+
import { Box, Card, Text, Button } from '@wix/design-system';
|
|
1007
|
+
|
|
1008
|
+
export const TopBannerComponent: React.FC = () => {
|
|
1009
|
+
return (
|
|
1010
|
+
<Card>
|
|
1011
|
+
<Card.Content>
|
|
1012
|
+
<Box direction="vertical" gap={2}>
|
|
1013
|
+
<Text size="large" weight="bold">Welcome to Pet Management</Text>
|
|
1014
|
+
<Text>Manage all your pets from this central dashboard.</Text>
|
|
1015
|
+
<Button size="small">Get Started</Button>
|
|
1016
|
+
</Box>
|
|
1017
|
+
</Card.Content>
|
|
1018
|
+
</Card>
|
|
1019
|
+
);
|
|
1020
|
+
};
|
|
1021
|
+
|
|
1022
|
+
export const BottomStatsComponent: React.FC = () => {
|
|
1023
|
+
return (
|
|
1024
|
+
<Card>
|
|
1025
|
+
<Card.Content>
|
|
1026
|
+
<Box direction="horizontal" gap={4}>
|
|
1027
|
+
<Box direction="vertical" gap={1}>
|
|
1028
|
+
<Text size="large" weight="bold">47</Text>
|
|
1029
|
+
<Text size="small">Total Pets</Text>
|
|
1030
|
+
</Box>
|
|
1031
|
+
<Box direction="vertical" gap={1}>
|
|
1032
|
+
<Text size="large" weight="bold">12</Text>
|
|
1033
|
+
<Text size="small">Available for Adoption</Text>
|
|
1034
|
+
</Box>
|
|
1035
|
+
</Box>
|
|
1036
|
+
</Card.Content>
|
|
1037
|
+
</Card>
|
|
1038
|
+
);
|
|
1039
|
+
};
|
|
1040
|
+
```
|
|
1041
|
+
|
|
1042
|
+
#### Creating the Slots Hook
|
|
1043
|
+
|
|
1044
|
+
In `components/slots/index.tsx`:
|
|
1045
|
+
|
|
1046
|
+
```tsx
|
|
1047
|
+
import { TopBannerComponent } from './TopBannerComponent';
|
|
1048
|
+
import { BottomStatsComponent } from './BottomStatsComponent';
|
|
1049
|
+
|
|
1050
|
+
export const useSlots = () => {
|
|
1051
|
+
// You can access React context and other hooks here
|
|
1052
|
+
return {
|
|
1053
|
+
topBanner: TopBannerComponent,
|
|
1054
|
+
bottomStats: BottomStatsComponent
|
|
1055
|
+
};
|
|
1056
|
+
};
|
|
1057
|
+
```
|
|
1058
|
+
|
|
1059
|
+
**Important:** Every time you create a new slot component, you must import it and add it to the `useSlots` hook return object. The key in the return object must match the `id` specified in your JSON configuration.
|
|
1060
|
+
|
|
1061
|
+
#### Registering Slots in Your Page
|
|
1062
|
+
|
|
1063
|
+
In your main page component:
|
|
1064
|
+
|
|
1065
|
+
```tsx
|
|
1066
|
+
import { useSlots } from '../components/slots';
|
|
1067
|
+
|
|
1068
|
+
export default function YourPage() {
|
|
1069
|
+
const slots = useSlots();
|
|
1070
|
+
|
|
1071
|
+
return (
|
|
1072
|
+
<PatternsWizardOverridesProvider value={{ slots }}>
|
|
1073
|
+
<AutoPatternsApp configuration={config} />
|
|
1074
|
+
</PatternsWizardOverridesProvider>
|
|
1075
|
+
);
|
|
1076
|
+
}
|
|
1077
|
+
```
|
|
1078
|
+
|
|
1079
|
+
### Important Guidelines for Slots
|
|
1080
|
+
|
|
1081
|
+
1. **Component Signature**: Slot components must be React functional components with no props: `React.FC`
|
|
1082
|
+
2. **Rendering Order**: Components render in the exact order specified in the `components` array
|
|
1083
|
+
3. **Performance**: Slot components re-render with the page, so optimize for performance if needed
|
|
1084
|
+
4. **Styling**: Follow the design system patterns and responsive design principles
|
|
1085
|
+
|
|
1086
|
+
|
|
1087
|
+
**Important:** Every time you create a new slot component, you must import it and add it to the `useSlots` hook return object in the `./components/slots/index.tsx` file. The key must match the `id` specified in your JSON configuration.
|
|
1088
|
+
|
|
1089
|
+
Slots provide a powerful way to enhance collection pages with custom functionality while maintaining the structure and features of the AutoPatterns system.
|
package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { AutoPatternsTableGridSwitch } from '../AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch';
|
|
2
|
+
import { AutoPatternsTable } from '../AutoPatternsTable';
|
|
3
|
+
import { AutoPatternsGrid } from '../AutoPatternsGrid';
|
|
4
|
+
import { SchemaProvider } from '../../providers';
|
|
5
|
+
import { SkeletonCollection } from '../AutoPatternsCollectionPageContent/SkeletonCollection';
|
|
6
|
+
import React, { useMemo } from 'react';
|
|
7
|
+
export const AutoPatternsCollectionComponent = _ref => {
|
|
8
|
+
let {
|
|
9
|
+
component,
|
|
10
|
+
index
|
|
11
|
+
} = _ref;
|
|
12
|
+
const {
|
|
13
|
+
layout,
|
|
14
|
+
...sharedConfig
|
|
15
|
+
} = component;
|
|
16
|
+
const memoized = useMemo(() => {
|
|
17
|
+
var _layout$find, _layout$find2;
|
|
18
|
+
if (!(layout != null && layout.length)) {
|
|
19
|
+
return {
|
|
20
|
+
componentToRender: null,
|
|
21
|
+
componentType: 'Table'
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const tableConfig = (_layout$find = layout.find(item => item.type === 'Table')) == null ? void 0 : _layout$find.table;
|
|
25
|
+
const gridConfig = (_layout$find2 = layout.find(item => item.type === 'Grid')) == null ? void 0 : _layout$find2.grid;
|
|
26
|
+
let componentType = 'Table';
|
|
27
|
+
let componentToRender = null;
|
|
28
|
+
if (tableConfig && gridConfig) {
|
|
29
|
+
const config = {
|
|
30
|
+
...sharedConfig,
|
|
31
|
+
...tableConfig,
|
|
32
|
+
...gridConfig
|
|
33
|
+
};
|
|
34
|
+
componentToRender = /*#__PURE__*/React.createElement(AutoPatternsTableGridSwitch, {
|
|
35
|
+
configuration: config
|
|
36
|
+
});
|
|
37
|
+
} else if (tableConfig) {
|
|
38
|
+
const config = {
|
|
39
|
+
...sharedConfig,
|
|
40
|
+
...tableConfig
|
|
41
|
+
};
|
|
42
|
+
componentToRender = /*#__PURE__*/React.createElement(AutoPatternsTable, {
|
|
43
|
+
configuration: config
|
|
44
|
+
});
|
|
45
|
+
} else if (gridConfig) {
|
|
46
|
+
componentType = 'Grid';
|
|
47
|
+
const config = {
|
|
48
|
+
...sharedConfig,
|
|
49
|
+
...gridConfig
|
|
50
|
+
};
|
|
51
|
+
componentToRender = /*#__PURE__*/React.createElement(AutoPatternsGrid, {
|
|
52
|
+
configuration: config
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
componentToRender,
|
|
57
|
+
componentType
|
|
58
|
+
};
|
|
59
|
+
}, [layout, sharedConfig]);
|
|
60
|
+
const {
|
|
61
|
+
componentToRender,
|
|
62
|
+
componentType
|
|
63
|
+
} = memoized;
|
|
64
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, componentToRender ? /*#__PURE__*/React.createElement(SchemaProvider, {
|
|
65
|
+
key: `${sharedConfig.collection.collectionId}-${index}`,
|
|
66
|
+
collection: sharedConfig.collection,
|
|
67
|
+
skeleton: /*#__PURE__*/React.createElement(SkeletonCollection, {
|
|
68
|
+
componentType: componentType
|
|
69
|
+
})
|
|
70
|
+
}, componentToRender) : null);
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=AutoPatternsCollectionComponent.js.map
|
package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AutoPatternsTableGridSwitch","AutoPatternsTable","AutoPatternsGrid","SchemaProvider","SkeletonCollection","React","useMemo","AutoPatternsCollectionComponent","_ref","component","index","layout","sharedConfig","memoized","_layout$find","_layout$find2","length","componentToRender","componentType","tableConfig","find","item","type","table","gridConfig","grid","config","createElement","configuration","Fragment","key","collection","collectionId","skeleton"],"sources":["../../../../src/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.tsx"],"sourcesContent":["import { CollectionComponentConfig } from '../../types';\nimport { AutoPatternsTableGridSwitch } from '../AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch';\nimport { AutoPatternsTable } from '../AutoPatternsTable';\nimport { AutoPatternsGrid } from '../AutoPatternsGrid';\nimport { SchemaProvider } from '../../providers';\nimport { SkeletonCollection } from '../AutoPatternsCollectionPageContent/SkeletonCollection';\nimport React, { useMemo } from 'react';\n\nexport const AutoPatternsCollectionComponent = ({\n component,\n index,\n}: {\n component: CollectionComponentConfig;\n index: number;\n}) => {\n const { layout, ...sharedConfig } = component;\n\n const memoized = useMemo(() => {\n if (!layout?.length) {\n return {\n componentToRender: null,\n componentType: 'Table' as 'Table' | 'Grid',\n };\n }\n\n const tableConfig = layout.find((item) => item.type === 'Table')?.table;\n const gridConfig = layout.find((item) => item.type === 'Grid')?.grid;\n\n let componentType: 'Table' | 'Grid' = 'Table';\n let componentToRender: React.ReactNode = 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, componentType };\n }, [layout, sharedConfig]);\n\n const { componentToRender, componentType } = memoized;\n\n return (\n <>\n {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 );\n};\n"],"mappings":"AACA,SAASA,2BAA2B,QAAQ,4DAA4D;AACxG,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,cAAc,QAAQ,iBAAiB;AAChD,SAASC,kBAAkB,QAAQ,yDAAyD;AAC5F,OAAOC,KAAK,IAAIC,OAAO,QAAQ,OAAO;AAEtC,OAAO,MAAMC,+BAA+B,GAAGC,IAAA,IA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AAY;QAAE,GAAGY;MAAW,CAAC;MACjDP,iBAAiB,gBAAGZ,KAAA,CAAAsB,aAAA,CAACzB,gBAAgB;QAAC0B,aAAa,EAAEF;MAAO,CAAE,CAAC;IACjE;IAEA,OAAO;MAAET,iBAAiB;MAAEC;IAAc,CAAC;EAC7C,CAAC,EAAE,CAACP,MAAM,EAAEC,YAAY,CAAC,CAAC;EAE1B,MAAM;IAAEK,iBAAiB;IAAEC;EAAc,CAAC,GAAGL,QAAQ;EAErD,oBACER,KAAA,CAAAsB,aAAA,CAAAtB,KAAA,CAAAwB,QAAA,QACGZ,iBAAiB,gBAChBZ,KAAA,CAAAsB,aAAA,CAACxB,cAAc;IACb2B,GAAG,EAAE,GAAGlB,YAAY,CAACmB,UAAU,CAACC,YAAY,IAAItB,KAAK,EAAG;IACxDqB,UAAU,EAAEnB,YAAY,CAACmB,UAAW;IACpCE,QAAQ,eAAE5B,KAAA,CAAAsB,aAAA,CAACvB,kBAAkB;MAACc,aAAa,EAAEA;IAAc,CAAE;EAAE,GAE9DD,iBACa,CAAC,GACf,IACJ,CAAC;AAEP,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CollectionPage } from '@wix/patterns/page';
|
|
3
3
|
import { AutoPatternsCollectionPageContent } from '../AutoPatternsCollectionPageContent';
|
|
4
|
-
import { usePatternsWizardOverridesContext } from '../../providers';
|
|
5
4
|
import { useCollectionPageActions } from '../../hooks/useCollectionPageActions';
|
|
6
5
|
export const AutoPatternsCollectionPage = _ref => {
|
|
7
6
|
let {
|
|
@@ -14,7 +13,6 @@ export const AutoPatternsCollectionPage = _ref => {
|
|
|
14
13
|
const actions = useCollectionPageActions({
|
|
15
14
|
collectionPageActions: configuration.actions
|
|
16
15
|
});
|
|
17
|
-
const context = usePatternsWizardOverridesContext();
|
|
18
16
|
return /*#__PURE__*/React.createElement(CollectionPage, {
|
|
19
17
|
height: "100vh",
|
|
20
18
|
dataHook: "auto-patterns-page"
|
|
@@ -23,7 +21,7 @@ export const AutoPatternsCollectionPage = _ref => {
|
|
|
23
21
|
subtitle: subtitle,
|
|
24
22
|
primaryAction: actions.primaryActions,
|
|
25
23
|
secondaryActions: actions.secondaryActions
|
|
26
|
-
}), /*#__PURE__*/React.createElement(CollectionPage.Content, null,
|
|
24
|
+
}), /*#__PURE__*/React.createElement(CollectionPage.Content, null, /*#__PURE__*/React.createElement(AutoPatternsCollectionPageContent, {
|
|
27
25
|
configuration: configuration
|
|
28
26
|
})));
|
|
29
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","CollectionPage","AutoPatternsCollectionPageContent","
|
|
1
|
+
{"version":3,"names":["React","CollectionPage","AutoPatternsCollectionPageContent","useCollectionPageActions","AutoPatternsCollectionPage","_ref","configuration","title","subtitle","actions","collectionPageActions","createElement","height","dataHook","Header","primaryAction","primaryActions","secondaryActions","Content"],"sources":["../../../../src/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.tsx"],"sourcesContent":["import React from 'react';\nimport { CollectionPage } from '@wix/patterns/page';\nimport { AutoPatternsCollectionPageContent } from '../AutoPatternsCollectionPageContent';\nimport { CollectionPageConfig } from '../../types/CollectionPageConfig';\nimport { useCollectionPageActions } from '../../hooks/useCollectionPageActions';\n\nexport interface AutoPatternsCollectionPageProps {\n configuration: CollectionPageConfig;\n}\n\nexport const AutoPatternsCollectionPage: React.FC<\n AutoPatternsCollectionPageProps\n> = ({ configuration }) => {\n const { title, subtitle } = configuration;\n\n const actions = useCollectionPageActions({\n collectionPageActions: configuration.actions,\n });\n\n return (\n <CollectionPage height=\"100vh\" dataHook=\"auto-patterns-page\">\n <CollectionPage.Header\n title={title}\n subtitle={subtitle}\n primaryAction={actions.primaryActions}\n secondaryActions={actions.secondaryActions}\n />\n <CollectionPage.Content>\n <AutoPatternsCollectionPageContent configuration={configuration} />\n </CollectionPage.Content>\n </CollectionPage>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,iCAAiC,QAAQ,sCAAsC;AAExF,SAASC,wBAAwB,QAAQ,sCAAsC;AAM/E,OAAO,MAAMC,0BAEZ,GAAGC,IAAA,IAAuB;EAAA,IAAtB;IAAEC;EAAc,CAAC,GAAAD,IAAA;EACpB,MAAM;IAAEE,KAAK;IAAEC;EAAS,CAAC,GAAGF,aAAa;EAEzC,MAAMG,OAAO,GAAGN,wBAAwB,CAAC;IACvCO,qBAAqB,EAAEJ,aAAa,CAACG;EACvC,CAAC,CAAC;EAEF,oBACET,KAAA,CAAAW,aAAA,CAACV,cAAc;IAACW,MAAM,EAAC,OAAO;IAACC,QAAQ,EAAC;EAAoB,gBAC1Db,KAAA,CAAAW,aAAA,CAACV,cAAc,CAACa,MAAM;IACpBP,KAAK,EAAEA,KAAM;IACbC,QAAQ,EAAEA,QAAS;IACnBO,aAAa,EAAEN,OAAO,CAACO,cAAe;IACtCC,gBAAgB,EAAER,OAAO,CAACQ;EAAiB,CAC5C,CAAC,eACFjB,KAAA,CAAAW,aAAA,CAACV,cAAc,CAACiB,OAAO,qBACrBlB,KAAA,CAAAW,aAAA,CAACT,iCAAiC;IAACI,aAAa,EAAEA;EAAc,CAAE,CAC5C,CACV,CAAC;AAErB,CAAC","ignoreList":[]}
|
package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { AutoPatternsTableGridSwitch } from '../AutoPatternsTableGridSwitch/AutoPatternsTableGridSwitch';
|
|
5
|
-
import { SchemaProvider } from '../../providers';
|
|
6
|
-
import { SkeletonCollection } from './SkeletonCollection';
|
|
2
|
+
import { usePatternsWizardOverridesContext } from '../../providers';
|
|
3
|
+
import { AutoPatternsCollectionComponent } from '../AutoPatternsCollectionComponent/AutoPatternsCollectionComponent';
|
|
7
4
|
export const AutoPatternsCollectionPageContent = _ref => {
|
|
8
5
|
let {
|
|
9
6
|
configuration
|
|
@@ -11,53 +8,25 @@ export const AutoPatternsCollectionPageContent = _ref => {
|
|
|
11
8
|
const {
|
|
12
9
|
components
|
|
13
10
|
} = configuration;
|
|
11
|
+
const overrides = usePatternsWizardOverridesContext();
|
|
14
12
|
return /*#__PURE__*/React.createElement(React.Fragment, null, components.map((component, index) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (!(layout != null && layout.length)) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
const tableConfig = (_layout$find = layout.find(item => item.type === 'Table')) == null ? void 0 : _layout$find.table;
|
|
24
|
-
const gridConfig = (_layout$find2 = layout.find(item => item.type === 'Grid')) == null ? void 0 : _layout$find2.grid;
|
|
25
|
-
let componentType = 'Table';
|
|
26
|
-
let componentToRender = null;
|
|
27
|
-
if (tableConfig && gridConfig) {
|
|
28
|
-
const config = {
|
|
29
|
-
...sharedConfig,
|
|
30
|
-
...tableConfig,
|
|
31
|
-
...gridConfig
|
|
32
|
-
};
|
|
33
|
-
componentToRender = /*#__PURE__*/React.createElement(AutoPatternsTableGridSwitch, {
|
|
34
|
-
configuration: config
|
|
35
|
-
});
|
|
36
|
-
} else if (tableConfig) {
|
|
37
|
-
const config = {
|
|
38
|
-
...sharedConfig,
|
|
39
|
-
...tableConfig
|
|
40
|
-
};
|
|
41
|
-
componentToRender = /*#__PURE__*/React.createElement(AutoPatternsTable, {
|
|
42
|
-
configuration: config
|
|
13
|
+
if (component.type === 'collection') {
|
|
14
|
+
return /*#__PURE__*/React.createElement(AutoPatternsCollectionComponent, {
|
|
15
|
+
key: `collection-${component.collection.collectionId}-${index}`,
|
|
16
|
+
component: component,
|
|
17
|
+
index: index
|
|
43
18
|
});
|
|
44
|
-
} else if (
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
19
|
+
} else if (component.type === 'custom') {
|
|
20
|
+
var _overrides$slots;
|
|
21
|
+
const CustomComponent = overrides == null || (_overrides$slots = overrides.slots) == null ? void 0 : _overrides$slots[component.id];
|
|
22
|
+
if (!CustomComponent) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return /*#__PURE__*/React.createElement(CustomComponent, {
|
|
26
|
+
key: `custom-${component.id}-${index}`
|
|
52
27
|
});
|
|
53
28
|
}
|
|
54
|
-
return
|
|
55
|
-
key: `${sharedConfig.collection.collectionId}-${index}`,
|
|
56
|
-
collection: sharedConfig.collection,
|
|
57
|
-
skeleton: /*#__PURE__*/React.createElement(SkeletonCollection, {
|
|
58
|
-
componentType: componentType
|
|
59
|
-
})
|
|
60
|
-
}, componentToRender) : null;
|
|
29
|
+
return null;
|
|
61
30
|
}).filter(Boolean));
|
|
62
31
|
};
|
|
63
32
|
//# sourceMappingURL=AutoPatternsCollectionPageContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","
|
|
1
|
+
{"version":3,"names":["React","usePatternsWizardOverridesContext","AutoPatternsCollectionComponent","AutoPatternsCollectionPageContent","_ref","configuration","components","overrides","createElement","Fragment","map","component","index","type","key","collection","collectionId","_overrides$slots","CustomComponent","slots","id","filter","Boolean"],"sources":["../../../../src/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.tsx"],"sourcesContent":["import React from 'react';\nimport { CollectionPageConfig } from '../../types';\nimport { usePatternsWizardOverridesContext } from '../../providers';\nimport { AutoPatternsCollectionComponent } from '../AutoPatternsCollectionComponent/AutoPatternsCollectionComponent';\n\nexport interface AutoPatternsCollectionPageContentProps {\n configuration: CollectionPageConfig;\n}\n\nexport const AutoPatternsCollectionPageContent = ({\n configuration,\n}: AutoPatternsCollectionPageContentProps) => {\n const { components } = configuration;\n const overrides = usePatternsWizardOverridesContext();\n\n return (\n <>\n {components\n .map((component, index) => {\n if (component.type === 'collection') {\n return (\n <AutoPatternsCollectionComponent\n key={`collection-${component.collection.collectionId}-${index}`}\n component={component}\n index={index}\n />\n );\n } else if (component.type === 'custom') {\n const CustomComponent = overrides?.slots?.[component.id];\n\n if (!CustomComponent) {\n return null;\n }\n\n return <CustomComponent key={`custom-${component.id}-${index}`} />;\n }\n\n return null;\n })\n .filter(Boolean)}\n </>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,iCAAiC,QAAQ,iBAAiB;AACnE,SAASC,+BAA+B,QAAQ,oEAAoE;AAMpH,OAAO,MAAMC,iCAAiC,GAAGC,IAAA,IAEH;EAAA,IAFI;IAChDC;EACsC,CAAC,GAAAD,IAAA;EACvC,MAAM;IAAEE;EAAW,CAAC,GAAGD,aAAa;EACpC,MAAME,SAAS,GAAGN,iCAAiC,CAAC,CAAC;EAErD,oBACED,KAAA,CAAAQ,aAAA,CAAAR,KAAA,CAAAS,QAAA,QACGH,UAAU,CACRI,GAAG,CAAC,CAACC,SAAS,EAAEC,KAAK,KAAK;IACzB,IAAID,SAAS,CAACE,IAAI,KAAK,YAAY,EAAE;MACnC,oBACEb,KAAA,CAAAQ,aAAA,CAACN,+BAA+B;QAC9BY,GAAG,EAAE,cAAcH,SAAS,CAACI,UAAU,CAACC,YAAY,IAAIJ,KAAK,EAAG;QAChED,SAAS,EAAEA,SAAU;QACrBC,KAAK,EAAEA;MAAM,CACd,CAAC;IAEN,CAAC,MAAM,IAAID,SAAS,CAACE,IAAI,KAAK,QAAQ,EAAE;MAAA,IAAAI,gBAAA;MACtC,MAAMC,eAAe,GAAGX,SAAS,aAAAU,gBAAA,GAATV,SAAS,CAAEY,KAAK,qBAAhBF,gBAAA,CAAmBN,SAAS,CAACS,EAAE,CAAC;MAExD,IAAI,CAACF,eAAe,EAAE;QACpB,OAAO,IAAI;MACb;MAEA,oBAAOlB,KAAA,CAAAQ,aAAA,CAACU,eAAe;QAACJ,GAAG,EAAE,UAAUH,SAAS,CAACS,EAAE,IAAIR,KAAK;MAAG,CAAE,CAAC;IACpE;IAEA,OAAO,IAAI;EACb,CAAC,CAAC,CACDS,MAAM,CAACC,OAAO,CACjB,CAAC;AAEP,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FormField, ImageViewer } from '@wix/design-system';
|
|
3
|
-
import { useEntityPageContext, useSelector, useWixPatternsContainer } from '@wix/patterns';
|
|
3
|
+
import { useEntityPageContext, useIsMobile, useSelector, useWixPatternsContainer } from '@wix/patterns';
|
|
4
4
|
import { useController } from '@wix/patterns/form';
|
|
5
5
|
import { getImageUrl } from '../../../utils/media/getImageUrl';
|
|
6
6
|
import { dashboard } from '@wix/dashboard';
|
|
@@ -15,6 +15,7 @@ export const ImageInput = props => {
|
|
|
15
15
|
...container
|
|
16
16
|
} = useWixPatternsContainer();
|
|
17
17
|
useSelector(() => container.initTask.status);
|
|
18
|
+
const isMobile = useIsMobile();
|
|
18
19
|
const pageState = useEntityPageContext();
|
|
19
20
|
async function openMedia() {
|
|
20
21
|
try {
|
|
@@ -53,8 +54,8 @@ export const ImageInput = props => {
|
|
|
53
54
|
}, /*#__PURE__*/React.createElement(ImageViewer, {
|
|
54
55
|
imageUrl: imageUrl,
|
|
55
56
|
dataHook: `image-${field.id}`,
|
|
56
|
-
onAddImage: () => openMedia(),
|
|
57
|
-
onUpdateImage: () => openMedia(),
|
|
57
|
+
onAddImage: isMobile ? undefined : () => openMedia(),
|
|
58
|
+
onUpdateImage: isMobile ? undefined : () => openMedia(),
|
|
58
59
|
updateImageInfo: t('cairo.replace-image.tooltip'),
|
|
59
60
|
removeImageInfo: t('cairo.remove-image.tooltip'),
|
|
60
61
|
addImageInfo: t('cairo.add-image.tooltip'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","FormField","ImageViewer","useEntityPageContext","useSelector","useWixPatternsContainer","useController","getImageUrl","dashboard","ImageInput","props","_pageState$entity","_field$validation2","_controller$fieldStat","field","dataHook","translate","t","container","initTask","status","pageState","openMedia","_chosenMediaItems$ite","chosenMediaItems","openMediaManager","multiSelect","category","newImage","items","media","image","controller","onChange","error","console","name","id","control","form","defaultValue","entity","rules","validate","value","_field$validation","validation","required","undefined","imageUrl","createElement","label","displayName","fieldState","statusMessage","message","onAddImage","onUpdateImage","updateImageInfo","removeImageInfo","addImageInfo","height","width","fit","onRemoveImage"],"sources":["../../../../../src/components/AutoPatternsEntityPage/Fields/ImageInput.tsx"],"sourcesContent":["import React from 'react';\nimport { FormField, ImageViewer } from '@wix/design-system';\nimport { BaseInputProps } from './types';\nimport {\n useEntityPageContext,\n useSelector,\n useWixPatternsContainer,\n} from '@wix/patterns';\nimport { useController } from '@wix/patterns/form';\nimport { getImageUrl } from '../../../utils/media/getImageUrl';\nimport { dashboard } from '@wix/dashboard';\n\nexport interface ImageInputProps extends BaseInputProps<string> {}\n\nexport const ImageInput = (props: ImageInputProps) => {\n const { field, dataHook } = props;\n\n const { translate: t, ...container } = useWixPatternsContainer();\n useSelector(() => container.initTask.status);\n
|
|
1
|
+
{"version":3,"names":["React","FormField","ImageViewer","useEntityPageContext","useIsMobile","useSelector","useWixPatternsContainer","useController","getImageUrl","dashboard","ImageInput","props","_pageState$entity","_field$validation2","_controller$fieldStat","field","dataHook","translate","t","container","initTask","status","isMobile","pageState","openMedia","_chosenMediaItems$ite","chosenMediaItems","openMediaManager","multiSelect","category","newImage","items","media","image","controller","onChange","error","console","name","id","control","form","defaultValue","entity","rules","validate","value","_field$validation","validation","required","undefined","imageUrl","createElement","label","displayName","fieldState","statusMessage","message","onAddImage","onUpdateImage","updateImageInfo","removeImageInfo","addImageInfo","height","width","fit","onRemoveImage"],"sources":["../../../../../src/components/AutoPatternsEntityPage/Fields/ImageInput.tsx"],"sourcesContent":["import React from 'react';\nimport { FormField, ImageViewer } from '@wix/design-system';\nimport { BaseInputProps } from './types';\nimport {\n useEntityPageContext,\n useIsMobile,\n useSelector,\n useWixPatternsContainer,\n} from '@wix/patterns';\nimport { useController } from '@wix/patterns/form';\nimport { getImageUrl } from '../../../utils/media/getImageUrl';\nimport { dashboard } from '@wix/dashboard';\n\nexport interface ImageInputProps extends BaseInputProps<string> {}\n\nexport const ImageInput = (props: ImageInputProps) => {\n const { field, dataHook } = props;\n\n const { translate: t, ...container } = useWixPatternsContainer();\n useSelector(() => container.initTask.status);\n const isMobile = useIsMobile();\n const pageState = useEntityPageContext();\n\n async function openMedia() {\n try {\n const chosenMediaItems = await dashboard.openMediaManager({\n multiSelect: false,\n category: 'IMAGE',\n });\n\n const newImage = chosenMediaItems?.items[0]?.media?.image?.image;\n\n controller.field.onChange(newImage);\n } catch (error) {\n console.error('Error opening Media Manager or no files selected:', error);\n }\n }\n\n const controller = useController({\n name: field?.id ?? '',\n control: pageState.form.control,\n defaultValue: (pageState.entity as any)?.[field?.id ?? ''],\n rules: {\n validate: (value) => {\n if (\n field.validation?.required &&\n (value === null || value === undefined || value === '')\n ) {\n return t('cairo.fieldValidation.requiredField');\n }\n\n return true;\n },\n },\n });\n\n const imageUrl =\n controller.field.value && getImageUrl(controller.field.value);\n\n return (\n <FormField\n label={field.displayName}\n required={field.validation?.required}\n status={controller.fieldState.error ? 'error' : undefined}\n statusMessage={controller.fieldState.error?.message}\n dataHook={dataHook}\n >\n <ImageViewer\n imageUrl={imageUrl}\n dataHook={`image-${field.id}`}\n onAddImage={isMobile ? undefined : () => openMedia()}\n onUpdateImage={isMobile ? undefined : () => openMedia()}\n updateImageInfo={t('cairo.replace-image.tooltip')}\n removeImageInfo={t('cairo.remove-image.tooltip')}\n addImageInfo={t('cairo.add-image.tooltip')}\n height=\"120px\"\n width=\"25%\"\n fit=\"cover\"\n onRemoveImage={() => controller.field.onChange(null)}\n />\n </FormField>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS,EAAEC,WAAW,QAAQ,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AC9BmB,UAAU,EAAEpC,QAAQ,GAAG4B,SAAS,GAAG,MAAM1B,SAAS,CAAC,CAAE;IACrDmC,aAAa,EAAErC,QAAQ,GAAG4B,SAAS,GAAG,MAAM1B,SAAS,CAAC,CAAE;IACxDoC,eAAe,EAAE1C,CAAC,CAAC,6BAA6B,CAAE;IAClD2C,eAAe,EAAE3C,CAAC,CAAC,4BAA4B,CAAE;IACjD4C,YAAY,EAAE5C,CAAC,CAAC,yBAAyB,CAAE;IAC3C6C,MAAM,EAAC,OAAO;IACdC,KAAK,EAAC,KAAK;IACXC,GAAG,EAAC,OAAO;IACXC,aAAa,EAAEA,CAAA,KAAMhC,UAAU,CAACnB,KAAK,CAACoB,QAAQ,CAAC,IAAI;EAAE,CACtD,CACQ,CAAC;AAEhB,CAAC","ignoreList":[]}
|
|
@@ -18,6 +18,7 @@ export const AutoPatternsTable = _ref => {
|
|
|
18
18
|
onRowClick,
|
|
19
19
|
stickyColumns,
|
|
20
20
|
stickySelectionColumn,
|
|
21
|
+
showTitleBar,
|
|
21
22
|
sections
|
|
22
23
|
} = useTableFeatures(configuration);
|
|
23
24
|
return /*#__PURE__*/React.createElement(Table, {
|
|
@@ -35,6 +36,7 @@ export const AutoPatternsTable = _ref => {
|
|
|
35
36
|
horizontalScroll: true,
|
|
36
37
|
stickyColumns: stickyColumns,
|
|
37
38
|
stickySelectionColumn: stickySelectionColumn,
|
|
39
|
+
showTitleBar: showTitleBar,
|
|
38
40
|
sections: sections
|
|
39
41
|
});
|
|
40
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Table","useTableFeatures","AutoPatternsTable","_ref","configuration","state","columns","customColumns","search","title","emptyState","filters","actionCell","bulkActionToolbar","onRowClick","stickyColumns","stickySelectionColumn","sections","createElement","dataHook","horizontalScroll"],"sources":["../../../../src/components/AutoPatternsTable/AutoPatternsTable.tsx"],"sourcesContent":["import React from 'react';\nimport { Table } from '@wix/patterns';\nimport { TableConfig } from '../../types';\nimport { useTableFeatures } from '../../hooks';\n\nexport interface AutoPatternsTableContentProps {\n configuration: TableConfig;\n}\n\nexport const AutoPatternsTable = ({\n configuration,\n}: AutoPatternsTableContentProps) => {\n const {\n state,\n columns,\n customColumns,\n search,\n title,\n emptyState,\n filters,\n actionCell,\n bulkActionToolbar,\n onRowClick,\n stickyColumns,\n stickySelectionColumn,\n sections,\n } = useTableFeatures(configuration);\n\n return (\n <Table\n dataHook=\"auto-patterns-table\"\n search={search}\n title={title}\n state={state}\n columns={columns}\n customColumns={customColumns}\n actionCell={actionCell}\n filters={filters}\n emptyState={emptyState}\n bulkActionToolbar={bulkActionToolbar}\n onRowClick={onRowClick}\n horizontalScroll\n stickyColumns={stickyColumns}\n stickySelectionColumn={stickySelectionColumn}\n sections={sections}\n />\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,KAAK,QAAQ,eAAe;AAErC,SAASC,gBAAgB,QAAQ,aAAa;AAM9C,OAAO,MAAMC,iBAAiB,GAAGC,IAAA,IAEI;EAAA,IAFH;IAChCC;EAC6B,CAAC,GAAAD,IAAA;EAC9B,MAAM;IACJE,KAAK;IACLC,OAAO;IACPC,aAAa;IACbC,MAAM;IACNC,KAAK;IACLC,UAAU;IACVC,OAAO;IACPC,UAAU;IACVC,iBAAiB;IACjBC,UAAU;IACVC,aAAa;IACbC,qBAAqB;IACrBC;EACF,CAAC,
|
|
1
|
+
{"version":3,"names":["React","Table","useTableFeatures","AutoPatternsTable","_ref","configuration","state","columns","customColumns","search","title","emptyState","filters","actionCell","bulkActionToolbar","onRowClick","stickyColumns","stickySelectionColumn","showTitleBar","sections","createElement","dataHook","horizontalScroll"],"sources":["../../../../src/components/AutoPatternsTable/AutoPatternsTable.tsx"],"sourcesContent":["import React from 'react';\nimport { Table } from '@wix/patterns';\nimport { TableConfig } from '../../types';\nimport { useTableFeatures } from '../../hooks';\n\nexport interface AutoPatternsTableContentProps {\n configuration: TableConfig;\n}\n\nexport const AutoPatternsTable = ({\n configuration,\n}: AutoPatternsTableContentProps) => {\n const {\n state,\n columns,\n customColumns,\n search,\n title,\n emptyState,\n filters,\n actionCell,\n bulkActionToolbar,\n onRowClick,\n stickyColumns,\n stickySelectionColumn,\n showTitleBar,\n sections,\n } = useTableFeatures(configuration);\n\n return (\n <Table\n dataHook=\"auto-patterns-table\"\n search={search}\n title={title}\n state={state}\n columns={columns}\n customColumns={customColumns}\n actionCell={actionCell}\n filters={filters}\n emptyState={emptyState}\n bulkActionToolbar={bulkActionToolbar}\n onRowClick={onRowClick}\n horizontalScroll\n stickyColumns={stickyColumns}\n stickySelectionColumn={stickySelectionColumn}\n showTitleBar={showTitleBar}\n sections={sections}\n />\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,KAAK,QAAQ,eAAe;AAErC,SAASC,gBAAgB,QAAQ,aAAa;AAM9C,OAAO,MAAMC,iBAAiB,GAAGC,IAAA,IAEI;EAAA,IAFH;IAChCC;EAC6B,CAAC,GAAAD,IAAA;EAC9B,MAAM;IACJE,KAAK;IACLC,OAAO;IACPC,aAAa;IACbC,MAAM;IACNC,KAAK;IACLC,UAAU;IACVC,OAAO;IACPC,UAAU;IACVC,iBAAiB;IACjBC,UAAU;IACVC,aAAa;IACbC,qBAAqB;IACrBC,YAAY;IACZC;EACF,CAAC,GAAGjB,gBAAgB,CAACG,aAAa,CAAC;EAEnC,oBACEL,KAAA,CAAAoB,aAAA,CAACnB,KAAK;IACJoB,QAAQ,EAAC,qBAAqB;IAC9BZ,MAAM,EAAEA,MAAO;IACfC,KAAK,EAAEA,KAAM;IACbJ,KAAK,EAAEA,KAAM;IACbC,OAAO,EAAEA,OAAQ;IACjBC,aAAa,EAAEA,aAAc;IAC7BK,UAAU,EAAEA,UAAW;IACvBD,OAAO,EAAEA,OAAQ;IACjBD,UAAU,EAAEA,UAAW;IACvBG,iBAAiB,EAAEA,iBAAkB;IACrCC,UAAU,EAAEA,UAAW;IACvBO,gBAAgB;IAChBN,aAAa,EAAEA,aAAc;IAC7BC,qBAAqB,EAAEA,qBAAsB;IAC7CC,YAAY,EAAEA,YAAa;IAC3BC,QAAQ,EAAEA;EAAS,CACpB,CAAC;AAEN,CAAC","ignoreList":[]}
|