@cloudscape-design/components 3.0.264 → 3.0.266
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/attribute-editor/interfaces.d.ts +3 -2
- package/attribute-editor/interfaces.d.ts.map +1 -1
- package/attribute-editor/interfaces.js.map +1 -1
- package/attribute-editor/row.d.ts.map +1 -1
- package/attribute-editor/row.js +2 -1
- package/attribute-editor/row.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
- package/table/selection-control/index.d.ts.map +1 -1
- package/table/selection-control/index.js +1 -1
- package/table/selection-control/index.js.map +1 -1
- package/tag-editor/index.d.ts.map +1 -1
- package/tag-editor/index.js +6 -1
- package/tag-editor/index.js.map +1 -1
- package/tag-editor/interfaces.d.ts +1 -0
- package/tag-editor/interfaces.d.ts.map +1 -1
- package/tag-editor/interfaces.js.map +1 -1
|
@@ -31,9 +31,10 @@ export declare namespace AttributeEditorProps {
|
|
|
31
31
|
*/
|
|
32
32
|
focusAddButton(): void;
|
|
33
33
|
}
|
|
34
|
-
interface I18nStrings {
|
|
34
|
+
interface I18nStrings<T = any> {
|
|
35
35
|
errorIconAriaLabel?: string;
|
|
36
36
|
itemRemovedAriaLive?: string;
|
|
37
|
+
removeButtonAriaLabel?: (item: T) => string;
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
export interface AttributeEditorProps<T> extends BaseComponentProps {
|
|
@@ -92,6 +93,6 @@ export interface AttributeEditorProps<T> extends BaseComponentProps {
|
|
|
92
93
|
/**
|
|
93
94
|
* An object containing all the necessary localized strings required by the component.
|
|
94
95
|
*/
|
|
95
|
-
i18nStrings?: AttributeEditorProps.I18nStrings
|
|
96
|
+
i18nStrings?: AttributeEditorProps.I18nStrings<T>;
|
|
96
97
|
}
|
|
97
98
|
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","source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xB;IAED,UAAiB,WAAW,CAAC,CAAC,GAAG,GAAG;QAClC,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;KAC7C;CACF;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC,CAAE,SAAQ,kBAAkB;IACjE;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAExB;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAEjC;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAEzB;;;;OAIG;IACH,eAAe,CAAC,EAAE,oBAAoB,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;IAElE;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;;;;;;;OAUG;IACH,UAAU,EAAE,aAAa,CAAC,oBAAoB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAEnE;;OAEG;IACH,gBAAgB,CAAC,EAAE,yBAAyB,CAAC;IAE7C;;;OAGG;IACH,mBAAmB,CAAC,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,CAAC;IAE9F;;OAEG;IACH,WAAW,CAAC,EAAE,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;CACnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["attribute-editor/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\n\n/*\n * HACK: Cast the component to a named parametrized interface.\n *\n * This lets us use React.forwardRef and still let the component have type\n * parameters, and the naming convention lets the documenter know that this is\n * a forwardRef-wrapped component.\n *\n * We don't need to expose this type to customers because it's just a simple\n * function type.\n */\nexport interface AttributeEditorForwardRefType {\n <T>(props: AttributeEditorProps<T> & { ref?: React.Ref<AttributeEditorProps.Ref> }): JSX.Element;\n}\n\nexport namespace AttributeEditorProps {\n export interface IsItemRemovableFunction<T> {\n (item: T): boolean;\n }\n\n export type FieldRenderable<T> = (item: T, itemIndex: number) => React.ReactNode;\n export interface FieldDefinition<T> {\n label?: React.ReactNode;\n info?: React.ReactNode;\n control?: FieldRenderable<T> | React.ReactNode;\n errorText?: FieldRenderable<T> | React.ReactNode;\n constraintText?: FieldRenderable<T> | React.ReactNode;\n }\n\n export interface RemoveButtonClickDetail {\n itemIndex: number;\n }\n\n export interface Ref {\n /**\n * Focuses the 'remove' button for the given row index.\n */\n focusRemoveButton(itemIndex: number): void;\n /**\n * Focuses the 'add' button. Use this, for example, after a user removes the last row.\n */\n focusAddButton(): void;\n }\n\n export interface I18nStrings {\n errorIconAriaLabel?: string;\n
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["attribute-editor/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\n\n/*\n * HACK: Cast the component to a named parametrized interface.\n *\n * This lets us use React.forwardRef and still let the component have type\n * parameters, and the naming convention lets the documenter know that this is\n * a forwardRef-wrapped component.\n *\n * We don't need to expose this type to customers because it's just a simple\n * function type.\n */\nexport interface AttributeEditorForwardRefType {\n <T>(props: AttributeEditorProps<T> & { ref?: React.Ref<AttributeEditorProps.Ref> }): JSX.Element;\n}\n\nexport namespace AttributeEditorProps {\n export interface IsItemRemovableFunction<T> {\n (item: T): boolean;\n }\n\n export type FieldRenderable<T> = (item: T, itemIndex: number) => React.ReactNode;\n export interface FieldDefinition<T> {\n label?: React.ReactNode;\n info?: React.ReactNode;\n control?: FieldRenderable<T> | React.ReactNode;\n errorText?: FieldRenderable<T> | React.ReactNode;\n constraintText?: FieldRenderable<T> | React.ReactNode;\n }\n\n export interface RemoveButtonClickDetail {\n itemIndex: number;\n }\n\n export interface Ref {\n /**\n * Focuses the 'remove' button for the given row index.\n */\n focusRemoveButton(itemIndex: number): void;\n /**\n * Focuses the 'add' button. Use this, for example, after a user removes the last row.\n */\n focusAddButton(): void;\n }\n\n export interface I18nStrings<T = any> {\n errorIconAriaLabel?: string;\n itemRemovedAriaLive?: string;\n removeButtonAriaLabel?: (item: T) => string;\n }\n}\n\nexport interface AttributeEditorProps<T> extends BaseComponentProps {\n /**\n * Displayed when there are no items to display.\n */\n empty?: React.ReactNode;\n\n /**\n * Displayed below the add button. Use it for additional information related to the attribute editor.\n */\n additionalInfo?: React.ReactNode;\n\n /**\n * Specifies the text that's displayed in the add button.\n */\n addButtonText: string;\n\n /**\n * Specifies the text that's displayed in the remove button.\n */\n removeButtonText: string;\n\n /**\n * Specifies the items that serve as the data source for all rows.\n * The display of a row is handled by the `definition` property.\n */\n items?: ReadonlyArray<T>;\n\n /**\n * Function that determines whether an item is removable. When this function returns `false`, the remove\n * button is not rendered and the user can't remove the item.\n * By default, all items are removable.\n */\n isItemRemovable?: AttributeEditorProps.IsItemRemovableFunction<T>;\n\n /**\n * Determines whether the add button is disabled.\n */\n disableAddButton?: boolean;\n\n /**\n * Defines the editor configuration. Each object in the array represents one form field in the row.\n * * `label` (ReactNode) - Text label for the form field.\n * * `info` (ReactNode) - Info link for the form field.\n * * `errorText` ((item, itemIndex) => ReactNode) - Error message text to display as a control validation message.\n * It renders the form field as invalid if the returned value is not `null` or `undefined`.\n * * `constraintText` ((item, itemIndex) => ReactNode) - Text to display as a constraint message below the field.\n * * `control` ((item, itemIndex) => ReactNode) - A control to use as the input for the field.\n *\n * A maximum of four fields are supported.\n */\n definition: ReadonlyArray<AttributeEditorProps.FieldDefinition<T>>;\n\n /**\n * Called when add button is clicked.\n */\n onAddButtonClick?: NonCancelableEventHandler;\n\n /**\n * Called when remove button is clicked.\n * The event `detail` contains the index of the corresponding item.\n */\n onRemoveButtonClick?: NonCancelableEventHandler<AttributeEditorProps.RemoveButtonClickDetail>;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n */\n i18nStrings?: AttributeEditorProps.I18nStrings<T>;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row.d.ts","sourceRoot":"lib/default/","sources":["attribute-editor/row.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAE3C,OAA6B,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAA0B,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAQvF,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,UAAU,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAC1C,IAAI,EAAE,CAAC,CAAC;IACR,UAAU,EAAE,aAAa,CAAC,oBAAoB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IACnE,WAAW,EAAE,oBAAoB,CAAC,WAAW,GAAG,SAAS,CAAC;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,GAAG,SAAS,CAAC,CAAC;IACrD,mBAAmB,CAAC,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,CAAC;CAC/F;AAYD,eAAO,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"row.d.ts","sourceRoot":"lib/default/","sources":["attribute-editor/row.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAE3C,OAA6B,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAA0B,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAQvF,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,UAAU,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAC1C,IAAI,EAAE,CAAC,CAAC;IACR,UAAU,EAAE,aAAa,CAAC,oBAAoB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IACnE,WAAW,EAAE,oBAAoB,CAAC,WAAW,GAAG,SAAS,CAAC;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,GAAG,SAAS,CAAC,CAAC;IACrD,mBAAmB,CAAC,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,CAAC;CAC/F;AAYD,eAAO,MAAM,GAAG,yLA2Ef,CAAC"}
|
package/attribute-editor/row.js
CHANGED
|
@@ -17,6 +17,7 @@ function render(item, itemIndex, slot) {
|
|
|
17
17
|
const GRID_DEFINITION = [{ colspan: { default: 12, xs: 9 } }];
|
|
18
18
|
const REMOVABLE_GRID_DEFINITION = [{ colspan: { default: 12, xs: 9 } }, { colspan: { default: 12, xs: 3 } }];
|
|
19
19
|
export const Row = React.memo(({ breakpoint, item, definition, i18nStrings = {}, index, removable, removeButtonText, removeButtonRefs, onRemoveButtonClick, }) => {
|
|
20
|
+
var _a;
|
|
20
21
|
const isNarrowViewport = breakpoint === 'default' || breakpoint === 'xxs';
|
|
21
22
|
const isWideViewport = !isNarrowViewport;
|
|
22
23
|
const handleRemoveClick = useCallback(() => {
|
|
@@ -30,7 +31,7 @@ export const Row = React.memo(({ breakpoint, item, definition, i18nStrings = {},
|
|
|
30
31
|
removable && (React.createElement(ButtonContainer, { index: index, isNarrowViewport: isNarrowViewport, hasLabel: definition.some(row => row.label) },
|
|
31
32
|
React.createElement(InternalButton, { className: styles['remove-button'], formAction: "none", ref: ref => {
|
|
32
33
|
removeButtonRefs[index] = ref !== null && ref !== void 0 ? ref : undefined;
|
|
33
|
-
}, onClick: handleRemoveClick }, removeButtonText))))),
|
|
34
|
+
}, ariaLabel: (_a = i18nStrings.removeButtonAriaLabel) === null || _a === void 0 ? void 0 : _a.call(i18nStrings, item), onClick: handleRemoveClick }, removeButtonText))))),
|
|
34
35
|
isNarrowViewport && React.createElement(Divider, null)));
|
|
35
36
|
});
|
|
36
37
|
const ButtonContainer = ({ index, children, isNarrowViewport, hasLabel }) => (React.createElement("div", { className: clsx({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row.js","sourceRoot":"lib/default/","sources":["attribute-editor/row.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AACvD,OAAO,oBAAgD,MAAM,2BAA2B,CAAC;AAGzF,OAAO,EAAE,sBAAsB,EAA6B,MAAM,oBAAoB,CAAC;AACvF,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,WAAW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c. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport InternalBox from '../box/internal';\nimport styles from './styles.css.js';\nimport React, { useCallback } from 'react';\nimport InternalFormField from '../form-field/internal';\nimport InternalColumnLayout, { ColumnLayoutBreakpoint } from '../column-layout/internal';\nimport { AttributeEditorProps } from './interfaces';\nimport { ButtonProps } from '../button/interfaces';\nimport { fireNonCancelableEvent, NonCancelableEventHandler } from '../internal/events';\nimport InternalGrid from '../grid/internal';\nimport { InternalButton } from '../button/internal';\nimport clsx from 'clsx';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\n\nconst Divider = () => <InternalBox className={styles.divider} padding={{ top: 'l' }} />;\n\nexport interface RowProps<T> {\n breakpoint: ColumnLayoutBreakpoint | null;\n item: T;\n definition: ReadonlyArray<AttributeEditorProps.FieldDefinition<T>>;\n i18nStrings: AttributeEditorProps.I18nStrings | undefined;\n index: number;\n removable: boolean;\n removeButtonText: string;\n removeButtonRefs: Array<ButtonProps.Ref | undefined>;\n onRemoveButtonClick?: NonCancelableEventHandler<AttributeEditorProps.RemoveButtonClickDetail>;\n}\n\nfunction render<T>(\n item: T,\n itemIndex: number,\n slot: AttributeEditorProps.FieldRenderable<T> | React.ReactNode | undefined\n) {\n return typeof slot === 'function' ? slot(item, itemIndex) : slot;\n}\n\nconst GRID_DEFINITION = [{ colspan: { default: 12, xs: 9 } }];\nconst REMOVABLE_GRID_DEFINITION = [{ colspan: { default: 12, xs: 9 } }, { colspan: { default: 12, xs: 3 } }];\nexport const Row = React.memo(\n <T,>({\n breakpoint,\n item,\n definition,\n i18nStrings = {},\n index,\n removable,\n removeButtonText,\n removeButtonRefs,\n onRemoveButtonClick,\n }: RowProps<T>) => {\n const isNarrowViewport = breakpoint === 'default' || breakpoint === 'xxs';\n const isWideViewport = !isNarrowViewport;\n\n const handleRemoveClick = useCallback(() => {\n fireNonCancelableEvent(onRemoveButtonClick, { itemIndex: index });\n }, [onRemoveButtonClick, index]);\n\n const firstControlId = useUniqueId('first-control-id-');\n\n return (\n <InternalBox className={styles.row} margin={{ bottom: 's' }}>\n <div role=\"group\" aria-labelledby={`${firstControlId}-label ${firstControlId}`}>\n <InternalGrid\n __breakpoint={breakpoint}\n gridDefinition={removable ? REMOVABLE_GRID_DEFINITION : GRID_DEFINITION}\n >\n <InternalColumnLayout\n className={styles['row-control']}\n columns={definition.length}\n __breakpoint={breakpoint}\n >\n {definition.map(({ info, label, constraintText, errorText, control }, defIndex) => (\n <InternalFormField\n key={defIndex}\n className={styles.field}\n label={label}\n info={info}\n constraintText={render(item, index, constraintText)}\n errorText={render(item, index, errorText)}\n stretch={true}\n i18nStrings={{ errorIconAriaLabel: i18nStrings.errorIconAriaLabel }}\n __hideLabel={isWideViewport && index > 0}\n controlId={defIndex === 0 ? firstControlId : undefined}\n >\n {render(item, index, control)}\n </InternalFormField>\n ))}\n </InternalColumnLayout>\n {removable && (\n <ButtonContainer\n index={index}\n isNarrowViewport={isNarrowViewport}\n hasLabel={definition.some(row => row.label)}\n >\n <InternalButton\n className={styles['remove-button']}\n formAction=\"none\"\n ref={ref => {\n removeButtonRefs[index] = ref ?? undefined;\n }}\n ariaLabel={i18nStrings.removeButtonAriaLabel?.(item)}\n onClick={handleRemoveClick}\n >\n {removeButtonText}\n </InternalButton>\n </ButtonContainer>\n )}\n </InternalGrid>\n </div>\n {isNarrowViewport && <Divider />}\n </InternalBox>\n );\n }\n);\n\ninterface ButtonContainer {\n index: number;\n children: React.ReactNode;\n isNarrowViewport: boolean;\n hasLabel: boolean;\n}\n\nconst ButtonContainer = ({ index, children, isNarrowViewport, hasLabel }: ButtonContainer) => (\n <div\n className={clsx({\n [styles['button-container-haslabel']]: !isNarrowViewport && index === 0 && hasLabel,\n [styles['button-container-nolabel']]: !isNarrowViewport && index === 0 && !hasLabel,\n [styles['right-align']]: isNarrowViewport,\n })}\n >\n {children}\n </div>\n);\n"]}
|
package/internal/environment.js
CHANGED
package/internal/manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["table/selection-control/index.tsx"],"names":[],"mappings":"AAGA,OAAc,EAAiB,oBAAoB,EAAc,MAAM,OAAO,CAAC;AAO/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC3D,aAAa,CAAC,CAAC,YAAY,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5C,SAAS,CAAC,EAAE,oBAAoB,CAAC;IACjC,WAAW,CAAC,EAAE,oBAAoB,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IAEd,gBAAgB,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC/C,wBAAwB,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,KAAK,IAAI,CAAC;CAC3E;AAED,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,aAAa,EACb,aAAqB,EACrB,aAAa,EACb,SAAS,EACT,WAAW,EACX,IAAI,EACJ,SAAS,EAET,gBAAgB,EAChB,wBAAwB,EACxB,GAAG,WAAW,EACf,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["table/selection-control/index.tsx"],"names":[],"mappings":"AAGA,OAAc,EAAiB,oBAAoB,EAAc,MAAM,OAAO,CAAC;AAO/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC3D,aAAa,CAAC,CAAC,YAAY,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5C,SAAS,CAAC,EAAE,oBAAoB,CAAC;IACjC,WAAW,CAAC,EAAE,oBAAoB,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IAEd,gBAAgB,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC/C,wBAAwB,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,KAAK,IAAI,CAAC;CAC3E;AAED,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,aAAa,EACb,aAAqB,EACrB,aAAa,EACb,SAAS,EACT,WAAW,EACX,IAAI,EACJ,SAAS,EAET,gBAAgB,EAChB,wBAAwB,EACxB,GAAG,WAAW,EACf,EAAE,qBAAqB,eA4EvB"}
|
|
@@ -48,7 +48,7 @@ export default function SelectionControl(_a) {
|
|
|
48
48
|
};
|
|
49
49
|
const selector = isMultiSelection ? (React.createElement(InternalCheckbox, Object.assign({}, sharedProps, { showOutline: (focusedComponent === null || focusedComponent === void 0 ? void 0 : focusedComponent.type) === 'selection', onFocus: () => onFocusedComponentChange === null || onFocusedComponentChange === void 0 ? void 0 : onFocusedComponentChange({ type: 'selection' }), onBlur: () => onFocusedComponentChange === null || onFocusedComponentChange === void 0 ? void 0 : onFocusedComponentChange(null), controlId: controlId, indeterminate: indeterminate }))) : (React.createElement(RadioButton, Object.assign({}, sharedProps, { controlId: controlId, name: name, value: '', label: '' })));
|
|
50
50
|
return (React.createElement(React.Fragment, null,
|
|
51
|
-
React.createElement("label", { onKeyDown: handleKeyDown, onKeyUp: setShiftState, onMouseDown: onMouseDownHandler, onMouseUp: setShiftState, onClick: handleClick, htmlFor: controlId, className: clsx(styles.label, styles.root), "aria-label": ariaLabel }, selector),
|
|
51
|
+
React.createElement("label", { onKeyDown: handleKeyDown, onKeyUp: setShiftState, onMouseDown: onMouseDownHandler, onMouseUp: setShiftState, onClick: handleClick, htmlFor: controlId, className: clsx(styles.label, styles.root), "aria-label": ariaLabel, title: ariaLabel }, selector),
|
|
52
52
|
React.createElement("span", { className: clsx(styles.stud), "aria-hidden": true }, "\u00A0")));
|
|
53
53
|
}
|
|
54
54
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["table/selection-control/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAA0D,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,gBAAgB,MAAM,yBAAyB,CAAC;AACvD,OAAO,WAAW,MAAM,gCAAgC,CAAC;AAEzD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAerC,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EAYjB;QAZiB,EACvC,aAAa,EACb,aAAa,GAAG,KAAK,EACrB,aAAa,EACb,SAAS,EACT,WAAW,EACX,IAAI,EACJ,SAAS,EAET,gBAAgB,EAChB,wBAAwB,OAEF,EADnB,WAAW,cAXyB,oJAYxC,CADe;IAEd,MAAM,SAAS,GAAG,WAAW,EAAE,CAAC;IAChC,MAAM,gBAAgB,GAAG,aAAa,KAAK,OAAO,CAAC;IAEnD,MAAM,aAAa,GAAG,CAAC,KAAiC,EAAE,EAAE;QAC1D,IAAI,gBAAgB,EAAE;YACpB,aAAa,IAAI,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;SAChD;IACH,CAAC,CAAC;IAEF,MAAM,kBAAkB,GAAG,CAAC,KAAiB,EAAE,EAAE;QAC/C,aAAa,CAAC,KAAK,CAAC,CAAC;QACrB,IAAI,gBAAgB,EAAE;YACpB,uBAAuB;YACvB,uFAAuF;YACvF,sDAAsD;YACtD,KAAK,CAAC,cAAc,EAAE,CAAC;SACxB;IACH,CAAC,CAAC;IAEF,+F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5B,CACH,CAAC,CAAC,CAAC,CACF,oBAAC,WAAW,oBAAK,WAAW,IAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,CACzF,CAAC;IAEF,OAAO,CACL;QACE,+BACE,SAAS,EAAE,aAAa,EACxB,OAAO,EAAE,aAAa,EACtB,WAAW,EAAE,kBAAkB,EAC/B,SAAS,EAAE,aAAa,EACxB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,SAAS,EAClB,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,gBAC9B,SAAS,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["table/selection-control/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAA0D,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,gBAAgB,MAAM,yBAAyB,CAAC;AACvD,OAAO,WAAW,MAAM,gCAAgC,CAAC;AAEzD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAerC,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EAYjB;QAZiB,EACvC,aAAa,EACb,aAAa,GAAG,KAAK,EACrB,aAAa,EACb,SAAS,EACT,WAAW,EACX,IAAI,EACJ,SAAS,EAET,gBAAgB,EAChB,wBAAwB,OAEF,EADnB,WAAW,cAXyB,oJAYxC,CADe;IAEd,MAAM,SAAS,GAAG,WAAW,EAAE,CAAC;IAChC,MAAM,gBAAgB,GAAG,aAAa,KAAK,OAAO,CAAC;IAEnD,MAAM,aAAa,GAAG,CAAC,KAAiC,EAAE,EAAE;QAC1D,IAAI,gBAAgB,EAAE;YACpB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AAhB,gBAAgB,CAAE,IAAI,MAAK,WAAW,EACnD,OAAO,EAAE,GAAG,EAAE,CAAC,wBAAwB,aAAxB,wBAAwB,uBAAxB,wBAAwB,CAAG,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,EAChE,MAAM,EAAE,GAAG,EAAE,CAAC,wBAAwB,aAAxB,wBAAwB,uBAAxB,wBAAwB,CAAG,IAAI,CAAC,EAC9C,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,aAAa,IAC5B,CACH,CAAC,CAAC,CAAC,CACF,oBAAC,WAAW,oBAAK,WAAW,IAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,CACzF,CAAC;IAEF,OAAO,CACL;QACE,+BACE,SAAS,EAAE,aAAa,EACxB,OAAO,EAAE,aAAa,EACtB,WAAW,EAAE,kBAAkB,EAC/B,SAAS,EAAE,aAAa,EACxB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,SAAS,EAClB,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,gBAC9B,SAAS,EACrB,KAAK,EAAE,SAAS,IAEf,QAAQ,CACH;QAER,8BAAM,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAe,IAAI,aAE9C,CACN,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React, { KeyboardEvent, KeyboardEventHandler, MouseEvent } from 'react';\nimport { KeyCode } from '../../internal/keycode';\nimport { useUniqueId } from '../../internal/hooks/use-unique-id';\nimport InternalCheckbox from '../../checkbox/internal';\nimport RadioButton from '../../radio-group/radio-button';\n\nimport styles from './styles.css.js';\nimport { InteractiveComponent } from '../thead';\nimport { SelectionProps } from '../use-selection';\n\nexport interface SelectionControlProps extends SelectionProps {\n onShiftToggle?(shiftPressed: boolean): void;\n onFocusUp?: KeyboardEventHandler;\n onFocusDown?: KeyboardEventHandler;\n ariaLabel?: string;\n tabIndex?: -1;\n\n focusedComponent?: InteractiveComponent | null;\n onFocusedComponentChange?: (element: InteractiveComponent | null) => void;\n}\n\nexport default function SelectionControl({\n selectionType,\n indeterminate = false,\n onShiftToggle,\n onFocusUp,\n onFocusDown,\n name,\n ariaLabel,\n\n focusedComponent,\n onFocusedComponentChange,\n ...sharedProps\n}: SelectionControlProps) {\n const controlId = useUniqueId();\n const isMultiSelection = selectionType === 'multi';\n\n const setShiftState = (event: KeyboardEvent | MouseEvent) => {\n if (isMultiSelection) {\n onShiftToggle && onShiftToggle(event.shiftKey);\n }\n };\n\n const onMouseDownHandler = (event: MouseEvent) => {\n setShiftState(event);\n if (isMultiSelection) {\n // To overcome an issue\n // If you shift+click or ctrl+click on a label for a checkbox, checkbox is not checked.\n // https://bugzilla.mozilla.org/show_bug.cgi?id=559506\n event.preventDefault();\n }\n };\n\n // native checkboxes do not have focus move via keyboard, we implement it here programmatically\n const handleKeyDown = (event: KeyboardEvent) => {\n setShiftState(event);\n if (isMultiSelection) {\n if (event.keyCode === KeyCode.up) {\n event.preventDefault();\n onFocusUp && onFocusUp(event);\n }\n if (event.keyCode === KeyCode.down) {\n event.preventDefault();\n onFocusDown && onFocusDown(event);\n }\n }\n };\n\n const handleClick = (event: MouseEvent) => {\n const target = event.currentTarget;\n const nativeInput = (target.tagName === 'INPUT' ? target : target.querySelector('input')) as HTMLInputElement;\n // Clicking on input, does not focus it on Firefox (AWSUI-11345)\n nativeInput?.focus();\n };\n\n const selector = isMultiSelection ? (\n <InternalCheckbox\n {...sharedProps}\n showOutline={focusedComponent?.type === 'selection'}\n onFocus={() => onFocusedComponentChange?.({ type: 'selection' })}\n onBlur={() => onFocusedComponentChange?.(null)}\n controlId={controlId}\n indeterminate={indeterminate}\n />\n ) : (\n <RadioButton {...sharedProps} controlId={controlId} name={name} value={''} label={''} />\n );\n\n return (\n <>\n <label\n onKeyDown={handleKeyDown}\n onKeyUp={setShiftState}\n onMouseDown={onMouseDownHandler}\n onMouseUp={setShiftState}\n onClick={handleClick}\n htmlFor={controlId}\n className={clsx(styles.label, styles.root)}\n aria-label={ariaLabel}\n title={ariaLabel}\n >\n {selector}\n </label>\n {/* HACK: IE11 collapses td's height to 0, if it contains only an absouletely positioned label */}\n <span className={clsx(styles.stud)} aria-hidden={true}>\n \n </span>\n </>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["tag-editor/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6E,MAAM,OAAO,CAAC;AAgBlG,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAS9C,OAAO,EAAE,cAAc,EAAE,CAAC;AAS1B,QAAA,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["tag-editor/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6E,MAAM,OAAO,CAAC;AAgBlG,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAS9C,OAAO,EAAE,cAAc,EAAE,CAAC;AAS1B,QAAA,MAAM,SAAS,2FAgRd,CAAC;AAGF,eAAe,SAAS,CAAC"}
|
package/tag-editor/index.js
CHANGED
|
@@ -152,13 +152,18 @@ const TagEditor = React.forwardRef((_a, ref) => {
|
|
|
152
152
|
errorText: ({ error }) => error === null || error === void 0 ? void 0 : error.value,
|
|
153
153
|
},
|
|
154
154
|
], [i18nStrings, keysRequest, onKeyChange, onKeyBlur, valuesRequest, onValueChange, onUndoRemoval]);
|
|
155
|
+
const forwardedI18nStrings = useMemo(() => ({
|
|
156
|
+
errorIconAriaLabel: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.errorIconAriaLabel,
|
|
157
|
+
itemRemovedAriaLive: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.itemRemovedAriaLive,
|
|
158
|
+
removeButtonAriaLabel: i18nStrings.removeButtonAriaLabel && (({ tag }) => i18nStrings.removeButtonAriaLabel(tag)),
|
|
159
|
+
}), [i18nStrings]);
|
|
155
160
|
if (loading) {
|
|
156
161
|
return (React.createElement("div", { className: styles.root, ref: baseComponentProps.__internalRootRef },
|
|
157
162
|
React.createElement(InternalStatusIndicator, { className: styles.loading, type: "loading" },
|
|
158
163
|
React.createElement(LiveRegion, { visible: true }, i18nStrings.loading))));
|
|
159
164
|
}
|
|
160
165
|
const baseProps = getBaseProps(restProps);
|
|
161
|
-
return (React.createElement(InternalAttributeEditor, Object.assign({}, baseProps, baseComponentProps, { ref: attributeEditorRef, className: clsx(styles.root, baseProps.className), items: internalTags, isItemRemovable: isItemRemovable, onAddButtonClick: onAddButtonClick, onRemoveButtonClick: onRemoveButtonClick, addButtonText: i18nStrings.addButton, removeButtonText: i18nStrings.removeButton, disableAddButton: remainingTags <= 0, empty: i18nStrings.emptyTags, additionalInfo: remainingTags < 0 ? (React.createElement(FormFieldError, { errorIconAriaLabel: i18nStrings.errorIconAriaLabel }, (_b = i18nStrings.tagLimitExceeded(tagLimit)) !== null && _b !== void 0 ? _b : '')) : remainingTags === 0 ? ((_c = i18nStrings.tagLimitReached(tagLimit)) !== null && _c !== void 0 ? _c : '') : (i18nStrings.tagLimit(remainingTags, tagLimit)), definition: definition, i18nStrings:
|
|
166
|
+
return (React.createElement(InternalAttributeEditor, Object.assign({}, baseProps, baseComponentProps, { ref: attributeEditorRef, className: clsx(styles.root, baseProps.className), items: internalTags, isItemRemovable: isItemRemovable, onAddButtonClick: onAddButtonClick, onRemoveButtonClick: onRemoveButtonClick, addButtonText: i18nStrings.addButton, removeButtonText: i18nStrings.removeButton, disableAddButton: remainingTags <= 0, empty: i18nStrings.emptyTags, additionalInfo: remainingTags < 0 ? (React.createElement(FormFieldError, { errorIconAriaLabel: i18nStrings.errorIconAriaLabel }, (_b = i18nStrings.tagLimitExceeded(tagLimit)) !== null && _b !== void 0 ? _b : '')) : remainingTags === 0 ? ((_c = i18nStrings.tagLimitReached(tagLimit)) !== null && _c !== void 0 ? _c : '') : (i18nStrings.tagLimit(remainingTags, tagLimit)), definition: definition, i18nStrings: forwardedI18nStrings })));
|
|
162
167
|
});
|
|
163
168
|
applyDisplayName(TagEditor, 'TagEditor');
|
|
164
169
|
export default TagEditor;
|
package/tag-editor/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["tag-editor/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,mBAAmB,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAClG,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAA4B,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AAKnF,OAAO,uBAAuB,MAAM,8BAA8B,CAAC;AACnE,OAAO,uBAAuB,MAAM,8BAA8B,CAAC;AACnE,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,EAAE,QAAQ,EAAmB,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEtD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,UAAU,MAAM,o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AAC,CACF,WAAW,CAAC,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC,CAC9C,EAEH,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,IACxB,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AACzC,eAAe,SAAS,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useImperativeHandle, useLayoutEffect, useMemo, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { fireNonCancelableEvent, NonCancelableCustomEvent } from '../internal/events';\nimport { useStableEventHandler } from '../internal/hooks/use-stable-event-handler';\n\nimport { InputProps } from '../input/interfaces';\nimport { AutosuggestProps } from '../autosuggest/interfaces';\nimport { AttributeEditorProps } from '../attribute-editor/interfaces';\nimport InternalAttributeEditor from '../attribute-editor/internal';\nimport InternalStatusIndicator from '../status-indicator/internal';\nimport InternalBox from '../box/internal';\nimport { FormFieldError } from '../form-field/internal';\n\nimport { TagControl, UndoButton } from './internal';\nimport { TagEditorProps } from './interfaces';\nimport { validate, ValidationError } from './validation';\nimport { findIndex, useMemoizedArray } from './utils';\n\nimport styles from './styles.css.js';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport LiveRegion from '../internal/components/live-region';\n\nexport { TagEditorProps };\n\ninterface InternalTag {\n tag: TagEditorProps.Tag;\n error?: ValidationError;\n}\n\nconst isItemRemovable = ({ tag }: InternalTag) => !tag.markedForRemoval;\n\nconst TagEditor = React.forwardRef(\n (\n {\n tags = [],\n i18nStrings,\n loading = false,\n tagLimit = 50,\n allowedCharacterPattern,\n keysRequest,\n valuesRequest,\n onChange,\n ...restProps\n }: TagEditorProps,\n ref: React.Ref<TagEditorProps.Ref>\n ) => {\n const baseComponentProps = useBaseComponent('TagEditor');\n\n const remainingTags = tagLimit - tags.filter(tag => !tag.markedForRemoval).length;\n\n const attributeEditorRef = useRef<AttributeEditorProps.Ref>(null);\n const keyInputRefs = useRef<(InputProps.Ref | undefined | null)[]>([]);\n const valueInputRefs = useRef<(InputProps.Ref | undefined | null)[]>([]);\n const undoButtonRefs = useRef<(HTMLAnchorElement | undefined | null)[]>([]);\n\n const initialKeyOptionsRef = useRef<AutosuggestProps.Options>([]);\n const keyDirtyStateRef = useRef<boolean[]>([]);\n const focusEventRef = useRef<() => void>();\n\n useLayoutEffect(() => {\n focusEventRef.current?.apply(undefined);\n focusEventRef.current = undefined;\n });\n\n const errors = validate(\n tags,\n keyDirtyStateRef.current,\n i18nStrings,\n allowedCharacterPattern ? new RegExp(allowedCharacterPattern) : undefined\n );\n\n const internalTags = useMemoizedArray(\n tags.map((tag, i) => ({ tag, error: errors[i] })),\n (prev, next) => {\n return prev.tag === next.tag && prev.error?.key === next.error?.key && prev.error?.value === next.error?.value;\n }\n );\n\n useImperativeHandle(\n ref,\n () => ({\n focus() {\n const errorIndex = findIndex(internalTags, ({ error }) => error?.key || error?.value);\n if (errorIndex !== -1) {\n const refArray = internalTags[errorIndex].error?.key ? keyInputRefs : valueInputRefs;\n refArray.current[errorIndex]?.focus();\n }\n },\n }),\n [internalTags]\n );\n\n const validateAndFire = useCallback(\n (newTags: ReadonlyArray<TagEditorProps.Tag>) => {\n fireNonCancelableEvent(onChange, {\n tags: newTags,\n valid: !validate(\n newTags,\n keyDirtyStateRef.current,\n i18nStrings,\n allowedCharacterPattern ? new RegExp(allowedCharacterPattern) : undefined\n ).some(error => error),\n });\n },\n [onChange, i18nStrings, allowedCharacterPattern]\n );\n\n const onAddButtonClick = () => {\n validateAndFire([...tags, { key: '', value: '', existing: false }]);\n focusEventRef.current = () => {\n keyInputRefs.current[tags.length]?.focus();\n };\n };\n\n const onRemoveButtonClick = useStableEventHandler(\n ({ detail }: NonCancelableCustomEvent<AttributeEditorProps.RemoveButtonClickDetail>) => {\n const existing = tags[detail.itemIndex].existing;\n validateAndFire([\n ...tags.slice(0, detail.itemIndex),\n ...(existing ? [{ ...tags[detail.itemIndex], markedForRemoval: true }] : []),\n ...tags.slice(detail.itemIndex + 1),\n ]);\n if (existing) {\n focusEventRef.current = () => {\n undoButtonRefs.current[detail.itemIndex]?.focus();\n };\n } else {\n keyDirtyStateRef.current.splice(detail.itemIndex, 1);\n const nextKey = keyInputRefs.current[detail.itemIndex + 1];\n if (nextKey) {\n // if next key is present, focus _current_ key which will be replaced by next after state update\n keyInputRefs.current[detail.itemIndex]?.focus();\n } else if (detail.itemIndex > 0) {\n // otherwise focus previous key/value/undo button\n const previousIsExisting = tags[detail.itemIndex - 1].existing;\n if (previousIsExisting) {\n if (tags[detail.itemIndex - 1].markedForRemoval) {\n undoButtonRefs.current[detail.itemIndex - 1]?.focus();\n } else {\n valueInputRefs.current[detail.itemIndex - 1]?.focus();\n }\n } else {\n keyInputRefs.current[detail.itemIndex - 1]?.focus();\n }\n } else {\n // or the 'add' button\n attributeEditorRef.current?.focusAddButton();\n }\n }\n }\n );\n\n const onKeyChange = useStableEventHandler((value: string, row: number) => {\n keyDirtyStateRef.current[row] = true;\n validateAndFire([...tags.slice(0, row), { ...tags[row], key: value }, ...tags.slice(row + 1)]);\n });\n\n const onKeyBlur = useStableEventHandler((row: number) => {\n keyDirtyStateRef.current[row] = true;\n // Force re-render by providing a new array reference\n validateAndFire([...tags]);\n });\n\n const onValueChange = useStableEventHandler((value: string, row: number) => {\n validateAndFire([...tags.slice(0, row), { ...tags[row], value }, ...tags.slice(row + 1)]);\n });\n\n const onUndoRemoval = useStableEventHandler((row: number) => {\n validateAndFire([...tags.slice(0, row), { ...tags[row], markedForRemoval: false }, ...tags.slice(row + 1)]);\n focusEventRef.current = () => {\n attributeEditorRef.current?.focusRemoveButton(row);\n };\n });\n\n const definition = useMemo(\n () => [\n {\n label: i18nStrings.keyHeader,\n control: ({ tag }: InternalTag, row: number) => (\n <TagControl\n row={row}\n value={tag.key}\n readOnly={tag.existing}\n limit={200}\n defaultOptions={[]}\n placeholder={i18nStrings.keyPlaceholder}\n errorText={i18nStrings.keysSuggestionError}\n loadingText={i18nStrings.keysSuggestionLoading}\n suggestionText={i18nStrings.keySuggestion}\n tooManySuggestionText={i18nStrings.tooManyKeysSuggestion}\n enteredTextLabel={i18nStrings.enteredKeyLabel}\n clearAriaLabel={i18nStrings.clearAriaLabel}\n onRequest={keysRequest}\n onChange={onKeyChange}\n onBlur={onKeyBlur}\n initialOptionsRef={initialKeyOptionsRef}\n ref={ref => {\n keyInputRefs.current[row] = ref;\n }}\n />\n ),\n errorText: ({ error }: InternalTag) => error?.key,\n },\n {\n label: (\n <>\n {i18nStrings.valueHeader} - <i>{i18nStrings.optional}</i>\n </>\n ),\n control: ({ tag }: InternalTag, row: number) =>\n tag.markedForRemoval ? (\n <div role=\"alert\">\n <InternalBox margin={{ top: 'xxs' }}>\n {i18nStrings.undoPrompt}{' '}\n <UndoButton\n onClick={() => onUndoRemoval(row)}\n ref={elem => {\n undoButtonRefs.current[row] = elem;\n }}\n >\n {i18nStrings.undoButton}\n </UndoButton>\n </InternalBox>\n </div>\n ) : (\n <TagControl\n row={row}\n value={tag.value}\n readOnly={false}\n limit={200}\n defaultOptions={tag.valueSuggestionOptions ?? []}\n placeholder={i18nStrings.valuePlaceholder}\n errorText={i18nStrings.valuesSuggestionError}\n loadingText={i18nStrings.valuesSuggestionLoading}\n suggestionText={i18nStrings.valueSuggestion}\n tooManySuggestionText={i18nStrings.tooManyValuesSuggestion}\n enteredTextLabel={i18nStrings.enteredValueLabel}\n clearAriaLabel={i18nStrings.clearAriaLabel}\n filteringKey={tag.key}\n onRequest={valuesRequest && (value => valuesRequest(tag.key, value))}\n onChange={onValueChange}\n ref={ref => {\n valueInputRefs.current[row] = ref;\n }}\n />\n ),\n errorText: ({ error }: InternalTag) => error?.value,\n },\n ],\n [i18nStrings, keysRequest, onKeyChange, onKeyBlur, valuesRequest, onValueChange, onUndoRemoval]\n );\n\n if (loading) {\n return (\n <div className={styles.root} ref={baseComponentProps.__internalRootRef}>\n <InternalStatusIndicator className={styles.loading} type=\"loading\">\n <LiveRegion visible={true}>{i18nStrings.loading}</LiveRegion>\n </InternalStatusIndicator>\n </div>\n );\n }\n\n const baseProps = getBaseProps(restProps);\n return (\n <InternalAttributeEditor<InternalTag>\n {...baseProps}\n {...baseComponentProps}\n ref={attributeEditorRef}\n className={clsx(styles.root, baseProps.className)}\n items={internalTags}\n isItemRemovable={isItemRemovable}\n onAddButtonClick={onAddButtonClick}\n onRemoveButtonClick={onRemoveButtonClick}\n addButtonText={i18nStrings.addButton}\n removeButtonText={i18nStrings.removeButton}\n disableAddButton={remainingTags <= 0}\n empty={i18nStrings.emptyTags}\n additionalInfo={\n remainingTags < 0 ? (\n <FormFieldError errorIconAriaLabel={i18nStrings.errorIconAriaLabel}>\n {i18nStrings.tagLimitExceeded(tagLimit) ?? ''}\n </FormFieldError>\n ) : remainingTags === 0 ? (\n i18nStrings.tagLimitReached(tagLimit) ?? ''\n ) : (\n i18nStrings.tagLimit(remainingTags, tagLimit)\n )\n }\n definition={definition}\n i18nStrings={i18nStrings}\n />\n );\n }\n);\n\napplyDisplayName(TagEditor, 'TagEditor');\nexport default TagEditor;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["tag-editor/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,mBAAmB,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAClG,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAA4B,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AAKnF,OAAO,uBAAuB,MA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AAG,WAAW,CAAC,OAAO,CAAc,CACrC,CACtB,CACP,CAAC;KACH;IAED,MAAM,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1C,OAAO,CACL,oBAAC,uBAAuB,oBAClB,SAAS,EACT,kBAAkB,IACtB,GAAG,EAAE,kBAAkB,EACvB,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC,EACjD,KAAK,EAAE,YAAY,EACnB,eAAe,EAAE,eAAe,EAChC,gBAAgB,EAAE,gBAAgB,EAClC,mBAAmB,EAAE,mBAAmB,EACxC,aAAa,EAAE,WAAW,CAAC,SAAS,EACpC,gBAAgB,EAAE,WAAW,CAAC,YAAY,EAC1C,gBAAgB,EAAE,aAAa,IAAI,CAAC,EACpC,KAAK,EAAE,WAAW,CAAC,SAAS,EAC5B,cAAc,EACZ,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC,CAClB,oBAAC,cAAc,IAAC,kBAAkB,EAAE,WAAW,CAAC,kBAAkB,IAC/D,MAAA,WAAW,CAAC,gBAAgB,CAAC,QAAQ,CAAC,mCAAI,EAAE,CAC9B,CAClB,CAAC,CAAC,CAAC,aAAa,KAAK,CAAC,CAAC,CAAC,CAAC,CACxB,MAAA,WAAW,CAAC,eAAe,CAAC,QAAQ,CAAC,mCAAI,EAAE,CAC5C,CAAC,CAAC,CAAC,CACF,WAAW,CAAC,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC,CAC9C,EAEH,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,oBAAoB,IACjC,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AACzC,eAAe,SAAS,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useCallback, useImperativeHandle, useLayoutEffect, useMemo, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { fireNonCancelableEvent, NonCancelableCustomEvent } from '../internal/events';\nimport { useStableEventHandler } from '../internal/hooks/use-stable-event-handler';\n\nimport { InputProps } from '../input/interfaces';\nimport { AutosuggestProps } from '../autosuggest/interfaces';\nimport { AttributeEditorProps } from '../attribute-editor/interfaces';\nimport InternalAttributeEditor from '../attribute-editor/internal';\nimport InternalStatusIndicator from '../status-indicator/internal';\nimport InternalBox from '../box/internal';\nimport { FormFieldError } from '../form-field/internal';\n\nimport { TagControl, UndoButton } from './internal';\nimport { TagEditorProps } from './interfaces';\nimport { validate, ValidationError } from './validation';\nimport { findIndex, useMemoizedArray } from './utils';\n\nimport styles from './styles.css.js';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport LiveRegion from '../internal/components/live-region';\n\nexport { TagEditorProps };\n\ninterface InternalTag {\n tag: TagEditorProps.Tag;\n error?: ValidationError;\n}\n\nconst isItemRemovable = ({ tag }: InternalTag) => !tag.markedForRemoval;\n\nconst TagEditor = React.forwardRef(\n (\n {\n tags = [],\n i18nStrings,\n loading = false,\n tagLimit = 50,\n allowedCharacterPattern,\n keysRequest,\n valuesRequest,\n onChange,\n ...restProps\n }: TagEditorProps,\n ref: React.Ref<TagEditorProps.Ref>\n ) => {\n const baseComponentProps = useBaseComponent('TagEditor');\n\n const remainingTags = tagLimit - tags.filter(tag => !tag.markedForRemoval).length;\n\n const attributeEditorRef = useRef<AttributeEditorProps.Ref>(null);\n const keyInputRefs = useRef<(InputProps.Ref | undefined | null)[]>([]);\n const valueInputRefs = useRef<(InputProps.Ref | undefined | null)[]>([]);\n const undoButtonRefs = useRef<(HTMLAnchorElement | undefined | null)[]>([]);\n\n const initialKeyOptionsRef = useRef<AutosuggestProps.Options>([]);\n const keyDirtyStateRef = useRef<boolean[]>([]);\n const focusEventRef = useRef<() => void>();\n\n useLayoutEffect(() => {\n focusEventRef.current?.apply(undefined);\n focusEventRef.current = undefined;\n });\n\n const errors = validate(\n tags,\n keyDirtyStateRef.current,\n i18nStrings,\n allowedCharacterPattern ? new RegExp(allowedCharacterPattern) : undefined\n );\n\n const internalTags = useMemoizedArray(\n tags.map((tag, i) => ({ tag, error: errors[i] })),\n (prev, next) => {\n return prev.tag === next.tag && prev.error?.key === next.error?.key && prev.error?.value === next.error?.value;\n }\n );\n\n useImperativeHandle(\n ref,\n () => ({\n focus() {\n const errorIndex = findIndex(internalTags, ({ error }) => error?.key || error?.value);\n if (errorIndex !== -1) {\n const refArray = internalTags[errorIndex].error?.key ? keyInputRefs : valueInputRefs;\n refArray.current[errorIndex]?.focus();\n }\n },\n }),\n [internalTags]\n );\n\n const validateAndFire = useCallback(\n (newTags: ReadonlyArray<TagEditorProps.Tag>) => {\n fireNonCancelableEvent(onChange, {\n tags: newTags,\n valid: !validate(\n newTags,\n keyDirtyStateRef.current,\n i18nStrings,\n allowedCharacterPattern ? new RegExp(allowedCharacterPattern) : undefined\n ).some(error => error),\n });\n },\n [onChange, i18nStrings, allowedCharacterPattern]\n );\n\n const onAddButtonClick = () => {\n validateAndFire([...tags, { key: '', value: '', existing: false }]);\n focusEventRef.current = () => {\n keyInputRefs.current[tags.length]?.focus();\n };\n };\n\n const onRemoveButtonClick = useStableEventHandler(\n ({ detail }: NonCancelableCustomEvent<AttributeEditorProps.RemoveButtonClickDetail>) => {\n const existing = tags[detail.itemIndex].existing;\n validateAndFire([\n ...tags.slice(0, detail.itemIndex),\n ...(existing ? [{ ...tags[detail.itemIndex], markedForRemoval: true }] : []),\n ...tags.slice(detail.itemIndex + 1),\n ]);\n if (existing) {\n focusEventRef.current = () => {\n undoButtonRefs.current[detail.itemIndex]?.focus();\n };\n } else {\n keyDirtyStateRef.current.splice(detail.itemIndex, 1);\n const nextKey = keyInputRefs.current[detail.itemIndex + 1];\n if (nextKey) {\n // if next key is present, focus _current_ key which will be replaced by next after state update\n keyInputRefs.current[detail.itemIndex]?.focus();\n } else if (detail.itemIndex > 0) {\n // otherwise focus previous key/value/undo button\n const previousIsExisting = tags[detail.itemIndex - 1].existing;\n if (previousIsExisting) {\n if (tags[detail.itemIndex - 1].markedForRemoval) {\n undoButtonRefs.current[detail.itemIndex - 1]?.focus();\n } else {\n valueInputRefs.current[detail.itemIndex - 1]?.focus();\n }\n } else {\n keyInputRefs.current[detail.itemIndex - 1]?.focus();\n }\n } else {\n // or the 'add' button\n attributeEditorRef.current?.focusAddButton();\n }\n }\n }\n );\n\n const onKeyChange = useStableEventHandler((value: string, row: number) => {\n keyDirtyStateRef.current[row] = true;\n validateAndFire([...tags.slice(0, row), { ...tags[row], key: value }, ...tags.slice(row + 1)]);\n });\n\n const onKeyBlur = useStableEventHandler((row: number) => {\n keyDirtyStateRef.current[row] = true;\n // Force re-render by providing a new array reference\n validateAndFire([...tags]);\n });\n\n const onValueChange = useStableEventHandler((value: string, row: number) => {\n validateAndFire([...tags.slice(0, row), { ...tags[row], value }, ...tags.slice(row + 1)]);\n });\n\n const onUndoRemoval = useStableEventHandler((row: number) => {\n validateAndFire([...tags.slice(0, row), { ...tags[row], markedForRemoval: false }, ...tags.slice(row + 1)]);\n focusEventRef.current = () => {\n attributeEditorRef.current?.focusRemoveButton(row);\n };\n });\n\n const definition = useMemo(\n () => [\n {\n label: i18nStrings.keyHeader,\n control: ({ tag }: InternalTag, row: number) => (\n <TagControl\n row={row}\n value={tag.key}\n readOnly={tag.existing}\n limit={200}\n defaultOptions={[]}\n placeholder={i18nStrings.keyPlaceholder}\n errorText={i18nStrings.keysSuggestionError}\n loadingText={i18nStrings.keysSuggestionLoading}\n suggestionText={i18nStrings.keySuggestion}\n tooManySuggestionText={i18nStrings.tooManyKeysSuggestion}\n enteredTextLabel={i18nStrings.enteredKeyLabel}\n clearAriaLabel={i18nStrings.clearAriaLabel}\n onRequest={keysRequest}\n onChange={onKeyChange}\n onBlur={onKeyBlur}\n initialOptionsRef={initialKeyOptionsRef}\n ref={ref => {\n keyInputRefs.current[row] = ref;\n }}\n />\n ),\n errorText: ({ error }: InternalTag) => error?.key,\n },\n {\n label: (\n <>\n {i18nStrings.valueHeader} - <i>{i18nStrings.optional}</i>\n </>\n ),\n control: ({ tag }: InternalTag, row: number) =>\n tag.markedForRemoval ? (\n <div role=\"alert\">\n <InternalBox margin={{ top: 'xxs' }}>\n {i18nStrings.undoPrompt}{' '}\n <UndoButton\n onClick={() => onUndoRemoval(row)}\n ref={elem => {\n undoButtonRefs.current[row] = elem;\n }}\n >\n {i18nStrings.undoButton}\n </UndoButton>\n </InternalBox>\n </div>\n ) : (\n <TagControl\n row={row}\n value={tag.value}\n readOnly={false}\n limit={200}\n defaultOptions={tag.valueSuggestionOptions ?? []}\n placeholder={i18nStrings.valuePlaceholder}\n errorText={i18nStrings.valuesSuggestionError}\n loadingText={i18nStrings.valuesSuggestionLoading}\n suggestionText={i18nStrings.valueSuggestion}\n tooManySuggestionText={i18nStrings.tooManyValuesSuggestion}\n enteredTextLabel={i18nStrings.enteredValueLabel}\n clearAriaLabel={i18nStrings.clearAriaLabel}\n filteringKey={tag.key}\n onRequest={valuesRequest && (value => valuesRequest(tag.key, value))}\n onChange={onValueChange}\n ref={ref => {\n valueInputRefs.current[row] = ref;\n }}\n />\n ),\n errorText: ({ error }: InternalTag) => error?.value,\n },\n ],\n [i18nStrings, keysRequest, onKeyChange, onKeyBlur, valuesRequest, onValueChange, onUndoRemoval]\n );\n\n const forwardedI18nStrings = useMemo<AttributeEditorProps.I18nStrings<InternalTag>>(\n () => ({\n errorIconAriaLabel: i18nStrings?.errorIconAriaLabel,\n itemRemovedAriaLive: i18nStrings?.itemRemovedAriaLive,\n removeButtonAriaLabel:\n i18nStrings.removeButtonAriaLabel && (({ tag }) => i18nStrings.removeButtonAriaLabel!(tag)),\n }),\n [i18nStrings]\n );\n\n if (loading) {\n return (\n <div className={styles.root} ref={baseComponentProps.__internalRootRef}>\n <InternalStatusIndicator className={styles.loading} type=\"loading\">\n <LiveRegion visible={true}>{i18nStrings.loading}</LiveRegion>\n </InternalStatusIndicator>\n </div>\n );\n }\n\n const baseProps = getBaseProps(restProps);\n return (\n <InternalAttributeEditor<InternalTag>\n {...baseProps}\n {...baseComponentProps}\n ref={attributeEditorRef}\n className={clsx(styles.root, baseProps.className)}\n items={internalTags}\n isItemRemovable={isItemRemovable}\n onAddButtonClick={onAddButtonClick}\n onRemoveButtonClick={onRemoveButtonClick}\n addButtonText={i18nStrings.addButton}\n removeButtonText={i18nStrings.removeButton}\n disableAddButton={remainingTags <= 0}\n empty={i18nStrings.emptyTags}\n additionalInfo={\n remainingTags < 0 ? (\n <FormFieldError errorIconAriaLabel={i18nStrings.errorIconAriaLabel}>\n {i18nStrings.tagLimitExceeded(tagLimit) ?? ''}\n </FormFieldError>\n ) : remainingTags === 0 ? (\n i18nStrings.tagLimitReached(tagLimit) ?? ''\n ) : (\n i18nStrings.tagLimit(remainingTags, tagLimit)\n )\n }\n definition={definition}\n i18nStrings={forwardedI18nStrings}\n />\n );\n }\n);\n\napplyDisplayName(TagEditor, 'TagEditor');\nexport default TagEditor;\n"]}
|
|
@@ -111,6 +111,7 @@ export declare namespace TagEditorProps {
|
|
|
111
111
|
tagLimitExceeded: (tagLimit: number) => string;
|
|
112
112
|
enteredKeyLabel: (enteredText: string) => string;
|
|
113
113
|
enteredValueLabel: (enteredText: string) => string;
|
|
114
|
+
removeButtonAriaLabel?: (item: TagEditorProps.Tag) => string;
|
|
114
115
|
}
|
|
115
116
|
interface ChangeDetail {
|
|
116
117
|
tags: ReadonlyArray<TagEditorProps.Tag>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"lib/default/","sources":["tag-editor/interfaces.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAo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;KAC9D;IAED,UAAiB,YAAY;QAC3B,IAAI,EAAE,aAAa,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QACxC,KAAK,EAAE,OAAO,CAAC;KAChB;IAED,UAAiB,GAAG;QAClB;;;WAGG;QACH,KAAK,IAAI,IAAI,CAAC;KACf;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["tag-editor/interfaces.tsx"],"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 { AutosuggestProps } from '../autosuggest/interfaces';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface TagEditorProps extends BaseComponentProps {\n /**\n * Specifies an array of tags that are displayed to the user. Each tag item has the following properties:\n * - `key` (string) - The key of the tag that's displayed in the corresponding key field.\n * - `value` (string) - The value of the tag that's displayed in the corresponding value field.\n * - `existing` (boolean) - Specifies if this is an existing tag for the resource.\n * When set to `true`, if the tag is deleted its `markedForRemoval` property is to `true`.\n * When set to `false`, deletion of the tag removes the tag from the `tags` list.\n * - `markedForRemoval` (boolean) - Specifies if this tag has been marked for removal.\n * This property is set to `true` by the component when a user removes an existing tag.\n * The item will remain in the `tags` list. When set to `true`, the user is presented with the option to undo the removal operation.\n * - `valueSuggestionOptions` (Array<AutosuggestProps.Option>) - An array of autosuggest suggestion options associated with the specified tag key.\n */\n tags?: ReadonlyArray<TagEditorProps.Tag>;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n */\n i18nStrings: TagEditorProps.I18nStrings;\n\n /**\n * Renders the component in a loading state.\n */\n loading?: boolean;\n\n /**\n * Specifies the maximum number of tags that a customer can add.\n */\n tagLimit?: number;\n\n /**\n * Specifies a regular expression string that overrides the default acceptable\n * character validation. You should use this property only when absolutely necessary.\n */\n allowedCharacterPattern?: string;\n\n /**\n * Specifies a function that returns all the keys for a resource.\n * The expected return type of the function should be a promise that\n * resolves to a list of strings of all the keys (for example, `['key1', 'key2']`).\n */\n keysRequest?: (key: string) => Promise<ReadonlyArray<string>>;\n\n /**\n * Specifies a function that returns all the values for a specified key\n * of a resource. The expected return type of the function should be a promise\n * that resolves to a list of strings of all the values (for example, `['value1', 'value2']`).\n *\n * You should return a rejected promise when the `key` parameter is an empty string.\n */\n valuesRequest?: (key: string, value: string) => Promise<ReadonlyArray<string>>;\n\n /**\n * Called when any tag operation occurs.\n * The event `detail` object contains the full updated state of `tags`,\n * and whether the component is in a `valid` state.\n */\n onChange?: NonCancelableEventHandler<TagEditorProps.ChangeDetail>;\n}\n\nexport namespace TagEditorProps {\n export interface Tag {\n /**\n * The key of the tag that will be displayed in the corresponding key field.\n */\n key: string;\n\n /**\n * The value of the tag that will be displayed in the corresponding value field.\n */\n value: string;\n\n /**\n * Whether this is an existing tag for the resource. If set to `true`, deletion of the tag will set the `markedForRemoval` property to `true`. If set to `false`, deletion of the tag will remove the tag from the `tags` list.\n */\n existing: boolean;\n\n /**\n * Whether this tag has been marked for removal. This property will be set to `true` by the component when a user tries to remove an existing tag. The item will remain in the `tags` list. When set to `true`, the user will be presented with the option to undo the removal operation.\n */\n markedForRemoval?: boolean;\n\n /**\n * An array of suggested values for the specified tag key.\n */\n valueSuggestionOptions?: ReadonlyArray<AutosuggestProps.Option>;\n }\n\n export interface I18nStrings {\n keyPlaceholder: string;\n valuePlaceholder: string;\n addButton: string;\n removeButton: string;\n undoButton: string;\n undoPrompt: string;\n loading: string;\n keyHeader: string;\n valueHeader: string;\n optional: string;\n keySuggestion: string;\n valueSuggestion: string;\n tooManyKeysSuggestion: string;\n tooManyValuesSuggestion: string;\n emptyTags: string;\n errorIconAriaLabel?: string;\n keysSuggestionLoading: string;\n keysSuggestionError: string;\n valuesSuggestionError: string;\n valuesSuggestionLoading: string;\n emptyKeyError: string;\n maxKeyCharLengthError: string;\n maxValueCharLengthError: string;\n duplicateKeyError: string;\n invalidKeyError: string;\n invalidValueError: string;\n awsPrefixError: string;\n clearAriaLabel?: string;\n itemRemovedAriaLive?: string;\n tagLimit: (availableTags: number, tagLimit: number) => string;\n tagLimitReached: (tagLimit: number) => string;\n tagLimitExceeded: (tagLimit: number) => string;\n enteredKeyLabel: (enteredText: string) => string;\n enteredValueLabel: (enteredText: string) => string;\n }\n\n export interface ChangeDetail {\n tags: ReadonlyArray<TagEditorProps.Tag>;\n valid: boolean;\n }\n\n export interface Ref {\n /**\n * Focuses the first error within the component.\n * If no error is present, no element is focused.\n */\n focus(): void;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["tag-editor/interfaces.tsx"],"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 { AutosuggestProps } from '../autosuggest/interfaces';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface TagEditorProps extends BaseComponentProps {\n /**\n * Specifies an array of tags that are displayed to the user. Each tag item has the following properties:\n * - `key` (string) - The key of the tag that's displayed in the corresponding key field.\n * - `value` (string) - The value of the tag that's displayed in the corresponding value field.\n * - `existing` (boolean) - Specifies if this is an existing tag for the resource.\n * When set to `true`, if the tag is deleted its `markedForRemoval` property is to `true`.\n * When set to `false`, deletion of the tag removes the tag from the `tags` list.\n * - `markedForRemoval` (boolean) - Specifies if this tag has been marked for removal.\n * This property is set to `true` by the component when a user removes an existing tag.\n * The item will remain in the `tags` list. When set to `true`, the user is presented with the option to undo the removal operation.\n * - `valueSuggestionOptions` (Array<AutosuggestProps.Option>) - An array of autosuggest suggestion options associated with the specified tag key.\n */\n tags?: ReadonlyArray<TagEditorProps.Tag>;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n */\n i18nStrings: TagEditorProps.I18nStrings;\n\n /**\n * Renders the component in a loading state.\n */\n loading?: boolean;\n\n /**\n * Specifies the maximum number of tags that a customer can add.\n */\n tagLimit?: number;\n\n /**\n * Specifies a regular expression string that overrides the default acceptable\n * character validation. You should use this property only when absolutely necessary.\n */\n allowedCharacterPattern?: string;\n\n /**\n * Specifies a function that returns all the keys for a resource.\n * The expected return type of the function should be a promise that\n * resolves to a list of strings of all the keys (for example, `['key1', 'key2']`).\n */\n keysRequest?: (key: string) => Promise<ReadonlyArray<string>>;\n\n /**\n * Specifies a function that returns all the values for a specified key\n * of a resource. The expected return type of the function should be a promise\n * that resolves to a list of strings of all the values (for example, `['value1', 'value2']`).\n *\n * You should return a rejected promise when the `key` parameter is an empty string.\n */\n valuesRequest?: (key: string, value: string) => Promise<ReadonlyArray<string>>;\n\n /**\n * Called when any tag operation occurs.\n * The event `detail` object contains the full updated state of `tags`,\n * and whether the component is in a `valid` state.\n */\n onChange?: NonCancelableEventHandler<TagEditorProps.ChangeDetail>;\n}\n\nexport namespace TagEditorProps {\n export interface Tag {\n /**\n * The key of the tag that will be displayed in the corresponding key field.\n */\n key: string;\n\n /**\n * The value of the tag that will be displayed in the corresponding value field.\n */\n value: string;\n\n /**\n * Whether this is an existing tag for the resource. If set to `true`, deletion of the tag will set the `markedForRemoval` property to `true`. If set to `false`, deletion of the tag will remove the tag from the `tags` list.\n */\n existing: boolean;\n\n /**\n * Whether this tag has been marked for removal. This property will be set to `true` by the component when a user tries to remove an existing tag. The item will remain in the `tags` list. When set to `true`, the user will be presented with the option to undo the removal operation.\n */\n markedForRemoval?: boolean;\n\n /**\n * An array of suggested values for the specified tag key.\n */\n valueSuggestionOptions?: ReadonlyArray<AutosuggestProps.Option>;\n }\n\n export interface I18nStrings {\n keyPlaceholder: string;\n valuePlaceholder: string;\n addButton: string;\n removeButton: string;\n undoButton: string;\n undoPrompt: string;\n loading: string;\n keyHeader: string;\n valueHeader: string;\n optional: string;\n keySuggestion: string;\n valueSuggestion: string;\n tooManyKeysSuggestion: string;\n tooManyValuesSuggestion: string;\n emptyTags: string;\n errorIconAriaLabel?: string;\n keysSuggestionLoading: string;\n keysSuggestionError: string;\n valuesSuggestionError: string;\n valuesSuggestionLoading: string;\n emptyKeyError: string;\n maxKeyCharLengthError: string;\n maxValueCharLengthError: string;\n duplicateKeyError: string;\n invalidKeyError: string;\n invalidValueError: string;\n awsPrefixError: string;\n clearAriaLabel?: string;\n itemRemovedAriaLive?: string;\n tagLimit: (availableTags: number, tagLimit: number) => string;\n tagLimitReached: (tagLimit: number) => string;\n tagLimitExceeded: (tagLimit: number) => string;\n enteredKeyLabel: (enteredText: string) => string;\n enteredValueLabel: (enteredText: string) => string;\n removeButtonAriaLabel?: (item: TagEditorProps.Tag) => string;\n }\n\n export interface ChangeDetail {\n tags: ReadonlyArray<TagEditorProps.Tag>;\n valid: boolean;\n }\n\n export interface Ref {\n /**\n * Focuses the first error within the component.\n * If no error is present, no element is focused.\n */\n focus(): void;\n }\n}\n"]}
|