@cloudscape-design/components 3.0.624 → 3.0.626

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 (168) hide show
  1. package/alert/index.d.ts.map +1 -1
  2. package/alert/index.js +9 -5
  3. package/alert/index.js.map +1 -1
  4. package/attribute-editor/interfaces.d.ts +4 -0
  5. package/attribute-editor/interfaces.d.ts.map +1 -1
  6. package/attribute-editor/interfaces.js.map +1 -1
  7. package/attribute-editor/row.d.ts.map +1 -1
  8. package/attribute-editor/row.js +4 -1
  9. package/attribute-editor/row.js.map +1 -1
  10. package/button/styles.css.js +19 -19
  11. package/button/styles.scoped.css +159 -151
  12. package/button/styles.selectors.js +19 -19
  13. package/container/index.js +1 -1
  14. package/container/index.js.map +1 -1
  15. package/date-picker/index.d.ts.map +1 -1
  16. package/date-picker/index.js +2 -2
  17. package/date-picker/index.js.map +1 -1
  18. package/date-range-picker/index.d.ts.map +1 -1
  19. package/date-range-picker/index.js +2 -2
  20. package/date-range-picker/index.js.map +1 -1
  21. package/drawer/styles.css.js +3 -3
  22. package/drawer/styles.scoped.css +13 -13
  23. package/drawer/styles.selectors.js +3 -3
  24. package/file-upload/interfaces.d.ts +14 -4
  25. package/file-upload/interfaces.d.ts.map +1 -1
  26. package/file-upload/interfaces.js.map +1 -1
  27. package/file-upload/internal.js +13 -7
  28. package/file-upload/internal.js.map +1 -1
  29. package/form/index.d.ts.map +1 -1
  30. package/form/index.js +17 -6
  31. package/form/index.js.map +1 -1
  32. package/form/internal.d.ts.map +1 -1
  33. package/form/internal.js +1 -14
  34. package/form/internal.js.map +1 -1
  35. package/form-field/index.d.ts.map +1 -1
  36. package/form-field/index.js +3 -2
  37. package/form-field/index.js.map +1 -1
  38. package/form-field/interfaces.d.ts +12 -1
  39. package/form-field/interfaces.d.ts.map +1 -1
  40. package/form-field/interfaces.js.map +1 -1
  41. package/form-field/internal.d.ts +9 -3
  42. package/form-field/internal.d.ts.map +1 -1
  43. package/form-field/internal.js +36 -11
  44. package/form-field/internal.js.map +1 -1
  45. package/form-field/styles.css.js +23 -19
  46. package/form-field/styles.scoped.css +45 -29
  47. package/form-field/styles.selectors.js +23 -19
  48. package/form-field/util.d.ts +3 -2
  49. package/form-field/util.d.ts.map +1 -1
  50. package/form-field/util.js +4 -3
  51. package/form-field/util.js.map +1 -1
  52. package/help-panel/styles.css.js +4 -4
  53. package/help-panel/styles.scoped.css +71 -71
  54. package/help-panel/styles.selectors.js +4 -4
  55. package/input/index.d.ts.map +1 -1
  56. package/input/index.js +2 -1
  57. package/input/index.js.map +1 -1
  58. package/input/internal.d.ts.map +1 -1
  59. package/input/internal.js +4 -1
  60. package/input/internal.js.map +1 -1
  61. package/input/styles.css.js +13 -12
  62. package/input/styles.scoped.css +46 -30
  63. package/input/styles.selectors.js +13 -12
  64. package/internal/analytics/components/analytics-funnel.d.ts +12 -12
  65. package/internal/analytics/components/analytics-funnel.d.ts.map +1 -1
  66. package/internal/analytics/components/analytics-funnel.js +38 -25
  67. package/internal/analytics/components/analytics-funnel.js.map +1 -1
  68. package/internal/analytics/context/analytics-context.d.ts +7 -2
  69. package/internal/analytics/context/analytics-context.d.ts.map +1 -1
  70. package/internal/analytics/context/analytics-context.js.map +1 -1
  71. package/internal/analytics/hooks/use-funnel.d.ts +5 -1
  72. package/internal/analytics/hooks/use-funnel.d.ts.map +1 -1
  73. package/internal/analytics/hooks/use-funnel.js +9 -5
  74. package/internal/analytics/hooks/use-funnel.js.map +1 -1
  75. package/internal/analytics/interfaces.d.ts +23 -37
  76. package/internal/analytics/interfaces.d.ts.map +1 -1
  77. package/internal/analytics/interfaces.js.map +1 -1
  78. package/internal/base-component/index.d.ts +1 -1
  79. package/internal/base-component/index.d.ts.map +1 -1
  80. package/internal/base-component/index.js +1 -1
  81. package/internal/base-component/index.js.map +1 -1
  82. package/internal/base-component/styles.scoped.css +20 -0
  83. package/internal/components/button-trigger/index.d.ts +1 -0
  84. package/internal/components/button-trigger/index.d.ts.map +1 -1
  85. package/internal/components/button-trigger/index.js +2 -2
  86. package/internal/components/button-trigger/index.js.map +1 -1
  87. package/internal/components/button-trigger/styles.css.js +11 -10
  88. package/internal/components/button-trigger/styles.scoped.css +35 -24
  89. package/internal/components/button-trigger/styles.selectors.js +11 -10
  90. package/internal/context/form-field-context.d.ts +14 -1
  91. package/internal/context/form-field-context.d.ts.map +1 -1
  92. package/internal/context/form-field-context.js +1 -1
  93. package/internal/context/form-field-context.js.map +1 -1
  94. package/internal/environment.js +1 -1
  95. package/internal/environment.json +1 -1
  96. package/internal/generated/styles/tokens.d.ts +5 -0
  97. package/internal/generated/styles/tokens.js +5 -0
  98. package/internal/generated/theming/index.cjs +75 -0
  99. package/internal/generated/theming/index.js +75 -0
  100. package/internal/manifest.json +1 -1
  101. package/link/internal.d.ts.map +1 -1
  102. package/link/internal.js +9 -3
  103. package/link/internal.js.map +1 -1
  104. package/modal/body-scroll.d.ts.map +1 -1
  105. package/modal/body-scroll.js +5 -0
  106. package/modal/body-scroll.js.map +1 -1
  107. package/package.json +1 -1
  108. package/select/parts/filter.d.ts +1 -1
  109. package/select/parts/filter.d.ts.map +1 -1
  110. package/select/parts/trigger.d.ts.map +1 -1
  111. package/select/parts/trigger.js +2 -2
  112. package/select/parts/trigger.js.map +1 -1
  113. package/side-navigation/styles.css.js +28 -28
  114. package/side-navigation/styles.scoped.css +44 -43
  115. package/side-navigation/styles.selectors.js +28 -28
  116. package/table/body-cell/disabled-inline-editor.d.ts +1 -1
  117. package/table/body-cell/disabled-inline-editor.d.ts.map +1 -1
  118. package/table/body-cell/disabled-inline-editor.js +2 -2
  119. package/table/body-cell/disabled-inline-editor.js.map +1 -1
  120. package/table/body-cell/index.d.ts +1 -0
  121. package/table/body-cell/index.d.ts.map +1 -1
  122. package/table/body-cell/index.js +2 -2
  123. package/table/body-cell/index.js.map +1 -1
  124. package/table/body-cell/styles.css.js +44 -43
  125. package/table/body-cell/styles.scoped.css +167 -165
  126. package/table/body-cell/styles.selectors.js +44 -43
  127. package/table/internal.d.ts.map +1 -1
  128. package/table/internal.js +1 -1
  129. package/table/internal.js.map +1 -1
  130. package/test-utils/dom/file-upload/index.d.ts +2 -0
  131. package/test-utils/dom/file-upload/index.js +6 -0
  132. package/test-utils/dom/file-upload/index.js.map +1 -1
  133. package/test-utils/dom/form-field/index.d.ts +1 -0
  134. package/test-utils/dom/form-field/index.js +3 -0
  135. package/test-utils/dom/form-field/index.js.map +1 -1
  136. package/test-utils/selectors/file-upload/index.d.ts +2 -0
  137. package/test-utils/selectors/file-upload/index.js +6 -0
  138. package/test-utils/selectors/file-upload/index.js.map +1 -1
  139. package/test-utils/selectors/form-field/index.d.ts +1 -0
  140. package/test-utils/selectors/form-field/index.js +3 -0
  141. package/test-utils/selectors/form-field/index.js.map +1 -1
  142. package/test-utils/tsconfig.tsbuildinfo +1 -1
  143. package/textarea/index.d.ts.map +1 -1
  144. package/textarea/index.js +2 -1
  145. package/textarea/index.js.map +1 -1
  146. package/textarea/styles.css.js +5 -4
  147. package/textarea/styles.scoped.css +23 -12
  148. package/textarea/styles.selectors.js +5 -4
  149. package/token-group/styles.css.js +9 -8
  150. package/token-group/styles.scoped.css +27 -16
  151. package/token-group/styles.selectors.js +9 -8
  152. package/token-group/token.d.ts +3 -1
  153. package/token-group/token.d.ts.map +1 -1
  154. package/token-group/token.js +8 -5
  155. package/token-group/token.js.map +1 -1
  156. package/wizard/analytics.d.ts +2 -1
  157. package/wizard/analytics.d.ts.map +1 -1
  158. package/wizard/analytics.js +7 -3
  159. package/wizard/analytics.js.map +1 -1
  160. package/wizard/index.js +1 -1
  161. package/wizard/index.js.map +1 -1
  162. package/wizard/internal.d.ts.map +1 -1
  163. package/wizard/internal.js +2 -2
  164. package/wizard/internal.js.map +1 -1
  165. package/wizard/wizard-form.d.ts +4 -2
  166. package/wizard/wizard-form.d.ts.map +1 -1
  167. package/wizard/wizard-form.js +31 -19
  168. package/wizard/wizard-form.js.map +1 -1
@@ -1 +1 @@
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AAW,GAAI,CACtE,CACI,CACf,CAAC,CAAC,CAAC,IAAI;QAEP,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAC9B,oBAAC,WAAW;YACV,oBAAC,SAAS,IACR,SAAS,EAAC,UAAU,EACpB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,CAC/B,oBAAC,KAAK,IACJ,SAAS,EAAE,IAAI,CAAC,IAAI,EACpB,YAAY,EAAE,WAAW,CAAC,mBAAmB,CAAC,SAAS,CAAC,EACxD,SAAS,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,EACxC,SAAS,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,SAAS,CAAC,EAClC,kBAAkB,EAAE,WAAW,CAAC,kBAAkB,gBACtC,SAAS;oBAErB,oBAAC,UAAU,IAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,GAAI,CAClE,CACT,EACD,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE;oBACX,cAAc,EAAE,WAAW,CAAC,cAAc;oBAC1C,aAAa,EAAE,WAAW,CAAC,aAAa;iBACzC,EACD,oBAAoB,EAAE,gBAAgB,GACtC,CACU,CACf,CAAC,CAAC,CAAC,IAAI,CACa,CACxB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { ForwardedRef, useRef, useState } from 'react';\nimport { FileUploadProps } from './interfaces';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\n\nimport { FileOption } from './file-option';\nimport { ButtonProps } from '../button/interfaces';\nimport InternalSpaceBetween from '../space-between/internal';\nimport styles from './styles.css.js';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { getBaseProps } from '../internal/base-component';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport clsx from 'clsx';\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport { Dropzone, useDropzoneVisible } from './dropzone';\nimport FileInput from './file-input';\nimport TokenList from '../internal/components/token-list';\nimport { Token } from '../token-group/token';\nimport { ConstraintText, FormFieldError } from '../form-field/internal';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { joinStrings } from '../internal/utils/strings';\nimport { useFormFieldContext } from '../contexts/form-field';\nimport InternalBox from '../box/internal';\n\ntype InternalFileUploadProps = FileUploadProps & InternalBaseComponentProps;\n\nexport default React.forwardRef(InternalFileUpload);\n\nfunction InternalFileUpload(\n {\n accept,\n ariaRequired,\n multiple = false,\n onChange,\n value,\n tokenLimit,\n showFileSize,\n showFileLastModified,\n showFileThumbnail,\n i18nStrings,\n __internalRootRef = null,\n constraintText,\n errorText,\n fileErrors,\n ...restProps\n }: InternalFileUploadProps,\n externalRef: ForwardedRef<ButtonProps.Ref>\n) {\n const baseProps = getBaseProps(restProps);\n const metadata = { showFileSize, showFileLastModified, showFileThumbnail };\n\n const errorId = useUniqueId('error-');\n const constraintTextId = useUniqueId('constraint-text-');\n\n const fileInputRef = useRef<ButtonProps.Ref>(null);\n const ref = useMergeRefs(fileInputRef, externalRef);\n\n const [removedFileIndex, setRemovedFileIndex] = useState<null | number>(null);\n\n checkControlled('FileUpload', 'value', value, 'onChange', onChange);\n\n if (!multiple && value.length > 1) {\n warnOnce('FileUpload', 'Value must be an array of size 0 or 1 when `multiple=false`.');\n }\n\n const handleFilesChange = (newFiles: File[]) => {\n const newValue = multiple ? [...value, ...newFiles] : newFiles[0] ? newFiles : [...value];\n fireNonCancelableEvent(onChange, { value: newValue });\n };\n\n const onFileRemove = (removeFileIndex: number) => {\n const newValue = value.filter((_, fileIndex) => fileIndex !== removeFileIndex);\n fireNonCancelableEvent(onChange, { value: newValue });\n setRemovedFileIndex(removeFileIndex);\n if (value.length === 1) {\n fileInputRef.current?.focus();\n }\n };\n\n const isDropzoneVisible = useDropzoneVisible(multiple);\n\n const formFieldContext = useFormFieldContext(restProps);\n const ariaDescribedBy = joinStrings(\n restProps.ariaDescribedby ?? formFieldContext.ariaDescribedby,\n errorText ? errorId : undefined,\n constraintText ? constraintTextId : undefined\n );\n\n const hasError = Boolean(errorText || fileErrors?.filter(Boolean).length);\n const invalid = restProps.invalid || formFieldContext.invalid || hasError;\n\n return (\n <InternalSpaceBetween\n {...baseProps}\n size=\"xs\"\n className={clsx(baseProps.className, styles.root)}\n __internalRootRef={__internalRootRef}\n >\n <InternalBox>\n {isDropzoneVisible ? (\n <Dropzone onChange={handleFilesChange}>{i18nStrings.dropzoneText(multiple)}</Dropzone>\n ) : (\n <FileInput\n ref={ref}\n accept={accept}\n ariaRequired={ariaRequired}\n multiple={multiple}\n onChange={handleFilesChange}\n value={value}\n {...restProps}\n ariaDescribedby={ariaDescribedBy}\n invalid={invalid}\n >\n {i18nStrings.uploadButtonText(multiple)}\n </FileInput>\n )}\n\n {(constraintText || errorText) && (\n <div className={styles.hints}>\n {errorText && (\n <FormFieldError id={errorId} errorIconAriaLabel={i18nStrings?.errorIconAriaLabel}>\n {errorText}\n </FormFieldError>\n )}\n {constraintText && (\n <ConstraintText id={constraintTextId} hasError={!!errorText}>\n {constraintText}\n </ConstraintText>\n )}\n </div>\n )}\n </InternalBox>\n\n {!multiple && value.length > 0 ? (\n <InternalBox>\n <Token\n ariaLabel={value[0].name}\n dismissLabel={i18nStrings.removeFileAriaLabel(0)}\n onDismiss={() => onFileRemove(0)}\n errorText={fileErrors?.[0]}\n errorIconAriaLabel={i18nStrings.errorIconAriaLabel}\n data-index={0}\n >\n <FileOption file={value[0]} metadata={metadata} i18nStrings={i18nStrings} />\n </Token>\n </InternalBox>\n ) : null}\n\n {multiple && value.length > 0 ? (\n <InternalBox>\n <TokenList\n alignment=\"vertical\"\n items={value}\n renderItem={(file, fileIndex) => (\n <Token\n ariaLabel={file.name}\n dismissLabel={i18nStrings.removeFileAriaLabel(fileIndex)}\n onDismiss={() => onFileRemove(fileIndex)}\n errorText={fileErrors?.[fileIndex]}\n errorIconAriaLabel={i18nStrings.errorIconAriaLabel}\n data-index={fileIndex}\n >\n <FileOption file={file} metadata={metadata} i18nStrings={i18nStrings} />\n </Token>\n )}\n limit={tokenLimit}\n i18nStrings={{\n limitShowFewer: i18nStrings.limitShowFewer,\n limitShowMore: i18nStrings.limitShowMore,\n }}\n moveFocusNextToIndex={removedFileIndex}\n />\n </InternalBox>\n ) : null}\n </InternalSpaceBetween>\n );\n}\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/file-upload/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAAgB,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAI9D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAC7D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,eAAe,MAAM,oCAAoC,CAAC;AACjE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,SAAS,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,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,EAAE,CAAC,CAC/B,oBAAC,KAAK,IACJ,SAAS,EAAE,IAAI,CAAC,IAAI,EACpB,YAAY,EAAE,WAAW,CAAC,mBAAmB,CAAC,SAAS,CAAC,EACxD,SAAS,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,EACxC,SAAS,EAAE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,SAAS,CAAC,EAClC,WAAW,EAAE,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,SAAS,CAAC,EACtC,kBAAkB,EAAE,WAAW,CAAC,kBAAkB,EAClD,oBAAoB,EAAE,WAAW,CAAC,oBAAoB,gBAC1C,SAAS;oBAErB,oBAAC,UAAU,IAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,GAAI,CAClE,CACT,EACD,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE;oBACX,cAAc,EAAE,WAAW,CAAC,cAAc;oBAC1C,aAAa,EAAE,WAAW,CAAC,aAAa;iBACzC,EACD,oBAAoB,EAAE,gBAAgB,GACtC,CACU,CACf,CAAC,CAAC,CAAC,IAAI,CACa,CACxB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { ForwardedRef, useRef, useState } from 'react';\nimport { FileUploadProps } from './interfaces';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\n\nimport { FileOption } from './file-option';\nimport { ButtonProps } from '../button/interfaces';\nimport InternalSpaceBetween from '../space-between/internal';\nimport styles from './styles.css.js';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { getBaseProps } from '../internal/base-component';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport clsx from 'clsx';\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport { Dropzone, useDropzoneVisible } from './dropzone';\nimport FileInput from './file-input';\nimport TokenList from '../internal/components/token-list';\nimport { Token } from '../token-group/token';\nimport { ConstraintText, FormFieldError, FormFieldWarning } from '../form-field/internal';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { joinStrings } from '../internal/utils/strings';\nimport { useFormFieldContext } from '../contexts/form-field';\nimport InternalBox from '../box/internal';\n\ntype InternalFileUploadProps = FileUploadProps & InternalBaseComponentProps;\n\nexport default React.forwardRef(InternalFileUpload);\n\nfunction InternalFileUpload(\n {\n accept,\n ariaRequired,\n multiple = false,\n onChange,\n value,\n tokenLimit,\n showFileSize,\n showFileLastModified,\n showFileThumbnail,\n i18nStrings,\n __internalRootRef = null,\n constraintText,\n errorText,\n warningText,\n fileErrors,\n fileWarnings,\n ...restProps\n }: InternalFileUploadProps,\n externalRef: ForwardedRef<ButtonProps.Ref>\n) {\n const baseProps = getBaseProps(restProps);\n const metadata = { showFileSize, showFileLastModified, showFileThumbnail };\n\n const errorId = useUniqueId('error-');\n const warningId = useUniqueId('warning-');\n const constraintTextId = useUniqueId('constraint-text-');\n\n const fileInputRef = useRef<ButtonProps.Ref>(null);\n const ref = useMergeRefs(fileInputRef, externalRef);\n\n const [removedFileIndex, setRemovedFileIndex] = useState<null | number>(null);\n\n checkControlled('FileUpload', 'value', value, 'onChange', onChange);\n\n if (!multiple && value.length > 1) {\n warnOnce('FileUpload', 'Value must be an array of size 0 or 1 when `multiple=false`.');\n }\n\n const handleFilesChange = (newFiles: File[]) => {\n const newValue = multiple ? [...value, ...newFiles] : newFiles[0] ? newFiles : [...value];\n fireNonCancelableEvent(onChange, { value: newValue });\n };\n\n const onFileRemove = (removeFileIndex: number) => {\n const newValue = value.filter((_, fileIndex) => fileIndex !== removeFileIndex);\n fireNonCancelableEvent(onChange, { value: newValue });\n setRemovedFileIndex(removeFileIndex);\n if (value.length === 1) {\n fileInputRef.current?.focus();\n }\n };\n\n const isDropzoneVisible = useDropzoneVisible(multiple);\n\n const showWarning = warningText && !errorText;\n\n if (warningText && errorText) {\n warnOnce('FileUpload', 'Both `errorText` and `warningText` exist. `warningText` will not be shown.');\n }\n\n const formFieldContext = useFormFieldContext(restProps);\n const ariaDescribedBy = joinStrings(\n restProps.ariaDescribedby ?? formFieldContext.ariaDescribedby,\n errorText ? errorId : undefined,\n showWarning ? warningId : undefined,\n constraintText ? constraintTextId : undefined\n );\n\n const hasError = Boolean(errorText || fileErrors?.filter(Boolean).length);\n const invalid = restProps.invalid || formFieldContext.invalid || hasError;\n\n return (\n <InternalSpaceBetween\n {...baseProps}\n size=\"xs\"\n className={clsx(baseProps.className, styles.root)}\n __internalRootRef={__internalRootRef}\n >\n <InternalBox>\n {isDropzoneVisible ? (\n <Dropzone onChange={handleFilesChange}>{i18nStrings.dropzoneText(multiple)}</Dropzone>\n ) : (\n <FileInput\n ref={ref}\n accept={accept}\n ariaRequired={ariaRequired}\n multiple={multiple}\n onChange={handleFilesChange}\n value={value}\n {...restProps}\n ariaDescribedby={ariaDescribedBy}\n invalid={invalid}\n >\n {i18nStrings.uploadButtonText(multiple)}\n </FileInput>\n )}\n\n {(constraintText || errorText || warningText) && (\n <div className={styles.hints}>\n {errorText && (\n <FormFieldError id={errorId} errorIconAriaLabel={i18nStrings?.errorIconAriaLabel}>\n {errorText}\n </FormFieldError>\n )}\n {showWarning && (\n <FormFieldWarning id={warningId} warningIconAriaLabel={i18nStrings?.warningIconAriaLabel}>\n {warningText}\n </FormFieldWarning>\n )}\n {constraintText && (\n <ConstraintText id={constraintTextId} hasValidationText={!!errorText || !!warningText}>\n {constraintText}\n </ConstraintText>\n )}\n </div>\n )}\n </InternalBox>\n\n {!multiple && value.length > 0 ? (\n <InternalBox>\n <Token\n ariaLabel={value[0].name}\n dismissLabel={i18nStrings.removeFileAriaLabel(0)}\n onDismiss={() => onFileRemove(0)}\n errorText={fileErrors?.[0]}\n warningText={fileWarnings?.[0]}\n errorIconAriaLabel={i18nStrings.errorIconAriaLabel}\n warningIconAriaLabel={i18nStrings.warningIconAriaLabel}\n data-index={0}\n >\n <FileOption file={value[0]} metadata={metadata} i18nStrings={i18nStrings} />\n </Token>\n </InternalBox>\n ) : null}\n\n {multiple && value.length > 0 ? (\n <InternalBox>\n <TokenList\n alignment=\"vertical\"\n items={value}\n renderItem={(file, fileIndex) => (\n <Token\n ariaLabel={file.name}\n dismissLabel={i18nStrings.removeFileAriaLabel(fileIndex)}\n onDismiss={() => onFileRemove(fileIndex)}\n errorText={fileErrors?.[fileIndex]}\n warningText={fileWarnings?.[fileIndex]}\n errorIconAriaLabel={i18nStrings.errorIconAriaLabel}\n warningIconAriaLabel={i18nStrings.warningIconAriaLabel}\n data-index={fileIndex}\n >\n <FileOption file={file} metadata={metadata} i18nStrings={i18nStrings} />\n </Token>\n )}\n limit={tokenLimit}\n i18nStrings={{\n limitShowFewer: i18nStrings.limitShowFewer,\n limitShowMore: i18nStrings.limitShowMore,\n }}\n moveFocusNextToIndex={removedFileIndex}\n />\n </InternalBox>\n ) : null}\n </InternalSpaceBetween>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/form/index.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAYzC,OAAO,EAAE,SAAS,EAAE,CAAC;AAoBrB,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAAE,OAAqB,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,eAyB1E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/form/index.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAazC,OAAO,EAAE,SAAS,EAAE,CAAC;AA+CrB,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAAE,OAAqB,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,eAyB1E"}
package/form/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { __rest } from "tslib";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import React from 'react';
4
+ import React, { useEffect } from 'react';
5
5
  import { applyDisplayName } from '../internal/utils/apply-display-name';
6
6
  import InternalForm from './internal';
7
7
  import useBaseComponent from '../internal/hooks/use-base-component';
@@ -11,9 +11,10 @@ import { useFunnel, useFunnelNameSelector, useFunnelStep } from '../internal/ana
11
11
  import formStyles from './styles.css.js';
12
12
  import headerStyles from '../header/styles.css.js';
13
13
  import { getAnalyticsMetadataProps } from '../internal/base-component';
14
+ import { FunnelMetrics } from '../internal/analytics';
14
15
  const FormWithAnalytics = (_a) => {
15
- var { variant = 'full-page', actions } = _a, props = __rest(_a, ["variant", "actions"]);
16
- const { funnelProps, funnelSubmit, funnelNextOrSubmitAttempt } = useFunnel();
16
+ var { variant = 'full-page', actions, errorText } = _a, props = __rest(_a, ["variant", "actions", "errorText"]);
17
+ const { funnelIdentifier, funnelInteractionId, funnelProps, funnelSubmit, funnelNextOrSubmitAttempt, errorCount, submissionAttempt, funnelErrorContext, } = useFunnel();
17
18
  const { funnelStepProps } = useFunnelStep();
18
19
  const handleActionButtonClick = ({ variant }) => {
19
20
  if (variant === 'primary') {
@@ -21,8 +22,18 @@ const FormWithAnalytics = (_a) => {
21
22
  funnelSubmit();
22
23
  }
23
24
  };
25
+ useEffect(() => {
26
+ if (funnelInteractionId && errorText) {
27
+ errorCount.current++;
28
+ FunnelMetrics.funnelError({ funnelInteractionId, funnelIdentifier, funnelErrorContext });
29
+ return () => {
30
+ // eslint-disable-next-line react-hooks/exhaustive-deps
31
+ errorCount.current--;
32
+ };
33
+ }
34
+ }, [funnelInteractionId, funnelIdentifier, errorText, submissionAttempt, errorCount, funnelErrorContext]);
24
35
  return (React.createElement(ButtonContext.Provider, { value: { onClick: handleActionButtonClick } },
25
- React.createElement(InternalForm, Object.assign({ variant: variant, actions: actions }, props, funnelProps, funnelStepProps))));
36
+ React.createElement(InternalForm, Object.assign({ variant: variant, actions: actions, errorText: errorText }, props, funnelProps, funnelStepProps))));
26
37
  };
27
38
  export default function Form(_a) {
28
39
  var { variant = 'full-page' } = _a, props = __rest(_a, ["variant"]);
@@ -30,8 +41,8 @@ export default function Form(_a) {
30
41
  const baseComponentProps = useBaseComponent('Form', { props: { variant } }, analyticsMetadata);
31
42
  const inheritedFunnelNameSelector = useFunnelNameSelector();
32
43
  const funnelNameSelector = inheritedFunnelNameSelector || `.${headerStyles['heading-text']}`;
33
- return (React.createElement(AnalyticsFunnel, { instanceIdentifier: analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.instanceIdentifier, flowType: analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.flowType, errorContext: analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.errorContext, funnelType: "single-page", optionalStepNumbers: [], totalFunnelSteps: 1, funnelNameSelectors: [funnelNameSelector, `.${formStyles.header}`] },
34
- React.createElement(AnalyticsFunnelStep, { instanceIdentifier: analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.instanceIdentifier, errorContext: analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.errorContext, stepNumber: 1 },
44
+ return (React.createElement(AnalyticsFunnel, { funnelIdentifier: analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.instanceIdentifier, funnelFlowType: analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.flowType, funnelErrorContext: analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.errorContext, funnelType: "single-page", optionalStepNumbers: [], totalFunnelSteps: 1, funnelNameSelectors: [funnelNameSelector, `.${formStyles.header}`] },
45
+ React.createElement(AnalyticsFunnelStep, { stepIdentifier: analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.instanceIdentifier, stepErrorContext: analyticsMetadata === null || analyticsMetadata === void 0 ? void 0 : analyticsMetadata.errorContext, stepNumber: 1 },
35
46
  React.createElement(FormWithAnalytics, Object.assign({ variant: variant }, props, baseComponentProps)))));
36
47
  }
37
48
  applyDisplayName(Form, 'Form');
package/form/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/form/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,YAAY,MAAM,YAAY,CAAC;AACtC,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AACzG,OAAO,EAAE,aAAa,EAAsB,MAAM,oCAAoC,CAAC;AACvF,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAEzG,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,YAAY,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAkC,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAIvG,MAAM,iBAAiB,GAAG,CAAC,EAAuD,EAAE,EAAE;QAA3D,EAAE,OAAO,GAAG,WAAW,EAAE,OAAO,OAAuB,EAAlB,KAAK,cAA1C,sBAA4C,CAAF;IACnE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,yBAAyB,EAAE,GAAG,SAAS,EAAE,CAAC;IAC7E,MAAM,EAAE,eAAe,EAAE,GAAG,aAAa,EAAE,CAAC;IAE5C,MAAM,uBAAuB,GAAkC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;QAC7E,IAAI,OAAO,KAAK,SAAS,EAAE;YACzB,yBAAyB,EAAE,CAAC;YAC5B,YAAY,EAAE,CAAC;SAChB;IACH,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,aAAa,CAAC,Q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AAE,CAAC;YAEb,oBAAC,iBAAiB,kBAAC,OAAO,EAAE,OAAO,IAAM,KAAK,EAAM,kBAAkB,EAAI,CACtD,CACN,CACnB,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { FormProps } from './interfaces';\nimport InternalForm from './internal';\nimport useBaseComponent from '../internal/hooks/use-base-component';\n\nimport { AnalyticsFunnel, AnalyticsFunnelStep } from '../internal/analytics/components/analytics-funnel';\nimport { ButtonContext, ButtonContextProps } from '../internal/context/button-context';\nimport { useFunnel, useFunnelNameSelector, useFunnelStep } from '../internal/analytics/hooks/use-funnel';\n\nimport formStyles from './styles.css.js';\nimport headerStyles from '../header/styles.css.js';\nimport { BasePropsWithAnalyticsMetadata, getAnalyticsMetadataProps } from '../internal/base-component';\n\nexport { FormProps };\n\nconst FormWithAnalytics = ({ variant = 'full-page', actions, ...props }: FormProps) => {\n const { funnelProps, funnelSubmit, funnelNextOrSubmitAttempt } = useFunnel();\n const { funnelStepProps } = useFunnelStep();\n\n const handleActionButtonClick: ButtonContextProps['onClick'] = ({ variant }) => {\n if (variant === 'primary') {\n funnelNextOrSubmitAttempt();\n funnelSubmit();\n }\n };\n\n return (\n <ButtonContext.Provider value={{ onClick: handleActionButtonClick }}>\n <InternalForm variant={variant} actions={actions} {...props} {...funnelProps} {...funnelStepProps} />\n </ButtonContext.Provider>\n );\n};\n\nexport default function Form({ variant = 'full-page', ...props }: FormProps) {\n const analyticsMetadata = getAnalyticsMetadataProps(props as BasePropsWithAnalyticsMetadata);\n const baseComponentProps = useBaseComponent('Form', { props: { variant } }, analyticsMetadata);\n const inheritedFunnelNameSelector = useFunnelNameSelector();\n const funnelNameSelector = inheritedFunnelNameSelector || `.${headerStyles['heading-text']}`;\n\n return (\n <AnalyticsFunnel\n instanceIdentifier={analyticsMetadata?.instanceIdentifier}\n flowType={analyticsMetadata?.flowType}\n errorContext={analyticsMetadata?.errorContext}\n funnelType=\"single-page\"\n optionalStepNumbers={[]}\n totalFunnelSteps={1}\n funnelNameSelectors={[funnelNameSelector, `.${formStyles.header}`]}\n >\n <AnalyticsFunnelStep\n instanceIdentifier={analyticsMetadata?.instanceIdentifier}\n errorContext={analyticsMetadata?.errorContext}\n stepNumber={1}\n >\n <FormWithAnalytics variant={variant} {...props} {...baseComponentProps} />\n </AnalyticsFunnelStep>\n </AnalyticsFunnel>\n );\n}\n\napplyDisplayName(Form, 'Form');\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/form/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,YAAY,MAAM,YAAY,CAAC;AACtC,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AACzG,OAAO,EAAE,aAAa,EAAsB,MAAM,oCAAoC,CAAC;AACvF,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAEzG,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,YAAY,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAkC,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvG,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAItD,MAAM,iBAAiB,GAAG,CAAC,EAAkE,EAAE,EAAE;QAAtE,EAAE,OAAO,GAAG,WAAW,EAAE,OAAO,EAAE,SAAS,OAAuB,EAAlB,KAAK,cAArD,mCAAuD,CAAF;IAC9E,M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7F,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,iBAAiB,CAAC,CAAC;IAC/F,MAAM,2BAA2B,GAAG,qBAAqB,EAAE,CAAC;IAC5D,MAAM,kBAAkB,GAAG,2BAA2B,IAAI,IAAI,YAAY,CAAC,cAAc,CAAC,EAAE,CAAC;IAE7F,OAAO,CACL,oBAAC,eAAe,IACd,gBAAgB,EAAE,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,kBAAkB,EACvD,cAAc,EAAE,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,QAAQ,EAC3C,kBAAkB,EAAE,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,YAAY,EACnD,UAAU,EAAC,aAAa,EACxB,mBAAmB,EAAE,EAAE,EACvB,gBAAgB,EAAE,CAAC,EACnB,mBAAmB,EAAE,CAAC,kBAAkB,EAAE,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;QAElE,oBAAC,mBAAmB,IAClB,cAAc,EAAE,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,kBAAkB,EACrD,gBAAgB,EAAE,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,YAAY,EACjD,UAAU,EAAE,CAAC;YAEb,oBAAC,iBAAiB,kBAAC,OAAO,EAAE,OAAO,IAAM,KAAK,EAAM,kBAAkB,EAAI,CACtD,CACN,CACnB,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect } from 'react';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { FormProps } from './interfaces';\nimport InternalForm from './internal';\nimport useBaseComponent from '../internal/hooks/use-base-component';\n\nimport { AnalyticsFunnel, AnalyticsFunnelStep } from '../internal/analytics/components/analytics-funnel';\nimport { ButtonContext, ButtonContextProps } from '../internal/context/button-context';\nimport { useFunnel, useFunnelNameSelector, useFunnelStep } from '../internal/analytics/hooks/use-funnel';\n\nimport formStyles from './styles.css.js';\nimport headerStyles from '../header/styles.css.js';\nimport { BasePropsWithAnalyticsMetadata, getAnalyticsMetadataProps } from '../internal/base-component';\nimport { FunnelMetrics } from '../internal/analytics';\n\nexport { FormProps };\n\nconst FormWithAnalytics = ({ variant = 'full-page', actions, errorText, ...props }: FormProps) => {\n const {\n funnelIdentifier,\n funnelInteractionId,\n funnelProps,\n funnelSubmit,\n funnelNextOrSubmitAttempt,\n errorCount,\n submissionAttempt,\n funnelErrorContext,\n } = useFunnel();\n const { funnelStepProps } = useFunnelStep();\n\n const handleActionButtonClick: ButtonContextProps['onClick'] = ({ variant }) => {\n if (variant === 'primary') {\n funnelNextOrSubmitAttempt();\n funnelSubmit();\n }\n };\n\n useEffect(() => {\n if (funnelInteractionId && errorText) {\n errorCount.current++;\n FunnelMetrics.funnelError({ funnelInteractionId, funnelIdentifier, funnelErrorContext });\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n errorCount.current--;\n };\n }\n }, [funnelInteractionId, funnelIdentifier, errorText, submissionAttempt, errorCount, funnelErrorContext]);\n\n return (\n <ButtonContext.Provider value={{ onClick: handleActionButtonClick }}>\n <InternalForm\n variant={variant}\n actions={actions}\n errorText={errorText}\n {...props}\n {...funnelProps}\n {...funnelStepProps}\n />\n </ButtonContext.Provider>\n );\n};\n\nexport default function Form({ variant = 'full-page', ...props }: FormProps) {\n const analyticsMetadata = getAnalyticsMetadataProps(props as BasePropsWithAnalyticsMetadata);\n const baseComponentProps = useBaseComponent('Form', { props: { variant } }, analyticsMetadata);\n const inheritedFunnelNameSelector = useFunnelNameSelector();\n const funnelNameSelector = inheritedFunnelNameSelector || `.${headerStyles['heading-text']}`;\n\n return (\n <AnalyticsFunnel\n funnelIdentifier={analyticsMetadata?.instanceIdentifier}\n funnelFlowType={analyticsMetadata?.flowType}\n funnelErrorContext={analyticsMetadata?.errorContext}\n funnelType=\"single-page\"\n optionalStepNumbers={[]}\n totalFunnelSteps={1}\n funnelNameSelectors={[funnelNameSelector, `.${formStyles.header}`]}\n >\n <AnalyticsFunnelStep\n stepIdentifier={analyticsMetadata?.instanceIdentifier}\n stepErrorContext={analyticsMetadata?.errorContext}\n stepNumber={1}\n >\n <FormWithAnalytics variant={variant} {...props} {...baseComponentProps} />\n </AnalyticsFunnelStep>\n </AnalyticsFunnel>\n );\n}\n\napplyDisplayName(Form, 'Form');\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/form/internal.tsx"],"names":[],"mappings":";AASA,OAAO,EAAmB,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAOlF,KAAK,iBAAiB,GAAG,SAAS,GAAG,0BAA0B,CAAC;AAEhE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,QAAQ,EACR,MAAM,EACN,SAAS,EACT,kBAAkB,EAAE,0BAA0B,EAC9C,OAAO,EACP,gBAAgB,EAChB,OAAO,EACP,iBAAiB,EACjB,GAAG,KAAK,EACT,EAAE,iBAAiB,eAkDnB"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/form/internal.tsx"],"names":[],"mappings":";AASA,OAAO,EAAmB,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAIlF,KAAK,iBAAiB,GAAG,SAAS,GAAG,0BAA0B,CAAC;AAEhE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,QAAQ,EACR,MAAM,EACN,SAAS,EACT,kBAAkB,EAAE,0BAA0B,EAC9C,OAAO,EACP,gBAAgB,EAChB,OAAO,EACP,iBAAiB,EACjB,GAAG,KAAK,EACT,EAAE,iBAAiB,eAqCnB"}
package/form/internal.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { __rest } from "tslib";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import React, { useEffect } from 'react';
4
+ import React from 'react';
5
5
  import clsx from 'clsx';
6
6
  import { getBaseProps } from '../internal/base-component';
7
7
  import InternalAlert from '../alert/internal';
@@ -10,24 +10,11 @@ import InternalContentLayout from '../content-layout/internal';
10
10
  import styles from './styles.css.js';
11
11
  import LiveRegion from '../internal/components/live-region';
12
12
  import { useInternalI18n } from '../i18n/context';
13
- import { useFunnel } from '../internal/analytics/hooks/use-funnel';
14
- import { FunnelMetrics } from '../internal/analytics';
15
13
  export default function InternalForm(_a) {
16
14
  var { children, header, errorText, errorIconAriaLabel: errorIconAriaLabelOverride, actions, secondaryActions, variant, __internalRootRef } = _a, props = __rest(_a, ["children", "header", "errorText", "errorIconAriaLabel", "actions", "secondaryActions", "variant", "__internalRootRef"]);
17
15
  const baseProps = getBaseProps(props);
18
16
  const i18n = useInternalI18n('form');
19
17
  const errorIconAriaLabel = i18n('errorIconAriaLabel', errorIconAriaLabelOverride);
20
- const { funnelInteractionId, submissionAttempt, errorCount } = useFunnel();
21
- useEffect(() => {
22
- if (funnelInteractionId && errorText) {
23
- errorCount.current++;
24
- FunnelMetrics.funnelError({ funnelInteractionId });
25
- return () => {
26
- // eslint-disable-next-line react-hooks/exhaustive-deps
27
- errorCount.current--;
28
- };
29
- }
30
- }, [funnelInteractionId, errorText, submissionAttempt, errorCount]);
31
18
  return (React.createElement("div", Object.assign({}, baseProps, { ref: __internalRootRef, className: clsx(styles.root, baseProps.className) }),
32
19
  React.createElement(FormLayout, { header: header && React.createElement("div", { className: clsx(styles.header, variant === 'full-page' && styles['full-page']) }, header), variant: variant },
33
20
  children && React.createElement("div", { className: styles.content }, children),
@@ -1 +1 @@
1
- {"version":3,"file":"internal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AAS,CACrB,CACd,CACU,CACT,CACP,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAmB;IAChE,OAAO,OAAO,KAAK,WAAW,IAAI,MAAM,CAAC,CAAC,CAAC,CACzC,oBAAC,qBAAqB,IAAC,MAAM,EAAE,MAAM,IAAG,QAAQ,CAAyB,CAC1E,CAAC,CAAC,CAAC,CACF;QACG,MAAM;QACN,QAAQ,CACR,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect } from 'react';\nimport clsx from 'clsx';\nimport { getBaseProps } from '../internal/base-component';\nimport InternalAlert from '../alert/internal';\nimport InternalBox from '../box/internal';\nimport InternalContentLayout from '../content-layout/internal';\nimport styles from './styles.css.js';\nimport { FormLayoutProps, FormProps } from './interfaces';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport LiveRegion from '../internal/components/live-region';\nimport { useInternalI18n } from '../i18n/context';\n\nimport { useFunnel } from '../internal/analytics/hooks/use-funnel';\nimport { FunnelMetrics } from '../internal/analytics';\n\ntype InternalFormProps = FormProps & InternalBaseComponentProps;\n\nexport default function InternalForm({\n children,\n header,\n errorText,\n errorIconAriaLabel: errorIconAriaLabelOverride,\n actions,\n secondaryActions,\n variant,\n __internalRootRef,\n ...props\n}: InternalFormProps) {\n const baseProps = getBaseProps(props);\n const i18n = useInternalI18n('form');\n const errorIconAriaLabel = i18n('errorIconAriaLabel', errorIconAriaLabelOverride);\n\n const { funnelInteractionId, submissionAttempt, errorCount } = useFunnel();\n\n useEffect(() => {\n if (funnelInteractionId && errorText) {\n errorCount.current++;\n FunnelMetrics.funnelError({ funnelInteractionId });\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n errorCount.current--;\n };\n }\n }, [funnelInteractionId, errorText, submissionAttempt, errorCount]);\n\n return (\n <div {...baseProps} ref={__internalRootRef} className={clsx(styles.root, baseProps.className)}>\n <FormLayout\n header={\n header && <div className={clsx(styles.header, variant === 'full-page' && styles['full-page'])}>{header}</div>\n }\n variant={variant}\n >\n {children && <div className={styles.content}>{children}</div>}\n {errorText && (\n <InternalBox margin={{ top: 'l' }}>\n <InternalAlert type=\"error\" statusIconAriaLabel={errorIconAriaLabel}>\n <div className={styles.error}>{errorText}</div>\n </InternalAlert>\n </InternalBox>\n )}\n {(actions || secondaryActions) && (\n <div className={styles.footer}>\n <div className={styles['actions-section']}>\n {actions && <div className={styles.actions}>{actions}</div>}\n {secondaryActions && <div className={styles['secondary-actions']}>{secondaryActions}</div>}\n </div>\n </div>\n )}\n {errorText && (\n <LiveRegion assertive={true}>\n {errorIconAriaLabel}, {errorText}\n </LiveRegion>\n )}\n </FormLayout>\n </div>\n );\n}\n\nfunction FormLayout({ children, header, variant }: FormLayoutProps) {\n return variant === 'full-page' && header ? (\n <InternalContentLayout header={header}>{children}</InternalContentLayout>\n ) : (\n <>\n {header}\n {children}\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/form/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,qBAAqB,MAAM,4BAA4B,CAAC;AAC/D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAGrC,OAAO,UAAU,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAIlD,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAUjB;QAViB,EACnC,QAAQ,EACR,MAAM,EACN,SAAS,EAC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IAAG,gBAAgB,CAAO,CACtF,CACF,CACP;YACA,SAAS,IAAI,CACZ,oBAAC,UAAU,IAAC,SAAS,EAAE,IAAI;gBACxB,kBAAkB;;gBAAI,SAAS,CACrB,CACd,CACU,CACT,CACP,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAmB;IAChE,OAAO,OAAO,KAAK,WAAW,IAAI,MAAM,CAAC,CAAC,CAAC,CACzC,oBAAC,qBAAqB,IAAC,MAAM,EAAE,MAAM,IAAG,QAAQ,CAAyB,CAC1E,CAAC,CAAC,CAAC,CACF;QACG,MAAM;QACN,QAAQ,CACR,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport clsx from 'clsx';\nimport { getBaseProps } from '../internal/base-component';\nimport InternalAlert from '../alert/internal';\nimport InternalBox from '../box/internal';\nimport InternalContentLayout from '../content-layout/internal';\nimport styles from './styles.css.js';\nimport { FormLayoutProps, FormProps } from './interfaces';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport LiveRegion from '../internal/components/live-region';\nimport { useInternalI18n } from '../i18n/context';\n\ntype InternalFormProps = FormProps & InternalBaseComponentProps;\n\nexport default function InternalForm({\n children,\n header,\n errorText,\n errorIconAriaLabel: errorIconAriaLabelOverride,\n actions,\n secondaryActions,\n variant,\n __internalRootRef,\n ...props\n}: InternalFormProps) {\n const baseProps = getBaseProps(props);\n const i18n = useInternalI18n('form');\n const errorIconAriaLabel = i18n('errorIconAriaLabel', errorIconAriaLabelOverride);\n\n return (\n <div {...baseProps} ref={__internalRootRef} className={clsx(styles.root, baseProps.className)}>\n <FormLayout\n header={\n header && <div className={clsx(styles.header, variant === 'full-page' && styles['full-page'])}>{header}</div>\n }\n variant={variant}\n >\n {children && <div className={styles.content}>{children}</div>}\n {errorText && (\n <InternalBox margin={{ top: 'l' }}>\n <InternalAlert type=\"error\" statusIconAriaLabel={errorIconAriaLabel}>\n <div className={styles.error}>{errorText}</div>\n </InternalAlert>\n </InternalBox>\n )}\n {(actions || secondaryActions) && (\n <div className={styles.footer}>\n <div className={styles['actions-section']}>\n {actions && <div className={styles.actions}>{actions}</div>}\n {secondaryActions && <div className={styles['secondary-actions']}>{secondaryActions}</div>}\n </div>\n </div>\n )}\n {errorText && (\n <LiveRegion assertive={true}>\n {errorIconAriaLabel}, {errorText}\n </LiveRegion>\n )}\n </FormLayout>\n </div>\n );\n}\n\nfunction FormLayout({ children, header, variant }: FormLayoutProps) {\n return variant === 'full-page' && header ? (\n <InternalContentLayout header={header}>{children}</InternalContentLayout>\n ) : (\n <>\n {header}\n {children}\n </>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/form-field/index.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAAE,OAAe,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,eAO9E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/form-field/index.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAAE,OAAe,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,eAa9E"}
@@ -8,8 +8,9 @@ import useBaseComponent from '../internal/hooks/use-base-component';
8
8
  import { getAnalyticsMetadataProps } from '../internal/base-component';
9
9
  export default function FormField(_a) {
10
10
  var { stretch = false } = _a, props = __rest(_a, ["stretch"]);
11
- const baseComponentProps = useBaseComponent('FormField', { props: { stretch } }, getAnalyticsMetadataProps(props));
12
- return React.createElement(InternalFormField, Object.assign({ stretch: stretch }, props, { __hideLabel: false }, baseComponentProps));
11
+ const analyticsMetadata = getAnalyticsMetadataProps(props);
12
+ const baseComponentProps = useBaseComponent('FormField', { props: { stretch } }, analyticsMetadata);
13
+ return (React.createElement(InternalFormField, Object.assign({ stretch: stretch }, props, { __hideLabel: false, __analyticsMetadata: analyticsMetadata }, baseComponentProps)));
13
14
  }
14
15
  applyDisplayName(FormField, 'FormField');
15
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/form-field/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,iBAAiB,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAkC,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAMvG,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAA6C;QAA7C,EAAE,OAAO,GAAG,KAAK,OAA4B,EAAvB,KAAK,cAA3B,WAA6B,CAAF;IAC3D,MAAM,kBAAkB,GAAG,gBAAgB,CACzC,WAAW,EACX,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EACtB,yBAAyB,CAAC,KAAuC,CAAC,CACnE,CAAC;IACF,OAAO,oBAAC,iBAAiB,kBAAC,OAAO,EAAE,OAAO,IAAM,KAAK,IAAE,WAAW,EAAE,KAAK,IAAM,kBAAkB,EAAI,CAAC;AACxG,CAAC;AAED,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport InternalFormField from './internal';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { BasePropsWithAnalyticsMetadata, getAnalyticsMetadataProps } from '../internal/base-component';\n\nimport { FormFieldProps } from './interfaces';\n\nexport { FormFieldProps };\n\nexport default function FormField({ stretch = false, ...props }: FormFieldProps) {\n const baseComponentProps = useBaseComponent(\n 'FormField',\n { props: { stretch } },\n getAnalyticsMetadataProps(props as BasePropsWithAnalyticsMetadata)\n );\n return <InternalFormField stretch={stretch} {...props} __hideLabel={false} {...baseComponentProps} />;\n}\n\napplyDisplayName(FormField, 'FormField');\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/form-field/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,iBAAiB,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAkC,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAMvG,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAA6C;QAA7C,EAAE,OAAO,GAAG,KAAK,OAA4B,EAAvB,KAAK,cAA3B,WAA6B,CAAF;IAC3D,MAAM,iBAAiB,GAAG,yBAAyB,CAAC,KAAuC,CAAC,CAAC;IAC7F,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,iBAAiB,CAAC,CAAC;IAEpG,OAAO,CACL,oBAAC,iBAAiB,kBAChB,OAAO,EAAE,OAAO,IACZ,KAAK,IACT,WAAW,EAAE,KAAK,EAClB,mBAAmB,EAAE,iBAAiB,IAClC,kBAAkB,EACtB,CACH,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport InternalFormField from './internal';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { BasePropsWithAnalyticsMetadata, getAnalyticsMetadataProps } from '../internal/base-component';\n\nimport { FormFieldProps } from './interfaces';\n\nexport { FormFieldProps };\n\nexport default function FormField({ stretch = false, ...props }: FormFieldProps) {\n const analyticsMetadata = getAnalyticsMetadataProps(props as BasePropsWithAnalyticsMetadata);\n const baseComponentProps = useBaseComponent('FormField', { props: { stretch } }, analyticsMetadata);\n\n return (\n <InternalFormField\n stretch={stretch}\n {...props}\n __hideLabel={false}\n __analyticsMetadata={analyticsMetadata}\n {...baseComponentProps}\n />\n );\n}\n\napplyDisplayName(FormField, 'FormField');\n"]}
@@ -1,6 +1,7 @@
1
1
  import { BaseComponentProps } from '../internal/base-component';
2
2
  import React from 'react';
3
3
  import { InternalBaseComponentProps } from '../internal/hooks/use-base-component';
4
+ import { AnalyticsMetadata } from '../internal/analytics/interfaces';
4
5
  export interface FormFieldProps extends BaseComponentProps {
5
6
  /**
6
7
  * The ID of the primary form control. You can use this to set the
@@ -55,10 +56,15 @@ export interface FormFieldProps extends BaseComponentProps {
55
56
  */
56
57
  constraintText?: React.ReactNode;
57
58
  /**
58
- * Text that displays as a validation message. If this is set to a
59
+ * Text that displays as a validation error message. If this is set to a
59
60
  * non-empty string, it will render the form field as invalid.
60
61
  */
61
62
  errorText?: React.ReactNode;
63
+ /**
64
+ * Text that displays as a validation warning message. If this is set to a
65
+ * non-empty string, it will render the form field in a warning state.
66
+ */
67
+ warningText?: React.ReactNode;
62
68
  }
63
69
  export declare namespace FormFieldProps {
64
70
  interface I18nStrings {
@@ -66,6 +72,10 @@ export declare namespace FormFieldProps {
66
72
  * Provides a text alternative for the error icon in the error message.
67
73
  */
68
74
  errorIconAriaLabel?: string;
75
+ /**
76
+ * Provides a text alternative for the warning icon in the warning message.
77
+ */
78
+ warningIconAriaLabel?: string;
69
79
  }
70
80
  }
71
81
  export interface InternalFormFieldProps extends FormFieldProps, InternalBaseComponentProps<HTMLDivElement> {
@@ -77,5 +87,6 @@ export interface InternalFormFieldProps extends FormFieldProps, InternalBaseComp
77
87
  * Disable the gutter applied by default.
78
88
  */
79
89
  __disableGutters?: boolean;
90
+ __analyticsMetadata?: AnalyticsMetadata;
80
91
  }
81
92
  //# sourceMappingURL=interfaces.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/form-field/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAElF,MAAM,WAAW,cAAe,SAAQ,kBAAkB;IACxD;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAExB;;;OAGG;IACH,WAAW,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC;IAEzC;;OAEG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAEvB;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE3B;;OAEG;IACH,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAEnC;;OAEG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE9B;;;OAGG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAEjC;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B;AAED,yBAAiB,cAAc,CAAC;IAC9B,UAAiB,WAAW;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CAC/B;AAED,yBAAiB,cAAc,CAAC;IAC9B,UAAiB,WAAW;QAC1B;;WAEG;QACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAE5B;;WAEG;QACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;KAC/B;CACF;AAED,MAAM,WAAW,sBAAuB,SAAQ,cAAc,EAAE,0BAA0B,CAAC,cAAc,CAAC;IACxG;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,mBAAmB,CAAC,EAAE,iBAAiB,CAAC;CACzC"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/form-field/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport React from 'react';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\n\nexport interface FormFieldProps extends BaseComponentProps {\n /**\n * The ID of the primary form control. You can use this to set the\n * `for` attribute of a label for accessibility.\n *\n * If you don't set this property, the control group automatically sets\n * the label to the ID of an inner form control (for example, an [input](/components/input) component).\n * This only works well if you're using a single control in the form field.\n */\n controlId?: string;\n\n /**\n * Determines whether the primary control should expand to 12 columns.\n *\n * By default (or when this property is set to `false`), the primary control\n * occupies 9 columns. The secondary control uses the remaining 3 columns.\n * On smaller viewports, both components occupy 12 columns and stack on top of each other.\n *\n * If this property is set to `true`, the primary control uses the full\n * 12 columns. The secondary control (if present) also uses 12 columns, and the two\n * controls stack on top of each other.\n */\n stretch?: boolean;\n\n /**\n * The main label for the form field.\n */\n label?: React.ReactNode;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n * @i18n\n */\n i18nStrings?: FormFieldProps.I18nStrings;\n\n /**\n * Use to display an 'Info' link next to the label.\n */\n info?: React.ReactNode;\n\n /**\n * The primary form control (for example, input, textarea, etc.).\n * @displayname control\n */\n children?: React.ReactNode;\n\n /**\n * A secondary control. You can use this for custom actions and content.\n */\n secondaryControl?: React.ReactNode;\n\n /**\n * Detailed information about the form field that's displayed below the label.\n */\n description?: React.ReactNode;\n\n /**\n * Constraint text that's displayed below the control. Use this to provide\n * additional information about valid formats, etc.\n */\n constraintText?: React.ReactNode;\n\n /**\n * Text that displays as a validation message. If this is set to a\n * non-empty string, it will render the form field as invalid.\n */\n errorText?: React.ReactNode;\n}\n\nexport namespace FormFieldProps {\n export interface I18nStrings {\n /**\n * Provides a text alternative for the error icon in the error message.\n */\n errorIconAriaLabel?: string;\n }\n}\n\nexport interface InternalFormFieldProps extends FormFieldProps, InternalBaseComponentProps<HTMLDivElement> {\n /**\n * Visually hide the label.\n */\n __hideLabel?: boolean;\n\n /**\n * Disable the gutter applied by default.\n */\n __disableGutters?: boolean;\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/form-field/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport React from 'react';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { AnalyticsMetadata } from '../internal/analytics/interfaces';\n\nexport interface FormFieldProps extends BaseComponentProps {\n /**\n * The ID of the primary form control. You can use this to set the\n * `for` attribute of a label for accessibility.\n *\n * If you don't set this property, the control group automatically sets\n * the label to the ID of an inner form control (for example, an [input](/components/input) component).\n * This only works well if you're using a single control in the form field.\n */\n controlId?: string;\n\n /**\n * Determines whether the primary control should expand to 12 columns.\n *\n * By default (or when this property is set to `false`), the primary control\n * occupies 9 columns. The secondary control uses the remaining 3 columns.\n * On smaller viewports, both components occupy 12 columns and stack on top of each other.\n *\n * If this property is set to `true`, the primary control uses the full\n * 12 columns. The secondary control (if present) also uses 12 columns, and the two\n * controls stack on top of each other.\n */\n stretch?: boolean;\n\n /**\n * The main label for the form field.\n */\n label?: React.ReactNode;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n * @i18n\n */\n i18nStrings?: FormFieldProps.I18nStrings;\n\n /**\n * Use to display an 'Info' link next to the label.\n */\n info?: React.ReactNode;\n\n /**\n * The primary form control (for example, input, textarea, etc.).\n * @displayname control\n */\n children?: React.ReactNode;\n\n /**\n * A secondary control. You can use this for custom actions and content.\n */\n secondaryControl?: React.ReactNode;\n\n /**\n * Detailed information about the form field that's displayed below the label.\n */\n description?: React.ReactNode;\n\n /**\n * Constraint text that's displayed below the control. Use this to provide\n * additional information about valid formats, etc.\n */\n constraintText?: React.ReactNode;\n\n /**\n * Text that displays as a validation error message. If this is set to a\n * non-empty string, it will render the form field as invalid.\n */\n errorText?: React.ReactNode;\n\n /**\n * Text that displays as a validation warning message. If this is set to a\n * non-empty string, it will render the form field in a warning state.\n */\n warningText?: React.ReactNode;\n}\n\nexport namespace FormFieldProps {\n export interface I18nStrings {\n /**\n * Provides a text alternative for the error icon in the error message.\n */\n errorIconAriaLabel?: string;\n\n /**\n * Provides a text alternative for the warning icon in the warning message.\n */\n warningIconAriaLabel?: string;\n }\n}\n\nexport interface InternalFormFieldProps extends FormFieldProps, InternalBaseComponentProps<HTMLDivElement> {\n /**\n * Visually hide the label.\n */\n __hideLabel?: boolean;\n\n /**\n * Disable the gutter applied by default.\n */\n __disableGutters?: boolean;\n __analyticsMetadata?: AnalyticsMetadata;\n}\n"]}
@@ -5,12 +5,18 @@ interface FormFieldErrorProps {
5
5
  children?: React.ReactNode;
6
6
  errorIconAriaLabel?: string;
7
7
  }
8
+ interface FormFieldWarningProps {
9
+ id?: string;
10
+ children?: React.ReactNode;
11
+ warningIconAriaLabel?: string;
12
+ }
8
13
  export declare function FormFieldError({ id, children, errorIconAriaLabel }: FormFieldErrorProps): JSX.Element;
9
- export declare function ConstraintText({ id, hasError, children, }: {
14
+ export declare function FormFieldWarning({ id, children, warningIconAriaLabel }: FormFieldWarningProps): JSX.Element;
15
+ export declare function ConstraintText({ id, hasValidationText, children, }: {
10
16
  id?: string;
11
- hasError: boolean;
17
+ hasValidationText: boolean;
12
18
  children: React.ReactNode;
13
19
  }): JSX.Element;
14
- export default function InternalFormField({ controlId, stretch, label, info, i18nStrings, children, secondaryControl, description, constraintText, errorText, __hideLabel, __internalRootRef, __disableGutters, ...rest }: InternalFormFieldProps): JSX.Element;
20
+ export default function InternalFormField({ controlId, stretch, label, info, i18nStrings, children, secondaryControl, description, constraintText, errorText, warningText, __hideLabel, __internalRootRef, __disableGutters, __analyticsMetadata, ...rest }: InternalFormFieldProps): JSX.Element;
15
21
  export {};
16
22
  //# sourceMappingURL=internal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/form-field/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAajD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAgBtD,UAAU,mBAAmB;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,kBAAkB,EAAE,EAAE,mBAAmB,eAqBvF;AAED,wBAAgB,cAAc,CAAC,EAC7B,EAAE,EACF,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,eAMA;AAED,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,SAAS,EACT,OAAe,EACf,KAAK,EACL,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,SAAS,EACT,WAAW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 import { getBaseProps } from '../internal/base-component';
7
7
  import { FormFieldContext, useFormFieldContext } from '../internal/context/form-field-context';
8
8
  import { useUniqueId } from '../internal/hooks/use-unique-id';
9
9
  import { useVisualRefresh } from '../internal/hooks/use-visual-mode';
10
+ import { warnOnce } from '@cloudscape-design/component-toolkit/internal';
10
11
  import InternalGrid from '../grid/internal';
11
12
  import InternalIcon from '../icon/internal';
12
13
  import { getAriaDescribedBy, getGridDefinition, getSlotIds } from './util';
@@ -26,31 +27,48 @@ export function FormFieldError({ id, children, errorIconAriaLabel }) {
26
27
  React.createElement("div", { id: id, className: styles.error },
27
28
  React.createElement("div", { className: styles['error-icon-shake-wrapper'] },
28
29
  React.createElement("div", { role: "img", "aria-label": i18nErrorIconAriaLabel, className: styles['error-icon-scale-wrapper'] },
29
- React.createElement(InternalIcon, { name: "status-warning", size: "small" }))),
30
+ React.createElement(InternalIcon, { name: "status-negative", size: "small" }))),
30
31
  React.createElement("span", { className: styles.error__message, ref: contentRef }, children)),
31
32
  React.createElement(LiveRegion, { assertive: true, source: [i18nErrorIconAriaLabel, contentRef] })));
32
33
  }
33
- export function ConstraintText({ id, hasError, children, }) {
34
- return (React.createElement("div", { id: id, className: clsx(styles.constraint, hasError && styles['constraint-has-error']) }, children));
34
+ export function FormFieldWarning({ id, children, warningIconAriaLabel }) {
35
+ const i18n = useInternalI18n('form-field');
36
+ const contentRef = useRef(null);
37
+ const i18nWarningIconAriaLabel = i18n('i18nStrings.warningIconAriaLabel', warningIconAriaLabel);
38
+ return (React.createElement(React.Fragment, null,
39
+ React.createElement("div", { id: id, className: styles.warning },
40
+ React.createElement("div", { className: styles['warning-icon-shake-wrapper'] },
41
+ React.createElement("div", { role: "img", "aria-label": i18nWarningIconAriaLabel, className: styles['warning-icon-scale-wrapper'] },
42
+ React.createElement(InternalIcon, { name: "status-warning", size: "small" }))),
43
+ React.createElement("span", { className: styles.warning__message, ref: contentRef }, children)),
44
+ React.createElement(LiveRegion, { assertive: true, source: [i18nWarningIconAriaLabel, contentRef] })));
45
+ }
46
+ export function ConstraintText({ id, hasValidationText, children, }) {
47
+ return (React.createElement("div", { id: id, className: clsx(styles.constraint, hasValidationText && styles['constraint-has-validation-text']) }, children));
35
48
  }
36
49
  export default function InternalFormField(_a) {
37
- var { controlId, stretch = false, label, info, i18nStrings, children, secondaryControl, description, constraintText, errorText, __hideLabel, __internalRootRef = null, __disableGutters = false } = _a, rest = __rest(_a, ["controlId", "stretch", "label", "info", "i18nStrings", "children", "secondaryControl", "description", "constraintText", "errorText", "__hideLabel", "__internalRootRef", "__disableGutters"]);
50
+ var { controlId, stretch = false, label, info, i18nStrings, children, secondaryControl, description, constraintText, errorText, warningText, __hideLabel, __internalRootRef = null, __disableGutters = false, __analyticsMetadata = undefined } = _a, rest = __rest(_a, ["controlId", "stretch", "label", "info", "i18nStrings", "children", "secondaryControl", "description", "constraintText", "errorText", "warningText", "__hideLabel", "__internalRootRef", "__disableGutters", "__analyticsMetadata"]);
38
51
  const baseProps = getBaseProps(rest);
39
52
  const isRefresh = useVisualRefresh();
40
53
  const instanceUniqueId = useUniqueId('formField');
41
54
  const generatedControlId = controlId || instanceUniqueId;
42
55
  const formFieldId = controlId || generatedControlId;
43
- const { funnelInteractionId, submissionAttempt, funnelState, errorCount } = useFunnel();
44
- const { stepNumber, stepNameSelector } = useFunnelStep();
45
- const { subStepSelector, subStepNameSelector } = useFunnelSubStep();
46
- const slotIds = getSlotIds(formFieldId, label, description, constraintText, errorText);
56
+ const { funnelIdentifier, funnelInteractionId, submissionAttempt, funnelState, errorCount } = useFunnel();
57
+ const { stepIdentifier, stepNumber, stepNameSelector } = useFunnelStep();
58
+ const { subStepErrorContext, subStepIdentifier, subStepSelector, subStepNameSelector } = useFunnelSubStep();
59
+ const showWarning = warningText && !errorText;
60
+ if (warningText && errorText) {
61
+ warnOnce('FileUpload', 'Both `errorText` and `warningText` exist. `warningText` will not be shown.');
62
+ }
63
+ const slotIds = getSlotIds(formFieldId, label, description, constraintText, errorText, showWarning ? warningText : undefined);
47
64
  const ariaDescribedBy = getAriaDescribedBy(slotIds);
48
65
  const gridDefinition = getGridDefinition(stretch, !!secondaryControl, isRefresh);
49
- const { ariaLabelledby: parentAriaLabelledby, ariaDescribedby: parentAriaDescribedby, invalid: parentInvalid, } = useFormFieldContext({});
66
+ const { ariaLabelledby: parentAriaLabelledby, ariaDescribedby: parentAriaDescribedby, invalid: parentInvalid, warning: parentWarning, } = useFormFieldContext({});
50
67
  const contextValuesWithoutControlId = {
51
68
  ariaLabelledby: joinStrings(parentAriaLabelledby, slotIds.label) || undefined,
52
69
  ariaDescribedby: joinStrings(parentAriaDescribedby, ariaDescribedBy) || undefined,
53
70
  invalid: !!errorText || !!parentInvalid,
71
+ warning: (!!warningText && !errorText) || (!!parentWarning && !parentInvalid),
54
72
  };
55
73
  const analyticsAttributes = {
56
74
  [DATA_ATTR_FIELD_LABEL]: slotIds.label ? getFieldSlotSeletor(slotIds.label) : undefined,
@@ -67,15 +85,21 @@ export default function InternalFormField(_a) {
67
85
  if (errorIsVisible) {
68
86
  FunnelMetrics.funnelSubStepError({
69
87
  funnelInteractionId,
88
+ funnelIdentifier,
70
89
  subStepSelector,
71
90
  subStepName,
72
91
  subStepNameSelector,
92
+ subStepIdentifier,
73
93
  stepNumber,
74
94
  stepName,
75
95
  stepNameSelector,
96
+ stepIdentifier,
97
+ subStepErrorContext,
76
98
  fieldErrorSelector: `${getFieldSlotSeletor(slotIds.error)} .${styles.error__message}`,
77
99
  fieldLabelSelector: getFieldSlotSeletor(slotIds.label),
78
100
  subStepAllSelector: getSubStepAllSelector(),
101
+ fieldIdentifier: __analyticsMetadata === null || __analyticsMetadata === void 0 ? void 0 : __analyticsMetadata.instanceIdentifier,
102
+ fieldErrorContext: __analyticsMetadata === null || __analyticsMetadata === void 0 ? void 0 : __analyticsMetadata.errorContext,
79
103
  });
80
104
  }
81
105
  return () => {
@@ -95,8 +119,9 @@ export default function InternalFormField(_a) {
95
119
  React.createElement(FormFieldContext.Provider, { value: Object.assign({ controlId: generatedControlId }, contextValuesWithoutControlId) }, children && React.createElement("div", { className: styles.control }, children)),
96
120
  secondaryControl && (React.createElement(FormFieldContext.Provider, { value: contextValuesWithoutControlId },
97
121
  React.createElement("div", { className: styles['secondary-control'] }, secondaryControl))))),
98
- (constraintText || errorText) && (React.createElement("div", { className: styles.hints },
122
+ (constraintText || errorText || warningText) && (React.createElement("div", { className: styles.hints },
99
123
  errorText && (React.createElement(FormFieldError, { id: slotIds.error, errorIconAriaLabel: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.errorIconAriaLabel }, errorText)),
100
- constraintText && (React.createElement(ConstraintText, { id: slotIds.constraint, hasError: !!errorText }, constraintText))))));
124
+ showWarning && (React.createElement(FormFieldWarning, { id: slotIds.warning, warningIconAriaLabel: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.warningIconAriaLabel }, warningText)),
125
+ constraintText && (React.createElement(ConstraintText, { id: slotIds.constraint, hasValidationText: !!errorText || !!warningText }, constraintText))))));
101
126
  }
102
127
  //# sourceMappingURL=internal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/form-field/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,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,CAAC,WAAW,EAAE,EAAE,EAAE,OAAO,CAAC,WAAW,IACxD,WAAW,CACR,CACP;QAED,6BAAK,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,WAAW,IAAI,MAAM,CAAC,cAAc,CAAC,CAAC;YAC1E,oBAAC,YAAY,IAAC,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB;gBAC5E,oBAAC,gBAAgB,CAAC,QAAQ,IACxB,KAAK,kBACH,SAAS,EAAE,kBAAkB,IAC1B,6BAA6B,KAGjC,QAAQ,IAAI,6BAAK,SAAS,EAAE,MAAM,CAAC,OAAO,IAAG,QAAQ,CAAO,CACnC;gBAE3B,gBAAgB,IAAI,CACnB,oBAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,6BAA6B;oBAC7D,6BAAK,SAAS,EAAE,MAAM,CAAC,mBAAmB,CAAC,IAAG,gBAAgB,CAAO,CAC3C,CAC7B,CACY,CACX;QAEL,CAAC,cAAc,IAAI,SAAS,CAAC,IAAI,CAChC,6BAAK,SAAS,EAAE,MAAM,CAAC,KAAK;YACzB,SAAS,IAAI,CACZ,oBAAC,cAAc,IAAC,EAAE,EAAE,OAAO,CAAC,KAAK,EAAE,kBAAkB,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,kBAAkB,IACnF,SAAS,CACK,CAClB;YACA,cAAc,IAAI,CACjB,oBAAC,cAAc,IAAC,EAAE,EAAE,OAAO,CAAC,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC,SAAS,IAC1D,cAAc,CACA,CAClB,CACG,CACP,CACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { FormFieldContext, useFormFieldContext } from '../internal/context/form-field-context';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\n\nimport InternalGrid from '../grid/internal';\nimport InternalIcon from '../icon/internal';\nimport { getAriaDescribedBy, getGridDefinition, getSlotIds } from './util';\n\nimport styles from './styles.css.js';\nimport { InternalFormFieldProps } from './interfaces';\nimport { joinStrings } from '../internal/utils/strings';\nimport { useInternalI18n } from '../i18n/context';\nimport { InfoLinkLabelContext } from '../internal/context/info-link-label-context';\n\nimport { FunnelMetrics } from '../internal/analytics';\nimport { useFunnel, useFunnelStep, useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';\nimport {\n DATA_ATTR_FIELD_ERROR,\n DATA_ATTR_FIELD_LABEL,\n getFieldSlotSeletor,\n getNameFromSelector,\n getSubStepAllSelector,\n} from '../internal/analytics/selectors';\nimport LiveRegion from '../internal/components/live-region';\n\ninterface FormFieldErrorProps {\n id?: string;\n children?: React.ReactNode;\n errorIconAriaLabel?: string;\n}\n\nexport function FormFieldError({ id, children, errorIconAriaLabel }: FormFieldErrorProps) {\n const i18n = useInternalI18n('form-field');\n const contentRef = useRef<HTMLDivElement | null>(null);\n const i18nErrorIconAriaLabel = i18n('i18nStrings.errorIconAriaLabel', errorIconAriaLabel);\n\n return (\n <>\n <div id={id} className={styles.error}>\n <div className={styles['error-icon-shake-wrapper']}>\n <div role=\"img\" aria-label={i18nErrorIconAriaLabel} className={styles['error-icon-scale-wrapper']}>\n <InternalIcon name=\"status-warning\" size=\"small\" />\n </div>\n </div>\n <span className={styles.error__message} ref={contentRef}>\n {children}\n </span>\n </div>\n\n <LiveRegion assertive={true} source={[i18nErrorIconAriaLabel, contentRef]} />\n </>\n );\n}\n\nexport function ConstraintText({\n id,\n hasError,\n children,\n}: {\n id?: string;\n hasError: boolean;\n children: React.ReactNode;\n}) {\n return (\n <div id={id} className={clsx(styles.constraint, hasError && styles['constraint-has-error'])}>\n {children}\n </div>\n );\n}\n\nexport default function InternalFormField({\n controlId,\n stretch = false,\n label,\n info,\n i18nStrings,\n children,\n secondaryControl,\n description,\n constraintText,\n errorText,\n __hideLabel,\n __internalRootRef = null,\n __disableGutters = false,\n ...rest\n}: InternalFormFieldProps) {\n const baseProps = getBaseProps(rest);\n const isRefresh = useVisualRefresh();\n\n const instanceUniqueId = useUniqueId('formField');\n const generatedControlId = controlId || instanceUniqueId;\n const formFieldId = controlId || generatedControlId;\n\n const { funnelInteractionId, submissionAttempt, funnelState, errorCount } = useFunnel();\n const { stepNumber, stepNameSelector } = useFunnelStep();\n const { subStepSelector, subStepNameSelector } = useFunnelSubStep();\n\n const slotIds = getSlotIds(formFieldId, label, description, constraintText, errorText);\n\n const ariaDescribedBy = getAriaDescribedBy(slotIds);\n\n const gridDefinition = getGridDefinition(stretch, !!secondaryControl, isRefresh);\n\n const {\n ariaLabelledby: parentAriaLabelledby,\n ariaDescribedby: parentAriaDescribedby,\n invalid: parentInvalid,\n } = useFormFieldContext({});\n\n const contextValuesWithoutControlId = {\n ariaLabelledby: joinStrings(parentAriaLabelledby, slotIds.label) || undefined,\n ariaDescribedby: joinStrings(parentAriaDescribedby, ariaDescribedBy) || undefined,\n invalid: !!errorText || !!parentInvalid,\n };\n\n const analyticsAttributes = {\n [DATA_ATTR_FIELD_LABEL]: slotIds.label ? getFieldSlotSeletor(slotIds.label) : undefined,\n [DATA_ATTR_FIELD_ERROR]: slotIds.error ? getFieldSlotSeletor(slotIds.error) : undefined,\n };\n\n useEffect(() => {\n if (funnelInteractionId && errorText && funnelState.current !== 'complete') {\n const stepName = getNameFromSelector(stepNameSelector);\n const subStepName = getNameFromSelector(subStepNameSelector);\n\n errorCount.current++;\n\n // We don't want to report an error if it is hidden, e.g. inside an Expandable Section.\n const errorIsVisible = (__internalRootRef?.current?.getBoundingClientRect()?.width ?? 0) > 0;\n\n if (errorIsVisible) {\n FunnelMetrics.funnelSubStepError({\n funnelInteractionId,\n subStepSelector,\n subStepName,\n subStepNameSelector,\n stepNumber,\n stepName,\n stepNameSelector,\n fieldErrorSelector: `${getFieldSlotSeletor(slotIds.error)} .${styles.error__message}`,\n fieldLabelSelector: getFieldSlotSeletor(slotIds.label),\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n errorCount.current--;\n };\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [funnelInteractionId, errorText, submissionAttempt, errorCount]);\n\n return (\n <div\n {...baseProps}\n className={clsx(baseProps.className, styles.root)}\n ref={__internalRootRef}\n {...analyticsAttributes}\n >\n <div className={clsx(__hideLabel && styles['visually-hidden'])}>\n {label && (\n <label className={styles.label} id={slotIds.label} htmlFor={generatedControlId}>\n {label}\n </label>\n )}\n <InfoLinkLabelContext.Provider value={slotIds.label}>\n {!__hideLabel && info && <span className={styles.info}>{info}</span>}\n </InfoLinkLabelContext.Provider>\n </div>\n\n {description && (\n <div className={styles.description} id={slotIds.description}>\n {description}\n </div>\n )}\n\n <div className={clsx(styles.controls, __hideLabel && styles['label-hidden'])}>\n <InternalGrid gridDefinition={gridDefinition} disableGutters={__disableGutters}>\n <FormFieldContext.Provider\n value={{\n controlId: generatedControlId,\n ...contextValuesWithoutControlId,\n }}\n >\n {children && <div className={styles.control}>{children}</div>}\n </FormFieldContext.Provider>\n\n {secondaryControl && (\n <FormFieldContext.Provider value={contextValuesWithoutControlId}>\n <div className={styles['secondary-control']}>{secondaryControl}</div>\n </FormFieldContext.Provider>\n )}\n </InternalGrid>\n </div>\n\n {(constraintText || errorText) && (\n <div className={styles.hints}>\n {errorText && (\n <FormFieldError id={slotIds.error} errorIconAriaLabel={i18nStrings?.errorIconAriaLabel}>\n {errorText}\n </FormFieldError>\n )}\n {constraintText && (\n <ConstraintText id={slotIds.constraint} hasError={!!errorText}>\n {constraintText}\n </ConstraintText>\n )}\n </div>\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/form-field/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AAC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6BAA6B;oBAC7D,6BAAK,SAAS,EAAE,MAAM,CAAC,mBAAmB,CAAC,IAAG,gBAAgB,CAAO,CAC3C,CAC7B,CACY,CACX;QAEL,CAAC,cAAc,IAAI,SAAS,IAAI,WAAW,CAAC,IAAI,CAC/C,6BAAK,SAAS,EAAE,MAAM,CAAC,KAAK;YACzB,SAAS,IAAI,CACZ,oBAAC,cAAc,IAAC,EAAE,EAAE,OAAO,CAAC,KAAK,EAAE,kBAAkB,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,kBAAkB,IACnF,SAAS,CACK,CAClB;YACA,WAAW,IAAI,CACd,oBAAC,gBAAgB,IAAC,EAAE,EAAE,OAAO,CAAC,OAAO,EAAE,oBAAoB,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,oBAAoB,IAC3F,WAAW,CACK,CACpB;YACA,cAAc,IAAI,CACjB,oBAAC,cAAc,IAAC,EAAE,EAAE,OAAO,CAAC,UAAU,EAAE,iBAAiB,EAAE,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,WAAW,IACpF,cAAc,CACA,CAClB,CACG,CACP,CACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { FormFieldContext, useFormFieldContext } from '../internal/context/form-field-context';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalGrid from '../grid/internal';\nimport InternalIcon from '../icon/internal';\nimport { getAriaDescribedBy, getGridDefinition, getSlotIds } from './util';\n\nimport styles from './styles.css.js';\nimport { InternalFormFieldProps } from './interfaces';\nimport { joinStrings } from '../internal/utils/strings';\nimport { useInternalI18n } from '../i18n/context';\nimport { InfoLinkLabelContext } from '../internal/context/info-link-label-context';\n\nimport { FunnelMetrics } from '../internal/analytics';\nimport { useFunnel, useFunnelStep, useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';\nimport {\n DATA_ATTR_FIELD_ERROR,\n DATA_ATTR_FIELD_LABEL,\n getFieldSlotSeletor,\n getNameFromSelector,\n getSubStepAllSelector,\n} from '../internal/analytics/selectors';\nimport LiveRegion from '../internal/components/live-region';\n\ninterface FormFieldErrorProps {\n id?: string;\n children?: React.ReactNode;\n errorIconAriaLabel?: string;\n}\n\ninterface FormFieldWarningProps {\n id?: string;\n children?: React.ReactNode;\n warningIconAriaLabel?: string;\n}\n\nexport function FormFieldError({ id, children, errorIconAriaLabel }: FormFieldErrorProps) {\n const i18n = useInternalI18n('form-field');\n const contentRef = useRef<HTMLDivElement | null>(null);\n const i18nErrorIconAriaLabel = i18n('i18nStrings.errorIconAriaLabel', errorIconAriaLabel);\n\n return (\n <>\n <div id={id} className={styles.error}>\n <div className={styles['error-icon-shake-wrapper']}>\n <div role=\"img\" aria-label={i18nErrorIconAriaLabel} className={styles['error-icon-scale-wrapper']}>\n <InternalIcon name=\"status-negative\" size=\"small\" />\n </div>\n </div>\n <span className={styles.error__message} ref={contentRef}>\n {children}\n </span>\n </div>\n\n <LiveRegion assertive={true} source={[i18nErrorIconAriaLabel, contentRef]} />\n </>\n );\n}\n\nexport function FormFieldWarning({ id, children, warningIconAriaLabel }: FormFieldWarningProps) {\n const i18n = useInternalI18n('form-field');\n const contentRef = useRef<HTMLDivElement | null>(null);\n const i18nWarningIconAriaLabel = i18n('i18nStrings.warningIconAriaLabel', warningIconAriaLabel);\n\n return (\n <>\n <div id={id} className={styles.warning}>\n <div className={styles['warning-icon-shake-wrapper']}>\n <div role=\"img\" aria-label={i18nWarningIconAriaLabel} className={styles['warning-icon-scale-wrapper']}>\n <InternalIcon name=\"status-warning\" size=\"small\" />\n </div>\n </div>\n <span className={styles.warning__message} ref={contentRef}>\n {children}\n </span>\n </div>\n\n <LiveRegion assertive={true} source={[i18nWarningIconAriaLabel, contentRef]} />\n </>\n );\n}\n\nexport function ConstraintText({\n id,\n hasValidationText,\n children,\n}: {\n id?: string;\n hasValidationText: boolean;\n children: React.ReactNode;\n}) {\n return (\n <div id={id} className={clsx(styles.constraint, hasValidationText && styles['constraint-has-validation-text'])}>\n {children}\n </div>\n );\n}\n\nexport default function InternalFormField({\n controlId,\n stretch = false,\n label,\n info,\n i18nStrings,\n children,\n secondaryControl,\n description,\n constraintText,\n errorText,\n warningText,\n __hideLabel,\n __internalRootRef = null,\n __disableGutters = false,\n __analyticsMetadata = undefined,\n ...rest\n}: InternalFormFieldProps) {\n const baseProps = getBaseProps(rest);\n const isRefresh = useVisualRefresh();\n\n const instanceUniqueId = useUniqueId('formField');\n const generatedControlId = controlId || instanceUniqueId;\n const formFieldId = controlId || generatedControlId;\n\n const { funnelIdentifier, funnelInteractionId, submissionAttempt, funnelState, errorCount } = useFunnel();\n const { stepIdentifier, stepNumber, stepNameSelector } = useFunnelStep();\n const { subStepErrorContext, subStepIdentifier, subStepSelector, subStepNameSelector } = useFunnelSubStep();\n\n const showWarning = warningText && !errorText;\n\n if (warningText && errorText) {\n warnOnce('FileUpload', 'Both `errorText` and `warningText` exist. `warningText` will not be shown.');\n }\n\n const slotIds = getSlotIds(\n formFieldId,\n label,\n description,\n constraintText,\n errorText,\n showWarning ? warningText : undefined\n );\n\n const ariaDescribedBy = getAriaDescribedBy(slotIds);\n\n const gridDefinition = getGridDefinition(stretch, !!secondaryControl, isRefresh);\n\n const {\n ariaLabelledby: parentAriaLabelledby,\n ariaDescribedby: parentAriaDescribedby,\n invalid: parentInvalid,\n warning: parentWarning,\n } = useFormFieldContext({});\n\n const contextValuesWithoutControlId = {\n ariaLabelledby: joinStrings(parentAriaLabelledby, slotIds.label) || undefined,\n ariaDescribedby: joinStrings(parentAriaDescribedby, ariaDescribedBy) || undefined,\n invalid: !!errorText || !!parentInvalid,\n warning: (!!warningText && !errorText) || (!!parentWarning && !parentInvalid),\n };\n\n const analyticsAttributes = {\n [DATA_ATTR_FIELD_LABEL]: slotIds.label ? getFieldSlotSeletor(slotIds.label) : undefined,\n [DATA_ATTR_FIELD_ERROR]: slotIds.error ? getFieldSlotSeletor(slotIds.error) : undefined,\n };\n\n useEffect(() => {\n if (funnelInteractionId && errorText && funnelState.current !== 'complete') {\n const stepName = getNameFromSelector(stepNameSelector);\n const subStepName = getNameFromSelector(subStepNameSelector);\n\n errorCount.current++;\n\n // We don't want to report an error if it is hidden, e.g. inside an Expandable Section.\n const errorIsVisible = (__internalRootRef?.current?.getBoundingClientRect()?.width ?? 0) > 0;\n\n if (errorIsVisible) {\n FunnelMetrics.funnelSubStepError({\n funnelInteractionId,\n funnelIdentifier,\n subStepSelector,\n subStepName,\n subStepNameSelector,\n subStepIdentifier,\n stepNumber,\n stepName,\n stepNameSelector,\n stepIdentifier,\n subStepErrorContext,\n fieldErrorSelector: `${getFieldSlotSeletor(slotIds.error)} .${styles.error__message}`,\n fieldLabelSelector: getFieldSlotSeletor(slotIds.label),\n subStepAllSelector: getSubStepAllSelector(),\n fieldIdentifier: __analyticsMetadata?.instanceIdentifier,\n fieldErrorContext: __analyticsMetadata?.errorContext,\n });\n }\n\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n errorCount.current--;\n };\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [funnelInteractionId, errorText, submissionAttempt, errorCount]);\n\n return (\n <div\n {...baseProps}\n className={clsx(baseProps.className, styles.root)}\n ref={__internalRootRef}\n {...analyticsAttributes}\n >\n <div className={clsx(__hideLabel && styles['visually-hidden'])}>\n {label && (\n <label className={styles.label} id={slotIds.label} htmlFor={generatedControlId}>\n {label}\n </label>\n )}\n <InfoLinkLabelContext.Provider value={slotIds.label}>\n {!__hideLabel && info && <span className={styles.info}>{info}</span>}\n </InfoLinkLabelContext.Provider>\n </div>\n\n {description && (\n <div className={styles.description} id={slotIds.description}>\n {description}\n </div>\n )}\n\n <div className={clsx(styles.controls, __hideLabel && styles['label-hidden'])}>\n <InternalGrid gridDefinition={gridDefinition} disableGutters={__disableGutters}>\n <FormFieldContext.Provider\n value={{\n controlId: generatedControlId,\n ...contextValuesWithoutControlId,\n }}\n >\n {children && <div className={styles.control}>{children}</div>}\n </FormFieldContext.Provider>\n\n {secondaryControl && (\n <FormFieldContext.Provider value={contextValuesWithoutControlId}>\n <div className={styles['secondary-control']}>{secondaryControl}</div>\n </FormFieldContext.Provider>\n )}\n </InternalGrid>\n </div>\n\n {(constraintText || errorText || warningText) && (\n <div className={styles.hints}>\n {errorText && (\n <FormFieldError id={slotIds.error} errorIconAriaLabel={i18nStrings?.errorIconAriaLabel}>\n {errorText}\n </FormFieldError>\n )}\n {showWarning && (\n <FormFieldWarning id={slotIds.warning} warningIconAriaLabel={i18nStrings?.warningIconAriaLabel}>\n {warningText}\n </FormFieldWarning>\n )}\n {constraintText && (\n <ConstraintText id={slotIds.constraint} hasValidationText={!!errorText || !!warningText}>\n {constraintText}\n </ConstraintText>\n )}\n </div>\n )}\n </div>\n );\n}\n"]}
@@ -1,24 +1,28 @@
1
1
 
2
2
  import './styles.scoped.css';
3
3
  export default {
4
- "error-icon-shake-wrapper": "awsui_error-icon-shake-wrapper_14mhv_av9zi_103",
5
- "awsui-motion-shake-horizontally": "awsui_awsui-motion-shake-horizontally_14mhv_av9zi_1",
6
- "error-icon-scale-wrapper": "awsui_error-icon-scale-wrapper_14mhv_av9zi_130",
7
- "awsui-motion-scale-popup": "awsui_awsui-motion-scale-popup_14mhv_av9zi_1",
8
- "error": "awsui_error_14mhv_av9zi_103",
9
- "awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-0_14mhv_av9zi_1",
10
- "root": "awsui_root_14mhv_av9zi_174",
11
- "label": "awsui_label_14mhv_av9zi_210",
12
- "info": "awsui_info_14mhv_av9zi_224",
13
- "description": "awsui_description_14mhv_av9zi_229",
14
- "constraint": "awsui_constraint_14mhv_av9zi_230",
15
- "hints": "awsui_hints_14mhv_av9zi_237",
16
- "constraint-has-error": "awsui_constraint-has-error_14mhv_av9zi_238",
17
- "secondary-control": "awsui_secondary-control_14mhv_av9zi_242",
18
- "controls": "awsui_controls_14mhv_av9zi_246",
19
- "label-hidden": "awsui_label-hidden_14mhv_av9zi_246",
20
- "control": "awsui_control_14mhv_av9zi_246",
21
- "error__message": "awsui_error__message_14mhv_av9zi_264",
22
- "visually-hidden": "awsui_visually-hidden_14mhv_av9zi_268"
4
+ "error-icon-shake-wrapper": "awsui_error-icon-shake-wrapper_14mhv_kp9ld_103",
5
+ "warning-icon-shake-wrapper": "awsui_warning-icon-shake-wrapper_14mhv_kp9ld_104",
6
+ "awsui-motion-shake-horizontally": "awsui_awsui-motion-shake-horizontally_14mhv_kp9ld_1",
7
+ "error-icon-scale-wrapper": "awsui_error-icon-scale-wrapper_14mhv_kp9ld_134",
8
+ "warning-icon-scale-wrapper": "awsui_warning-icon-scale-wrapper_14mhv_kp9ld_135",
9
+ "awsui-motion-scale-popup": "awsui_awsui-motion-scale-popup_14mhv_kp9ld_1",
10
+ "warning": "awsui_warning_14mhv_kp9ld_104",
11
+ "error": "awsui_error_14mhv_kp9ld_103",
12
+ "awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-0_14mhv_kp9ld_1",
13
+ "root": "awsui_root_14mhv_kp9ld_186",
14
+ "label": "awsui_label_14mhv_kp9ld_222",
15
+ "info": "awsui_info_14mhv_kp9ld_236",
16
+ "description": "awsui_description_14mhv_kp9ld_241",
17
+ "constraint": "awsui_constraint_14mhv_kp9ld_242",
18
+ "hints": "awsui_hints_14mhv_kp9ld_249",
19
+ "constraint-has-validation-text": "awsui_constraint-has-validation-text_14mhv_kp9ld_250",
20
+ "secondary-control": "awsui_secondary-control_14mhv_kp9ld_254",
21
+ "controls": "awsui_controls_14mhv_kp9ld_258",
22
+ "label-hidden": "awsui_label-hidden_14mhv_kp9ld_258",
23
+ "control": "awsui_control_14mhv_kp9ld_258",
24
+ "error__message": "awsui_error__message_14mhv_kp9ld_285",
25
+ "warning__message": "awsui_warning__message_14mhv_kp9ld_286",
26
+ "visually-hidden": "awsui_visually-hidden_14mhv_kp9ld_290"
23
27
  };
24
28