@wix/auto-patterns 1.23.0 → 1.25.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 (207) hide show
  1. package/dist/cjs/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +12 -323
  2. package/dist/cjs/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
  3. package/dist/cjs/components/AutoPatternsEntityPage/EditModeEntityPage.js +172 -0
  4. package/dist/cjs/components/AutoPatternsEntityPage/EditModeEntityPage.js.map +1 -0
  5. package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutCard.js +78 -0
  6. package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutCard.js.map +1 -0
  7. package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.js +119 -0
  8. package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.js.map +1 -0
  9. package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderViewField.js +79 -0
  10. package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/RenderViewField.js.map +1 -0
  11. package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/index.js +16 -0
  12. package/dist/cjs/components/AutoPatternsEntityPage/RenderLayout/index.js.map +1 -0
  13. package/dist/cjs/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutCard.js +77 -0
  14. package/dist/cjs/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutCard.js.map +1 -0
  15. package/dist/cjs/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.js +109 -0
  16. package/dist/cjs/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.js.map +1 -0
  17. package/dist/cjs/components/AutoPatternsEntityPage/ViewModeEntityPage.js +198 -0
  18. package/dist/cjs/components/AutoPatternsEntityPage/ViewModeEntityPage.js.map +1 -0
  19. package/dist/cjs/components/AutoPatternsEntityPage/index.js +12 -0
  20. package/dist/cjs/components/AutoPatternsEntityPage/index.js.map +1 -1
  21. package/dist/cjs/dataSourceAdapters/cms/cmsAdapter.js +2 -1
  22. package/dist/cjs/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
  23. package/dist/cjs/hooks/useActionCell.js +2 -1
  24. package/dist/cjs/hooks/useActionCell.js.map +1 -1
  25. package/dist/cjs/hooks/useBulkActionToolbar.js +2 -1
  26. package/dist/cjs/hooks/useBulkActionToolbar.js.map +1 -1
  27. package/dist/cjs/hooks/useCollectionPageActions.js +2 -1
  28. package/dist/cjs/hooks/useCollectionPageActions.js.map +1 -1
  29. package/dist/cjs/hooks/useEntityPageActions.js +106 -0
  30. package/dist/cjs/hooks/useEntityPageActions.js.map +1 -0
  31. package/dist/cjs/hooks/useEntityPageMoreActions.js +11 -1
  32. package/dist/cjs/hooks/useEntityPageMoreActions.js.map +1 -1
  33. package/dist/cjs/hooks/useNavigateEditEntityAction.js +50 -0
  34. package/dist/cjs/hooks/useNavigateEditEntityAction.js.map +1 -0
  35. package/dist/cjs/hooks/useNavigationUtils.js +12 -1
  36. package/dist/cjs/hooks/useNavigationUtils.js.map +1 -1
  37. package/dist/cjs/providers/ErrorContext.js +6 -3
  38. package/dist/cjs/providers/ErrorContext.js.map +1 -1
  39. package/dist/cjs/providers/PatternsWizardOverridesContext.js +1 -1
  40. package/dist/cjs/providers/PatternsWizardOverridesContext.js.map +1 -1
  41. package/dist/cjs/types/EntityPageConfig.js.map +1 -1
  42. package/dist/cjs/types/actions/actionCell.js.map +1 -1
  43. package/dist/cjs/types/actions/entityPageActions.js.map +1 -1
  44. package/dist/cjs/utils/actions/types.js.map +1 -1
  45. package/dist/docs/action_cell.md +11 -6
  46. package/dist/docs/app_config_structure.md +49 -4
  47. package/dist/docs/auto-patterns-guide.md +311 -43
  48. package/dist/docs/bulk_actions.md +7 -2
  49. package/dist/docs/collection_page_actions.md +14 -4
  50. package/dist/docs/entity_page.md +65 -1
  51. package/dist/docs/entity_page_actions.md +13 -11
  52. package/dist/docs/entity_page_view_actions.md +137 -0
  53. package/dist/docs/index.md +6 -2
  54. package/dist/docs/pages_configuration.md +1 -11
  55. package/dist/docs/sdk_utilities.md +11 -4
  56. package/dist/docs/wix_fqdn_custom_data_source.md +25 -5
  57. package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js +4 -3
  58. package/dist/esm/components/AutoPatternsCollectionComponent/AutoPatternsCollectionComponent.js.map +1 -1
  59. package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js +2 -1
  60. package/dist/esm/components/AutoPatternsCollectionPageContent/AutoPatternsCollectionPageContent.js.map +1 -1
  61. package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js +9 -196
  62. package/dist/esm/components/AutoPatternsEntityPage/AutoPatternsEntityPage.js.map +1 -1
  63. package/dist/esm/components/AutoPatternsEntityPage/EditModeEntityPage.js +115 -0
  64. package/dist/esm/components/AutoPatternsEntityPage/EditModeEntityPage.js.map +1 -0
  65. package/dist/esm/components/AutoPatternsEntityPage/Fields/DateInput.js +10 -6
  66. package/dist/esm/components/AutoPatternsEntityPage/Fields/DateInput.js.map +1 -1
  67. package/dist/esm/components/AutoPatternsEntityPage/Fields/DateTime.js +23 -16
  68. package/dist/esm/components/AutoPatternsEntityPage/Fields/DateTime.js.map +1 -1
  69. package/dist/esm/components/AutoPatternsEntityPage/Fields/FormFieldInput.js +3 -2
  70. package/dist/esm/components/AutoPatternsEntityPage/Fields/FormFieldInput.js.map +1 -1
  71. package/dist/esm/components/AutoPatternsEntityPage/Fields/ImageInput.js +9 -6
  72. package/dist/esm/components/AutoPatternsEntityPage/Fields/ImageInput.js.map +1 -1
  73. package/dist/esm/components/AutoPatternsEntityPage/Fields/LongText.js +8 -6
  74. package/dist/esm/components/AutoPatternsEntityPage/Fields/LongText.js.map +1 -1
  75. package/dist/esm/components/AutoPatternsEntityPage/Fields/Number.js +10 -8
  76. package/dist/esm/components/AutoPatternsEntityPage/Fields/Number.js.map +1 -1
  77. package/dist/esm/components/AutoPatternsEntityPage/Fields/ShortText.js +12 -10
  78. package/dist/esm/components/AutoPatternsEntityPage/Fields/ShortText.js.map +1 -1
  79. package/dist/esm/components/AutoPatternsEntityPage/Fields/Url.js +8 -6
  80. package/dist/esm/components/AutoPatternsEntityPage/Fields/Url.js.map +1 -1
  81. package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutCard.js +33 -0
  82. package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutCard.js.map +1 -0
  83. package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.js +70 -0
  84. package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.js.map +1 -0
  85. package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/RenderViewField.js +48 -0
  86. package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/RenderViewField.js.map +1 -0
  87. package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/index.js +3 -0
  88. package/dist/esm/components/AutoPatternsEntityPage/RenderLayout/index.js.map +1 -0
  89. package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js +7 -4
  90. package/dist/esm/components/AutoPatternsEntityPage/SkeletonEntity.js.map +1 -1
  91. package/dist/esm/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutCard.js +31 -0
  92. package/dist/esm/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutCard.js.map +1 -0
  93. package/dist/esm/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.js +66 -0
  94. package/dist/esm/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.js.map +1 -0
  95. package/dist/esm/components/AutoPatternsEntityPage/ViewModeEntityPage.js +111 -0
  96. package/dist/esm/components/AutoPatternsEntityPage/ViewModeEntityPage.js.map +1 -0
  97. package/dist/esm/components/AutoPatternsEntityPage/index.js +2 -0
  98. package/dist/esm/components/AutoPatternsEntityPage/index.js.map +1 -1
  99. package/dist/esm/components/ModalRenderer.js +2 -1
  100. package/dist/esm/components/ModalRenderer.js.map +1 -1
  101. package/dist/esm/components/modals/actions/BulkDeleteModal.js +12 -7
  102. package/dist/esm/components/modals/actions/BulkDeleteModal.js.map +1 -1
  103. package/dist/esm/components/modals/actions/CreateModal.js +11 -6
  104. package/dist/esm/components/modals/actions/CreateModal.js.map +1 -1
  105. package/dist/esm/components/modals/actions/EditModal.js +11 -6
  106. package/dist/esm/components/modals/actions/EditModal.js.map +1 -1
  107. package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js +6 -4
  108. package/dist/esm/dataSourceAdapters/cms/cmsAdapter.js.map +1 -1
  109. package/dist/esm/dataSourceAdapters/cms/filterUtils.js +2 -1
  110. package/dist/esm/dataSourceAdapters/cms/filterUtils.js.map +1 -1
  111. package/dist/esm/dataSourceAdapters/cms/sortUtils.js +2 -2
  112. package/dist/esm/dataSourceAdapters/cms/sortUtils.js.map +1 -1
  113. package/dist/esm/hooks/useActionCell.js +14 -9
  114. package/dist/esm/hooks/useActionCell.js.map +1 -1
  115. package/dist/esm/hooks/useBaseTableFeatures.js +2 -1
  116. package/dist/esm/hooks/useBaseTableFeatures.js.map +1 -1
  117. package/dist/esm/hooks/useBulkActionToolbar.js +4 -3
  118. package/dist/esm/hooks/useBulkActionToolbar.js.map +1 -1
  119. package/dist/esm/hooks/useCollectionPageActions.js +5 -4
  120. package/dist/esm/hooks/useCollectionPageActions.js.map +1 -1
  121. package/dist/esm/hooks/useCollectionPageOnRowClickActions.js +1 -1
  122. package/dist/esm/hooks/useCollectionPageOnRowClickActions.js.map +1 -1
  123. package/dist/esm/hooks/useColumns.js +12 -7
  124. package/dist/esm/hooks/useColumns.js.map +1 -1
  125. package/dist/esm/hooks/useCommonCollectionFeatures.js +8 -7
  126. package/dist/esm/hooks/useCommonCollectionFeatures.js.map +1 -1
  127. package/dist/esm/hooks/useEmptyStates.js +6 -5
  128. package/dist/esm/hooks/useEmptyStates.js.map +1 -1
  129. package/dist/esm/hooks/useEntityPageActions.js +83 -0
  130. package/dist/esm/hooks/useEntityPageActions.js.map +1 -0
  131. package/dist/esm/hooks/useEntityPageMoreActions.js +12 -2
  132. package/dist/esm/hooks/useEntityPageMoreActions.js.map +1 -1
  133. package/dist/esm/hooks/useFilters.js +7 -7
  134. package/dist/esm/hooks/useFilters.js.map +1 -1
  135. package/dist/esm/hooks/useNavigateEditEntityAction.js +46 -0
  136. package/dist/esm/hooks/useNavigateEditEntityAction.js.map +1 -0
  137. package/dist/esm/hooks/useNavigationUtils.js +15 -3
  138. package/dist/esm/hooks/useNavigationUtils.js.map +1 -1
  139. package/dist/esm/hooks/usePagePath.js +4 -3
  140. package/dist/esm/hooks/usePagePath.js.map +1 -1
  141. package/dist/esm/hooks/useTableFeatures.js +2 -1
  142. package/dist/esm/hooks/useTableFeatures.js.map +1 -1
  143. package/dist/esm/providers/ErrorContext.js +4 -1
  144. package/dist/esm/providers/ErrorContext.js.map +1 -1
  145. package/dist/esm/providers/PatternsWizardOverridesContext.js.map +1 -1
  146. package/dist/esm/providers/SchemaContext.js +3 -2
  147. package/dist/esm/providers/SchemaContext.js.map +1 -1
  148. package/dist/esm/providers/SchemaRegistryContext.js +1 -1
  149. package/dist/esm/providers/SchemaRegistryContext.js.map +1 -1
  150. package/dist/esm/types/EntityPageConfig.js.map +1 -1
  151. package/dist/esm/types/actions/actionCell.js.map +1 -1
  152. package/dist/esm/types/actions/entityPageActions.js.map +1 -1
  153. package/dist/esm/utils/actions/customAction.js +2 -1
  154. package/dist/esm/utils/actions/customAction.js.map +1 -1
  155. package/dist/esm/utils/actions/deleteAction.js +10 -5
  156. package/dist/esm/utils/actions/deleteAction.js.map +1 -1
  157. package/dist/esm/utils/actions/types.js.map +1 -1
  158. package/dist/esm/utils/filterCreators.js +11 -11
  159. package/dist/esm/utils/filterCreators.js.map +1 -1
  160. package/dist/types/components/AutoPatternsEntityPage/AutoPatternsEntityPage.d.ts.map +1 -1
  161. package/dist/types/components/AutoPatternsEntityPage/EditModeEntityPage.d.ts +6 -0
  162. package/dist/types/components/AutoPatternsEntityPage/EditModeEntityPage.d.ts.map +1 -0
  163. package/dist/types/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutCard.d.ts +11 -0
  164. package/dist/types/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutCard.d.ts.map +1 -0
  165. package/dist/types/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.d.ts +13 -0
  166. package/dist/types/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutContent.d.ts.map +1 -0
  167. package/dist/types/components/AutoPatternsEntityPage/RenderLayout/RenderViewField.d.ts +8 -0
  168. package/dist/types/components/AutoPatternsEntityPage/RenderLayout/RenderViewField.d.ts.map +1 -0
  169. package/dist/types/components/AutoPatternsEntityPage/RenderLayout/index.d.ts +3 -0
  170. package/dist/types/components/AutoPatternsEntityPage/RenderLayout/index.d.ts.map +1 -0
  171. package/dist/types/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutCard.d.ts +8 -0
  172. package/dist/types/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutCard.d.ts.map +1 -0
  173. package/dist/types/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.d.ts +8 -0
  174. package/dist/types/components/AutoPatternsEntityPage/ViewEntityPage/RenderViewLayoutContent.d.ts.map +1 -0
  175. package/dist/types/components/AutoPatternsEntityPage/ViewModeEntityPage.d.ts +8 -0
  176. package/dist/types/components/AutoPatternsEntityPage/ViewModeEntityPage.d.ts.map +1 -0
  177. package/dist/types/components/AutoPatternsEntityPage/index.d.ts +2 -0
  178. package/dist/types/components/AutoPatternsEntityPage/index.d.ts.map +1 -1
  179. package/dist/types/dataSourceAdapters/cms/cmsAdapter.d.ts.map +1 -1
  180. package/dist/types/hooks/useActionCell.d.ts.map +1 -1
  181. package/dist/types/hooks/useEntityPageActions.d.ts +9 -0
  182. package/dist/types/hooks/useEntityPageActions.d.ts.map +1 -0
  183. package/dist/types/hooks/useEntityPageHeaderTexts.d.ts.map +1 -1
  184. package/dist/types/hooks/useEntityPageMoreActions.d.ts +2 -2
  185. package/dist/types/hooks/useEntityPageMoreActions.d.ts.map +1 -1
  186. package/dist/types/hooks/useNavigateEditEntityAction.d.ts +6 -0
  187. package/dist/types/hooks/useNavigateEditEntityAction.d.ts.map +1 -0
  188. package/dist/types/hooks/useNavigationUtils.d.ts +1 -0
  189. package/dist/types/hooks/useNavigationUtils.d.ts.map +1 -1
  190. package/dist/types/providers/ErrorContext.d.ts +7 -0
  191. package/dist/types/providers/ErrorContext.d.ts.map +1 -1
  192. package/dist/types/providers/PatternsWizardOverridesContext.d.ts +2 -2
  193. package/dist/types/providers/PatternsWizardOverridesContext.d.ts.map +1 -1
  194. package/dist/types/types/EntityPageConfig.d.ts +20 -4
  195. package/dist/types/types/EntityPageConfig.d.ts.map +1 -1
  196. package/dist/types/types/actions/actionCell.d.ts +7 -1
  197. package/dist/types/types/actions/actionCell.d.ts.map +1 -1
  198. package/dist/types/types/actions/entityPageActions.d.ts +24 -5
  199. package/dist/types/types/actions/entityPageActions.d.ts.map +1 -1
  200. package/dist/types/utils/actions/customAction.d.ts +1 -1
  201. package/dist/types/utils/actions/customAction.d.ts.map +1 -1
  202. package/dist/types/utils/actions/resolveAction.d.ts +1 -0
  203. package/dist/types/utils/actions/resolveAction.d.ts.map +1 -1
  204. package/dist/types/utils/actions/types.d.ts +2 -1
  205. package/dist/types/utils/actions/types.d.ts.map +1 -1
  206. package/package.json +16 -15
  207. package/dist/docs/config_schema.md +0 -184
@@ -1 +1 @@
1
- {"version":3,"names":["React","useRef","useMemo","useState","useEffect","Cell","DatePicker","FormField","Layout","TimeInput","useWixPatternsContainer","useSelector","useEntityPageContext","useController","DateTime","props","field","dataHook","inputRef","translate","t","container","initTask","status","pageState","controller","name","id","control","form","defaultValue","entity","rules","validate","v","validation","required","undefined","date","value","d","Date","isNaN","getTime","dateStatusMessage","setDateStatusMessage","timeStatusMessage","setTimeStatusMessage","ref","dateRef","timeRef","dateValue","setDateValue","getDate","timeValue","setTimeValue","current","focus","invalid","createElement","label","displayName","span","internalRef","state","width","onChange","onValidate","_ref","validationType","newValue","format","dateWithNewDate","_value","setFullYear","getFullYear","setMonth","getMonth","setDate","toISOString","dateFormat","fieldState","error","statusMessage","onInvalid","_ref2","dateWithNewTime","setHours","getHours","setMinutes","getMinutes","setSeconds","getSeconds","setMilliseconds","getMilliseconds"],"sources":["../../../../../src/components/AutoPatternsEntityPage/Fields/DateTime.tsx"],"sourcesContent":["import React, { useRef, useMemo, useState, useEffect } from 'react';\nimport {\n Cell,\n DatePicker,\n FormField,\n Layout,\n TimeInput,\n} from '@wix/design-system';\nimport { BaseInputProps, BaseInputRef } from './types';\nimport {\n useWixPatternsContainer,\n useSelector,\n useEntityPageContext,\n} from '@wix/patterns';\nimport { useController } from '@wix/patterns/form';\n\nexport interface DateTimeProps extends BaseInputProps<string | null> {}\n\nexport const DateTime = (props: DateTimeProps) => {\n const { field, dataHook, inputRef } = props;\n const { translate: t, ...container } = useWixPatternsContainer();\n useSelector(() => container.initTask.status);\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: (v) => {\n if (\n field?.validation?.required &&\n (v === null || v === undefined || v === '')\n ) {\n return t('cairo.fieldValidation.requiredField');\n }\n return true;\n },\n },\n });\n\n const date = useMemo(() => {\n if (!controller.field.value) {\n return undefined;\n }\n const d = new Date(controller.field.value);\n return isNaN(d.getTime()) ? undefined : d;\n }, [controller.field.value]);\n\n const [dateStatusMessage, setDateStatusMessage] = useState('');\n const [timeStatusMessage, setTimeStatusMessage] = useState('');\n\n const ref = useRef<BaseInputRef>({});\n const dateRef = useRef<BaseInputRef>({});\n const timeRef = useRef<BaseInputRef>({});\n const [dateValue, setDateValue] = useState<number | string | undefined>(\n date?.getDate(),\n );\n const [timeValue, setTimeValue] = useState<number | string | undefined>(\n date?.getTime(),\n );\n\n useEffect(() => {\n ref.current.focus = () => {\n if (dateRef.current.invalid) {\n return dateRef.current.focus?.();\n }\n\n return timeRef.current.focus?.();\n };\n\n inputRef?.(ref.current);\n }, [inputRef]);\n\n return (\n <FormField\n label={field.displayName}\n required={field.validation?.required}\n dataHook={dataHook}\n >\n <Layout>\n <Cell span={6}>\n <DatePicker\n ref={(internalRef) => {\n dateRef.current.focus = () =>\n // TODO: PR to WSR needed to expose as public API\n // @ts-expect-error\n internalRef?.state?.inputRef?.focus?.();\n }}\n width=\"100%\"\n value={date}\n // onChange is triggered only when you have valid, non-empty value. and onValidate is triggered on every change so we use onValidate\n onChange={() => {}}\n onValidate={({ validationType, value: newValue, format }) => {\n if (validationType === 'valid') {\n const dateWithNewDate = date\n ? new Date(date)\n : new Date(newValue);\n const _value = new Date(newValue);\n dateWithNewDate.setFullYear(_value.getFullYear());\n dateWithNewDate.setMonth(_value.getMonth());\n dateWithNewDate.setDate(_value.getDate());\n controller.field.onChange(dateWithNewDate.toISOString());\n setDateValue(new Date(newValue).getDate());\n setDateStatusMessage('');\n dateRef.current.invalid = false;\n } else if (validationType === 'formatError' && newValue === '') {\n if (field.validation?.required) {\n setDateStatusMessage(\n t('cairo.fieldValidation.requiredField'),\n );\n dateRef.current.invalid = true;\n } else {\n setDateStatusMessage('');\n dateRef.current.invalid = false;\n }\n setDateValue(newValue);\n if (!timeValue) {\n controller.field.onChange(null);\n }\n } else {\n setDateStatusMessage(\n t('cairo.customFields.fieldType.date.invalid.value', {\n dateFormat: format ?? '',\n }),\n );\n dateRef.current.invalid = true;\n }\n\n ref.current.invalid =\n dateRef.current.invalid || timeRef.current.invalid;\n }}\n status={\n controller.fieldState.error || dateStatusMessage\n ? 'error'\n : undefined\n }\n statusMessage={controller.fieldState.error || dateStatusMessage}\n dataHook={`datetime-date-${field.id}`}\n />\n </Cell>\n <Cell span={6}>\n <TimeInput\n ref={(internalRef) => {\n timeRef.current.focus = () => internalRef?.focus();\n }}\n dataHook={`datetime-time-${field.id}`}\n value={date ?? null}\n status={\n controller.fieldState.error || timeStatusMessage\n ? 'error'\n : undefined\n }\n statusMessage={controller.fieldState.error || timeStatusMessage}\n onInvalid={() => {\n timeRef.current.invalid = true;\n setTimeStatusMessage(\n t('cairo.customFields.fieldType.dateAndTime.invalid.value'),\n );\n ref.current.invalid =\n dateRef.current.invalid || timeRef.current.invalid;\n }}\n onChange={({ date: newValue }) => {\n timeRef.current.invalid = false;\n ref.current.invalid =\n dateRef.current.invalid || timeRef.current.invalid;\n\n if (newValue) {\n const dateWithNewTime = date ? new Date(date) : newValue;\n dateWithNewTime.setHours(newValue.getHours());\n dateWithNewTime.setMinutes(newValue.getMinutes());\n dateWithNewTime.setSeconds(newValue.getSeconds());\n dateWithNewTime.setMilliseconds(newValue.getMilliseconds());\n controller.field.onChange(dateWithNewTime.toISOString());\n setTimeStatusMessage('');\n setDateStatusMessage('');\n } else {\n if (!newValue) {\n setTimeValue('');\n if (field.validation?.required) {\n setTimeStatusMessage(\n t('cairo.fieldValidation.requiredField'),\n );\n timeRef.current.invalid = true;\n } else {\n setTimeStatusMessage('');\n timeRef.current.invalid = false;\n }\n if (!ref.current.invalid) {\n if (!dateValue) {\n controller.field.onChange(null);\n }\n }\n }\n }\n }}\n />\n </Cell>\n </Layout>\n </FormField>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,MAAM,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AACnE,SACEC,IAAI,EACJC,UAAU,EACVC,SAAS,EACTC,MAAM,EACNC,SAAS,QACJ,oBAAoB;AAE3B,SACEC,uBAAuB,EACvBC,WAAW,EACXC,oBAAoB,QACf,eAAe;AACtB,SAASC,aAAa,QAAQ,oBAAoB;AAIlD,OAAO,MAAMC,QAAQ,GAAIC,KAAoB,IAAK;EAChD,MAAM;IAAEC,KAAK;IAAEC,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B,CAAC,CAAC,qCAAqC,CACzC,CAAC;YACD8B,OAAO,CAACM,OAAO,CAACE,OAAO,GAAG,IAAI;UAChC,CAAC,MAAM;YACLX,oBAAoB,CAAC,EAAE,CAAC;YACxBG,OAAO,CAACM,OAAO,CAACE,OAAO,GAAG,KAAK;UACjC;UACA,IAAI,CAACV,GAAG,CAACQ,OAAO,CAACE,OAAO,EAAE;YACxB,IAAI,CAACP,SAAS,EAAE;cACd1B,UAAU,CAACT,KAAK,CAACkD,QAAQ,CAAC,IAAI,CAAC;YACjC;UACF;QACF;MACF;IACF;EAAE,CACH,CACG,CACA,CACC,CAAC;AAEhB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","useRef","useMemo","useState","useEffect","Cell","DatePicker","FormField","Layout","TimeInput","useWixPatternsContainer","useSelector","useEntityPageContext","useController","DateTime","props","_pageState$entity","_field$validation2","field","dataHook","inputRef","translate","t","container","initTask","status","pageState","controller","name","id","control","form","defaultValue","entity","rules","validate","v","_field$validation","validation","required","undefined","date","value","d","Date","isNaN","getTime","dateStatusMessage","setDateStatusMessage","timeStatusMessage","setTimeStatusMessage","ref","dateRef","timeRef","dateValue","setDateValue","getDate","timeValue","setTimeValue","current","focus","invalid","createElement","label","displayName","span","internalRef","_internalRef$state","state","width","onChange","onValidate","_ref","validationType","newValue","format","dateWithNewDate","_value","setFullYear","getFullYear","setMonth","getMonth","setDate","toISOString","_field$validation3","dateFormat","fieldState","error","statusMessage","onInvalid","_ref2","dateWithNewTime","setHours","getHours","setMinutes","getMinutes","setSeconds","getSeconds","setMilliseconds","getMilliseconds","_field$validation4"],"sources":["../../../../../src/components/AutoPatternsEntityPage/Fields/DateTime.tsx"],"sourcesContent":["import React, { useRef, useMemo, useState, useEffect } from 'react';\nimport {\n Cell,\n DatePicker,\n FormField,\n Layout,\n TimeInput,\n} from '@wix/design-system';\nimport { BaseInputProps, BaseInputRef } from './types';\nimport {\n useWixPatternsContainer,\n useSelector,\n useEntityPageContext,\n} from '@wix/patterns';\nimport { useController } from '@wix/patterns/form';\n\nexport interface DateTimeProps extends BaseInputProps<string | null> {}\n\nexport const DateTime = (props: DateTimeProps) => {\n const { field, dataHook, inputRef } = props;\n const { translate: t, ...container } = useWixPatternsContainer();\n useSelector(() => container.initTask.status);\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: (v) => {\n if (\n field?.validation?.required &&\n (v === null || v === undefined || v === '')\n ) {\n return t('cairo.fieldValidation.requiredField');\n }\n return true;\n },\n },\n });\n\n const date = useMemo(() => {\n if (!controller.field.value) {\n return undefined;\n }\n const d = new Date(controller.field.value);\n return isNaN(d.getTime()) ? undefined : d;\n }, [controller.field.value]);\n\n const [dateStatusMessage, setDateStatusMessage] = useState('');\n const [timeStatusMessage, setTimeStatusMessage] = useState('');\n\n const ref = useRef<BaseInputRef>({});\n const dateRef = useRef<BaseInputRef>({});\n const timeRef = useRef<BaseInputRef>({});\n const [dateValue, setDateValue] = useState<number | string | undefined>(\n date?.getDate(),\n );\n const [timeValue, setTimeValue] = useState<number | string | undefined>(\n date?.getTime(),\n );\n\n useEffect(() => {\n ref.current.focus = () => {\n if (dateRef.current.invalid) {\n return dateRef.current.focus?.();\n }\n\n return timeRef.current.focus?.();\n };\n\n inputRef?.(ref.current);\n }, [inputRef]);\n\n return (\n <FormField\n label={field.displayName}\n required={field.validation?.required}\n dataHook={dataHook}\n >\n <Layout>\n <Cell span={6}>\n <DatePicker\n ref={(internalRef) => {\n dateRef.current.focus = () =>\n // TODO: PR to WSR needed to expose as public API\n // @ts-expect-error\n internalRef?.state?.inputRef?.focus?.();\n }}\n width=\"100%\"\n value={date}\n // onChange is triggered only when you have valid, non-empty value. and onValidate is triggered on every change so we use onValidate\n onChange={() => {}}\n onValidate={({ validationType, value: newValue, format }) => {\n if (validationType === 'valid') {\n const dateWithNewDate = date\n ? new Date(date)\n : new Date(newValue);\n const _value = new Date(newValue);\n dateWithNewDate.setFullYear(_value.getFullYear());\n dateWithNewDate.setMonth(_value.getMonth());\n dateWithNewDate.setDate(_value.getDate());\n controller.field.onChange(dateWithNewDate.toISOString());\n setDateValue(new Date(newValue).getDate());\n setDateStatusMessage('');\n dateRef.current.invalid = false;\n } else if (validationType === 'formatError' && newValue === '') {\n if (field.validation?.required) {\n setDateStatusMessage(\n t('cairo.fieldValidation.requiredField'),\n );\n dateRef.current.invalid = true;\n } else {\n setDateStatusMessage('');\n dateRef.current.invalid = false;\n }\n setDateValue(newValue);\n if (!timeValue) {\n controller.field.onChange(null);\n }\n } else {\n setDateStatusMessage(\n t('cairo.customFields.fieldType.date.invalid.value', {\n dateFormat: format ?? '',\n }),\n );\n dateRef.current.invalid = true;\n }\n\n ref.current.invalid =\n dateRef.current.invalid || timeRef.current.invalid;\n }}\n status={\n controller.fieldState.error || dateStatusMessage\n ? 'error'\n : undefined\n }\n statusMessage={controller.fieldState.error || dateStatusMessage}\n dataHook={`datetime-date-${field.id}`}\n />\n </Cell>\n <Cell span={6}>\n <TimeInput\n ref={(internalRef) => {\n timeRef.current.focus = () => internalRef?.focus();\n }}\n dataHook={`datetime-time-${field.id}`}\n value={date ?? null}\n status={\n controller.fieldState.error || timeStatusMessage\n ? 'error'\n : undefined\n }\n statusMessage={controller.fieldState.error || timeStatusMessage}\n onInvalid={() => {\n timeRef.current.invalid = true;\n setTimeStatusMessage(\n t('cairo.customFields.fieldType.dateAndTime.invalid.value'),\n );\n ref.current.invalid =\n dateRef.current.invalid || timeRef.current.invalid;\n }}\n onChange={({ date: newValue }) => {\n timeRef.current.invalid = false;\n ref.current.invalid =\n dateRef.current.invalid || timeRef.current.invalid;\n\n if (newValue) {\n const dateWithNewTime = date ? new Date(date) : newValue;\n dateWithNewTime.setHours(newValue.getHours());\n dateWithNewTime.setMinutes(newValue.getMinutes());\n dateWithNewTime.setSeconds(newValue.getSeconds());\n dateWithNewTime.setMilliseconds(newValue.getMilliseconds());\n controller.field.onChange(dateWithNewTime.toISOString());\n setTimeStatusMessage('');\n setDateStatusMessage('');\n } else {\n if (!newValue) {\n setTimeValue('');\n if (field.validation?.required) {\n setTimeStatusMessage(\n t('cairo.fieldValidation.requiredField'),\n );\n timeRef.current.invalid = true;\n } else {\n setTimeStatusMessage('');\n timeRef.current.invalid = false;\n }\n if (!ref.current.invalid) {\n if (!dateValue) {\n controller.field.onChange(null);\n }\n }\n }\n }\n }}\n />\n </Cell>\n </Layout>\n </FormField>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,MAAM,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AACnE,SACEC,IAAI,EACJC,UAAU,EACVC,SAAS,EACTC,MAAM,EACNC,SAAS,QACJ,oBAAoB;AAE3B,SACEC,uBAAuB,EACvBC,WAAW,EACXC,oBAAoB,QACf,eAAe;AACtB,SAASC,aAAa,QAAQ,oBAAoB;AAIlD,OAAO,MAAMC,QAAQ,GAAIC,KAAoB,IAAK;EAAA,IAAAC,iBAAA,EAAAC,kBAAA;EAChD,MAAM;IAAEC,KAAK;IAAEC,QAAQ;IAAEC;EAAS,CAAC,GAAGL,KAAK;EAC3C,MAAM;IAAEM,SAAS,EAAEC,CAAC;IAAE,GAAGC;EAAU,CAAC,GAAGb,uBAAuB,CAAC,CAAC;EAChEC,WAAW,CAAC,MAAMY,SAAS,CAACC,QAAQ,CAACC,MAAM,CAAC;EAC5C,MAAMC,SAAS,GAAGd,oBAAoB,CAAC,CAAC;EAExC,MAAMe,UAAU,GAAGd,aAAa,CAAC;IAC/Be,IAAI,EAAE,CAAAV,KAAK,oBAALA,KAAK,CAAEW,EAAE,KAAI,EAAE;IACrBC,OAAO,EAAEJ,SAAS,CAACK,IAAI,CAACD,OAAO;IAC/BE,YAAY,GAAAhB,iBAAA,GAAGU,SAAS,CAACO,MAAM,qBAAjBjB,iBAAA,CAA4B,CAAAE,KAAK,oBAALA,KAAK,CAAEW,EAAE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AkB7D,QAAQ,EAAE;YAC9BW,oBAAoB,CAClB5B,CAAC,CAAC,qCAAqC,CACzC,CAAC;YACD+B,OAAO,CAACM,OAAO,CAACE,OAAO,GAAG,IAAI;UAChC,CAAC,MAAM;YACLX,oBAAoB,CAAC,EAAE,CAAC;YACxBG,OAAO,CAACM,OAAO,CAACE,OAAO,GAAG,KAAK;UACjC;UACA,IAAI,CAACV,GAAG,CAACQ,OAAO,CAACE,OAAO,EAAE;YACxB,IAAI,CAACP,SAAS,EAAE;cACd3B,UAAU,CAACT,KAAK,CAACoD,QAAQ,CAAC,IAAI,CAAC;YACjC;UACF;QACF;MACF;IACF;EAAE,CACH,CACG,CACA,CACC,CAAC;AAEhB,CAAC","ignoreList":[]}
@@ -20,15 +20,16 @@ export const EDITABLE_INPUT_ELEMENTS = {
20
20
  IMAGE: ImageInput
21
21
  };
22
22
  export const FormFieldInput = props => {
23
+ var _pageState$entity;
23
24
  const {
24
25
  field,
25
26
  inputRef
26
27
  } = props;
27
28
  const pageState = useEntityPageContext();
28
29
  const controller = useController({
29
- name: field?.id ?? '',
30
+ name: (field == null ? void 0 : field.id) ?? '',
30
31
  control: pageState.form.control,
31
- defaultValue: pageState.entity?.[field?.id ?? '']
32
+ defaultValue: (_pageState$entity = pageState.entity) == null ? void 0 : _pageState$entity[(field == null ? void 0 : field.id) ?? '']
32
33
  });
33
34
  if (!EDITABLE_INPUT_ELEMENTS.hasOwnProperty(field.type) || !pageState) {
34
35
  return null;
@@ -1 +1 @@
1
- {"version":3,"names":["React","ShortText","useEntityPageContext","useController","Checkbox","DateInput","DateTime","Number","LongText","Url","ImageInput","EDITABLE_INPUT_ELEMENTS","SHORT_TEXT","LONG_TEXT","BOOLEAN","DATE","DATETIME","NUMBER","URL","IMAGE","FormFieldInput","props","field","inputRef","pageState","controller","name","id","control","form","defaultValue","entity","hasOwnProperty","type","FieldInput","createElement","value","onChange","dataHook"],"sources":["../../../../../src/components/AutoPatternsEntityPage/Fields/FormFieldInput.tsx"],"sourcesContent":["import React from 'react';\nimport { ShortText } from './ShortText';\nimport { useEntityPageContext } from '@wix/patterns';\nimport { useController } from '@wix/patterns/form';\nimport { Field, PatternsFieldType } from '../../../types';\nimport { Checkbox } from './Checkbox';\nimport { DateInput } from './DateInput';\nimport { DateTime } from './DateTime';\nimport { Number } from './Number';\nimport { LongText } from './LongText';\nimport { Url } from './Url';\nimport { BaseInputProps } from './types';\nimport { ImageInput } from './ImageInput';\n\nexport const EDITABLE_INPUT_ELEMENTS: Partial<\n Record<PatternsFieldType, React.ComponentType<any>>\n> = {\n SHORT_TEXT: ShortText,\n LONG_TEXT: LongText,\n BOOLEAN: Checkbox,\n DATE: DateInput,\n DATETIME: DateTime,\n NUMBER: Number,\n URL: Url,\n IMAGE: ImageInput,\n};\n\nexport interface FormFieldInputProps {\n field: Field;\n inputRef?: BaseInputProps<any>['inputRef'];\n}\n\nexport const FormFieldInput = (props: FormFieldInputProps) => {\n const { field, inputRef } = props;\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 });\n\n if (!EDITABLE_INPUT_ELEMENTS.hasOwnProperty(field.type) || !pageState) {\n return null;\n }\n\n const FieldInput = EDITABLE_INPUT_ELEMENTS[field.type]!;\n\n return (\n <FieldInput\n field={field}\n value={controller.field.value}\n onChange={controller.field.onChange}\n dataHook={`form-field-${field.id}`}\n inputRef={inputRef}\n />\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,oBAAoB,QAAQ,eAAe;AACpD,SAASC,aAAa,QAAQ,oBAAoB;AAElD,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,MAAM,QAAQ,UAAU;AACjC,SAASC,QAAQ,QAAQ,YAAY;AACrC,SA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Input","DateTime","Number","LongText","Url","ImageInput","EDITABLE_INPUT_ELEMENTS","SHORT_TEXT","LONG_TEXT","BOOLEAN","DATE","DATETIME","NUMBER","URL","IMAGE","FormFieldInput","props","_pageState$entity","field","inputRef","pageState","controller","name","id","control","form","defaultValue","entity","hasOwnProperty","type","FieldInput","createElement","value","onChange","dataHook"],"sources":["../../../../../src/components/AutoPatternsEntityPage/Fields/FormFieldInput.tsx"],"sourcesContent":["import React from 'react';\nimport { ShortText } from './ShortText';\nimport { useEntityPageContext } from '@wix/patterns';\nimport { useController } from '@wix/patterns/form';\nimport { Field, PatternsFieldType } from '../../../types';\nimport { Checkbox } from './Checkbox';\nimport { DateInput } from './DateInput';\nimport { DateTime } from './DateTime';\nimport { Number } from './Number';\nimport { LongText } from './LongText';\nimport { Url } from './Url';\nimport { BaseInputProps } from './types';\nimport { ImageInput } from './ImageInput';\n\nexport const EDITABLE_INPUT_ELEMENTS: Partial<\n Record<PatternsFieldType, React.ComponentType<any>>\n> = {\n SHORT_TEXT: ShortText,\n LONG_TEXT: LongText,\n BOOLEAN: Checkbox,\n DATE: DateInput,\n DATETIME: DateTime,\n NUMBER: Number,\n URL: Url,\n IMAGE: ImageInput,\n};\n\nexport interface FormFieldInputProps {\n field: Field;\n inputRef?: BaseInputProps<any>['inputRef'];\n}\n\nexport const FormFieldInput = (props: FormFieldInputProps) => {\n const { field, inputRef } = props;\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 });\n\n if (!EDITABLE_INPUT_ELEMENTS.hasOwnProperty(field.type) || !pageState) {\n return null;\n }\n\n const FieldInput = EDITABLE_INPUT_ELEMENTS[field.type]!;\n\n return (\n <FieldInput\n field={field}\n value={controller.field.value}\n onChange={controller.field.onChange}\n dataHook={`form-field-${field.id}`}\n inputRef={inputRef}\n />\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACz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AAI,CAAE;EAEvD,oBACElC,KAAA,CAAAoC,aAAA,CAACD,UAAU;IACTZ,KAAK,EAAEA,KAAM;IACbc,KAAK,EAAEX,UAAU,CAACH,KAAK,CAACc,KAAM;IAC9BC,QAAQ,EAAEZ,UAAU,CAACH,KAAK,CAACe,QAAS;IACpCC,QAAQ,EAAE,cAAchB,KAAK,CAACK,EAAE,EAAG;IACnCJ,QAAQ,EAAEA;EAAS,CACpB,CAAC;AAEN,CAAC","ignoreList":[]}
@@ -5,6 +5,7 @@ import { useController } from '@wix/patterns/form';
5
5
  import { getImageUrl } from '../../../utils/media/getImageUrl';
6
6
  import { dashboard } from '@wix/dashboard';
7
7
  export const ImageInput = props => {
8
+ var _pageState$entity, _field$validation2, _controller$fieldStat;
8
9
  const {
9
10
  field,
10
11
  dataHook
@@ -18,23 +19,25 @@ export const ImageInput = props => {
18
19
  const pageState = useEntityPageContext();
19
20
  async function openMedia() {
20
21
  try {
22
+ var _chosenMediaItems$ite;
21
23
  const chosenMediaItems = await dashboard.openMediaManager({
22
24
  multiSelect: false,
23
25
  category: 'IMAGE'
24
26
  });
25
- const newImage = chosenMediaItems?.items[0]?.media?.image?.image;
27
+ const newImage = chosenMediaItems == null || (_chosenMediaItems$ite = chosenMediaItems.items[0]) == null || (_chosenMediaItems$ite = _chosenMediaItems$ite.media) == null || (_chosenMediaItems$ite = _chosenMediaItems$ite.image) == null ? void 0 : _chosenMediaItems$ite.image;
26
28
  controller.field.onChange(newImage);
27
29
  } catch (error) {
28
30
  console.error('Error opening Media Manager or no files selected:', error);
29
31
  }
30
32
  }
31
33
  const controller = useController({
32
- name: field?.id ?? '',
34
+ name: (field == null ? void 0 : field.id) ?? '',
33
35
  control: pageState.form.control,
34
- defaultValue: pageState.entity?.[field?.id ?? ''],
36
+ defaultValue: (_pageState$entity = pageState.entity) == null ? void 0 : _pageState$entity[(field == null ? void 0 : field.id) ?? ''],
35
37
  rules: {
36
38
  validate: value => {
37
- if (field.validation?.required && (value === null || value === undefined || value === '')) {
39
+ var _field$validation;
40
+ if ((_field$validation = field.validation) != null && _field$validation.required && (value === null || value === undefined || value === '')) {
38
41
  return t('cairo.fieldValidation.requiredField');
39
42
  }
40
43
  return true;
@@ -44,9 +47,9 @@ export const ImageInput = props => {
44
47
  const imageUrl = controller.field.value && getImageUrl(controller.field.value);
45
48
  return /*#__PURE__*/React.createElement(FormField, {
46
49
  label: field.displayName,
47
- required: field.validation?.required,
50
+ required: (_field$validation2 = field.validation) == null ? void 0 : _field$validation2.required,
48
51
  status: controller.fieldState.error ? 'error' : undefined,
49
- statusMessage: controller.fieldState.error?.message,
52
+ statusMessage: (_controller$fieldStat = controller.fieldState.error) == null ? void 0 : _controller$fieldStat.message,
50
53
  dataHook: dataHook
51
54
  }, /*#__PURE__*/React.createElement(ImageViewer, {
52
55
  imageUrl: imageUrl,
@@ -1 +1 @@
1
- {"version":3,"names":["React","FormField","ImageViewer","useEntityPageContext","useIsMobile","useSelector","useWixPatternsContainer","useController","getImageUrl","dashboard","ImageInput","props","field","dataHook","translate","t","container","initTask","status","isMobile","pageState","openMedia","chosenMediaItems","openMediaManager","multiSelect","category","newImage","items","media","image","controller","onChange","error","console","name","id","control","form","defaultValue","entity","rules","validate","value","validation","required","undefined","imageUrl","createElement","label","displayName","fieldState","statusMessage","message","onAddImage","onUpdateImage","updateImageInfo","removeImageInfo","addImageInfo","height","width","fit","onRemoveImage"],"sources":["../../../../../src/components/AutoPatternsEntityPage/Fields/ImageInput.tsx"],"sourcesContent":["import React from 'react';\nimport { FormField, ImageViewer } from '@wix/design-system';\nimport { BaseInputProps } from './types';\nimport {\n useEntityPageContext,\n useIsMobile,\n useSelector,\n useWixPatternsContainer,\n} from '@wix/patterns';\nimport { useController } from '@wix/patterns/form';\nimport { getImageUrl } from '../../../utils/media/getImageUrl';\nimport { dashboard } from '@wix/dashboard';\n\nexport interface ImageInputProps extends BaseInputProps<string> {}\n\nexport const ImageInput = (props: ImageInputProps) => {\n const { field, dataHook } = props;\n\n const { translate: t, ...container } = useWixPatternsContainer();\n useSelector(() => container.initTask.status);\n const isMobile = useIsMobile();\n const pageState = useEntityPageContext();\n\n async function openMedia() {\n try {\n const chosenMediaItems = await dashboard.openMediaManager({\n multiSelect: false,\n category: 'IMAGE',\n });\n\n const newImage = chosenMediaItems?.items[0]?.media?.image?.image;\n\n controller.field.onChange(newImage);\n } catch (error) {\n console.error('Error opening Media Manager or no files selected:', error);\n }\n }\n\n const controller = useController({\n name: field?.id ?? '',\n control: pageState.form.control,\n defaultValue: (pageState.entity as any)?.[field?.id ?? ''],\n rules: {\n validate: (value) => {\n if (\n field.validation?.required &&\n (value === null || value === undefined || value === '')\n ) {\n return t('cairo.fieldValidation.requiredField');\n }\n\n return true;\n },\n },\n });\n\n const imageUrl =\n controller.field.value && getImageUrl(controller.field.value);\n\n return (\n <FormField\n label={field.displayName}\n required={field.validation?.required}\n status={controller.fieldState.error ? 'error' : undefined}\n statusMessage={controller.fieldState.error?.message}\n dataHook={dataHook}\n >\n <ImageViewer\n imageUrl={imageUrl}\n dataHook={`image-${field.id}`}\n onAddImage={isMobile ? undefined : () => openMedia()}\n onUpdateImage={isMobile ? undefined : () => openMedia()}\n updateImageInfo={t('cairo.replace-image.tooltip')}\n removeImageInfo={t('cairo.remove-image.tooltip')}\n addImageInfo={t('cairo.add-image.tooltip')}\n height=\"120px\"\n width=\"25%\"\n fit=\"cover\"\n onRemoveImage={() => controller.field.onChange(null)}\n />\n </FormField>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS,EAAEC,WAAW,QAAQ,oBAAoB;AAE3D,SACEC,oBAAoB,EACpBC,WAAW,EACXC,WAAW,EACXC,uBAAuB,QAClB,eAAe;AACtB,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,WAAW,QAAQ,kCAAkC;AAC9D,SAASC,SAAS,QAAQ,gBAAgB;AAI1C,OAAO,MAAMC,UAAU,GAAIC,KAAsB,IAAK;EACpD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AO,IAAI;MACb;IACF;EACF,CAAC,CAAC;EAEF,MAAM+B,QAAQ,GACZhB,UAAU,CAAClB,KAAK,CAAC8B,KAAK,IAAIlC,WAAW,CAACsB,UAAU,CAAClB,KAAK,CAAC8B,KAAK,CAAC;EAE/D,oBACE1C,KAAA,CAAA+C,aAAA,CAAC9C,SAAS;IACR+C,KAAK,EAAEpC,KAAK,CAACqC,WAAY;IACzBL,QAAQ,EAAEhC,KAAK,CAAC+B,UAAU,EAAEC,QAAS;IACrC1B,MAAM,EAAEY,UAAU,CAACoB,UAAU,CAAClB,KAAK,GAAG,OAAO,GAAGa,SAAU;IAC1DM,aAAa,EAAErB,UAAU,CAACoB,UAAU,CAAClB,KAAK,EAAEoB,OAAQ;IACpDvC,QAAQ,EAAEA;EAAS,gBAEnBb,KAAA,CAAA+C,aAAA,CAAC7C,WAAW;IACV4C,QAAQ,EAAEA,QAAS;IACnBjC,QAAQ,EAAE,SAASD,KAAK,CAACuB,EAAE,EAAG;IAC9BkB,UAAU,EAAElC,QAAQ,GAAG0B,SAAS,GAAG,MAAMxB,SAAS,CAAC,CAAE;IACrDiC,aAAa,EAAEnC,QAAQ,GAAG0B,SAAS,GAAG,MAAMxB,SAAS,CAAC,CAAE;IACxDkC,eAAe,EAAExC,CAAC,CAAC,6BAA6B,CAAE;IAClDyC,eAAe,EAAEzC,CAAC,CAAC,4BAA4B,CAAE;IACjD0C,YAAY,EAAE1C,CAAC,CAAC,yBAAyB,CAAE;IAC3C2C,MAAM,EAAC,OAAO;IACdC,KAAK,EAAC,KAAK;IACXC,GAAG,EAAC,OAAO;IACXC,aAAa,EAAEA,CAAA,KAAM/B,UAAU,CAAClB,KAAK,CAACmB,QAAQ,CAAC,IAAI;EAAE,CACtD,CACQ,CAAC;AAEhB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","FormField","ImageViewer","useEntityPageContext","useIsMobile","useSelector","useWixPatternsContainer","useController","getImageUrl","dashboard","ImageInput","props","_pageState$entity","_field$validation2","_controller$fieldStat","field","dataHook","translate","t","container","initTask","status","isMobile","pageState","openMedia","_chosenMediaItems$ite","chosenMediaItems","openMediaManager","multiSelect","category","newImage","items","media","image","controller","onChange","error","console","name","id","control","form","defaultValue","entity","rules","validate","value","_field$validation","validation","required","undefined","imageUrl","createElement","label","displayName","fieldState","statusMessage","message","onAddImage","onUpdateImage","updateImageInfo","removeImageInfo","addImageInfo","height","width","fit","onRemoveImage"],"sources":["../../../../../src/components/AutoPatternsEntityPage/Fields/ImageInput.tsx"],"sourcesContent":["import React from 'react';\nimport { FormField, ImageViewer } from '@wix/design-system';\nimport { BaseInputProps } from './types';\nimport {\n useEntityPageContext,\n useIsMobile,\n useSelector,\n useWixPatternsContainer,\n} from '@wix/patterns';\nimport { useController } from '@wix/patterns/form';\nimport { getImageUrl } from '../../../utils/media/getImageUrl';\nimport { dashboard } from '@wix/dashboard';\n\nexport interface ImageInputProps extends BaseInputProps<string> {}\n\nexport const ImageInput = (props: ImageInputProps) => {\n const { field, dataHook } = props;\n\n const { translate: t, ...container } = useWixPatternsContainer();\n useSelector(() => container.initTask.status);\n const isMobile = useIsMobile();\n const pageState = useEntityPageContext();\n\n async function openMedia() {\n try {\n const chosenMediaItems = await dashboard.openMediaManager({\n multiSelect: false,\n category: 'IMAGE',\n });\n\n const newImage = chosenMediaItems?.items[0]?.media?.image?.image;\n\n controller.field.onChange(newImage);\n } catch (error) {\n console.error('Error opening Media Manager or no files selected:', error);\n }\n }\n\n const controller = useController({\n name: field?.id ?? '',\n control: pageState.form.control,\n defaultValue: (pageState.entity as any)?.[field?.id ?? ''],\n rules: {\n validate: (value) => {\n if (\n field.validation?.required &&\n (value === null || value === undefined || value === '')\n ) {\n return t('cairo.fieldValidation.requiredField');\n }\n\n return true;\n },\n },\n });\n\n const imageUrl =\n controller.field.value && getImageUrl(controller.field.value);\n\n return (\n <FormField\n label={field.displayName}\n required={field.validation?.required}\n status={controller.fieldState.error ? 'error' : undefined}\n statusMessage={controller.fieldState.error?.message}\n dataHook={dataHook}\n >\n <ImageViewer\n imageUrl={imageUrl}\n dataHook={`image-${field.id}`}\n onAddImage={isMobile ? undefined : () => openMedia()}\n onUpdateImage={isMobile ? undefined : () => openMedia()}\n updateImageInfo={t('cairo.replace-image.tooltip')}\n removeImageInfo={t('cairo.remove-image.tooltip')}\n addImageInfo={t('cairo.add-image.tooltip')}\n height=\"120px\"\n width=\"25%\"\n fit=\"cover\"\n onRemoveImage={() => controller.field.onChange(null)}\n />\n </FormField>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS,EAAEC,WAAW,QAAQ,oBAAoB;AAE3D,SACEC,oBAAoB,EACpBC,WAAW,EACXC,WAAW,EACXC,uBAAuB,QAClB,eAAe;AACtB,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,WAAW,QAAQ,kCAAkC;AAC9D,SAASC,SAAS,QAAQ,gBAAgB;AAI1C,OAAO,MAAMC,UAAU,GAAIC,KAAsB,IAAK;EAAA,IAAAC,iBAAA,EAAAC,kBAAA,EAAAC,qBAAA;EACpD,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAC,GAAGL,KAAK;EAEjC,MAAM;IAAEM,SAAS,EAAEC,CAAC;IAAE,GAAGC;EAAU,CAAC,GAAGb,uBAAuB,CAAC,CAAC;EAChED,WAAW,CAAC,MAAMc,SAAS,CAACC,QAAQ,CAACC,MAAM,CAAC;EAC5C,MAAMC,QAAQ,GAAGlB,WAAW,CAAC,CAAC;EAC9B,MAAMmB,SAAS,GAAGpB,oBAAoB,CAAC,CAAC;EAExC,eAAeqB,SAASA,CAAA,EAAG;IACzB,IAAI;MAAA,IAAAC,qBAAA;MACF,MAAMC,gBAAgB,GAAG,MAAMjB,SAAS,CAACkB,gBAAgB,CAAC;QACxDC,WAAW,EAAE,KAAK;QAClBC,QAAQ,EAAE;MACZ,CAAC,CAAC;MAEF,MAAMC,QAAQ,GAAGJ,gBAAgB,aAAAD,qBAAA,G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EE,KAAK,CAACiC,UAAU,qBAAhBnC,kBAAA,CAAkBoC,QAAS;IACrC5B,MAAM,EAAEa,UAAU,CAACqB,UAAU,CAACnB,KAAK,GAAG,OAAO,GAAGc,SAAU;IAC1DM,aAAa,GAAA1C,qBAAA,GAAEoB,UAAU,CAACqB,UAAU,CAACnB,KAAK,qBAA3BtB,qBAAA,CAA6B2C,OAAQ;IACpDzC,QAAQ,EAAEA;EAAS,gBAEnBhB,KAAA,CAAAoD,aAAA,CAAClD,WAAW;IACViD,QAAQ,EAAEA,QAAS;IACnBnC,QAAQ,EAAE,SAASD,KAAK,CAACwB,EAAE,EAAG;IAC9BmB,UAAU,EAAEpC,QAAQ,GAAG4B,SAAS,GAAG,MAAM1B,SAAS,CAAC,CAAE;IACrDmC,aAAa,EAAErC,QAAQ,GAAG4B,SAAS,GAAG,MAAM1B,SAAS,CAAC,CAAE;IACxDoC,eAAe,EAAE1C,CAAC,CAAC,6BAA6B,CAAE;IAClD2C,eAAe,EAAE3C,CAAC,CAAC,4BAA4B,CAAE;IACjD4C,YAAY,EAAE5C,CAAC,CAAC,yBAAyB,CAAE;IAC3C6C,MAAM,EAAC,OAAO;IACdC,KAAK,EAAC,KAAK;IACXC,GAAG,EAAC,OAAO;IACXC,aAAa,EAAEA,CAAA,KAAMhC,UAAU,CAACnB,KAAK,CAACoB,QAAQ,CAAC,IAAI;EAAE,CACtD,CACQ,CAAC;AAEhB,CAAC","ignoreList":[]}
@@ -3,6 +3,7 @@ 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;
6
7
  const {
7
8
  field,
8
9
  dataHook
@@ -14,12 +15,13 @@ export const LongText = props => {
14
15
  useSelector(() => container.initTask.status);
15
16
  const pageState = useEntityPageContext();
16
17
  const controller = useController({
17
- name: field?.id ?? '',
18
+ name: (field == null ? void 0 : field.id) ?? '',
18
19
  control: pageState.form.control,
19
- defaultValue: pageState.entity?.[field?.id ?? ''],
20
+ defaultValue: (_pageState$entity = pageState.entity) == null ? void 0 : _pageState$entity[(field == null ? void 0 : field.id) ?? ''],
20
21
  rules: {
21
22
  validate: value => {
22
- if (field.validation?.required && (value === null || value === undefined || value === '')) {
23
+ var _field$validation;
24
+ if ((_field$validation = field.validation) != null && _field$validation.required && (value === null || value === undefined || value === '')) {
23
25
  return t('cairo.fieldValidation.requiredField');
24
26
  }
25
27
  return true;
@@ -28,13 +30,13 @@ export const LongText = props => {
28
30
  });
29
31
  return /*#__PURE__*/React.createElement(FormField, {
30
32
  label: field.displayName,
31
- required: field.validation?.required,
33
+ required: (_field$validation2 = field.validation) == null ? void 0 : _field$validation2.required,
32
34
  status: controller.fieldState.error ? 'error' : undefined,
33
- statusMessage: controller.fieldState.error?.message,
35
+ statusMessage: (_controller$fieldStat = controller.fieldState.error) == null ? void 0 : _controller$fieldStat.message,
34
36
  dataHook: dataHook
35
37
  }, /*#__PURE__*/React.createElement(InputArea, {
36
38
  value: controller.field.value,
37
- onChange: e => controller.field.onChange?.(e.target.value),
39
+ onChange: e => controller.field.onChange == null ? void 0 : controller.field.onChange(e.target.value),
38
40
  onBlur: controller.field.onBlur,
39
41
  ref: controller.field.ref,
40
42
  dataHook: `long-text-${field.id}`
@@ -1 +1 @@
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":[]}
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,oBAAoB;AAIlD,OAAO,MAAMC,QAAQ,GAAIC,KAAoB,IAAK;EAAA,IAAAC,iBAAA,EAAAC,kBAAA,EAAAC,qBAAA;EAChD,MAAM;IAAEC,KAAK;IAAEC;EAA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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":[]}
@@ -3,6 +3,7 @@ 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;
6
7
  const {
7
8
  field,
8
9
  dataHook
@@ -13,16 +14,17 @@ export const Number = props => {
13
14
  } = useWixPatternsContainer();
14
15
  useSelector(() => container.initTask.status);
15
16
  const pageState = useEntityPageContext();
16
- const numberRange = field.validation?.numberRange;
17
- const min = numberRange?.min;
18
- const max = numberRange?.max;
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;
19
20
  const controller = useController({
20
- name: field?.id ?? '',
21
+ name: (field == null ? void 0 : field.id) ?? '',
21
22
  control: pageState.form.control,
22
- defaultValue: pageState.entity?.[field?.id ?? ''],
23
+ defaultValue: (_pageState$entity = pageState.entity) == null ? void 0 : _pageState$entity[(field == null ? void 0 : field.id) ?? ''],
23
24
  rules: {
24
25
  validate: value => {
25
- if (field.validation?.required && (value === null || value === undefined || value === '')) {
26
+ var _field$validation2;
27
+ if ((_field$validation2 = field.validation) != null && _field$validation2.required && (value === null || value === undefined || value === '')) {
26
28
  return t('cairo.fieldValidation.requiredField');
27
29
  }
28
30
  if (value !== null && value !== undefined) {
@@ -43,9 +45,9 @@ export const Number = props => {
43
45
  });
44
46
  return /*#__PURE__*/React.createElement(FormField, {
45
47
  label: field.displayName,
46
- required: field.validation?.required,
48
+ required: (_field$validation3 = field.validation) == null ? void 0 : _field$validation3.required,
47
49
  status: controller.fieldState.error ? 'error' : undefined,
48
- statusMessage: controller.fieldState.error?.message,
50
+ statusMessage: (_controller$fieldStat = controller.fieldState.error) == null ? void 0 : _controller$fieldStat.message,
49
51
  dataHook: dataHook
50
52
  }, /*#__PURE__*/React.createElement(NumberInput, {
51
53
  value: controller.field.value ?? undefined,
@@ -1 +1 @@
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,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CU,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":[]}
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,EAAAC,qBAAA;EAC5C,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAC,GAAGN,KAAK;EAEjC,MAAM;IAAEO,SAAS,EAAEC,CAAC;IAAE,GAAGC;EAAU,CAAC,GAAGZ,uBAAuB,CAAC,CAAC;EAChED,WAAW,CAAC,MAAMa,SAAS,CAACC,QAAQ,CAACC,MAAM,CAAC;EAE5C,MAAMC,SAAS,GAAGjB,oBAAoB,CAAC,CAAC;EAExC,MAAMkB,WAAW,IAAAZ,iBAAA,GAAGI,KAAK,CAACS,UAAU,qBAAhBb,iBAAA,CAAkBY,WAAW;EACjD,MAAME,GAAG,GAAGF,WAAW,oBAAXA,WAAW,CAAEE,GAAG;EAC5B,MAAMC,GAAG,GAAGH,WAAW,oBAAXA,WAAW,CAAEG,GAAG;EAE5B,MAAMC,UAAU,GAAGnB,aAAa,CAAC;IAC/BoB,IAAI,EAAE,CAAAb,KAAK,oBAALA,KAAK,CAAEc,EAAE,KAAI,EAAE;IACrBC,OAAO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AQ;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":[]}
@@ -3,6 +3,7 @@ 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;
6
7
  const {
7
8
  field,
8
9
  dataHook
@@ -13,16 +14,17 @@ export const ShortText = props => {
13
14
  } = useWixPatternsContainer();
14
15
  useSelector(() => container.initTask.status);
15
16
  const pageState = useEntityPageContext();
16
- const stringLengthRange = field.validation?.stringLengthRange;
17
- const minLength = stringLengthRange?.minLength;
18
- const maxLength = stringLengthRange?.maxLength;
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;
19
20
  const controller = useController({
20
- name: field?.id ?? '',
21
+ name: (field == null ? void 0 : field.id) ?? '',
21
22
  control: pageState.form.control,
22
- defaultValue: pageState.entity?.[field?.id ?? ''],
23
+ defaultValue: (_pageState$entity = pageState.entity) == null ? void 0 : _pageState$entity[(field == null ? void 0 : field.id) ?? ''],
23
24
  rules: {
24
25
  validate: value => {
25
- if (field.validation?.required && (value === null || value === undefined || value === '')) {
26
+ var _field$validation2;
27
+ if ((_field$validation2 = field.validation) != null && _field$validation2.required && (value === null || value === undefined || value === '')) {
26
28
  return t('cairo.fieldValidation.requiredField');
27
29
  }
28
30
  if (minLength && value && value.length < minLength) {
@@ -38,17 +40,17 @@ export const ShortText = props => {
38
40
  }
39
41
  }
40
42
  });
41
- const charCount = maxLength ? maxLength - controller.field.value?.length : undefined;
43
+ const charCount = maxLength ? maxLength - ((_controller$field$val = controller.field.value) == null ? void 0 : _controller$field$val.length) : undefined;
42
44
  return /*#__PURE__*/React.createElement(FormField, {
43
45
  label: field.displayName,
44
- required: field.validation?.required,
46
+ required: (_field$validation3 = field.validation) == null ? void 0 : _field$validation3.required,
45
47
  charCount: charCount,
46
48
  status: controller.fieldState.error ? 'error' : undefined,
47
- statusMessage: controller.fieldState.error?.message,
49
+ statusMessage: (_controller$fieldStat = controller.fieldState.error) == null ? void 0 : _controller$fieldStat.message,
48
50
  dataHook: dataHook
49
51
  }, /*#__PURE__*/React.createElement(Input, {
50
52
  value: controller.field.value,
51
- onChange: e => controller.field.onChange?.(e.target.value),
53
+ onChange: e => controller.field.onChange == null ? void 0 : controller.field.onChange(e.target.value),
52
54
  onBlur: controller.field.onBlur,
53
55
  dataHook: `short-text-${field.id}`,
54
56
  ref: controller.field.ref
@@ -1 +1 @@
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;I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GAAGC,UAAU,CAACZ,KAAK,CAACqB,KAAK,EAAEG,MAAM,GAC1CD,SAAS;EAEb,oBACEhC,KAAA,CAAAqC,aAAA,CAACpC,SAAS;IACRqC,KAAK,EAAE7B,KAAK,CAAC8B,WAAY;IACzBR,QAAQ,EAAEtB,KAAK,CAACS,UAAU,EAAEa,QAAS;IACrCK,SAAS,EAAEA,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":[]}
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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U,CAACZ,KAAK,CAACwC;EAAI,CAC3B,CACQ,CAAC;AAEhB,CAAC","ignoreList":[]}
@@ -4,6 +4,7 @@ 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;
7
8
  const {
8
9
  field,
9
10
  dataHook
@@ -20,12 +21,13 @@ export const Url = props => {
20
21
  // eslint-disable-next-line no-useless-escape
21
22
  /^[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._~\-%!$&'()*+,;=:@\/?]*)?$/;
22
23
  const controller = useController({
23
- name: field?.id ?? '',
24
+ name: (field == null ? void 0 : field.id) ?? '',
24
25
  control: pageState.form.control,
25
- defaultValue: pageState.entity?.[field?.id ?? ''],
26
+ defaultValue: (_pageState$entity = pageState.entity) == null ? void 0 : _pageState$entity[(field == null ? void 0 : field.id) ?? ''],
26
27
  rules: {
27
28
  validate: value => {
28
- if (field.validation?.required && (value === null || value === undefined || value === '')) {
29
+ var _field$validation;
30
+ if ((_field$validation = field.validation) != null && _field$validation.required && (value === null || value === undefined || value === '')) {
29
31
  return t('cairo.fieldValidation.requiredField');
30
32
  } else if (value) {
31
33
  return uriPattern.test(value) || t('cairo.customFields.url-input.error');
@@ -36,16 +38,16 @@ export const Url = props => {
36
38
  });
37
39
  return /*#__PURE__*/React.createElement(FormField, {
38
40
  label: field.displayName,
39
- required: field.validation?.required,
41
+ required: (_field$validation2 = field.validation) == null ? void 0 : _field$validation2.required,
40
42
  dataHook: dataHook,
41
43
  status: controller.fieldState.error ? 'error' : undefined,
42
- statusMessage: controller.fieldState.error?.message
44
+ statusMessage: (_controller$fieldStat = controller.fieldState.error) == null ? void 0 : _controller$fieldStat.message
43
45
  }, /*#__PURE__*/React.createElement(Input, {
44
46
  prefix: /*#__PURE__*/React.createElement(Input.IconAffix, null, /*#__PURE__*/React.createElement(Link, null)),
45
47
  placeholder: t('cairo.customFields.url-input.placeholder'),
46
48
  dataHook: `url-${field.id}`,
47
49
  value: controller.field.value,
48
- onChange: e => controller.field.onChange?.(e.target.value),
50
+ onChange: e => controller.field.onChange == null ? void 0 : controller.field.onChange(e.target.value),
49
51
  onBlur: controller.field.onBlur,
50
52
  ref: controller.field.ref
51
53
  }));
@@ -1 +1 @@
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,CAA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9B,IAAI,MAAE,CACQ,CAClB;IACDuC,WAAW,EAAE7B,CAAC,CAAC,0CAA0C,CAAE;IAC3DF,QAAQ,EAAE,OAAOD,KAAK,CAACW,EAAE,EAAG;IAC5BO,KAAK,EAAET,UAAU,CAACT,KAAK,CAACkB,KAAM;IAC9Be,QAAQ,EAAGC,CAAC,IAAKzB,UAAU,CAACT,KAAK,CAACiC,QAAQ,GAAGC,CAAC,CAACC,MAAM,CAACjB,KAAK,CAAE;IAC7DkB,MAAM,EAAE3B,UAAU,CAACT,KAAK,CAACoC,MAAO;IAChCC,GAAG,EAAE5B,UAAU,CAACT,KAAK,CAACqC;EAAI,CAC3B,CACQ,CAAC;AAEhB,CAAC","ignoreList":[]}
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"],"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;EAAA,IAAAC,iBAAA,EAAAC,kBAAA,EAAAC,qBAAA;EACtC,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAC,GAAGL,KAA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,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":[]}
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { Card, Layout } from '@wix/design-system';
3
+ import { EntityPage } from '@wix/patterns';
4
+ import { RenderLayoutContent } from './RenderLayoutContent';
5
+ export const RenderLayoutCard = _ref => {
6
+ var _layout$card$subtitle;
7
+ let {
8
+ layout,
9
+ sectionId,
10
+ cardIndex,
11
+ setInputRef
12
+ } = _ref;
13
+ switch (layout.type) {
14
+ case 'card':
15
+ return /*#__PURE__*/React.createElement(EntityPage.Card, {
16
+ minHeight: "50px"
17
+ }, /*#__PURE__*/React.createElement(Card.Header, {
18
+ title: layout.card.title.text,
19
+ subtitle: (_layout$card$subtitle = layout.card.subtitle) == null ? void 0 : _layout$card$subtitle.text
20
+ }), /*#__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, {
21
+ key: `${sectionId}-card-${cardIndex}-content-${index}`,
22
+ content: child,
23
+ level: 0,
24
+ sectionId: sectionId,
25
+ cardIndex: cardIndex,
26
+ contentIndex: index,
27
+ setInputRef: setInputRef
28
+ })))));
29
+ default:
30
+ return null;
31
+ }
32
+ };
33
+ //# sourceMappingURL=RenderLayoutCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Card","Layout","EntityPage","RenderLayoutContent","RenderLayoutCard","_ref","_layout$card$subtitle","layout","sectionId","cardIndex","setInputRef","type","createElement","minHeight","Header","title","card","text","subtitle","Divider","Content","children","map","child","index","key","content","level","contentIndex"],"sources":["../../../../../src/components/AutoPatternsEntityPage/RenderLayout/RenderLayoutCard.tsx"],"sourcesContent":["import React from 'react';\nimport { Card, Layout } from '@wix/design-system';\nimport { EntityPage } from '@wix/patterns';\nimport { RenderLayoutContent } from './RenderLayoutContent';\nimport { CardLayout } from '../../../types';\nimport { BaseInputRef } from '../Fields/types';\n\nexport interface RenderLayoutCardProps {\n layout: CardLayout;\n sectionId: string;\n cardIndex: number;\n setInputRef: (id: string, input: BaseInputRef) => void;\n}\n\nexport const RenderLayoutCard: React.FC<RenderLayoutCardProps> = ({\n layout,\n sectionId,\n cardIndex,\n setInputRef,\n}) => {\n switch (layout.type) {\n case 'card':\n return (\n <EntityPage.Card minHeight=\"50px\">\n <Card.Header\n title={layout.card.title.text}\n subtitle={layout.card.subtitle?.text}\n />\n <Card.Divider />\n <Card.Content>\n <Layout>\n {layout.card.children.map((child, index: number) => (\n <RenderLayoutContent\n key={`${sectionId}-card-${cardIndex}-content-${index}`}\n content={child}\n level={0}\n sectionId={sectionId}\n cardIndex={cardIndex}\n contentIndex={index}\n setInputRef={setInputRef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