@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.
Files changed (110) hide show
  1. package/dist/cjs/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js +109 -0
  2. package/dist/cjs/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js.map +1 -0
  3. package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +5 -14
  4. package/dist/cjs/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
  5. package/dist/cjs/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +19 -68
  6. package/dist/cjs/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
  7. package/dist/cjs/hooks/useActionCell.js +10 -2
  8. package/dist/cjs/hooks/useActionCell.js.map +1 -1
  9. package/dist/cjs/providers/PatternsWizardOverridesContext.js +1 -1
  10. package/dist/cjs/providers/PatternsWizardOverridesContext.js.map +1 -1
  11. package/dist/cjs/types/CollectionPageConfig.js.map +1 -1
  12. package/dist/cjs/types/actions/actionCell.js.map +1 -1
  13. package/dist/cjs/types/actions/base.js.map +1 -1
  14. package/dist/docs/action_cell.md +13 -3
  15. package/dist/docs/app_config_structure.md +7 -4
  16. package/dist/docs/auto-patterns-guide.md +288 -35
  17. package/dist/docs/bulk_actions.md +1 -4
  18. package/dist/docs/custom_overrides.md +267 -24
  19. package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js +71 -0
  20. package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js.map +1 -0
  21. package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js +1 -3
  22. package/dist/esm/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.js.map +1 -1
  23. package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +16 -48
  24. package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
  25. package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +8 -13
  26. package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
  27. package/dist/esm/components/AutoPatternsEntityPage/Fields/DateInput.js +6 -10
  28. package/dist/esm/components/AutoPatternsEntityPage/Fields/DateInput.js.map +1 -1
  29. package/dist/esm/components/AutoPatternsEntityPage/Fields/DateTime.js +16 -23
  30. package/dist/esm/components/AutoPatternsEntityPage/Fields/DateTime.js.map +1 -1
  31. package/dist/esm/components/AutoPatternsEntityPage/Fields/FormFieldInput.js +2 -3
  32. package/dist/esm/components/AutoPatternsEntityPage/Fields/FormFieldInput.js.map +1 -1
  33. package/dist/esm/components/AutoPatternsEntityPage/Fields/ImageInput.js +6 -9
  34. package/dist/esm/components/AutoPatternsEntityPage/Fields/ImageInput.js.map +1 -1
  35. package/dist/esm/components/AutoPatternsEntityPage/Fields/LongText.js +6 -8
  36. package/dist/esm/components/AutoPatternsEntityPage/Fields/LongText.js.map +1 -1
  37. package/dist/esm/components/AutoPatternsEntityPage/Fields/Number.js +8 -10
  38. package/dist/esm/components/AutoPatternsEntityPage/Fields/Number.js.map +1 -1
  39. package/dist/esm/components/AutoPatternsEntityPage/Fields/ShortText.js +10 -12
  40. package/dist/esm/components/AutoPatternsEntityPage/Fields/ShortText.js.map +1 -1
  41. package/dist/esm/components/AutoPatternsEntityPage/Fields/Url.js +6 -8
  42. package/dist/esm/components/AutoPatternsEntityPage/Fields/Url.js.map +1 -1
  43. package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js +4 -7
  44. package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js.map +1 -1
  45. package/dist/esm/components/ModalRenderer.js +1 -2
  46. package/dist/esm/components/ModalRenderer.js.map +1 -1
  47. package/dist/esm/components/modals/actions/BulkDeleteModal.js +7 -12
  48. package/dist/esm/components/modals/actions/BulkDeleteModal.js.map +1 -1
  49. package/dist/esm/components/modals/actions/CreateModal.js +6 -11
  50. package/dist/esm/components/modals/actions/CreateModal.js.map +1 -1
  51. package/dist/esm/components/modals/actions/EditModal.js +6 -11
  52. package/dist/esm/components/modals/actions/EditModal.js.map +1 -1
  53. package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js +3 -4
  54. package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
  55. package/dist/esm/dataSourceAdapters/cms/filterUtils.js +1 -2
  56. package/dist/esm/dataSourceAdapters/cms/filterUtils.js.map +1 -1
  57. package/dist/esm/dataSourceAdapters/cms/sortUtils.js +2 -2
  58. package/dist/esm/dataSourceAdapters/cms/sortUtils.js.map +1 -1
  59. package/dist/esm/hooks/useActionCell.js +16 -12
  60. package/dist/esm/hooks/useActionCell.js.map +1 -1
  61. package/dist/esm/hooks/useBaseTableFeatures.js +1 -2
  62. package/dist/esm/hooks/useBaseTableFeatures.js.map +1 -1
  63. package/dist/esm/hooks/useBulkActionToolbar.js +2 -2
  64. package/dist/esm/hooks/useBulkActionToolbar.js.map +1 -1
  65. package/dist/esm/hooks/useCollectionPageActions.js +3 -3
  66. package/dist/esm/hooks/useCollectionPageActions.js.map +1 -1
  67. package/dist/esm/hooks/useCollectionPageOnRowClickActions.js +1 -1
  68. package/dist/esm/hooks/useCollectionPageOnRowClickActions.js.map +1 -1
  69. package/dist/esm/hooks/useColumns.js +7 -12
  70. package/dist/esm/hooks/useColumns.js.map +1 -1
  71. package/dist/esm/hooks/useCommonCollectionFeatures.js +7 -8
  72. package/dist/esm/hooks/useCommonCollectionFeatures.js.map +1 -1
  73. package/dist/esm/hooks/useEmptyStates.js +5 -6
  74. package/dist/esm/hooks/useEmptyStates.js.map +1 -1
  75. package/dist/esm/hooks/useFilters.js +7 -7
  76. package/dist/esm/hooks/useFilters.js.map +1 -1
  77. package/dist/esm/hooks/useNavigationUtils.js +2 -3
  78. package/dist/esm/hooks/useNavigationUtils.js.map +1 -1
  79. package/dist/esm/hooks/usePagePath.js +3 -4
  80. package/dist/esm/hooks/usePagePath.js.map +1 -1
  81. package/dist/esm/hooks/useTableFeatures.js +1 -2
  82. package/dist/esm/hooks/useTableFeatures.js.map +1 -1
  83. package/dist/esm/providers/PatternsWizardOverridesContext.js.map +1 -1
  84. package/dist/esm/providers/SchemaContext.js +2 -3
  85. package/dist/esm/providers/SchemaContext.js.map +1 -1
  86. package/dist/esm/providers/SchemaRegistryContext.js +1 -1
  87. package/dist/esm/providers/SchemaRegistryContext.js.map +1 -1
  88. package/dist/esm/types/CollectionPageConfig.js.map +1 -1
  89. package/dist/esm/types/actions/actionCell.js.map +1 -1
  90. package/dist/esm/types/actions/base.js.map +1 -1
  91. package/dist/esm/utils/actions/customAction.js +1 -2
  92. package/dist/esm/utils/actions/customAction.js.map +1 -1
  93. package/dist/esm/utils/actions/deleteAction.js +5 -10
  94. package/dist/esm/utils/actions/deleteAction.js.map +1 -1
  95. package/dist/esm/utils/filterCreators.js +11 -11
  96. package/dist/esm/utils/filterCreators.js.map +1 -1
  97. package/dist/types/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.d.ts +7 -0
  98. package/dist/types/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.d.ts.map +1 -0
  99. package/dist/types/components/AutoPatternsCollectionPage/AutoPatternsCollectionPage.d.ts.map +1 -1
  100. package/dist/types/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.d.ts.map +1 -1
  101. package/dist/types/hooks/useActionCell.d.ts.map +1 -1
  102. package/dist/types/providers/PatternsWizardOverridesContext.d.ts +3 -6
  103. package/dist/types/providers/PatternsWizardOverridesContext.d.ts.map +1 -1
  104. package/dist/types/types/CollectionPageConfig.d.ts +7 -1
  105. package/dist/types/types/CollectionPageConfig.d.ts.map +1 -1
  106. package/dist/types/types/actions/actionCell.d.ts +1 -0
  107. package/dist/types/types/actions/actionCell.d.ts.map +1 -1
  108. package/dist/types/types/actions/base.d.ts +0 -4
  109. package/dist/types/types/actions/base.d.ts.map +1 -1
  110. 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: (field == null ? void 0 : field.id) ?? '',
17
+ name: field?.id ?? '',
19
18
  control: pageState.form.control,
20
- defaultValue: (_pageState$entity = pageState.entity) == null ? void 0 : _pageState$entity[(field == null ? void 0 : field.id) ?? ''],
19
+ defaultValue: pageState.entity?.[field?.id ?? ''],
21
20
  rules: {
22
21
  validate: value => {
23
- var _field$validation;
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: (_field$validation2 = field.validation) == null ? void 0 : _field$validation2.required,
31
+ required: field.validation?.required,
34
32
  status: controller.fieldState.error ? 'error' : undefined,
35
- statusMessage: (_controller$fieldStat = controller.fieldState.error) == null ? void 0 : _controller$fieldStat.message,
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 == null ? void 0 : controller.field.onChange(e.target.value),
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","_pageState$entity","_field$validation2","_controller$fieldStat","field","dataHook","translate","t","container","initTask","status","pageState","controller","name","id","control","form","defaultValue","entity","rules","validate","value","_field$validation","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,oBAAo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GAAG,OAAO,GAAGL,SAAU;IAC1DM,aAAa,GAAA5B,qBAAA,GAAES,UAAU,CAACiB,UAAU,CAACC,KAAK,qBAA3B3B,qBAAA,CAA6B6B,OAAQ;IACpD3B,QAAQ,EAAEA;EAAS,gBAEnBb,KAAA,CAAAkC,aAAA,CAAChC,SAAS;IACR2B,KAAK,EAAET,UAAU,CAACR,KAAK,CAACiB,KAAM;IAC9BY,QAAQ,EAAGC,CAAC,IAAKtB,UAAU,CAACR,KAAK,CAAC6B,QAAQ,oBAAzBrB,UAAU,CAACR,KAAK,CAAC6B,QAAQ,CAAGC,CAAC,CAACC,MAAM,CAACd,KAAK,CAAE;IAC7De,MAAM,EAAExB,UAAU,CAACR,KAAK,CAACgC,MAAO;IAChCC,GAAG,EAAEzB,UAAU,CAACR,KAAK,CAACiC,GAAI;IAC1BhC,QAAQ,EAAE,aAAaD,KAAK,CAACU,EAAE;EAAG,CACnC,CACQ,CAAC;AAEhB,CAAC","ignoreList":[]}
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,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,UAAU,GAAGX,aAAa,CAAC;IAC/BY,IAAI,EAAET,KAAK,EAAEU,EAAE,IAAI,EAAE;IACrBC,OAAO,EAAEJ,SAAS,CAACK,IAAI,CAACD,OAAO;IAC/BE,YAAY,EAAGN,SAAS,CAACO,MAAM,GAAWd,KAAK,EAAEU,EAAE,IAAI,EAAE,CAAC;IAC1DK,KAAK,EAAE;MACLC,QAAQ,EAAGC,KAAK,IAAK;QACnB,IACEjB,KAAK,CAACkB,UAAU,EAAEC,QAAQ,KACzBF,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKG,SAAS,IAAIH,KAAK,KAAK,EAAE,CAAC,EACvD;UACA,OAAOd,CAAC,CAAC,qCAAqC,CAAC;QACjD;QAEA,OAAO,IAAI;MACb;IACF;EACF,CAAC,CAAC;EAEF,oBACEZ,KAAA,CAAA8B,aAAA,CAAC7B,SAAS;IACR8B,KAAK,EAAEtB,KAAK,CAACuB,WAAY;IACzBJ,QAAQ,EAAEnB,KAAK,CAACkB,UAAU,EAAEC,QAAS;IACrCb,MAAM,EAAEE,UAAU,CAACgB,UAAU,CAACC,KAAK,GAAG,OAAO,GAAGL,SAAU;IAC1DM,aAAa,EAAElB,UAAU,CAACgB,UAAU,CAACC,KAAK,EAAEE,OAAQ;IACpD1B,QAAQ,EAAEA;EAAS,gBAEnBV,KAAA,CAAA8B,aAAA,CAAC5B,SAAS;IACRwB,KAAK,EAAET,UAAU,CAACR,KAAK,CAACiB,KAAM;IAC9BW,QAAQ,EAAGC,CAAC,IAAKrB,UAAU,CAACR,KAAK,CAAC4B,QAAQ,GAAGC,CAAC,CAACC,MAAM,CAACb,KAAK,CAAE;IAC7Dc,MAAM,EAAEvB,UAAU,CAACR,KAAK,CAAC+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 = (_field$validation = field.validation) == null ? void 0 : _field$validation.numberRange;
18
- const min = numberRange == null ? void 0 : numberRange.min;
19
- const max = numberRange == null ? void 0 : numberRange.max;
16
+ const numberRange = field.validation?.numberRange;
17
+ const min = numberRange?.min;
18
+ const max = numberRange?.max;
20
19
  const controller = useController({
21
- name: (field == null ? void 0 : field.id) ?? '',
20
+ name: field?.id ?? '',
22
21
  control: pageState.form.control,
23
- defaultValue: (_pageState$entity = pageState.entity) == null ? void 0 : _pageState$entity[(field == null ? void 0 : field.id) ?? ''],
22
+ defaultValue: pageState.entity?.[field?.id ?? ''],
24
23
  rules: {
25
24
  validate: value => {
26
- var _field$validation2;
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: (_field$validation3 = field.validation) == null ? void 0 : _field$validation3.required,
46
+ required: field.validation?.required,
49
47
  status: controller.fieldState.error ? 'error' : undefined,
50
- statusMessage: (_controller$fieldStat = controller.fieldState.error) == null ? void 0 : _controller$fieldStat.message,
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","_field$validation","_pageState$entity","_field$validation3","_controller$fieldStat","field","dataHook","translate","t","container","initTask","status","pageState","numberRange","validation","min","max","controller","name","id","control","form","defaultValue","entity","rules","validate","value","_field$validation2","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;EAAA,IAAAC,iBAAA,EAAAC,iBAAA,EAAAC,kBAAA,E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AAC,iCAAiC,EAAE;cAC1CsB,SAAS,EAAEf;YACb,CAAC,CAAC;UACJ;UACA,IAAIC,GAAG,KAAKa,SAAS,IAAIH,KAAK,GAAGV,GAAG,EAAE;YACpC,OAAOR,CAAC,CAAC,iCAAiC,EAAE;cAC1CuB,SAAS,EAAEf;YACb,CAAC,CAAC;UACJ;QACF;QAEA,OAAO,IAAI;MACb;IACF;EACF,CAAC,CAAC;EAEF,oBACExB,KAAA,CAAAwC,aAAA,CAACvC,SAAS;IACRwC,KAAK,EAAE5B,KAAK,CAAC6B,WAAY;IACzBN,QAAQ,GAAAzB,kBAAA,GAAEE,KAAK,CAACS,UAAU,qBAAhBX,kBAAA,CAAkByB,QAAS;IACrCjB,MAAM,EAAEM,UAAU,CAACkB,UAAU,CAACC,KAAK,GAAG,OAAO,GAAGP,SAAU;IAC1DQ,aAAa,GAAAjC,qBAAA,GAAEa,UAAU,CAACkB,UAAU,CAACC,KAAK,qBAA3BhC,qBAAA,CAA6BkC,OAAQ;IACpDhC,QAAQ,EAAEA;EAAS,gBAEnBd,KAAA,CAAAwC,aAAA,CAACtC,WAAW;IACVgC,KAAK,EAAET,UAAU,CAACZ,KAAK,CAACqB,KAAK,IAAIG,SAAU;IAC3CU,QAAQ,EAAGC,CAAC,IAAKvB,UAAU,CAACZ,KAAK,CAACkC,QAAQ,CAACC,CAAC,CAAE;IAC9CC,MAAM,EAAExB,UAAU,CAACZ,KAAK,CAACoC,MAAO;IAChCC,QAAQ,EAAEzB,UAAU,CAACZ,KAAK,CAACsC,GAAI;IAC/BrC,QAAQ,EAAE,UAAUD,KAAK,CAACc,EAAE;EAAG,CAChC,CACQ,CAAC;AAEhB,CAAC","ignoreList":[]}
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,oBAA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C,EAAE;cAC1CsB,SAAS,EAAEd;YACb,CAAC,CAAC;UACJ;QACF;QAEA,OAAO,IAAI;MACb;IACF;EACF,CAAC,CAAC;EAEF,oBACEpB,KAAA,CAAAmC,aAAA,CAAClC,SAAS;IACRmC,KAAK,EAAE3B,KAAK,CAAC4B,WAAY;IACzBN,QAAQ,EAAEtB,KAAK,CAACS,UAAU,EAAEa,QAAS;IACrChB,MAAM,EAAEM,UAAU,CAACiB,UAAU,CAACC,KAAK,GAAG,OAAO,GAAGP,SAAU;IAC1DQ,aAAa,EAAEnB,UAAU,CAACiB,UAAU,CAACC,KAAK,EAAEE,OAAQ;IACpD/B,QAAQ,EAAEA;EAAS,gBAEnBV,KAAA,CAAAmC,aAAA,CAACjC,WAAW;IACV4B,KAAK,EAAET,UAAU,CAACZ,KAAK,CAACqB,KAAK,IAAIE,SAAU;IAC3CU,QAAQ,EAAGC,CAAC,IAAKtB,UAAU,CAACZ,KAAK,CAACiC,QAAQ,CAACC,CAAC,CAAE;IAC9CC,MAAM,EAAEvB,UAAU,CAACZ,KAAK,CAACmC,MAAO;IAChCC,QAAQ,EAAExB,UAAU,CAACZ,KAAK,CAACqC,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 = (_field$validation = field.validation) == null ? void 0 : _field$validation.stringLengthRange;
18
- const minLength = stringLengthRange == null ? void 0 : stringLengthRange.minLength;
19
- const maxLength = stringLengthRange == null ? void 0 : stringLengthRange.maxLength;
16
+ const stringLengthRange = field.validation?.stringLengthRange;
17
+ const minLength = stringLengthRange?.minLength;
18
+ const maxLength = stringLengthRange?.maxLength;
20
19
  const controller = useController({
21
- name: (field == null ? void 0 : field.id) ?? '',
20
+ name: field?.id ?? '',
22
21
  control: pageState.form.control,
23
- defaultValue: (_pageState$entity = pageState.entity) == null ? void 0 : _pageState$entity[(field == null ? void 0 : field.id) ?? ''],
22
+ defaultValue: pageState.entity?.[field?.id ?? ''],
24
23
  rules: {
25
24
  validate: value => {
26
- var _field$validation2;
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 - ((_controller$field$val = controller.field.value) == null ? void 0 : _controller$field$val.length) : undefined;
41
+ const charCount = maxLength ? maxLength - controller.field.value?.length : undefined;
44
42
  return /*#__PURE__*/React.createElement(FormField, {
45
43
  label: field.displayName,
46
- required: (_field$validation3 = field.validation) == null ? void 0 : _field$validation3.required,
44
+ required: field.validation?.required,
47
45
  charCount: charCount,
48
46
  status: controller.fieldState.error ? 'error' : undefined,
49
- statusMessage: (_controller$fieldStat = controller.fieldState.error) == null ? void 0 : _controller$fieldStat.message,
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 == null ? void 0 : controller.field.onChange(e.target.value),
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","_field$validation","_pageState$entity","_controller$field$val","_field$validation3","_controller$fieldStat","field","dataHook","translate","t","container","initTask","status","pageState","stringLengthRange","validation","minLength","maxLength","controller","name","id","control","form","defaultValue","entity","rules","validate","value","_field$validation2","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;EAAA,IAAAC,iBAAA,EAAAC,iBAAA,EAAAC,qBAAA,EAAAC,kBAAA,EAAAC,qBAAA;EAClD,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAC,GAAGP,KAAK;EAEjC,MAAM;IAAEQ,SAAS,EAAEC,CAAC;IAAE,GAAGC;EAAU,CAAC,GAAGb,uBAAuB,CAAC,CAAC;EAChED,WAAW,CAAC,MAAMc,SAAS,CAACC,QAAQ,CAACC,MAAM,CAAC;EAE5C,MAAMC,SAAS,GAAGlB,oBAAoB,CAAC,CAAC;EAExC,MAAMmB,iBAAiB,IAAAb,iBAAA,GAAGK,KAAK,CAACS,UAAU,qBAAhBd,iBAAA,CAAkBa,iBAAiB;EAC7D,MAAME,SAAS,GAAGF,iBAAiB,oBAAjBA,iBAAiB,CAAEE,SAAS;EAC9C,MAAMC,SAAS,GAAGH,iBAAiB,oBAAjBA,iBAAiB,CAAEG,SAAS;EAE9C,MAAMC,UAAU,GAAGpB,aAAa,CAAC;IAC/BqB,IAAI,EAAE,CAAAb,KAAK,oBAALA,KAAK,CAAEc,EAAE,KAAI,EAAE;IACrBC,OAAO,EAAER,SAAS,CAACS,IAAI,CAACD,OAAO;IAC/BE,YAAY,GAAArB,iBAAA,GAAGW,SAAS,CAACW,MAAM,qBAAjBtB,iBAAA,CAA4B,CAAAI,KAAK,oBAALA,KAAK,CAAEc,EAAE,KAAI,E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EAAEA;EAAS,gBAEnBf,KAAA,CAAA2C,aAAA,CAACzC,KAAK;IACJiC,KAAK,EAAET,UAAU,CAACZ,KAAK,CAACqB,KAAM;IAC9Be,QAAQ,EAAGC,CAAC,IAAKzB,UAAU,CAACZ,KAAK,CAACoC,QAAQ,oBAAzBxB,UAAU,CAACZ,KAAK,CAACoC,QAAQ,CAAGC,CAAC,CAACC,MAAM,CAACjB,KAAK,CAAE;IAC7DkB,MAAM,EAAE3B,UAAU,CAACZ,KAAK,CAACuC,MAAO;IAChCtC,QAAQ,EAAE,cAAcD,KAAK,CAACc,EAAE,EAAG;IACnC0B,GAAG,EAAE5B,UAAU,CAACZ,KAAK,CAACwC;EAAI,CAC3B,CACQ,CAAC;AAEhB,CAAC","ignoreList":[]}
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,UAAU,EAAED,iBAAiB;EAC7D,MAAME,SAAS,GAAGF,iBAAiB,EAAEE,SAAS;EAC9C,MAAMC,SAAS,GAAGH,iBAAiB,EAAEG,SAAS;EAE9C,MAAMC,UAAU,GAAGf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E,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: (field == null ? void 0 : field.id) ?? '',
23
+ name: field?.id ?? '',
25
24
  control: pageState.form.control,
26
- defaultValue: (_pageState$entity = pageState.entity) == null ? void 0 : _pageState$entity[(field == null ? void 0 : field.id) ?? ''],
25
+ defaultValue: pageState.entity?.[field?.id ?? ''],
27
26
  rules: {
28
27
  validate: value => {
29
- var _field$validation;
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: (_field$validation2 = field.validation) == null ? void 0 : _field$validation2.required,
39
+ required: field.validation?.required,
42
40
  dataHook: dataHook,
43
41
  status: controller.fieldState.error ? 'error' : undefined,
44
- statusMessage: (_controller$fieldStat = controller.fieldState.error) == null ? void 0 : _controller$fieldStat.message
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 == null ? void 0 : controller.field.onChange(e.target.value),
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","_pageState$entity","_field$validation2","_controller$fieldStat","field","dataHook","translate","t","container","initTask","status","pageState","uriPattern","controller","name","id","control","form","defaultValue","entity","rules","validate","value","_field$validation","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"],"m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AK,EAAE;UAChB,OACEV,UAAU,CAACe,IAAI,CAACL,KAAK,CAAC,IAAIf,CAAC,CAAC,oCAAoC,CAAC;QAErE;QACA,OAAO,IAAI;MACb;IACF;EACF,CAAC,CAAC;EAEF,oBACEhB,KAAA,CAAAqC,aAAA,CAACpC,SAAS;IACRqC,KAAK,EAAEzB,KAAK,CAAC0B,WAAY;IACzBL,QAAQ,GAAAvB,kBAAA,GAAEE,KAAK,CAACoB,UAAU,qBAAhBtB,kBAAA,CAAkBuB,QAAS;IACrCpB,QAAQ,EAAEA,QAAS;IACnBK,MAAM,EAAEG,UAAU,CAACkB,UAAU,CAACC,KAAK,GAAG,OAAO,GAAGN,SAAU;IAC1DO,aAAa,GAAA9B,qBAAA,GAAEU,UAAU,CAACkB,UAAU,CAACC,KAAK,qBAA3B7B,qBAAA,CAA6B+B;EAAQ,gBAEpD3C,KAAA,CAAAqC,aAAA,CAACnC,KAAK;IACJ0C,MAAM,eACJ5C,KAAA,CAAAqC,aAAA,CAACnC,KAAK,CAAC2C,SAAS,qBACd7C,KAAA,CAAAqC,aAAA,CAAClC,IAAI,MAAE,CACQ,CAClB;IACD2C,WAAW,EAAE9B,CAAC,CAAC,0CAA0C,CAAE;IAC3DF,QAAQ,EAAE,OAAOD,KAAK,CAACW,EAAE,EAAG;IAC5BO,KAAK,EAAET,UAAU,CAACT,KAAK,CAACkB,KAAM;IAC9BgB,QAAQ,EAAGC,CAAC,IAAK1B,UAAU,CAACT,KAAK,CAACkC,QAAQ,oBAAzBzB,UAAU,CAACT,KAAK,CAACkC,QAAQ,CAAGC,CAAC,CAACC,MAAM,CAAClB,KAAK,CAAE;IAC7DmB,MAAM,EAAE5B,UAAU,CAACT,KAAK,CAACqC,MAAO;IAChCC,GAAG,EAAE7B,UAAU,CAACT,KAAK,CAACsC;EAAI,CAC3B,CACQ,CAAC;AAEhB,CAAC","ignoreList":[]}
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,KA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3
3
  import React from 'react';
4
4
  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 (!((_content$container$ch = content.container.children) != null && _content$container$ch.length)) {
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: (_layout$card$subtitle = layout.card.subtitle) == null ? void 0 : _layout$card$subtitle.text
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, (_entityPage$layout = entityPage.layout) == null || (_entityPage$layout = _entityPage$layout.main) == null ? void 0 : _entityPage$layout.map((layout, layoutIndex) => /*#__PURE__*/React.createElement(RenderLayoutCard, {
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
- }))), (_entityPage$layout2 = entityPage.layout) != null && _entityPage$layout2.sidebar ? /*#__PURE__*/React.createElement(EntityPage.AdditionalContent, null, (_entityPage$layout$si = entityPage.layout.sidebar) == null ? void 0 : _entityPage$layout$si.map((layout, layoutIndex) => /*#__PURE__*/React.createElement(RenderLayoutCard, {
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","_content$container$ch","content","level","sectionId","cardIndex","contentIndex","type","container","children","length","createElement","span","map","child","index","key","RenderLayoutCard","_ref2","_layout$card$subtitle","layout","minHeight","Header","title","card","text","subtitle","Divider","Content","SkeletonEntity","_ref3","_entityPage$layout","_entityPage$layout2","_entityPage$layout$si","entityPage","form","state","parentPath","onSave","updatedEntity","fetch","Promise","Fragment","MainContent","main","layoutIndex","sidebar","AdditionalContent"],"sources":["../../../../src/components/AutoPatternsEntityPage/SkeletonEntity.tsx"],"sourcesContent":["import { EntityPage, EntityPageState, useEntityPage } from '@wix/patterns';\nimport { useForm } from '../../exports/form';\nimport React from 'react';\nimport { EntityPageConfig, CardLayout, LayoutContent } from '../../types';\n\nexport interface SkeletonEntityProps {\n entityPage: EntityPageConfig;\n}\nimport { Card, Cell, Layout } from '@wix/design-system';\n\nconst RenderLayoutContent: React.FC<{\n content: LayoutContent;\n level: number;\n sectionId: string;\n cardIndex: number;\n contentIndex: number;\n}> = ({ content, level, sectionId, cardIndex, contentIndex }) => {\n switch (content.type) {\n case 'container':\n if (!content.container.children?.length) {\n return null;\n }\n\n return (\n <Cell span={content.container.span}>\n <Layout>\n {content.container.children.map((child, index) => (\n <RenderLayoutContent\n key={`${sectionId}-card-${cardIndex}-content-${contentIndex}-level-${level}-child-${index}`}\n content={child}\n level={level + 1}\n sectionId={sectionId}\n cardIndex={cardIndex}\n contentIndex={index}\n />\n ))}\n </Layout>\n </Cell>\n );\n\n default:\n return null;\n }\n};\n\nconst RenderLayoutCard: React.FC<{\n layout: CardLayout;\n sectionId: string;\n cardIndex: number;\n}> = ({ layout, sectionId, cardIndex }) => {\n switch (layout.type) {\n case 'card':\n return (\n <EntityPage.Card minHeight=\"50px\">\n <Card.Header\n title={layout.card.title.text}\n subtitle={layout.card.subtitle?.text}\n />\n <Card.Divider />\n <Card.Content>\n <Layout>\n {layout.card.children.map((child, index: number) => (\n <RenderLayoutContent\n key={`${sectionId}-card-${cardIndex}-content-${index}`}\n content={child}\n level={0}\n sectionId={sectionId}\n cardIndex={cardIndex}\n contentIndex={index}\n />\n ))}\n </Layout>\n </Card.Content>\n </EntityPage.Card>\n );\n default:\n return null;\n }\n};\n\nexport const SkeletonEntity = ({ entityPage }: SkeletonEntityProps) => {\n const form = useForm();\n\n const state: EntityPageState<any> = useEntityPage<any, any>({\n parentPath: '',\n form,\n onSave: async () => ({ updatedEntity: {} }),\n fetch: async () => new Promise(() => {}),\n });\n\n return (\n <>\n <EntityPage state={state}>\n <EntityPage.Header title={{ text: '' }} />\n <EntityPage.Content>\n <EntityPage.MainContent>\n {entityPage.layout?.main?.map((layout, layoutIndex) => (\n <RenderLayoutCard\n key={`main-section-card-${layoutIndex}`}\n layout={layout}\n sectionId=\"main\"\n cardIndex={layoutIndex}\n />\n ))}\n </EntityPage.MainContent>\n {entityPage.layout?.sidebar ? (\n <EntityPage.AdditionalContent>\n {entityPage.layout.sidebar?.map((layout, layoutIndex) => (\n <RenderLayoutCard\n key={`sidebar-section-card-${layoutIndex}`}\n layout={layout}\n sectionId=\"sidebar\"\n cardIndex={layoutIndex}\n />\n ))}\n </EntityPage.AdditionalContent>\n ) : null}\n </EntityPage.Content>\n </EntityPage>\n </>\n );\n};\n"],"mappings":"AAAA,SAASA,UAAU,EAAmBC,aAAa,QAAQ,eAAe;AAC1E,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,OAAOC,KAAK,MAAM,OAAO;AAMzB,SAASC,IAAI,EAAEC,IAAI,EAAEC,MAAM,QAAQ,oBAAoB;AAEvD,MAAMC,mBAMJ,GAAGC,IAAA,IAA4D;EAAA,IAAAC,qBAAA;EAAA,IAA3D;IAAEC,OAAO;IAAEC,KAAK;IAAEC,SAAS;IAAEC,SAAS;IAAEC;EAAa,CAAC,GAAAN,IAAA;EAC1D,QAAQE,OAAO,CAACK,IAAI;IAClB,KAAK,WAAW;MACd,IAAI,GAAAN,qBAAA,GAACC,OAAO,CAACM,SAAS,CAACC,QAAQ,aAA1BR,qBAAA,CAA4BS,MAAM,GAAE;QACvC,OAAO,IAAI;MACb;MAEA,oBACEf,KAAA,CAAAgB,aAAA,CAACd,IAAI;QAACe,IAAI,EAAEV,OAAO,CAACM,SAAS,CAACI;MAAK,gBACjCjB,KAAA,CAAAgB,aAAA,CAACb,MAAM,QACJI,OAAO,CAACM,SAAS,CAACC,QAAQ,CAACI,GAAG,CAAC,CAACC,KAAK,EAAEC,KAAK,kBAC3CpB,KAAA,CAAAgB,aAAA,CAACZ,mBAAmB;QAClBiB,GAAG,EAAE,GAAGZ,SAAS,SAASC,SAAS,YAAYC,YAAY,UAAUH,KAAK,UAAUY,KAAK,EAAG;QAC5Fb,OAAO,EAAEY,KAAM;QACfX,KAAK,EAAEA,KAAK,GAAG,CAAE;QACjBC,SA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BAAiB,SAAAd,qBAAA,GAC1BC,UAAU,CAACd,MAAM,CAAC0B,OAAO,qBAAzBb,qBAAA,CAA2BpB,GAAG,CAAC,CAACO,MAAM,EAAEyB,WAAW,kBAClDlD,KAAA,CAAAgB,aAAA,CAACM,gBAAgB;IACfD,GAAG,EAAE,wBAAwB6B,WAAW,EAAG;IAC3CzB,MAAM,EAAEA,MAAO;IACfhB,SAAS,EAAC,SAAS;IACnBC,SAAS,EAAEwC;EAAY,CACxB,CACF,CAC2B,CAAC,GAC7B,IACc,CACV,CACZ,CAAC;AAEP,CAAC","ignoreList":[]}
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,KA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CAAClB,UAAU,CAAC4B,MAAM;IAACC,KAAK,EAAE;MAAEE,IAAI,EAAE;IAAG;EAAE,CAAE,CAAC,eAC1C5B,KAAA,CAAAe,aAAA,CAAClB,UAAU,CAACkC,OAAO,qBACjB/B,KAAA,CAAAe,aAAA,CAAClB,UAAU,CAAC8C,WAAW,QACpBT,UAAU,CAACX,MAAM,EAAEqB,IAAI,EAAE3B,GAAG,CAAC,CAACM,MAAM,EAAEsB,WAAW,kBAChD7C,KAAA,CAAAe,aAAA,CAACM,gBAAgB;IACfD,GAAG,EAAE,qBAAqByB,WAAW,EAAG;IACxCtB,MAAM,EAAEA,MAAO;IACff,SAAS,EAAC,MAAM;IAChBC,SAAS,EAAEoC;EAAY,CACxB,CACF,CACqB,CAAC,EACxBX,UAAU,CAACX,MAAM,EAAEuB,OAAO,gBACzB9C,KAAA,CAAAe,aAAA,CAAClB,UAAU,CAACkD,iBAAiB,QAC1Bb,UAAU,CAACX,MAAM,CAACuB,OAAO,EAAE7B,GAAG,CAAC,CAACM,MAAM,EAAEsB,WAAW,kBAClD7C,KAAA,CAAAe,aAAA,CAACM,gBAAgB;IACfD,GAAG,EAAE,wBAAwByB,WAAW,EAAG;IAC3CtB,MAAM,EAAEA,MAAO;IACff,SAAS,EAAC,SAAS;IACnBC,SAAS,EAAEoC;EAAY,CACxB,CACF,CAC2B,CAAC,GAC7B,IACc,CACV,CACZ,CAAC;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 = (overrides == null || (_overrides$modals = overrides.modals) == null ? void 0 : _overrides$modals[modal.id]) || modals[modal.id];
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","_overrides$modals","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;EAAA,IAAAC,iBAAA;EACjC,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGL,eAAe,CAAC,CAAC;EAC/C,MAAMM,SAAS,GAAGL,iCAAiC,CAAC,CAAC;EAErD,IAAI,CAACG,KAAK,CAACG,EAAE,EAAE;IACb,OAAO,IAAI;EACb;EAEA,MAAMC,cAAc,GAClB,CAAAF,SAAS,aAAAH,iBAAA,GAATG,SAAS,CAAEP,MAAM,qBAAjBI,iBAAA,CAAoBC,KAAK,CAACG,EAAE,CAAC,KAC5BR,MAAM,CAA8CK,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,oBAAOT,KAAA,CAAAa,aAAA,CAACH,cAAc,EAAAI,QAAA,KAAKR,KAAK,CAACS,KAAK;IAAEC,OAAO,EAAET;EAAW,EAAE,CAAC;AACjE,CAAC","ignoreList":[]}
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: ((_modalParams$title = modalParams.title) == null ? void 0 : _modalParams$title.text) || 'Delete item?',
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 == null || optimisticActions.deleteMany(actionParams.selectedValues, {
33
- successToast: ((_modalParams$feedback = modalParams.feedback) == null || (_modalParams$feedback = _modalParams$feedback.successToast) == null ? void 0 : _modalParams$feedback.text) || 'Items deleted successfully',
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: ((_modalParams$actions = modalParams.actions) == null || (_modalParams$actions = _modalParams$actions.submit) == null ? void 0 : _modalParams$actions.text) || 'Save',
49
- secondaryButtonText: ((_modalParams$actions2 = modalParams.actions) == null || (_modalParams$actions2 = _modalParams$actions2.cancel) == null ? void 0 : _modalParams$actions2.text) || 'Cancel',
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, ((_modalParams$descript = modalParams.description) == null ? void 0 : _modalParams$descript.text) || 'This items will be deleted')))
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","_modalParams$title","_modalParams$actions","_modalParams$actions2","_modalParams$descript","sdk","modalParams","actionParams","getOptimisticActions","collectionId","closeModal","optimisticActions","createElement","isOpen","onRequestClose","title","text","theme","onCloseButtonClick","primaryButtonOnClick","_modalParams$feedback","schema","getSchema","Error","selectedIds","selectedValues","map","value","idField","deleteMany","successToast","feedback","errorToast","_modalParams$feedback2","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,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ACF,CACI,CAAC;AAEZ,CAAC","ignoreList":[]}
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: ((_modalParams$title = modalParams.title) == null ? void 0 : _modalParams$title.text) || 'Create',
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 == null || optimisticActions.createOne(createdItem, {
36
- successToast: ((_modalParams$feedback = modalParams.feedback) == null || (_modalParams$feedback = _modalParams$feedback.successToast) == null ? void 0 : _modalParams$feedback.text) || 'Item created successfully',
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: ((_modalParams$actions = modalParams.actions) == null || (_modalParams$actions = _modalParams$actions.submit) == null ? void 0 : _modalParams$actions.text) || 'Save',
55
- secondaryButtonText: ((_modalParams$actions2 = modalParams.actions) == null || (_modalParams$actions2 = _modalParams$actions2.cancel) == null ? void 0 : _modalParams$actions2.text) || 'Cancel',
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",