@wix/auto-patterns 1.21.0 → 1.23.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/hooks/useActionCell.js +10 -2
- package/dist/cjs/hooks/useActionCell.js.map +1 -1
- package/dist/cjs/providers/PatternsWizardOverridesContext.js +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/cjs/types/actions/base.js.map +1 -1
- package/dist/docs/action_cell.md +13 -3
- package/dist/docs/app_config_structure.md +7 -4
- package/dist/docs/auto-patterns-guide.md +288 -35
- package/dist/docs/bulk_actions.md +1 -4
- package/dist/docs/custom_overrides.md +267 -24
- package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js +71 -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 +16 -48
- package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +8 -13
- package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/DateInput.js +6 -10
- package/dist/esm/components/AutoPatternsEntityPage/Fields/DateInput.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/DateTime.js +16 -23
- package/dist/esm/components/AutoPatternsEntityPage/Fields/DateTime.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/FormFieldInput.js +2 -3
- package/dist/esm/components/AutoPatternsEntityPage/Fields/FormFieldInput.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/ImageInput.js +6 -9
- package/dist/esm/components/AutoPatternsEntityPage/Fields/ImageInput.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/LongText.js +6 -8
- package/dist/esm/components/AutoPatternsEntityPage/Fields/LongText.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/Number.js +8 -10
- package/dist/esm/components/AutoPatternsEntityPage/Fields/Number.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/ShortText.js +10 -12
- package/dist/esm/components/AutoPatternsEntityPage/Fields/ShortText.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/Fields/Url.js +6 -8
- package/dist/esm/components/AutoPatternsEntityPage/Fields/Url.js.map +1 -1
- package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js +4 -7
- package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js.map +1 -1
- package/dist/esm/components/ModalRenderer.js +1 -2
- package/dist/esm/components/ModalRenderer.js.map +1 -1
- package/dist/esm/components/modals/actions/BulkDeleteModal.js +7 -12
- package/dist/esm/components/modals/actions/BulkDeleteModal.js.map +1 -1
- package/dist/esm/components/modals/actions/CreateModal.js +6 -11
- package/dist/esm/components/modals/actions/CreateModal.js.map +1 -1
- package/dist/esm/components/modals/actions/EditModal.js +6 -11
- package/dist/esm/components/modals/actions/EditModal.js.map +1 -1
- package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js +3 -4
- package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
- package/dist/esm/dataSourceAdapters/cms/filterUtils.js +1 -2
- package/dist/esm/dataSourceAdapters/cms/filterUtils.js.map +1 -1
- package/dist/esm/dataSourceAdapters/cms/sortUtils.js +2 -2
- package/dist/esm/dataSourceAdapters/cms/sortUtils.js.map +1 -1
- package/dist/esm/hooks/useActionCell.js +16 -12
- package/dist/esm/hooks/useActionCell.js.map +1 -1
- package/dist/esm/hooks/useBaseTableFeatures.js +1 -2
- package/dist/esm/hooks/useBaseTableFeatures.js.map +1 -1
- package/dist/esm/hooks/useBulkActionToolbar.js +2 -2
- package/dist/esm/hooks/useBulkActionToolbar.js.map +1 -1
- package/dist/esm/hooks/useCollectionPageActions.js +3 -3
- package/dist/esm/hooks/useCollectionPageActions.js.map +1 -1
- package/dist/esm/hooks/useCollectionPageOnRowClickActions.js +1 -1
- package/dist/esm/hooks/useCollectionPageOnRowClickActions.js.map +1 -1
- package/dist/esm/hooks/useColumns.js +7 -12
- package/dist/esm/hooks/useColumns.js.map +1 -1
- package/dist/esm/hooks/useCommonCollectionFeatures.js +7 -8
- package/dist/esm/hooks/useCommonCollectionFeatures.js.map +1 -1
- package/dist/esm/hooks/useEmptyStates.js +5 -6
- package/dist/esm/hooks/useEmptyStates.js.map +1 -1
- package/dist/esm/hooks/useFilters.js +7 -7
- package/dist/esm/hooks/useFilters.js.map +1 -1
- package/dist/esm/hooks/useNavigationUtils.js +2 -3
- package/dist/esm/hooks/useNavigationUtils.js.map +1 -1
- package/dist/esm/hooks/usePagePath.js +3 -4
- package/dist/esm/hooks/usePagePath.js.map +1 -1
- package/dist/esm/hooks/useTableFeatures.js +1 -2
- package/dist/esm/hooks/useTableFeatures.js.map +1 -1
- package/dist/esm/providers/PatternsWizardOverridesContext.js.map +1 -1
- package/dist/esm/providers/SchemaContext.js +2 -3
- package/dist/esm/providers/SchemaContext.js.map +1 -1
- package/dist/esm/providers/SchemaRegistryContext.js +1 -1
- package/dist/esm/providers/SchemaRegistryContext.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/esm/types/actions/base.js.map +1 -1
- package/dist/esm/utils/actions/customAction.js +1 -2
- package/dist/esm/utils/actions/customAction.js.map +1 -1
- package/dist/esm/utils/actions/deleteAction.js +5 -10
- package/dist/esm/utils/actions/deleteAction.js.map +1 -1
- package/dist/esm/utils/filterCreators.js +11 -11
- package/dist/esm/utils/filterCreators.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/hooks/useActionCell.d.ts.map +1 -1
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts +3 -6
- package/dist/types/providers/PatternsWizardOverridesContext.d.ts.map +1 -1
- package/dist/types/types/CollectionPageConfig.d.ts +7 -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/dist/types/types/actions/base.d.ts +0 -4
- package/dist/types/types/actions/base.d.ts.map +1 -1
- package/package.json +11 -11
|
@@ -3,7 +3,6 @@ import { FormField, InputArea } from '@wix/design-system';
|
|
|
3
3
|
import { useEntityPageContext, useSelector, useWixPatternsContainer } from '@wix/patterns';
|
|
4
4
|
import { useController } from '@wix/patterns/form';
|
|
5
5
|
export const LongText = props => {
|
|
6
|
-
var _pageState$entity, _field$validation2, _controller$fieldStat;
|
|
7
6
|
const {
|
|
8
7
|
field,
|
|
9
8
|
dataHook
|
|
@@ -15,13 +14,12 @@ export const LongText = props => {
|
|
|
15
14
|
useSelector(() => container.initTask.status);
|
|
16
15
|
const pageState = useEntityPageContext();
|
|
17
16
|
const controller = useController({
|
|
18
|
-
name:
|
|
17
|
+
name: field?.id ?? '',
|
|
19
18
|
control: pageState.form.control,
|
|
20
|
-
defaultValue:
|
|
19
|
+
defaultValue: pageState.entity?.[field?.id ?? ''],
|
|
21
20
|
rules: {
|
|
22
21
|
validate: value => {
|
|
23
|
-
|
|
24
|
-
if ((_field$validation = field.validation) != null && _field$validation.required && (value === null || value === undefined || value === '')) {
|
|
22
|
+
if (field.validation?.required && (value === null || value === undefined || value === '')) {
|
|
25
23
|
return t('cairo.fieldValidation.requiredField');
|
|
26
24
|
}
|
|
27
25
|
return true;
|
|
@@ -30,13 +28,13 @@ export const LongText = props => {
|
|
|
30
28
|
});
|
|
31
29
|
return /*#__PURE__*/React.createElement(FormField, {
|
|
32
30
|
label: field.displayName,
|
|
33
|
-
required:
|
|
31
|
+
required: field.validation?.required,
|
|
34
32
|
status: controller.fieldState.error ? 'error' : undefined,
|
|
35
|
-
statusMessage:
|
|
33
|
+
statusMessage: controller.fieldState.error?.message,
|
|
36
34
|
dataHook: dataHook
|
|
37
35
|
}, /*#__PURE__*/React.createElement(InputArea, {
|
|
38
36
|
value: controller.field.value,
|
|
39
|
-
onChange: e => controller.field.onChange
|
|
37
|
+
onChange: e => controller.field.onChange?.(e.target.value),
|
|
40
38
|
onBlur: controller.field.onBlur,
|
|
41
39
|
ref: controller.field.ref,
|
|
42
40
|
dataHook: `long-text-${field.id}`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","FormField","InputArea","useEntityPageContext","useSelector","useWixPatternsContainer","useController","LongText","props","
|
|
1
|
+
{"version":3,"names":["React","FormField","InputArea","useEntityPageContext","useSelector","useWixPatternsContainer","useController","LongText","props","field","dataHook","translate","t","container","initTask","status","pageState","controller","name","id","control","form","defaultValue","entity","rules","validate","value","validation","required","undefined","createElement","label","displayName","fieldState","error","statusMessage","message","onChange","e","target","onBlur","ref"],"sources":["../../../../../src/components/AutoPatternsEntityPage/Fields/LongText.tsx"],"sourcesContent":["import React from 'react';\nimport { FormField, InputArea } 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';\n\nexport interface LongTextProps extends BaseInputProps<string> {}\n\nexport const LongText = (props: LongTextProps) => {\n const { field, dataHook } = props;\n\n const { translate: t, ...container } = useWixPatternsContainer();\n useSelector(() => container.initTask.status);\n\n const pageState = useEntityPageContext();\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 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 <InputArea\n value={controller.field.value}\n onChange={(e) => controller.field.onChange?.(e.target.value)}\n onBlur={controller.field.onBlur}\n ref={controller.field.ref}\n dataHook={`long-text-${field.id}`}\n />\n </FormField>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS,EAAEC,SAAS,QAAQ,oBAAoB;AAEzD,SACEC,oBAAoB,EACpBC,WAAW,EACXC,uBAAuB,QAClB,eAAe;AACtB,SAASC,aAAa,QAAQ,oBAAoB;AAIlD,OAAO,MAAMC,QAAQ,GAAIC,KAAoB,IAAK;EAChD,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAC,GAAGF,KAAK;EAEjC,MAAM;IAAEG,SAAS,EAAEC,CAAC;IAAE,GA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AAC+B,MAAO;IAChCC,GAAG,EAAExB,UAAU,CAACR,KAAK,CAACgC,GAAI;IAC1B/B,QAAQ,EAAE,aAAaD,KAAK,CAACU,EAAE;EAAG,CACnC,CACQ,CAAC;AAEhB,CAAC","ignoreList":[]}
|
|
@@ -3,7 +3,6 @@ import { FormField, NumberInput } from '@wix/design-system';
|
|
|
3
3
|
import { useEntityPageContext, useSelector, useWixPatternsContainer } from '@wix/patterns';
|
|
4
4
|
import { useController } from '@wix/patterns/form';
|
|
5
5
|
export const Number = props => {
|
|
6
|
-
var _field$validation, _pageState$entity, _field$validation3, _controller$fieldStat;
|
|
7
6
|
const {
|
|
8
7
|
field,
|
|
9
8
|
dataHook
|
|
@@ -14,17 +13,16 @@ export const Number = props => {
|
|
|
14
13
|
} = useWixPatternsContainer();
|
|
15
14
|
useSelector(() => container.initTask.status);
|
|
16
15
|
const pageState = useEntityPageContext();
|
|
17
|
-
const numberRange =
|
|
18
|
-
const min = numberRange
|
|
19
|
-
const max = numberRange
|
|
16
|
+
const numberRange = field.validation?.numberRange;
|
|
17
|
+
const min = numberRange?.min;
|
|
18
|
+
const max = numberRange?.max;
|
|
20
19
|
const controller = useController({
|
|
21
|
-
name:
|
|
20
|
+
name: field?.id ?? '',
|
|
22
21
|
control: pageState.form.control,
|
|
23
|
-
defaultValue:
|
|
22
|
+
defaultValue: pageState.entity?.[field?.id ?? ''],
|
|
24
23
|
rules: {
|
|
25
24
|
validate: value => {
|
|
26
|
-
|
|
27
|
-
if ((_field$validation2 = field.validation) != null && _field$validation2.required && (value === null || value === undefined || value === '')) {
|
|
25
|
+
if (field.validation?.required && (value === null || value === undefined || value === '')) {
|
|
28
26
|
return t('cairo.fieldValidation.requiredField');
|
|
29
27
|
}
|
|
30
28
|
if (value !== null && value !== undefined) {
|
|
@@ -45,9 +43,9 @@ export const Number = props => {
|
|
|
45
43
|
});
|
|
46
44
|
return /*#__PURE__*/React.createElement(FormField, {
|
|
47
45
|
label: field.displayName,
|
|
48
|
-
required:
|
|
46
|
+
required: field.validation?.required,
|
|
49
47
|
status: controller.fieldState.error ? 'error' : undefined,
|
|
50
|
-
statusMessage:
|
|
48
|
+
statusMessage: controller.fieldState.error?.message,
|
|
51
49
|
dataHook: dataHook
|
|
52
50
|
}, /*#__PURE__*/React.createElement(NumberInput, {
|
|
53
51
|
value: controller.field.value ?? undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","FormField","NumberInput","useEntityPageContext","useSelector","useWixPatternsContainer","useController","Number","props","
|
|
1
|
+
{"version":3,"names":["React","FormField","NumberInput","useEntityPageContext","useSelector","useWixPatternsContainer","useController","Number","props","field","dataHook","translate","t","container","initTask","status","pageState","numberRange","validation","min","max","controller","name","id","control","form","defaultValue","entity","rules","validate","value","required","undefined","minAmount","maxAmount","createElement","label","displayName","fieldState","error","statusMessage","message","onChange","e","onBlur","inputRef","ref"],"sources":["../../../../../src/components/AutoPatternsEntityPage/Fields/Number.tsx"],"sourcesContent":["import React from 'react';\nimport { FormField, NumberInput } 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';\n\nexport interface NumberProps extends BaseInputProps<number | null> {}\n\nexport const Number = (props: NumberProps) => {\n const { field, dataHook } = props;\n\n const { translate: t, ...container } = useWixPatternsContainer();\n useSelector(() => container.initTask.status);\n\n const pageState = useEntityPageContext();\n\n const numberRange = field.validation?.numberRange;\n const min = numberRange?.min;\n const max = numberRange?.max;\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 if (value !== null && value !== undefined) {\n if (min !== undefined && value < min) {\n return t('cairo.fieldValidation.minNumber', {\n minAmount: min,\n });\n }\n if (max !== undefined && value > max) {\n return t('cairo.fieldValidation.maxNumber', {\n maxAmount: max,\n });\n }\n }\n\n return true;\n },\n },\n });\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 <NumberInput\n value={controller.field.value ?? undefined}\n onChange={(e) => controller.field.onChange(e)}\n onBlur={controller.field.onBlur}\n inputRef={controller.field.ref}\n dataHook={`number-${field.id}`}\n />\n </FormField>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS,EAAEC,WAAW,QAAQ,oBAAoB;AAE3D,SACEC,oBAAoB,EACpBC,WAAW,EACXC,uBAAuB,QAClB,eAAe;AACtB,SAASC,aAAa,QAAQ,oBAAoB;AAIlD,OAAO,MAAMC,MAAM,GAAIC,KAAkB,IAAK;EAC5C,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAC,GAAGF,KAAK;EAEjC,MAAM;IAAEG,SAAS,EAAEC,CAAC;IAAE,GAAGC;EAAU,CAAC,GAAGR,uBAAuB,CAAC,CAAC;EAChED,WAAW,CAAC,MAAMS,SAAS,CAACC,QAAQ,CAACC,MAAM,CAAC;EAE5C,MAAMC,SAAS,GAAGb,oBAAoB,CAAC,CAAC;EAExC,MAAMc,WAAW,GAAGR,KAAK,CAACS,UAAU,EAAED,WAAW;EACjD,MAAME,GAAG,GAAGF,WAAW,EAAEE,GAAG;EAC5B,MAAMC,GAAG,GAAGH,WAAW,EAAEG,GAAG;EAE5B,MAAMC,UAAU,GAAGf,aAAa,CAAC;IAC/BgB,IAAI,EAAEb,KAAK,EAAEc,EAAE,IAAI,EAAE;IACrBC,OAAO,EAAER,SAAS,CAACS,IAAI,CAACD,OAAO;IAC/BE,YAAY,EAAGV,SAAS,CAACW,MAAM,GAAWlB,KAAK,EAAEc,EAAE,IAAI,EAAE,CAAC;IAC1DK,KAAK,EAAE;MACLC,QAAQ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qC,GAAI;IAC/BpC,QAAQ,EAAE,UAAUD,KAAK,CAACc,EAAE;EAAG,CAChC,CACQ,CAAC;AAEhB,CAAC","ignoreList":[]}
|
|
@@ -3,7 +3,6 @@ import { FormField, Input } from '@wix/design-system';
|
|
|
3
3
|
import { useEntityPageContext, useSelector, useWixPatternsContainer } from '@wix/patterns';
|
|
4
4
|
import { useController } from '@wix/patterns/form';
|
|
5
5
|
export const ShortText = props => {
|
|
6
|
-
var _field$validation, _pageState$entity, _controller$field$val, _field$validation3, _controller$fieldStat;
|
|
7
6
|
const {
|
|
8
7
|
field,
|
|
9
8
|
dataHook
|
|
@@ -14,17 +13,16 @@ export const ShortText = props => {
|
|
|
14
13
|
} = useWixPatternsContainer();
|
|
15
14
|
useSelector(() => container.initTask.status);
|
|
16
15
|
const pageState = useEntityPageContext();
|
|
17
|
-
const stringLengthRange =
|
|
18
|
-
const minLength = stringLengthRange
|
|
19
|
-
const maxLength = stringLengthRange
|
|
16
|
+
const stringLengthRange = field.validation?.stringLengthRange;
|
|
17
|
+
const minLength = stringLengthRange?.minLength;
|
|
18
|
+
const maxLength = stringLengthRange?.maxLength;
|
|
20
19
|
const controller = useController({
|
|
21
|
-
name:
|
|
20
|
+
name: field?.id ?? '',
|
|
22
21
|
control: pageState.form.control,
|
|
23
|
-
defaultValue:
|
|
22
|
+
defaultValue: pageState.entity?.[field?.id ?? ''],
|
|
24
23
|
rules: {
|
|
25
24
|
validate: value => {
|
|
26
|
-
|
|
27
|
-
if ((_field$validation2 = field.validation) != null && _field$validation2.required && (value === null || value === undefined || value === '')) {
|
|
25
|
+
if (field.validation?.required && (value === null || value === undefined || value === '')) {
|
|
28
26
|
return t('cairo.fieldValidation.requiredField');
|
|
29
27
|
}
|
|
30
28
|
if (minLength && value && value.length < minLength) {
|
|
@@ -40,17 +38,17 @@ export const ShortText = props => {
|
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
40
|
});
|
|
43
|
-
const charCount = maxLength ? maxLength -
|
|
41
|
+
const charCount = maxLength ? maxLength - controller.field.value?.length : undefined;
|
|
44
42
|
return /*#__PURE__*/React.createElement(FormField, {
|
|
45
43
|
label: field.displayName,
|
|
46
|
-
required:
|
|
44
|
+
required: field.validation?.required,
|
|
47
45
|
charCount: charCount,
|
|
48
46
|
status: controller.fieldState.error ? 'error' : undefined,
|
|
49
|
-
statusMessage:
|
|
47
|
+
statusMessage: controller.fieldState.error?.message,
|
|
50
48
|
dataHook: dataHook
|
|
51
49
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
52
50
|
value: controller.field.value,
|
|
53
|
-
onChange: e => controller.field.onChange
|
|
51
|
+
onChange: e => controller.field.onChange?.(e.target.value),
|
|
54
52
|
onBlur: controller.field.onBlur,
|
|
55
53
|
dataHook: `short-text-${field.id}`,
|
|
56
54
|
ref: controller.field.ref
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","FormField","Input","useEntityPageContext","useSelector","useWixPatternsContainer","useController","ShortText","props","
|
|
1
|
+
{"version":3,"names":["React","FormField","Input","useEntityPageContext","useSelector","useWixPatternsContainer","useController","ShortText","props","field","dataHook","translate","t","container","initTask","status","pageState","stringLengthRange","validation","minLength","maxLength","controller","name","id","control","form","defaultValue","entity","rules","validate","value","required","undefined","length","charMin","charMax","charCount","createElement","label","displayName","fieldState","error","statusMessage","message","onChange","e","target","onBlur","ref"],"sources":["../../../../../src/components/AutoPatternsEntityPage/Fields/ShortText.tsx"],"sourcesContent":["import React from 'react';\nimport { FormField, Input } 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';\n\nexport interface ShortTextProps extends BaseInputProps<string> {}\n\nexport const ShortText = (props: ShortTextProps) => {\n const { field, dataHook } = props;\n\n const { translate: t, ...container } = useWixPatternsContainer();\n useSelector(() => container.initTask.status);\n\n const pageState = useEntityPageContext();\n\n const stringLengthRange = field.validation?.stringLengthRange;\n const minLength = stringLengthRange?.minLength;\n const maxLength = stringLengthRange?.maxLength;\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 if (minLength && value && value.length < minLength) {\n return t('cairo.fieldValidation.minCharacter', {\n charMin: minLength,\n });\n } else if (maxLength && value && value.length > maxLength) {\n return t('cairo.fieldValidation.maxCharacter', {\n charMax: maxLength,\n });\n }\n\n return true;\n },\n },\n });\n\n const charCount = maxLength\n ? maxLength - controller.field.value?.length\n : undefined;\n\n return (\n <FormField\n label={field.displayName}\n required={field.validation?.required}\n charCount={charCount}\n status={controller.fieldState.error ? 'error' : undefined}\n statusMessage={controller.fieldState.error?.message}\n dataHook={dataHook}\n >\n <Input\n value={controller.field.value}\n onChange={(e) => controller.field.onChange?.(e.target.value)}\n onBlur={controller.field.onBlur}\n dataHook={`short-text-${field.id}`}\n ref={controller.field.ref}\n />\n </FormField>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS,EAAEC,KAAK,QAAQ,oBAAoB;AAErD,SACEC,oBAAoB,EACpBC,WAAW,EACXC,uBAAuB,QAClB,eAAe;AACtB,SAASC,aAAa,QAAQ,oBAAoB;AAIlD,OAAO,MAAMC,SAAS,GAAIC,KAAqB,IAAK;EAClD,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAC,GAAGF,KAAK;EAEjC,MAAM;IAAEG,SAAS,EAAEC,CAAC;IAAE,GAAGC;EAAU,CAAC,GAAGR,uBAAuB,CAAC,CAAC;EAChED,WAAW,CAAC,MAAMS,SAAS,CAACC,QAAQ,CAACC,MAAM,CAAC;EAE5C,MAAMC,SAAS,GAAGb,oBAAoB,CAAC,CAAC;EAExC,MAAMc,iBAAiB,GAAGR,KAAK,CAACS,U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,SAAU;IACrBrB,MAAM,EAAEM,UAAU,CAACmB,UAAU,CAACC,KAAK,GAAG,OAAO,GAAGT,SAAU;IAC1DU,aAAa,EAAErB,UAAU,CAACmB,UAAU,CAACC,KAAK,EAAEE,OAAQ;IACpDjC,QAAQ,EAAEA;EAAS,gBAEnBV,KAAA,CAAAqC,aAAA,CAACnC,KAAK;IACJ4B,KAAK,EAAET,UAAU,CAACZ,KAAK,CAACqB,KAAM;IAC9Bc,QAAQ,EAAGC,CAAC,IAAKxB,UAAU,CAACZ,KAAK,CAACmC,QAAQ,GAAGC,CAAC,CAACC,MAAM,CAAChB,KAAK,CAAE;IAC7DiB,MAAM,EAAE1B,UAAU,CAACZ,KAAK,CAACsC,MAAO;IAChCrC,QAAQ,EAAE,cAAcD,KAAK,CAACc,EAAE,EAAG;IACnCyB,GAAG,EAAE3B,UAAU,CAACZ,KAAK,CAACuC;EAAI,CAC3B,CACQ,CAAC;AAEhB,CAAC","ignoreList":[]}
|
|
@@ -4,7 +4,6 @@ import { Link } from '@wix/wix-ui-icons-common';
|
|
|
4
4
|
import { useEntityPageContext, useSelector, useWixPatternsContainer } from '@wix/patterns';
|
|
5
5
|
import { useController } from '@wix/patterns/form';
|
|
6
6
|
export const Url = props => {
|
|
7
|
-
var _pageState$entity, _field$validation2, _controller$fieldStat;
|
|
8
7
|
const {
|
|
9
8
|
field,
|
|
10
9
|
dataHook
|
|
@@ -21,13 +20,12 @@ export const Url = props => {
|
|
|
21
20
|
// eslint-disable-next-line no-useless-escape
|
|
22
21
|
/^[A-Za-z][A-Za-z0-9+.-]*:(\/\/([A-Za-z0-9._~\-%!$&'()*+,;=:]*@)?[A-Za-z0-9._~\-!$&'()*+,;=%:\[\]]*(:[0-9]*)?)?[A-Za-z0-9._~\-%!$&'()*+,;=:@\/]*([?][A-Za-z0-9._~\-%!$&'()*+,;=:@\/?]*)?([#][A-Za-z0-9._~\-%!$&'()*+,;=:@\/?]*)?$/;
|
|
23
22
|
const controller = useController({
|
|
24
|
-
name:
|
|
23
|
+
name: field?.id ?? '',
|
|
25
24
|
control: pageState.form.control,
|
|
26
|
-
defaultValue:
|
|
25
|
+
defaultValue: pageState.entity?.[field?.id ?? ''],
|
|
27
26
|
rules: {
|
|
28
27
|
validate: value => {
|
|
29
|
-
|
|
30
|
-
if ((_field$validation = field.validation) != null && _field$validation.required && (value === null || value === undefined || value === '')) {
|
|
28
|
+
if (field.validation?.required && (value === null || value === undefined || value === '')) {
|
|
31
29
|
return t('cairo.fieldValidation.requiredField');
|
|
32
30
|
} else if (value) {
|
|
33
31
|
return uriPattern.test(value) || t('cairo.customFields.url-input.error');
|
|
@@ -38,16 +36,16 @@ export const Url = props => {
|
|
|
38
36
|
});
|
|
39
37
|
return /*#__PURE__*/React.createElement(FormField, {
|
|
40
38
|
label: field.displayName,
|
|
41
|
-
required:
|
|
39
|
+
required: field.validation?.required,
|
|
42
40
|
dataHook: dataHook,
|
|
43
41
|
status: controller.fieldState.error ? 'error' : undefined,
|
|
44
|
-
statusMessage:
|
|
42
|
+
statusMessage: controller.fieldState.error?.message
|
|
45
43
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
46
44
|
prefix: /*#__PURE__*/React.createElement(Input.IconAffix, null, /*#__PURE__*/React.createElement(Link, null)),
|
|
47
45
|
placeholder: t('cairo.customFields.url-input.placeholder'),
|
|
48
46
|
dataHook: `url-${field.id}`,
|
|
49
47
|
value: controller.field.value,
|
|
50
|
-
onChange: e => controller.field.onChange
|
|
48
|
+
onChange: e => controller.field.onChange?.(e.target.value),
|
|
51
49
|
onBlur: controller.field.onBlur,
|
|
52
50
|
ref: controller.field.ref
|
|
53
51
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","FormField","Input","Link","useEntityPageContext","useSelector","useWixPatternsContainer","useController","Url","props","
|
|
1
|
+
{"version":3,"names":["React","FormField","Input","Link","useEntityPageContext","useSelector","useWixPatternsContainer","useController","Url","props","field","dataHook","translate","t","container","initTask","status","pageState","uriPattern","controller","name","id","control","form","defaultValue","entity","rules","validate","value","validation","required","undefined","test","createElement","label","displayName","fieldState","error","statusMessage","message","prefix","IconAffix","placeholder","onChange","e","target","onBlur","ref"],"sources":["../../../../../src/components/AutoPatternsEntityPage/Fields/Url.tsx"],"sourcesContent":["import React from 'react';\nimport { FormField, Input } from '@wix/design-system';\nimport { BaseInputProps } from './types';\nimport { Link } from '@wix/wix-ui-icons-common';\nimport {\n useEntityPageContext,\n useSelector,\n useWixPatternsContainer,\n} from '@wix/patterns';\nimport { useController } from '@wix/patterns/form';\n\nexport interface UrlProps extends BaseInputProps<string> {}\n\nexport const Url = (props: UrlProps) => {\n const { field, dataHook } = props;\n const { translate: t, ...container } = useWixPatternsContainer();\n useSelector(() => container.initTask.status);\n const pageState = useEntityPageContext();\n\n // Same regex as data-extensions https://github.com/wix-private/server-infra/blob/a6c3009d39bbb0312c929f68ee81c559e1eb5b4e/iptf/dataextensions/src/main/scala/com/wixpress/infra/dataextensions/runtime/validator/Formats.scala#L31\n const uriPattern =\n // eslint-disable-next-line no-useless-escape\n /^[A-Za-z][A-Za-z0-9+.-]*:(\\/\\/([A-Za-z0-9._~\\-%!$&'()*+,;=:]*@)?[A-Za-z0-9._~\\-!$&'()*+,;=%:\\[\\]]*(:[0-9]*)?)?[A-Za-z0-9._~\\-%!$&'()*+,;=:@\\/]*([?][A-Za-z0-9._~\\-%!$&'()*+,;=:@\\/?]*)?([#][A-Za-z0-9._~\\-%!$&'()*+,;=:@\\/?]*)?$/;\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: string | null | undefined) => {\n if (\n field.validation?.required &&\n (value === null || value === undefined || value === '')\n ) {\n return t('cairo.fieldValidation.requiredField');\n } else if (value) {\n return (\n uriPattern.test(value) || t('cairo.customFields.url-input.error')\n );\n }\n return true;\n },\n },\n });\n\n return (\n <FormField\n label={field.displayName}\n required={field.validation?.required}\n dataHook={dataHook}\n status={controller.fieldState.error ? 'error' : undefined}\n statusMessage={controller.fieldState.error?.message}\n >\n <Input\n prefix={\n <Input.IconAffix>\n <Link />\n </Input.IconAffix>\n }\n placeholder={t('cairo.customFields.url-input.placeholder')}\n dataHook={`url-${field.id}`}\n value={controller.field.value}\n onChange={(e) => controller.field.onChange?.(e.target.value)}\n onBlur={controller.field.onBlur}\n ref={controller.field.ref}\n />\n </FormField>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS,EAAEC,KAAK,QAAQ,oBAAoB;AAErD,SAASC,IAAI,QAAQ,0BAA0B;AAC/C,SACEC,oBAAoB,EACpBC,WAAW,EACXC,uBAAuB,QAClB,eAAe;AACtB,SAASC,aAAa,QAAQ,oBAAoB;AAIlD,OAAO,MAAMC,GAAG,GAAIC,KAAe,IAAK;EACtC,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAC,GAAGF,KAAK;EACjC,MAAM;IAAEG,SAAS,EAAEC,CAAC;IAAE,GAAGC;EAAU,CAAC,GAAGR,uBAAuB,CAAC,CAAC;EAChED,WAAW,CAAC,MAAMS,SAAS,CAACC,QAAQ,CAACC,MAAM,CAAC;EAC5C,MAAMC,SAAS,GAAGb,oBAAoB,CAAC,CAAC;;EAExC;EACA,MAAMc,UAAU;EACd;EACA,kOAAkO;EAEpO,MAAMC,UAAU,GAAGZ,aAAa,CAAC;IAC/Ba,IAAI,EAAEV,KAAK,EAAEW,EAAE,IAAI,EAAE;IACrBC,OAAO,EAAEL,SAAS,CAACM,IAAI,CAACD,OAAO;IAC/BE,YAAY,EAAGP,SAAS,CAACQ,MAAM,GAAWf,KAAK,EAAEW,EAAE,IAAI,EAAE,CAAC;IAC1DK,KAAK,EAAE;MACLC,QAAQ,EAAGC,KAAgC,IAAK;QAC9C,IACElB,KAAK,CAACmB,UAAU,EAAEC,QAAQ,KACzBF,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKG,SAAS,I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
|
import { Card, Cell, Layout } from '@wix/design-system';
|
|
5
5
|
const RenderLayoutContent = _ref => {
|
|
6
|
-
var _content$container$ch;
|
|
7
6
|
let {
|
|
8
7
|
content,
|
|
9
8
|
level,
|
|
@@ -13,7 +12,7 @@ const RenderLayoutContent = _ref => {
|
|
|
13
12
|
} = _ref;
|
|
14
13
|
switch (content.type) {
|
|
15
14
|
case 'container':
|
|
16
|
-
if (!
|
|
15
|
+
if (!content.container.children?.length) {
|
|
17
16
|
return null;
|
|
18
17
|
}
|
|
19
18
|
return /*#__PURE__*/React.createElement(Cell, {
|
|
@@ -31,7 +30,6 @@ const RenderLayoutContent = _ref => {
|
|
|
31
30
|
}
|
|
32
31
|
};
|
|
33
32
|
const RenderLayoutCard = _ref2 => {
|
|
34
|
-
var _layout$card$subtitle;
|
|
35
33
|
let {
|
|
36
34
|
layout,
|
|
37
35
|
sectionId,
|
|
@@ -43,7 +41,7 @@ const RenderLayoutCard = _ref2 => {
|
|
|
43
41
|
minHeight: "50px"
|
|
44
42
|
}, /*#__PURE__*/React.createElement(Card.Header, {
|
|
45
43
|
title: layout.card.title.text,
|
|
46
|
-
subtitle:
|
|
44
|
+
subtitle: layout.card.subtitle?.text
|
|
47
45
|
}), /*#__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
46
|
key: `${sectionId}-card-${cardIndex}-content-${index}`,
|
|
49
47
|
content: child,
|
|
@@ -57,7 +55,6 @@ const RenderLayoutCard = _ref2 => {
|
|
|
57
55
|
}
|
|
58
56
|
};
|
|
59
57
|
export const SkeletonEntity = _ref3 => {
|
|
60
|
-
var _entityPage$layout, _entityPage$layout2, _entityPage$layout$si;
|
|
61
58
|
let {
|
|
62
59
|
entityPage
|
|
63
60
|
} = _ref3;
|
|
@@ -76,12 +73,12 @@ export const SkeletonEntity = _ref3 => {
|
|
|
76
73
|
title: {
|
|
77
74
|
text: ''
|
|
78
75
|
}
|
|
79
|
-
}), /*#__PURE__*/React.createElement(EntityPage.Content, null, /*#__PURE__*/React.createElement(EntityPage.MainContent, null,
|
|
76
|
+
}), /*#__PURE__*/React.createElement(EntityPage.Content, null, /*#__PURE__*/React.createElement(EntityPage.MainContent, null, entityPage.layout?.main?.map((layout, layoutIndex) => /*#__PURE__*/React.createElement(RenderLayoutCard, {
|
|
80
77
|
key: `main-section-card-${layoutIndex}`,
|
|
81
78
|
layout: layout,
|
|
82
79
|
sectionId: "main",
|
|
83
80
|
cardIndex: layoutIndex
|
|
84
|
-
}))),
|
|
81
|
+
}))), entityPage.layout?.sidebar ? /*#__PURE__*/React.createElement(EntityPage.AdditionalContent, null, entityPage.layout.sidebar?.map((layout, layoutIndex) => /*#__PURE__*/React.createElement(RenderLayoutCard, {
|
|
85
82
|
key: `sidebar-section-card-${layoutIndex}`,
|
|
86
83
|
layout: layout,
|
|
87
84
|
sectionId: "sidebar",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["EntityPage","useEntityPage","useForm","React","Card","Cell","Layout","RenderLayoutContent","_ref","
|
|
1
|
+
{"version":3,"names":["EntityPage","useEntityPage","useForm","React","Card","Cell","Layout","RenderLayoutContent","_ref","content","level","sectionId","cardIndex","contentIndex","type","container","children","length","createElement","span","map","child","index","key","RenderLayoutCard","_ref2","layout","minHeight","Header","title","card","text","subtitle","Divider","Content","SkeletonEntity","_ref3","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,IAA3D;IAAEC,OAAO;IAAEC,KAAK;IAAEC,SAAS;IAAEC,SAAS;IAAEC;EAAa,CAAC,GAAAL,IAAA;EAC1D,QAAQC,OAAO,CAACK,IAAI;IAClB,KAAK,WAAW;MACd,IAAI,CAACL,OAAO,CAACM,SAAS,CAACC,QAAQ,EAAEC,MAAM,EAAE;QACvC,OAAO,IAAI;MACb;MAEA,oBACEd,KAAA,CAAAe,aAAA,CAACb,IAAI;QAACc,IAAI,EAAEV,OAAO,CAACM,SAAS,CAACI;MAAK,gBACjChB,KAAA,CAAAe,aAAA,CAACZ,MAAM,QACJG,OAAO,CAACM,SAAS,CAACC,QAAQ,CAACI,GAAG,CAAC,CAACC,KAAK,EAAEC,KAAK,kBAC3CnB,KAAA,CAAAe,aAAA,CAACX,mBAAmB;QAClBgB,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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;AAEP,CAAC","ignoreList":[]}
|
|
@@ -4,7 +4,6 @@ import * as modals from './modals';
|
|
|
4
4
|
import { useModalContext } from '../providers/ModalContext';
|
|
5
5
|
import { usePatternsWizardOverridesContext } from '../providers';
|
|
6
6
|
export const ModalRenderer = () => {
|
|
7
|
-
var _overrides$modals;
|
|
8
7
|
const {
|
|
9
8
|
modal,
|
|
10
9
|
closeModal
|
|
@@ -13,7 +12,7 @@ export const ModalRenderer = () => {
|
|
|
13
12
|
if (!modal.id) {
|
|
14
13
|
return null;
|
|
15
14
|
}
|
|
16
|
-
const ModalComponent =
|
|
15
|
+
const ModalComponent = overrides?.modals?.[modal.id] || modals[modal.id];
|
|
17
16
|
if (!ModalComponent) {
|
|
18
17
|
console.warn(`No modal registered for id: ${modal.id}`);
|
|
19
18
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","modals","useModalContext","usePatternsWizardOverridesContext","ModalRenderer","
|
|
1
|
+
{"version":3,"names":["React","modals","useModalContext","usePatternsWizardOverridesContext","ModalRenderer","modal","closeModal","overrides","id","ModalComponent","console","warn","createElement","_extends","props","onClose"],"sources":["../../../src/components/ModalRenderer.tsx"],"sourcesContent":["import React from 'react';\nimport * as modals from './modals';\nimport { useModalContext } from '../providers/ModalContext';\nimport { usePatternsWizardOverridesContext } from '../providers';\n\nexport const ModalRenderer = () => {\n const { modal, closeModal } = useModalContext();\n const overrides = usePatternsWizardOverridesContext();\n\n if (!modal.id) {\n return null;\n }\n\n const ModalComponent =\n overrides?.modals?.[modal.id] ||\n (modals as Record<string, React.ComponentType<any>>)[modal.id];\n\n if (!ModalComponent) {\n console.warn(`No modal registered for id: ${modal.id}`);\n return null;\n }\n\n return <ModalComponent {...modal.props} onClose={closeModal} />;\n};\n"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAO,KAAKC,MAAM,MAAM,UAAU;AAClC,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,SAASC,iCAAiC,QAAQ,cAAc;AAEhE,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EACjC,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGJ,eAAe,CAAC,CAAC;EAC/C,MAAMK,SAAS,GAAGJ,iCAAiC,CAAC,CAAC;EAErD,IAAI,CAACE,KAAK,CAACG,EAAE,EAAE;IACb,OAAO,IAAI;EACb;EAEA,MAAMC,cAAc,GAClBF,SAAS,EAAEN,MAAM,GAAGI,KAAK,CAACG,EAAE,CAAC,IAC5BP,MAAM,CAA8CI,KAAK,CAACG,EAAE,CAAC;EAEhE,IAAI,CAACC,cAAc,EAAE;IACnBC,OAAO,CAACC,IAAI,CAAC,+BAA+BN,KAAK,CAACG,EAAE,EAAE,CAAC;IACvD,OAAO,IAAI;EACb;EAEA,oBAAOR,KAAA,CAAAY,aAAA,CAACH,cAAc,EAAAI,QAAA,KAAKR,KAAK,CAACS,KAAK;IAAEC,OAAO,EAAET;EAAW,EAAE,CAAC;AACjE,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Box, CustomModalLayout, Modal, Text } from '@wix/design-system';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
export const BulkDeleteModal = _ref => {
|
|
4
|
-
var _modalParams$title, _modalParams$actions, _modalParams$actions2, _modalParams$descript;
|
|
5
4
|
let {
|
|
6
5
|
sdk,
|
|
7
6
|
modalParams,
|
|
@@ -17,24 +16,20 @@ export const BulkDeleteModal = _ref => {
|
|
|
17
16
|
isOpen: true,
|
|
18
17
|
onRequestClose: closeModal
|
|
19
18
|
}, /*#__PURE__*/React.createElement(CustomModalLayout, {
|
|
20
|
-
title:
|
|
19
|
+
title: modalParams.title?.text || 'Delete item?',
|
|
21
20
|
theme: "destructive",
|
|
22
21
|
onCloseButtonClick: () => {
|
|
23
22
|
closeModal();
|
|
24
23
|
},
|
|
25
24
|
primaryButtonOnClick: () => {
|
|
26
|
-
var _modalParams$feedback;
|
|
27
25
|
const schema = sdk.getSchema(sdk.collectionId);
|
|
28
26
|
if (!schema) {
|
|
29
27
|
throw new Error('Schema not found');
|
|
30
28
|
}
|
|
31
29
|
const selectedIds = actionParams.selectedValues.map(value => value[schema.idField]);
|
|
32
|
-
optimisticActions
|
|
33
|
-
successToast:
|
|
34
|
-
errorToast: () =>
|
|
35
|
-
var _modalParams$feedback2;
|
|
36
|
-
return ((_modalParams$feedback2 = modalParams.feedback) == null || (_modalParams$feedback2 = _modalParams$feedback2.errorToast) == null ? void 0 : _modalParams$feedback2.text) || 'Failed to delete items';
|
|
37
|
-
},
|
|
30
|
+
optimisticActions?.deleteMany(actionParams.selectedValues, {
|
|
31
|
+
successToast: modalParams.feedback?.successToast?.text || 'Items deleted successfully',
|
|
32
|
+
errorToast: () => modalParams.feedback?.errorToast?.text || 'Failed to delete items',
|
|
38
33
|
submit: async () => {
|
|
39
34
|
const result = await schema.actions.bulkDelete(selectedIds);
|
|
40
35
|
return [result];
|
|
@@ -45,15 +40,15 @@ export const BulkDeleteModal = _ref => {
|
|
|
45
40
|
secondaryButtonOnClick: () => {
|
|
46
41
|
closeModal();
|
|
47
42
|
},
|
|
48
|
-
primaryButtonText:
|
|
49
|
-
secondaryButtonText:
|
|
43
|
+
primaryButtonText: modalParams.actions?.submit?.text || 'Save',
|
|
44
|
+
secondaryButtonText: modalParams.actions?.cancel?.text || 'Cancel',
|
|
50
45
|
content: /*#__PURE__*/React.createElement(Box, {
|
|
51
46
|
direction: "vertical",
|
|
52
47
|
width: "552px",
|
|
53
48
|
gap: "SP2",
|
|
54
49
|
paddingTop: "SP1",
|
|
55
50
|
paddingBottom: "SP1"
|
|
56
|
-
}, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Text, null,
|
|
51
|
+
}, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Text, null, modalParams.description?.text || 'This items will be deleted')))
|
|
57
52
|
}));
|
|
58
53
|
};
|
|
59
54
|
//# sourceMappingURL=BulkDeleteModal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Box","CustomModalLayout","Modal","Text","React","BulkDeleteModal","_ref","
|
|
1
|
+
{"version":3,"names":["Box","CustomModalLayout","Modal","Text","React","BulkDeleteModal","_ref","sdk","modalParams","actionParams","getOptimisticActions","collectionId","closeModal","optimisticActions","createElement","isOpen","onRequestClose","title","text","theme","onCloseButtonClick","primaryButtonOnClick","schema","getSchema","Error","selectedIds","selectedValues","map","value","idField","deleteMany","successToast","feedback","errorToast","submit","result","actions","bulkDelete","secondaryButtonOnClick","primaryButtonText","secondaryButtonText","cancel","content","direction","width","gap","paddingTop","paddingBottom","description"],"sources":["../../../../../src/components/modals/actions/BulkDeleteModal.tsx"],"sourcesContent":["import { Box, CustomModalLayout, Modal, Text } from '@wix/design-system';\nimport React from 'react';\nimport { BulkActionsActionParams, BulkDeleteActionModal } from '../../../types';\nimport { ActionModalProps } from './types';\n\nexport interface BulkDeleteModalProps extends ActionModalProps {\n modalParams: BulkDeleteActionModal;\n actionParams: BulkActionsActionParams;\n}\n\nexport const BulkDeleteModal = ({\n sdk,\n modalParams,\n actionParams,\n}: BulkDeleteModalProps) => {\n const { getOptimisticActions, collectionId, closeModal } = sdk;\n const optimisticActions = getOptimisticActions(collectionId);\n\n return (\n <Modal isOpen onRequestClose={closeModal}>\n <CustomModalLayout\n title={modalParams.title?.text || 'Delete item?'}\n theme=\"destructive\"\n onCloseButtonClick={() => {\n closeModal();\n }}\n primaryButtonOnClick={() => {\n const schema = sdk.getSchema(sdk.collectionId);\n if (!schema) {\n throw new Error('Schema not found');\n }\n const selectedIds = actionParams.selectedValues.map(\n (value) => value[schema.idField],\n );\n optimisticActions?.deleteMany(actionParams.selectedValues, {\n successToast:\n modalParams.feedback?.successToast?.text ||\n 'Items deleted successfully',\n errorToast: () =>\n modalParams.feedback?.errorToast?.text ||\n 'Failed to delete items',\n submit: async () => {\n const result = await schema.actions.bulkDelete(selectedIds);\n return [result];\n },\n });\n closeModal();\n }}\n secondaryButtonOnClick={() => {\n closeModal();\n }}\n primaryButtonText={modalParams.actions?.submit?.text || 'Save'}\n secondaryButtonText={modalParams.actions?.cancel?.text || 'Cancel'}\n content={\n <Box\n direction=\"vertical\"\n width=\"552px\"\n gap=\"SP2\"\n paddingTop=\"SP1\"\n paddingBottom=\"SP1\"\n >\n <Box>\n <Text>\n {modalParams.description?.text || 'This items will be deleted'}\n </Text>\n </Box>\n </Box>\n }\n />\n </Modal>\n );\n};\n"],"mappings":"AAAA,SAASA,GAAG,EAAEC,iBAAiB,EAAEC,KAAK,EAAEC,IAAI,QAAQ,oBAAoB;AACxE,OAAOC,KAAK,MAAM,OAAO;AASzB,OAAO,MAAMC,eAAe,GAAGC,IAAA,IAIH;EAAA,IAJI;IAC9BC,GAAG;IACHC,WAAW;IACXC;EACoB,CAAC,GAAAH,IAAA;EACrB,MAAM;IAAEI,oBAAoB;IAAEC,YAAY;IAAEC;EAAW,CAAC,GAAGL,GAAG;EAC9D,MAAMM,iBAAiB,GAAGH,oBAAoB,CAACC,YAAY,CAAC;EAE5D,oBACEP,KAAA,CAAAU,aAAA,CAACZ,KAAK;IAACa,MAAM;IAACC,cAAc,EAAEJ;EAAW,gBACvCR,KAAA,CAAAU,aAAA,CAACb,iBAAiB;IAChBgB,KAAK,EAAET,WAAW,CAACS,KAAK,EAAEC,IAAI,IAAI,cAAe;IACjDC,KAAK,EAAC,aAAa;IACnBC,kBAAkB,EAAEA,CAAA,KAAM;MACxBR,UAAU,CAAC,CAAC;IACd,CAAE;IACFS,oBAAoB,EAAEA,CAAA,KAAM;MAC1B,MAAMC,MAAM,GAAGf,GAAG,CAACgB,SAAS,CAAChB,GAAG,CAACI,YAAY,CAAC;MAC9C,IAAI,CAACW,MAAM,EAAE;QACX,MAAM,IAAIE,KAAK,CAAC,kBAAkB,CAAC;MACrC;MACA,MAAMC,WAAW,GAAGhB,YAAY,CAACiB,cAAc,CAACC,GAAG,CAChDC,KAAK,IAAKA,KAAK,CAACN,MAAM,CAACO,OAAO,CACjC,CAAC;MACDhB,iBAAiB,EAAEiB,UAAU,CAACrB,YAAY,CAACiB,cAAc,EAAE;QACzDK,YAAY,EACVvB,WAAW,CAACwB,QAAQ,EAAED,YAAY,EAAEb,IAAI,IACxC,4BAA4B;QAC9Be,UAAU,EAAEA,CAAA,KACVzB,WAAW,CAACwB,QAAQ,EAAEC,UAAU,EAAEf,IAAI,IACtC,wBAAwB;QAC1BgB,MAAM,EAAE,MAAAA,CAAA,KAAY;UAClB,MAAMC,MAAM,GAAG,MAAMb,MAAM,CAACc,OAAO,CAACC,UAAU,CAACZ,WAAW,CAAC;UAC3D,OAAO,CAACU,MAAM,CAAC;QACjB;MACF,CAAC,CAAC;MACFvB,UAAU,CAAC,CAAC;IACd,CAAE;IACF0B,sBAAsB,EAAEA,CAAA,KAAM;MAC5B1B,UAAU,CAAC,CAAC;IACd,CAAE;IACF2B,iBAAiB,EAAE/B,WAAW,CAAC4B,OAAO,EAAEF,MAAM,EAAEhB,IAAI,IAAI,MAAO;IAC/DsB,mBAAmB,EAAEhC,WAAW,CAAC4B,OAAO,EAAEK,MAAM,EAAEvB,IAAI,IAAI,QAAS;IACnEwB,OAAO,eACLtC,KAAA,CAAAU,aAAA,CAACd,GAAG;MACF2C,SAAS,EAAC,UAAU;MACpBC,KAAK,EAAC,OAAO;MACbC,GAAG,EAAC,KAAK;MACTC,UAAU,EAAC,KAAK;MAChBC,aAAa,EAAC;IAAK,gBAEnB3C,KAAA,CAAAU,aAAA,CAACd,GAAG,qBACFI,KAAA,CAAAU,aAAA,CAACX,IAAI,QACFK,WAAW,CAACwC,WAAW,EAAE9B,IAAI,IAAI,4BAC9B,CACH,CACF;EACN,CACF,CACI,CAAC;AAEZ,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Box, CustomModalLayout, Input, Modal, Text } from '@wix/design-system';
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
3
|
export const CreateModal = _ref => {
|
|
4
|
-
var _modalParams$title, _modalParams$actions, _modalParams$actions2;
|
|
5
4
|
let {
|
|
6
5
|
sdk,
|
|
7
6
|
modalParams
|
|
@@ -22,22 +21,18 @@ export const CreateModal = _ref => {
|
|
|
22
21
|
isOpen: true,
|
|
23
22
|
onRequestClose: closeModal
|
|
24
23
|
}, /*#__PURE__*/React.createElement(CustomModalLayout, {
|
|
25
|
-
title:
|
|
24
|
+
title: modalParams.title?.text || 'Create',
|
|
26
25
|
onCloseButtonClick: () => {
|
|
27
26
|
closeModal();
|
|
28
27
|
},
|
|
29
28
|
primaryButtonOnClick: () => {
|
|
30
|
-
var _modalParams$feedback;
|
|
31
29
|
const schema = sdk.getSchema(sdk.collectionId);
|
|
32
30
|
const createdItem = {
|
|
33
31
|
...values
|
|
34
32
|
};
|
|
35
|
-
optimisticActions
|
|
36
|
-
successToast:
|
|
37
|
-
errorToast: () =>
|
|
38
|
-
var _modalParams$feedback2;
|
|
39
|
-
return ((_modalParams$feedback2 = modalParams.feedback) == null || (_modalParams$feedback2 = _modalParams$feedback2.errorToast) == null ? void 0 : _modalParams$feedback2.text) || 'Failed to create item';
|
|
40
|
-
},
|
|
33
|
+
optimisticActions?.createOne(createdItem, {
|
|
34
|
+
successToast: modalParams.feedback?.successToast?.text || 'Item created successfully',
|
|
35
|
+
errorToast: () => modalParams.feedback?.errorToast?.text || 'Failed to create item',
|
|
41
36
|
submit: async () => {
|
|
42
37
|
if (!schema) {
|
|
43
38
|
throw new Error('Schema not found');
|
|
@@ -51,8 +46,8 @@ export const CreateModal = _ref => {
|
|
|
51
46
|
secondaryButtonOnClick: () => {
|
|
52
47
|
closeModal();
|
|
53
48
|
},
|
|
54
|
-
primaryButtonText:
|
|
55
|
-
secondaryButtonText:
|
|
49
|
+
primaryButtonText: modalParams.actions?.submit?.text || 'Save',
|
|
50
|
+
secondaryButtonText: modalParams.actions?.cancel?.text || 'Cancel',
|
|
56
51
|
content: /*#__PURE__*/React.createElement(Box, {
|
|
57
52
|
direction: "vertical",
|
|
58
53
|
width: "552px",
|