This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move
TextInput
, ValidatedTextInput
and ValidationInputError
to …
…the `@woocommerce/blocks-components` package. (#11654)
- Loading branch information
Showing
20 changed files
with
76 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
assets/js/base/components/cart-checkout/address-form/address-form.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default as TextInput } from '../../../components/text-input/text-input'; | ||
export { default as ValidatedTextInput } from '../../../components/text-input/validated-text-input'; |
47 changes: 1 addition & 46 deletions
47
packages/checkout/components/validation-input-error/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { useSelect } from '@wordpress/data'; | ||
import { VALIDATION_STORE_KEY } from '@woocommerce/block-data'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import './style.scss'; | ||
|
||
interface ValidationInputErrorProps { | ||
errorMessage?: string; | ||
propertyName?: string; | ||
elementId?: string; | ||
} | ||
|
||
export const ValidationInputError = ( { | ||
errorMessage = '', | ||
propertyName = '', | ||
elementId = '', | ||
}: ValidationInputErrorProps ): JSX.Element | null => { | ||
const { validationError, validationErrorId } = useSelect( ( select ) => { | ||
const store = select( VALIDATION_STORE_KEY ); | ||
return { | ||
validationError: store.getValidationError( propertyName ), | ||
validationErrorId: store.getValidationErrorId( elementId ), | ||
}; | ||
} ); | ||
|
||
if ( ! errorMessage || typeof errorMessage !== 'string' ) { | ||
if ( validationError?.message && ! validationError?.hidden ) { | ||
errorMessage = validationError.message; | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
return ( | ||
<div className="wc-block-components-validation-error" role="alert"> | ||
<p id={ validationErrorId }>{ errorMessage }</p> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ValidationInputError; | ||
export { ValidationInputError } from '../../../components/validation-input-error/'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { useSelect } from '@wordpress/data'; | ||
import { VALIDATION_STORE_KEY } from '@woocommerce/block-data'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import './style.scss'; | ||
|
||
interface ValidationInputErrorProps { | ||
errorMessage?: string; | ||
propertyName?: string; | ||
elementId?: string; | ||
} | ||
|
||
export const ValidationInputError = ( { | ||
errorMessage = '', | ||
propertyName = '', | ||
elementId = '', | ||
}: ValidationInputErrorProps ): JSX.Element | null => { | ||
const { validationError, validationErrorId } = useSelect( ( select ) => { | ||
const store = select( VALIDATION_STORE_KEY ); | ||
return { | ||
validationError: store.getValidationError( propertyName ), | ||
validationErrorId: store.getValidationErrorId( elementId ), | ||
}; | ||
} ); | ||
|
||
if ( ! errorMessage || typeof errorMessage !== 'string' ) { | ||
if ( validationError?.message && ! validationError?.hidden ) { | ||
errorMessage = validationError.message; | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
return ( | ||
<div className="wc-block-components-validation-error" role="alert"> | ||
<p id={ validationErrorId }>{ errorMessage }</p> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ValidationInputError; |
File renamed without changes.