react-aria-components 1.11.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Autocomplete.main.js +7 -20
- package/dist/Autocomplete.main.js.map +1 -1
- package/dist/Autocomplete.mjs +8 -20
- package/dist/Autocomplete.module.js +8 -20
- package/dist/Autocomplete.module.js.map +1 -1
- package/dist/Breadcrumbs.main.js +4 -1
- package/dist/Breadcrumbs.main.js.map +1 -1
- package/dist/Breadcrumbs.mjs +5 -2
- package/dist/Breadcrumbs.module.js +5 -2
- package/dist/Breadcrumbs.module.js.map +1 -1
- package/dist/GridList.main.js +96 -15
- package/dist/GridList.main.js.map +1 -1
- package/dist/GridList.mjs +98 -19
- package/dist/GridList.module.js +98 -19
- package/dist/GridList.module.js.map +1 -1
- package/dist/Header.main.js +1 -1
- package/dist/Header.main.js.map +1 -1
- package/dist/Header.mjs +2 -2
- package/dist/Header.module.js +2 -2
- package/dist/Header.module.js.map +1 -1
- package/dist/ListBox.main.js +6 -18
- package/dist/ListBox.main.js.map +1 -1
- package/dist/ListBox.mjs +8 -20
- package/dist/ListBox.module.js +8 -20
- package/dist/ListBox.module.js.map +1 -1
- package/dist/Menu.main.js +29 -15
- package/dist/Menu.main.js.map +1 -1
- package/dist/Menu.mjs +31 -17
- package/dist/Menu.module.js +31 -17
- package/dist/Menu.module.js.map +1 -1
- package/dist/Popover.main.js +7 -11
- package/dist/Popover.main.js.map +1 -1
- package/dist/Popover.mjs +8 -12
- package/dist/Popover.module.js +8 -12
- package/dist/Popover.module.js.map +1 -1
- package/dist/SearchField.main.js +6 -4
- package/dist/SearchField.main.js.map +1 -1
- package/dist/SearchField.mjs +7 -5
- package/dist/SearchField.module.js +7 -5
- package/dist/SearchField.module.js.map +1 -1
- package/dist/Separator.main.js +13 -1
- package/dist/Separator.main.js.map +1 -1
- package/dist/Separator.mjs +15 -3
- package/dist/Separator.module.js +15 -3
- package/dist/Separator.module.js.map +1 -1
- package/dist/Table.main.js +58 -17
- package/dist/Table.main.js.map +1 -1
- package/dist/Table.mjs +60 -19
- package/dist/Table.module.js +60 -19
- package/dist/Table.module.js.map +1 -1
- package/dist/Tabs.main.js +4 -1
- package/dist/Tabs.main.js.map +1 -1
- package/dist/Tabs.mjs +5 -2
- package/dist/Tabs.module.js +5 -2
- package/dist/Tabs.module.js.map +1 -1
- package/dist/TagGroup.main.js +13 -4
- package/dist/TagGroup.main.js.map +1 -1
- package/dist/TagGroup.mjs +15 -6
- package/dist/TagGroup.module.js +15 -6
- package/dist/TagGroup.module.js.map +1 -1
- package/dist/TextField.main.js +7 -5
- package/dist/TextField.main.js.map +1 -1
- package/dist/TextField.mjs +8 -6
- package/dist/TextField.module.js +8 -6
- package/dist/TextField.module.js.map +1 -1
- package/dist/Tooltip.main.js +4 -11
- package/dist/Tooltip.main.js.map +1 -1
- package/dist/Tooltip.mjs +6 -13
- package/dist/Tooltip.module.js +6 -13
- package/dist/Tooltip.module.js.map +1 -1
- package/dist/Tree.main.js +9 -3
- package/dist/Tree.main.js.map +1 -1
- package/dist/Tree.mjs +10 -4
- package/dist/Tree.module.js +10 -4
- package/dist/Tree.module.js.map +1 -1
- package/dist/context.main.js +25 -0
- package/dist/context.main.js.map +1 -0
- package/dist/context.mjs +19 -0
- package/dist/context.module.js +19 -0
- package/dist/context.module.js.map +1 -0
- package/dist/import.mjs +3 -3
- package/dist/main.js +3 -0
- package/dist/main.js.map +1 -1
- package/dist/module.js +3 -3
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +178 -171
- package/dist/types.d.ts.map +1 -1
- package/dist/useDragAndDrop.main.js.map +1 -1
- package/dist/useDragAndDrop.module.js.map +1 -1
- package/package.json +23 -22
- package/src/Autocomplete.tsx +14 -25
- package/src/Breadcrumbs.tsx +6 -2
- package/src/GridList.tsx +89 -21
- package/src/Header.tsx +2 -2
- package/src/ListBox.tsx +12 -15
- package/src/Menu.tsx +37 -17
- package/src/Popover.tsx +11 -11
- package/src/SearchField.tsx +5 -4
- package/src/Separator.tsx +17 -2
- package/src/Table.tsx +65 -22
- package/src/Tabs.tsx +6 -2
- package/src/TagGroup.tsx +15 -6
- package/src/TextField.tsx +8 -7
- package/src/Tooltip.tsx +10 -14
- package/src/Tree.tsx +13 -5
- package/src/context.tsx +34 -0
- package/src/index.ts +2 -2
- package/src/useDragAndDrop.tsx +9 -9
package/dist/TagGroup.main.js
CHANGED
|
@@ -3,6 +3,7 @@ var $3114c2382242bdc0$exports = require("./Collection.main.js");
|
|
|
3
3
|
var $c5ccf687772c0422$exports = require("./utils.main.js");
|
|
4
4
|
var $84ae0bf5bd8e2a5f$exports = require("./Label.main.js");
|
|
5
5
|
var $a03b42240404b420$exports = require("./ListBox.main.js");
|
|
6
|
+
var $09cb5ee89bb327e1$exports = require("./context.main.js");
|
|
6
7
|
var $a8a589c28affdc40$exports = require("./Text.main.js");
|
|
7
8
|
var $4TsYs$reactaria = require("react-aria");
|
|
8
9
|
var $4TsYs$reactariacollections = require("@react-aria/collections");
|
|
@@ -45,6 +46,7 @@ $parcel$export(module.exports, "Tag", () => $ecf55d0c218a575e$export$3288d34c523
|
|
|
45
46
|
|
|
46
47
|
|
|
47
48
|
|
|
49
|
+
|
|
48
50
|
const $ecf55d0c218a575e$export$5b07b5dd2cbd96e3 = /*#__PURE__*/ (0, $4TsYs$react.createContext)(null);
|
|
49
51
|
const $ecf55d0c218a575e$export$e755ce3685dd0ca9 = /*#__PURE__*/ (0, $4TsYs$react.createContext)(null);
|
|
50
52
|
const $ecf55d0c218a575e$export$67ea30858aaf75e3 = /*#__PURE__*/ (0, $4TsYs$react.forwardRef)(function TagGroup(props, ref) {
|
|
@@ -58,13 +60,19 @@ const $ecf55d0c218a575e$export$67ea30858aaf75e3 = /*#__PURE__*/ (0, $4TsYs$react
|
|
|
58
60
|
}));
|
|
59
61
|
});
|
|
60
62
|
function $ecf55d0c218a575e$var$TagGroupInner({ props: props, forwardedRef: ref, collection: collection }) {
|
|
63
|
+
let contextProps;
|
|
64
|
+
[contextProps] = (0, $c5ccf687772c0422$exports.useContextProps)({}, null, (0, $09cb5ee89bb327e1$exports.SelectableCollectionContext));
|
|
65
|
+
let { filter: filter, ...collectionProps } = contextProps;
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
67
|
+
let { shouldUseVirtualFocus: shouldUseVirtualFocus, disallowTypeAhead: disallowTypeAhead, ...DOMCollectionProps } = collectionProps || {};
|
|
61
68
|
let tagListRef = (0, $4TsYs$react.useRef)(null);
|
|
62
69
|
let [labelRef, label] = (0, $c5ccf687772c0422$exports.useSlot)(!props['aria-label'] && !props['aria-labelledby']);
|
|
63
|
-
let
|
|
70
|
+
let tagGroupState = (0, $4TsYs$reactstately.useListState)({
|
|
64
71
|
...props,
|
|
65
72
|
children: undefined,
|
|
66
73
|
collection: collection
|
|
67
74
|
});
|
|
75
|
+
let filteredState = (0, $4TsYs$reactstately.UNSTABLE_useFilteredListState)(tagGroupState, filter);
|
|
68
76
|
// Prevent DOM props from going to two places.
|
|
69
77
|
let domProps = (0, $4TsYs$reactariautils.filterDOMProps)(props, {
|
|
70
78
|
global: true
|
|
@@ -76,8 +84,9 @@ function $ecf55d0c218a575e$var$TagGroupInner({ props: props, forwardedRef: ref,
|
|
|
76
84
|
let { gridProps: gridProps, labelProps: labelProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $4TsYs$reactaria.useTagGroup)({
|
|
77
85
|
...props,
|
|
78
86
|
...domPropOverrides,
|
|
87
|
+
...DOMCollectionProps,
|
|
79
88
|
label: label
|
|
80
|
-
},
|
|
89
|
+
}, filteredState, tagListRef);
|
|
81
90
|
var _props_className;
|
|
82
91
|
return /*#__PURE__*/ (0, ($parcel$interopDefault($4TsYs$react))).createElement("div", {
|
|
83
92
|
...domProps,
|
|
@@ -104,7 +113,7 @@ function $ecf55d0c218a575e$var$TagGroupInner({ props: props, forwardedRef: ref,
|
|
|
104
113
|
],
|
|
105
114
|
[
|
|
106
115
|
(0, $a03b42240404b420$exports.ListStateContext),
|
|
107
|
-
|
|
116
|
+
filteredState
|
|
108
117
|
],
|
|
109
118
|
[
|
|
110
119
|
(0, $a8a589c28affdc40$exports.TextContext),
|
|
@@ -157,7 +166,7 @@ function $ecf55d0c218a575e$var$TagListInner({ props: props, forwardedRef: forwar
|
|
|
157
166
|
persistedKeys: persistedKeys
|
|
158
167
|
}));
|
|
159
168
|
}
|
|
160
|
-
const $ecf55d0c218a575e$export$3288d34c523a1192 = /*#__PURE__*/ (0, $4TsYs$reactariacollections.createLeafComponent)(
|
|
169
|
+
const $ecf55d0c218a575e$export$3288d34c523a1192 = /*#__PURE__*/ (0, $4TsYs$reactariacollections.createLeafComponent)((0, $4TsYs$reactariacollections.ItemNode), (props, forwardedRef, item)=>{
|
|
161
170
|
let state = (0, $4TsYs$react.useContext)((0, $a03b42240404b420$exports.ListStateContext));
|
|
162
171
|
let ref = (0, $4TsYs$reactariautils.useObjectRef)(forwardedRef);
|
|
163
172
|
let { focusProps: focusProps, isFocusVisible: isFocusVisible } = (0, $4TsYs$reactaria.useFocusRing)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;AA4CM,MAAM,0DAAkB,CAAA,GAAA,0BAAY,EAA+C;AACnF,MAAM,0DAAiB,CAAA,GAAA,0BAAY,EAAmD;AAKtF,MAAM,4CAAyB,AAAd,WAAW,GAAI,CAAA,GAAA,uBAAS,EAAqB,SAAS,SAAS,KAAoB,EAAE,GAAiC;IAC5I,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,qBACE,0DAAC,CAAA,GAAA,6CAAgB;QAAE,SAAS,MAAM,QAAQ;OACvC,CAAA,2BAAc,0DAAC;YAAc,OAAO;YAAO,cAAc;YAAK,YAAY;;AAGjF;AAQA,SAAS,oCAAc,SAAC,KAAK,EAA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,GAAG,CAAA,GAAA,gCAAS,EAAE,UAAU,aAAa,UAAU,YAAY,WAAW;QACvE,iBAAe,OAAO,UAAU,IAAI;QACpC,iBAAe,OAAO,UAAU,IAAI;QACpC,gBAAc,aAAa;QAC3B,gBAAc,OAAO,SAAS,IAAI;QAClC,sBAAoB,kBAAkB;QACtC,gBAAc,OAAO,SAAS,IAAI;QAClC,wBAAsB,OAAO,cAAc,IAAI;QAC/C,uBAAqB,MAAM,gBAAgB,CAAC,aAAa,KAAK,SAAS,YAAY,MAAM,gBAAgB,CAAC,aAAa;qBACvH,0DAAC;QAAK,GAAG,aAAa;QAAE,OAAO;YAAC,SAAS;QAAU;qBACjD,0DAAC,CAAA,GAAA,kCAAO;QACN,QAAQ;YACN;gBAAC,CAAA,GAAA,uCAAY;gBAAG;oBACd,OAAO;wBACL,QAAQ;oBACV;gBACF;aAAE;YACF;gBAAC,CAAA,GAAA,mDAAwB;gBAAG,CAAA,GAAA,mDAAwB;aAAE;SACvD;OACA,YAAY,QAAQ;AAK/B","sources":["packages/react-aria-components/src/TagGroup.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaTagGroupProps, useFocusRing, useHover, useTag, useTagGroup} from 'react-aria';\nimport {ButtonContext} from './Button';\nimport {Collection, CollectionBuilder, createLeafComponent} from '@react-aria/collections';\nimport {CollectionProps, CollectionRendererContext, DefaultCollectionRenderer, ItemRenderProps, usePersistedKeys} from './Collection';\nimport {ContextValue, DOMProps, Provider, RenderProps, SlotProps, StyleRenderProps, useContextProps, useRenderProps, useSlot} from './utils';\nimport {filterDOMProps, mergeProps, useObjectRef} from '@react-aria/utils';\nimport {forwardRefType, GlobalDOMAttributes, HoverEvents, Key, LinkDOMProps, PressEvents} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {ListState, Node, useListState} from 'react-stately';\nimport {ListStateContext} from './ListBox';\nimport React, {createContext, ForwardedRef, forwardRef, JSX, ReactNode, useContext, useEffect, useRef} from 'react';\nimport {TextContext} from './Text';\n\nexport interface TagGroupProps extends Omit<AriaTagGroupProps<unknown>, 'children' | 'items' | 'label' | 'description' | 'errorMessage' | 'keyboardDelegate'>, DOMProps, SlotProps, GlobalDOMAttributes<HTMLDivElement> {}\n\nexport interface TagListRenderProps {\n /**\n * Whether the tag list has no items and should display its empty state.\n * @selector [data-empty]\n */\n isEmpty: boolean,\n /**\n * Whether the tag list is currently focused.\n * @selector [data-focused]\n */\n isFocused: boolean,\n /**\n * Whether the tag list is currently keyboard focused.\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean,\n /**\n * State of the TagGroup.\n */\n state: ListState<unknown>\n}\n\nexport interface TagListProps<T> extends Omit<CollectionProps<T>, 'disabledKeys'>, StyleRenderProps<TagListRenderProps>, GlobalDOMAttributes<HTMLDivElement> {\n /** Provides content to display when there are no items in the tag list. */\n renderEmptyState?: (props: TagListRenderProps) => ReactNode\n}\n\nexport const TagGroupContext = createContext<ContextValue<TagGroupProps, HTMLDivElement>>(null);\nexport const TagListContext = createContext<ContextValue<TagListProps<any>, HTMLDivElement>>(null);\n\n/**\n * A tag group is a focusable list of labels, categories, keywords, filters, or other items, with support for keyboard navigation, selection, and removal.\n */\nexport const TagGroup = /*#__PURE__*/ (forwardRef as forwardRefType)(function TagGroup(props: TagGroupProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, TagGroupContext);\n return (\n <CollectionBuilder content={props.children}>\n {collection => <TagGroupInner props={props} forwardedRef={ref} collection={collection} />}\n </CollectionBuilder>\n );\n});\n\ninterface TagGroupInnerProps {\n props: TagGroupProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n collection\n}\n\nfunction TagGroupInner({props, forwardedRef: ref, collection}: TagGroupInnerProps) {\n let tagListRef = useRef<HTMLDivElement>(null);\n let [labelRef, label] = useSlot(\n !props['aria-label'] && !props['aria-labelledby']\n );\n let state = useListState({\n ...props,\n children: undefined,\n collection\n });\n\n // Prevent DOM props from going to two places.\n let domProps = filterDOMProps(props, {global: true});\n let domPropOverrides = Object.fromEntries(Object.entries(domProps).map(([k]) => [k, undefined]));\n let {\n gridProps,\n labelProps,\n descriptionProps,\n errorMessageProps\n } = useTagGroup({\n ...props,\n ...domPropOverrides,\n label\n }, state, tagListRef);\n\n return (\n <div\n {...domProps}\n ref={ref}\n slot={props.slot || undefined}\n className={props.className ?? 'react-aria-TagGroup'}\n style={props.style}>\n <Provider\n values={[\n [LabelContext, {...labelProps, elementType: 'span', ref: labelRef}],\n [TagListContext, {...gridProps, ref: tagListRef}],\n [ListStateContext, state],\n [TextContext, {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }]\n ]}>\n {props.children}\n </Provider>\n </div>\n );\n}\n\n/**\n * A tag list is a container for tags within a TagGroup.\n */\nexport const TagList = /*#__PURE__*/ (forwardRef as forwardRefType)(function TagList<T extends object>(props: TagListProps<T>, ref: ForwardedRef<HTMLDivElement>): JSX.Element {\n let state = useContext(ListStateContext);\n return state\n ? <TagListInner props={props} forwardedRef={ref} />\n : <Collection {...props} />;\n});\n\ninterface TagListInnerProps<T> {\n props: TagListProps<T>,\n forwardedRef: ForwardedRef<HTMLDivElement>\n}\n\nfunction TagListInner<T extends object>({props, forwardedRef}: TagListInnerProps<T>) {\n let state = useContext(ListStateContext)!;\n let {CollectionRoot} = useContext(CollectionRendererContext);\n let [gridProps, ref] = useContextProps({}, forwardedRef, TagListContext);\n\n let {focusProps, isFocused, isFocusVisible} = useFocusRing();\n let renderValues = {\n isEmpty: state.collection.size === 0,\n isFocused,\n isFocusVisible,\n state\n };\n let renderProps = useRenderProps({\n className: props.className,\n style: props.style,\n defaultClassName: 'react-aria-TagList',\n values: renderValues\n });\n\n let persistedKeys = usePersistedKeys(state.selectionManager.focusedKey);\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <div\n {...mergeProps(DOMProps, renderProps, gridProps, focusProps)}\n ref={ref}\n data-empty={state.collection.size === 0 || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}>\n {state.collection.size === 0 && props.renderEmptyState\n ? props.renderEmptyState(renderValues)\n : <CollectionRoot collection={state.collection} persistedKeys={persistedKeys} />}\n </div>\n );\n}\n\nexport interface TagRenderProps extends Omit<ItemRenderProps, 'allowsDragging' | 'isDragging' | 'isDropTarget'> {\n /**\n * Whether the tag group allows items to be removed.\n * @selector [data-allows-removing]\n */\n allowsRemoving: boolean\n}\n\nexport interface TagProps extends RenderProps<TagRenderProps>, LinkDOMProps, HoverEvents, PressEvents, Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {\n /** A unique id for the tag. */\n id?: Key,\n /**\n * A string representation of the tags's contents, used for accessibility.\n * Required if children is not a plain text string.\n */\n textValue?: string,\n /** Whether the tag is disabled. */\n isDisabled?: boolean\n}\n\n/**\n * A Tag is an individual item within a TagList.\n */\nexport const Tag = /*#__PURE__*/ createLeafComponent('item', (props: TagProps, forwardedRef: ForwardedRef<HTMLDivElement>, item: Node<unknown>) => {\n let state = useContext(ListStateContext)!;\n let ref = useObjectRef<HTMLDivElement>(forwardedRef);\n let {focusProps, isFocusVisible} = useFocusRing({within: false});\n let {rowProps, gridCellProps, removeButtonProps, ...states} = useTag({item}, state, ref);\n\n let {hoverProps, isHovered} = useHover({\n isDisabled: !states.allowsSelection,\n onHoverStart: item.props.onHoverStart,\n onHoverChange: item.props.onHoverChange,\n onHoverEnd: item.props.onHoverEnd\n });\n\n let renderProps = useRenderProps({\n ...props,\n id: undefined,\n children: item.rendered,\n defaultClassName: 'react-aria-Tag',\n values: {\n ...states,\n isFocusVisible,\n isHovered,\n selectionMode: state.selectionManager.selectionMode,\n selectionBehavior: state.selectionManager.selectionBehavior\n }\n });\n\n useEffect(() => {\n if (!item.textValue && process.env.NODE_ENV !== 'production') {\n console.warn('A `textValue` prop is required for <Tag> elements with non-plain text children for accessibility.');\n }\n }, [item.textValue]);\n\n let DOMProps = filterDOMProps(props as any, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <div\n ref={ref}\n {...mergeProps(DOMProps, renderProps, rowProps, focusProps, hoverProps)}\n data-selected={states.isSelected || undefined}\n data-disabled={states.isDisabled || undefined}\n data-hovered={isHovered || undefined}\n data-focused={states.isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-pressed={states.isPressed || undefined}\n data-allows-removing={states.allowsRemoving || undefined}\n data-selection-mode={state.selectionManager.selectionMode === 'none' ? undefined : state.selectionManager.selectionMode}>\n <div {...gridCellProps} style={{display: 'contents'}}>\n <Provider\n values={[\n [ButtonContext, {\n slots: {\n remove: removeButtonProps\n }\n }],\n [CollectionRendererContext, DefaultCollectionRenderer]\n ]}>\n {renderProps.children}\n </Provider>\n </div>\n </div>\n );\n});\n"],"names":[],"version":3,"file":"TagGroup.main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;AA6CM,MAAM,0DAAkB,CAAA,GAAA,0BAAY,EAA+C;AACnF,MAAM,0DAAiB,CAAA,GAAA,0BAAY,EAAmD;AAKtF,MAAM,4CAAyB,AAAd,WAAW,GAAI,CAAA,GAAA,uBAAS,EAAqB,SAAS,SAAS,KAAoB,EAAE,GAAiC;IAC5I,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,qBACE,0DAAC,CAAA,GAAA,6CAAgB;QAAE,SAAS,MAAM,QAAQ;OACvC,CAAA,2BAAc,0DAAC;YAAc,OAAO;YAAO,cAA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,eAAe,MAAM,gBAAgB,CAAC,aAAa;YACnD,mBAAmB,MAAM,gBAAgB,CAAC,iBAAiB;QAC7D;IACF;IAEA,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,CAAC,KAAK,SAAS,IAAI,QAAQ,GAAG,CAAC,QAAQ,KAAK,cAC9C,QAAQ,IAAI,CAAC;IAEjB,GAAG;QAAC,KAAK,SAAS;KAAC;IAEnB,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAc;QAAC,QAAQ;IAAI;IACzD,OAAO,SAAS,EAAE;IAClB,OAAO,SAAS,OAAO;IAEvB,qBACE,0DAAC;QACC,KAAK;QACJ,GAAG,CAAA,GAAA,gCAAS,EAAE,UAAU,aAAa,UAAU,YAAY,WAAW;QACvE,iBAAe,OAAO,UAAU,IAAI;QACpC,iBAAe,OAAO,UAAU,IAAI;QACpC,gBAAc,aAAa;QAC3B,gBAAc,OAAO,SAAS,IAAI;QAClC,sBAAoB,kBAAkB;QACtC,gBAAc,OAAO,SAAS,IAAI;QAClC,wBAAsB,OAAO,cAAc,IAAI;QAC/C,uBAAqB,MAAM,gBAAgB,CAAC,aAAa,KAAK,SAAS,YAAY,MAAM,gBAAgB,CAAC,aAAa;qBACvH,0DAAC;QAAK,GAAG,aAAa;QAAE,OAAO;YAAC,SAAS;QAAU;qBACjD,0DAAC,CAAA,GAAA,kCAAO;QACN,QAAQ;YACN;gBAAC,CAAA,GAAA,uCAAY;gBAAG;oBACd,OAAO;wBACL,QAAQ;oBACV;gBACF;aAAE;YACF;gBAAC,CAAA,GAAA,mDAAwB;gBAAG,CAAA,GAAA,mDAAwB;aAAE;SACvD;OACA,YAAY,QAAQ;AAK/B","sources":["packages/react-aria-components/src/TagGroup.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaTagGroupProps, useFocusRing, useHover, useTag, useTagGroup} from 'react-aria';\nimport {ButtonContext} from './Button';\nimport {Collection, CollectionBuilder, createLeafComponent, ItemNode} from '@react-aria/collections';\nimport {CollectionProps, CollectionRendererContext, DefaultCollectionRenderer, ItemRenderProps, usePersistedKeys} from './Collection';\nimport {ContextValue, DOMProps, Provider, RenderProps, SlotProps, StyleRenderProps, useContextProps, useRenderProps, useSlot} from './utils';\nimport {filterDOMProps, mergeProps, useObjectRef} from '@react-aria/utils';\nimport {forwardRefType, GlobalDOMAttributes, HoverEvents, Key, LinkDOMProps, PressEvents} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {ListState, Node, UNSTABLE_useFilteredListState, useListState} from 'react-stately';\nimport {ListStateContext} from './ListBox';\nimport React, {createContext, ForwardedRef, forwardRef, JSX, ReactNode, useContext, useEffect, useRef} from 'react';\nimport {SelectableCollectionContext} from './context';\nimport {TextContext} from './Text';\n\nexport interface TagGroupProps extends Omit<AriaTagGroupProps<unknown>, 'children' | 'items' | 'label' | 'description' | 'errorMessage' | 'keyboardDelegate'>, DOMProps, SlotProps, GlobalDOMAttributes<HTMLDivElement> {}\n\nexport interface TagListRenderProps {\n /**\n * Whether the tag list has no items and should display its empty state.\n * @selector [data-empty]\n */\n isEmpty: boolean,\n /**\n * Whether the tag list is currently focused.\n * @selector [data-focused]\n */\n isFocused: boolean,\n /**\n * Whether the tag list is currently keyboard focused.\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean,\n /**\n * State of the TagGroup.\n */\n state: ListState<unknown>\n}\n\nexport interface TagListProps<T> extends Omit<CollectionProps<T>, 'disabledKeys'>, StyleRenderProps<TagListRenderProps>, GlobalDOMAttributes<HTMLDivElement> {\n /** Provides content to display when there are no items in the tag list. */\n renderEmptyState?: (props: TagListRenderProps) => ReactNode\n}\n\nexport const TagGroupContext = createContext<ContextValue<TagGroupProps, HTMLDivElement>>(null);\nexport const TagListContext = createContext<ContextValue<TagListProps<any>, HTMLDivElement>>(null);\n\n/**\n * A tag group is a focusable list of labels, categories, keywords, filters, or other items, with support for keyboard navigation, selection, and removal.\n */\nexport const TagGroup = /*#__PURE__*/ (forwardRef as forwardRefType)(function TagGroup(props: TagGroupProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, TagGroupContext);\n return (\n <CollectionBuilder content={props.children}>\n {collection => <TagGroupInner props={props} forwardedRef={ref} collection={collection} />}\n </CollectionBuilder>\n );\n});\n\ninterface TagGroupInnerProps {\n props: TagGroupProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n collection\n}\n\nfunction TagGroupInner({props, forwardedRef: ref, collection}: TagGroupInnerProps) {\n let contextProps;\n [contextProps] = useContextProps({}, null, SelectableCollectionContext);\n let {filter, ...collectionProps} = contextProps;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n let {shouldUseVirtualFocus, disallowTypeAhead, ...DOMCollectionProps} = collectionProps || {};\n let tagListRef = useRef<HTMLDivElement>(null);\n let [labelRef, label] = useSlot(\n !props['aria-label'] && !props['aria-labelledby']\n );\n let tagGroupState = useListState({\n ...props,\n children: undefined,\n collection\n });\n\n let filteredState = UNSTABLE_useFilteredListState(tagGroupState, filter);\n\n // Prevent DOM props from going to two places.\n let domProps = filterDOMProps(props, {global: true});\n let domPropOverrides = Object.fromEntries(Object.entries(domProps).map(([k]) => [k, undefined]));\n let {\n gridProps,\n labelProps,\n descriptionProps,\n errorMessageProps\n } = useTagGroup({\n ...props,\n ...domPropOverrides,\n ...DOMCollectionProps,\n label\n }, filteredState, tagListRef);\n\n return (\n <div\n {...domProps}\n ref={ref}\n slot={props.slot || undefined}\n className={props.className ?? 'react-aria-TagGroup'}\n style={props.style}>\n <Provider\n values={[\n [LabelContext, {...labelProps, elementType: 'span', ref: labelRef}],\n [TagListContext, {...gridProps, ref: tagListRef}],\n [ListStateContext, filteredState],\n [TextContext, {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }]\n ]}>\n {props.children}\n </Provider>\n </div>\n );\n}\n\n/**\n * A tag list is a container for tags within a TagGroup.\n */\nexport const TagList = /*#__PURE__*/ (forwardRef as forwardRefType)(function TagList<T extends object>(props: TagListProps<T>, ref: ForwardedRef<HTMLDivElement>): JSX.Element {\n let state = useContext(ListStateContext);\n return state\n ? <TagListInner props={props} forwardedRef={ref} />\n : <Collection {...props} />;\n});\n\ninterface TagListInnerProps<T> {\n props: TagListProps<T>,\n forwardedRef: ForwardedRef<HTMLDivElement>\n}\n\nfunction TagListInner<T extends object>({props, forwardedRef}: TagListInnerProps<T>) {\n let state = useContext(ListStateContext)!;\n let {CollectionRoot} = useContext(CollectionRendererContext);\n let [gridProps, ref] = useContextProps({}, forwardedRef, TagListContext);\n\n let {focusProps, isFocused, isFocusVisible} = useFocusRing();\n let renderValues = {\n isEmpty: state.collection.size === 0,\n isFocused,\n isFocusVisible,\n state\n };\n let renderProps = useRenderProps({\n className: props.className,\n style: props.style,\n defaultClassName: 'react-aria-TagList',\n values: renderValues\n });\n\n let persistedKeys = usePersistedKeys(state.selectionManager.focusedKey);\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <div\n {...mergeProps(DOMProps, renderProps, gridProps, focusProps)}\n ref={ref}\n data-empty={state.collection.size === 0 || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}>\n {state.collection.size === 0 && props.renderEmptyState\n ? props.renderEmptyState(renderValues)\n : <CollectionRoot collection={state.collection} persistedKeys={persistedKeys} />}\n </div>\n );\n}\n\nexport interface TagRenderProps extends Omit<ItemRenderProps, 'allowsDragging' | 'isDragging' | 'isDropTarget'> {\n /**\n * Whether the tag group allows items to be removed.\n * @selector [data-allows-removing]\n */\n allowsRemoving: boolean\n}\n\nexport interface TagProps extends RenderProps<TagRenderProps>, LinkDOMProps, HoverEvents, PressEvents, Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {\n /** A unique id for the tag. */\n id?: Key,\n /**\n * A string representation of the tags's contents, used for accessibility.\n * Required if children is not a plain text string.\n */\n textValue?: string,\n /** Whether the tag is disabled. */\n isDisabled?: boolean\n}\n\n/**\n * A Tag is an individual item within a TagList.\n */\nexport const Tag = /*#__PURE__*/ createLeafComponent(ItemNode, (props: TagProps, forwardedRef: ForwardedRef<HTMLDivElement>, item: Node<unknown>) => {\n let state = useContext(ListStateContext)!;\n let ref = useObjectRef<HTMLDivElement>(forwardedRef);\n let {focusProps, isFocusVisible} = useFocusRing({within: false});\n let {rowProps, gridCellProps, removeButtonProps, ...states} = useTag({item}, state, ref);\n\n let {hoverProps, isHovered} = useHover({\n isDisabled: !states.allowsSelection,\n onHoverStart: item.props.onHoverStart,\n onHoverChange: item.props.onHoverChange,\n onHoverEnd: item.props.onHoverEnd\n });\n\n let renderProps = useRenderProps({\n ...props,\n id: undefined,\n children: item.rendered,\n defaultClassName: 'react-aria-Tag',\n values: {\n ...states,\n isFocusVisible,\n isHovered,\n selectionMode: state.selectionManager.selectionMode,\n selectionBehavior: state.selectionManager.selectionBehavior\n }\n });\n\n useEffect(() => {\n if (!item.textValue && process.env.NODE_ENV !== 'production') {\n console.warn('A `textValue` prop is required for <Tag> elements with non-plain text children for accessibility.');\n }\n }, [item.textValue]);\n\n let DOMProps = filterDOMProps(props as any, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <div\n ref={ref}\n {...mergeProps(DOMProps, renderProps, rowProps, focusProps, hoverProps)}\n data-selected={states.isSelected || undefined}\n data-disabled={states.isDisabled || undefined}\n data-hovered={isHovered || undefined}\n data-focused={states.isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-pressed={states.isPressed || undefined}\n data-allows-removing={states.allowsRemoving || undefined}\n data-selection-mode={state.selectionManager.selectionMode === 'none' ? undefined : state.selectionManager.selectionMode}>\n <div {...gridCellProps} style={{display: 'contents'}}>\n <Provider\n values={[\n [ButtonContext, {\n slots: {\n remove: removeButtonProps\n }\n }],\n [CollectionRendererContext, DefaultCollectionRenderer]\n ]}>\n {renderProps.children}\n </Provider>\n </div>\n </div>\n );\n});\n"],"names":[],"version":3,"file":"TagGroup.main.js.map"}
|
package/dist/TagGroup.mjs
CHANGED
|
@@ -3,11 +3,12 @@ import {CollectionRendererContext as $7135fc7d473fd974$export$4feb769f8ddf26c5,
|
|
|
3
3
|
import {Provider as $64fa3d84918910a7$export$2881499e37b75b9a, useContextProps as $64fa3d84918910a7$export$29f1550f4b0d4415, useRenderProps as $64fa3d84918910a7$export$4d86445c2cf5e3, useSlot as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8} from "./utils.mjs";
|
|
4
4
|
import {LabelContext as $01b77f81d0f07f68$export$75b6ee27786ba447} from "./Label.mjs";
|
|
5
5
|
import {ListStateContext as $eed445e0843c11d0$export$7c5906fe4f1f2af2} from "./ListBox.mjs";
|
|
6
|
+
import {SelectableCollectionContext as $8e6cc465cc68f603$export$b0d3ecf7112093a7} from "./context.mjs";
|
|
6
7
|
import {TextContext as $514c0188e459b4c0$export$9afb8bc826b033ea} from "./Text.mjs";
|
|
7
8
|
import {useTagGroup as $7lruP$useTagGroup, useFocusRing as $7lruP$useFocusRing, useTag as $7lruP$useTag, useHover as $7lruP$useHover} from "react-aria";
|
|
8
|
-
import {CollectionBuilder as $7lruP$CollectionBuilder, Collection as $7lruP$Collection, createLeafComponent as $7lruP$createLeafComponent} from "@react-aria/collections";
|
|
9
|
+
import {CollectionBuilder as $7lruP$CollectionBuilder, Collection as $7lruP$Collection, createLeafComponent as $7lruP$createLeafComponent, ItemNode as $7lruP$ItemNode} from "@react-aria/collections";
|
|
9
10
|
import {filterDOMProps as $7lruP$filterDOMProps, mergeProps as $7lruP$mergeProps, useObjectRef as $7lruP$useObjectRef} from "@react-aria/utils";
|
|
10
|
-
import {useListState as $7lruP$useListState} from "react-stately";
|
|
11
|
+
import {useListState as $7lruP$useListState, UNSTABLE_useFilteredListState as $7lruP$UNSTABLE_useFilteredListState} from "react-stately";
|
|
11
12
|
import $7lruP$react, {createContext as $7lruP$createContext, forwardRef as $7lruP$forwardRef, useRef as $7lruP$useRef, useContext as $7lruP$useContext, useEffect as $7lruP$useEffect} from "react";
|
|
12
13
|
|
|
13
14
|
/*
|
|
@@ -31,6 +32,7 @@ import $7lruP$react, {createContext as $7lruP$createContext, forwardRef as $7lru
|
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
|
|
35
|
+
|
|
34
36
|
const $eaf9e70818b436db$export$5b07b5dd2cbd96e3 = /*#__PURE__*/ (0, $7lruP$createContext)(null);
|
|
35
37
|
const $eaf9e70818b436db$export$e755ce3685dd0ca9 = /*#__PURE__*/ (0, $7lruP$createContext)(null);
|
|
36
38
|
const $eaf9e70818b436db$export$67ea30858aaf75e3 = /*#__PURE__*/ (0, $7lruP$forwardRef)(function TagGroup(props, ref) {
|
|
@@ -44,13 +46,19 @@ const $eaf9e70818b436db$export$67ea30858aaf75e3 = /*#__PURE__*/ (0, $7lruP$forwa
|
|
|
44
46
|
}));
|
|
45
47
|
});
|
|
46
48
|
function $eaf9e70818b436db$var$TagGroupInner({ props: props, forwardedRef: ref, collection: collection }) {
|
|
49
|
+
let contextProps;
|
|
50
|
+
[contextProps] = (0, $64fa3d84918910a7$export$29f1550f4b0d4415)({}, null, (0, $8e6cc465cc68f603$export$b0d3ecf7112093a7));
|
|
51
|
+
let { filter: filter, ...collectionProps } = contextProps;
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
53
|
+
let { shouldUseVirtualFocus: shouldUseVirtualFocus, disallowTypeAhead: disallowTypeAhead, ...DOMCollectionProps } = collectionProps || {};
|
|
47
54
|
let tagListRef = (0, $7lruP$useRef)(null);
|
|
48
55
|
let [labelRef, label] = (0, $64fa3d84918910a7$export$9d4c57ee4c6ffdd8)(!props['aria-label'] && !props['aria-labelledby']);
|
|
49
|
-
let
|
|
56
|
+
let tagGroupState = (0, $7lruP$useListState)({
|
|
50
57
|
...props,
|
|
51
58
|
children: undefined,
|
|
52
59
|
collection: collection
|
|
53
60
|
});
|
|
61
|
+
let filteredState = (0, $7lruP$UNSTABLE_useFilteredListState)(tagGroupState, filter);
|
|
54
62
|
// Prevent DOM props from going to two places.
|
|
55
63
|
let domProps = (0, $7lruP$filterDOMProps)(props, {
|
|
56
64
|
global: true
|
|
@@ -62,8 +70,9 @@ function $eaf9e70818b436db$var$TagGroupInner({ props: props, forwardedRef: ref,
|
|
|
62
70
|
let { gridProps: gridProps, labelProps: labelProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $7lruP$useTagGroup)({
|
|
63
71
|
...props,
|
|
64
72
|
...domPropOverrides,
|
|
73
|
+
...DOMCollectionProps,
|
|
65
74
|
label: label
|
|
66
|
-
},
|
|
75
|
+
}, filteredState, tagListRef);
|
|
67
76
|
var _props_className;
|
|
68
77
|
return /*#__PURE__*/ (0, $7lruP$react).createElement("div", {
|
|
69
78
|
...domProps,
|
|
@@ -90,7 +99,7 @@ function $eaf9e70818b436db$var$TagGroupInner({ props: props, forwardedRef: ref,
|
|
|
90
99
|
],
|
|
91
100
|
[
|
|
92
101
|
(0, $eed445e0843c11d0$export$7c5906fe4f1f2af2),
|
|
93
|
-
|
|
102
|
+
filteredState
|
|
94
103
|
],
|
|
95
104
|
[
|
|
96
105
|
(0, $514c0188e459b4c0$export$9afb8bc826b033ea),
|
|
@@ -143,7 +152,7 @@ function $eaf9e70818b436db$var$TagListInner({ props: props, forwardedRef: forwar
|
|
|
143
152
|
persistedKeys: persistedKeys
|
|
144
153
|
}));
|
|
145
154
|
}
|
|
146
|
-
const $eaf9e70818b436db$export$3288d34c523a1192 = /*#__PURE__*/ (0, $7lruP$createLeafComponent)(
|
|
155
|
+
const $eaf9e70818b436db$export$3288d34c523a1192 = /*#__PURE__*/ (0, $7lruP$createLeafComponent)((0, $7lruP$ItemNode), (props, forwardedRef, item)=>{
|
|
147
156
|
let state = (0, $7lruP$useContext)((0, $eed445e0843c11d0$export$7c5906fe4f1f2af2));
|
|
148
157
|
let ref = (0, $7lruP$useObjectRef)(forwardedRef);
|
|
149
158
|
let { focusProps: focusProps, isFocusVisible: isFocusVisible } = (0, $7lruP$useFocusRing)({
|
package/dist/TagGroup.module.js
CHANGED
|
@@ -3,11 +3,12 @@ import {CollectionRendererContext as $7135fc7d473fd974$export$4feb769f8ddf26c5,
|
|
|
3
3
|
import {Provider as $64fa3d84918910a7$export$2881499e37b75b9a, useContextProps as $64fa3d84918910a7$export$29f1550f4b0d4415, useRenderProps as $64fa3d84918910a7$export$4d86445c2cf5e3, useSlot as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8} from "./utils.module.js";
|
|
4
4
|
import {LabelContext as $01b77f81d0f07f68$export$75b6ee27786ba447} from "./Label.module.js";
|
|
5
5
|
import {ListStateContext as $eed445e0843c11d0$export$7c5906fe4f1f2af2} from "./ListBox.module.js";
|
|
6
|
+
import {SelectableCollectionContext as $8e6cc465cc68f603$export$b0d3ecf7112093a7} from "./context.module.js";
|
|
6
7
|
import {TextContext as $514c0188e459b4c0$export$9afb8bc826b033ea} from "./Text.module.js";
|
|
7
8
|
import {useTagGroup as $7lruP$useTagGroup, useFocusRing as $7lruP$useFocusRing, useTag as $7lruP$useTag, useHover as $7lruP$useHover} from "react-aria";
|
|
8
|
-
import {CollectionBuilder as $7lruP$CollectionBuilder, Collection as $7lruP$Collection, createLeafComponent as $7lruP$createLeafComponent} from "@react-aria/collections";
|
|
9
|
+
import {CollectionBuilder as $7lruP$CollectionBuilder, Collection as $7lruP$Collection, createLeafComponent as $7lruP$createLeafComponent, ItemNode as $7lruP$ItemNode} from "@react-aria/collections";
|
|
9
10
|
import {filterDOMProps as $7lruP$filterDOMProps, mergeProps as $7lruP$mergeProps, useObjectRef as $7lruP$useObjectRef} from "@react-aria/utils";
|
|
10
|
-
import {useListState as $7lruP$useListState} from "react-stately";
|
|
11
|
+
import {useListState as $7lruP$useListState, UNSTABLE_useFilteredListState as $7lruP$UNSTABLE_useFilteredListState} from "react-stately";
|
|
11
12
|
import $7lruP$react, {createContext as $7lruP$createContext, forwardRef as $7lruP$forwardRef, useRef as $7lruP$useRef, useContext as $7lruP$useContext, useEffect as $7lruP$useEffect} from "react";
|
|
12
13
|
|
|
13
14
|
/*
|
|
@@ -31,6 +32,7 @@ import $7lruP$react, {createContext as $7lruP$createContext, forwardRef as $7lru
|
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
|
|
35
|
+
|
|
34
36
|
const $eaf9e70818b436db$export$5b07b5dd2cbd96e3 = /*#__PURE__*/ (0, $7lruP$createContext)(null);
|
|
35
37
|
const $eaf9e70818b436db$export$e755ce3685dd0ca9 = /*#__PURE__*/ (0, $7lruP$createContext)(null);
|
|
36
38
|
const $eaf9e70818b436db$export$67ea30858aaf75e3 = /*#__PURE__*/ (0, $7lruP$forwardRef)(function TagGroup(props, ref) {
|
|
@@ -44,13 +46,19 @@ const $eaf9e70818b436db$export$67ea30858aaf75e3 = /*#__PURE__*/ (0, $7lruP$forwa
|
|
|
44
46
|
}));
|
|
45
47
|
});
|
|
46
48
|
function $eaf9e70818b436db$var$TagGroupInner({ props: props, forwardedRef: ref, collection: collection }) {
|
|
49
|
+
let contextProps;
|
|
50
|
+
[contextProps] = (0, $64fa3d84918910a7$export$29f1550f4b0d4415)({}, null, (0, $8e6cc465cc68f603$export$b0d3ecf7112093a7));
|
|
51
|
+
let { filter: filter, ...collectionProps } = contextProps;
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
53
|
+
let { shouldUseVirtualFocus: shouldUseVirtualFocus, disallowTypeAhead: disallowTypeAhead, ...DOMCollectionProps } = collectionProps || {};
|
|
47
54
|
let tagListRef = (0, $7lruP$useRef)(null);
|
|
48
55
|
let [labelRef, label] = (0, $64fa3d84918910a7$export$9d4c57ee4c6ffdd8)(!props['aria-label'] && !props['aria-labelledby']);
|
|
49
|
-
let
|
|
56
|
+
let tagGroupState = (0, $7lruP$useListState)({
|
|
50
57
|
...props,
|
|
51
58
|
children: undefined,
|
|
52
59
|
collection: collection
|
|
53
60
|
});
|
|
61
|
+
let filteredState = (0, $7lruP$UNSTABLE_useFilteredListState)(tagGroupState, filter);
|
|
54
62
|
// Prevent DOM props from going to two places.
|
|
55
63
|
let domProps = (0, $7lruP$filterDOMProps)(props, {
|
|
56
64
|
global: true
|
|
@@ -62,8 +70,9 @@ function $eaf9e70818b436db$var$TagGroupInner({ props: props, forwardedRef: ref,
|
|
|
62
70
|
let { gridProps: gridProps, labelProps: labelProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $7lruP$useTagGroup)({
|
|
63
71
|
...props,
|
|
64
72
|
...domPropOverrides,
|
|
73
|
+
...DOMCollectionProps,
|
|
65
74
|
label: label
|
|
66
|
-
},
|
|
75
|
+
}, filteredState, tagListRef);
|
|
67
76
|
var _props_className;
|
|
68
77
|
return /*#__PURE__*/ (0, $7lruP$react).createElement("div", {
|
|
69
78
|
...domProps,
|
|
@@ -90,7 +99,7 @@ function $eaf9e70818b436db$var$TagGroupInner({ props: props, forwardedRef: ref,
|
|
|
90
99
|
],
|
|
91
100
|
[
|
|
92
101
|
(0, $eed445e0843c11d0$export$7c5906fe4f1f2af2),
|
|
93
|
-
|
|
102
|
+
filteredState
|
|
94
103
|
],
|
|
95
104
|
[
|
|
96
105
|
(0, $514c0188e459b4c0$export$9afb8bc826b033ea),
|
|
@@ -143,7 +152,7 @@ function $eaf9e70818b436db$var$TagListInner({ props: props, forwardedRef: forwar
|
|
|
143
152
|
persistedKeys: persistedKeys
|
|
144
153
|
}));
|
|
145
154
|
}
|
|
146
|
-
const $eaf9e70818b436db$export$3288d34c523a1192 = /*#__PURE__*/ (0, $7lruP$createLeafComponent)(
|
|
155
|
+
const $eaf9e70818b436db$export$3288d34c523a1192 = /*#__PURE__*/ (0, $7lruP$createLeafComponent)((0, $7lruP$ItemNode), (props, forwardedRef, item)=>{
|
|
147
156
|
let state = (0, $7lruP$useContext)((0, $eed445e0843c11d0$export$7c5906fe4f1f2af2));
|
|
148
157
|
let ref = (0, $7lruP$useObjectRef)(forwardedRef);
|
|
149
158
|
let { focusProps: focusProps, isFocusVisible: isFocusVisible } = (0, $7lruP$useFocusRing)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;AA4CM,MAAM,0DAAkB,CAAA,GAAA,oBAAY,EAA+C;AACnF,MAAM,0DAAiB,CAAA,GAAA,oBAAY,EAAmD;AAKtF,MAAM,4CAAyB,AAAd,WAAW,GAAI,CAAA,GAAA,iBAAS,EAAqB,SAAS,SAAS,KAAoB,EAAE,GAAiC;IAC5I,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,qBACE,gCAAC,CAAA,GAAA,wBAAgB;QAAE,SAAS,MAAM,QAAQ;OACvC,CAAA,2BAAc,gCAAC;YAAc,OAAO;YAAO,cAAc;YAAK,YAAY;;AAGjF;AAQA,SAAS,oCAAc,SAAC,KAAK,EAAE,cAAc,GAAG,cAAE,UAAU,EAAqB;IAC/E,IAAI,aAAa,CAAA,GAAA,aAAK,EAAkB;IACxC,IAAI,CAAC,UAAU,MAAM,GAAG,CAAA,GAAA,yCAAM,EAC5B,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB;IAEnD,IAAI,QAAQ,CAAA,GAAA,mBAAW,EAAE;QACvB,GAAG,KAAK;QACR,UAAU;oBACV;IACF;IAEA,8CAA8C;IAC9C,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAClD,IAAI,mBAAmB,OAAO,WAAW,CAAC,OAAO,OAAO,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,EAAE,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;gBAAC,CAAA,GAAA,yCAAY;gBAAG;oBACd,OAAO;wBACL,QAAQ;oBACV;gBACF;aAAE;YACF;gBAAC,CAAA,GAAA,yCAAwB;gBAAG,CAAA,GAAA,yCAAwB;aAAE;SACvD;OACA,YAAY,QAAQ;AAK/B","sources":["packages/react-aria-components/src/TagGroup.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaTagGroupProps, useFocusRing, useHover, useTag, useTagGroup} from 'react-aria';\nimport {ButtonContext} from './Button';\nimport {Collection, CollectionBuilder, createLeafComponent} from '@react-aria/collections';\nimport {CollectionProps, CollectionRendererContext, DefaultCollectionRenderer, ItemRenderProps, usePersistedKeys} from './Collection';\nimport {ContextValue, DOMProps, Provider, RenderProps, SlotProps, StyleRenderProps, useContextProps, useRenderProps, useSlot} from './utils';\nimport {filterDOMProps, mergeProps, useObjectRef} from '@react-aria/utils';\nimport {forwardRefType, GlobalDOMAttributes, HoverEvents, Key, LinkDOMProps, PressEvents} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {ListState, Node, useListState} from 'react-stately';\nimport {ListStateContext} from './ListBox';\nimport React, {createContext, ForwardedRef, forwardRef, JSX, ReactNode, useContext, useEffect, useRef} from 'react';\nimport {TextContext} from './Text';\n\nexport interface TagGroupProps extends Omit<AriaTagGroupProps<unknown>, 'children' | 'items' | 'label' | 'description' | 'errorMessage' | 'keyboardDelegate'>, DOMProps, SlotProps, GlobalDOMAttributes<HTMLDivElement> {}\n\nexport interface TagListRenderProps {\n /**\n * Whether the tag list has no items and should display its empty state.\n * @selector [data-empty]\n */\n isEmpty: boolean,\n /**\n * Whether the tag list is currently focused.\n * @selector [data-focused]\n */\n isFocused: boolean,\n /**\n * Whether the tag list is currently keyboard focused.\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean,\n /**\n * State of the TagGroup.\n */\n state: ListState<unknown>\n}\n\nexport interface TagListProps<T> extends Omit<CollectionProps<T>, 'disabledKeys'>, StyleRenderProps<TagListRenderProps>, GlobalDOMAttributes<HTMLDivElement> {\n /** Provides content to display when there are no items in the tag list. */\n renderEmptyState?: (props: TagListRenderProps) => ReactNode\n}\n\nexport const TagGroupContext = createContext<ContextValue<TagGroupProps, HTMLDivElement>>(null);\nexport const TagListContext = createContext<ContextValue<TagListProps<any>, HTMLDivElement>>(null);\n\n/**\n * A tag group is a focusable list of labels, categories, keywords, filters, or other items, with support for keyboard navigation, selection, and removal.\n */\nexport const TagGroup = /*#__PURE__*/ (forwardRef as forwardRefType)(function TagGroup(props: TagGroupProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, TagGroupContext);\n return (\n <CollectionBuilder content={props.children}>\n {collection => <TagGroupInner props={props} forwardedRef={ref} collection={collection} />}\n </CollectionBuilder>\n );\n});\n\ninterface TagGroupInnerProps {\n props: TagGroupProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n collection\n}\n\nfunction TagGroupInner({props, forwardedRef: ref, collection}: TagGroupInnerProps) {\n let tagListRef = useRef<HTMLDivElement>(null);\n let [labelRef, label] = useSlot(\n !props['aria-label'] && !props['aria-labelledby']\n );\n let state = useListState({\n ...props,\n children: undefined,\n collection\n });\n\n // Prevent DOM props from going to two places.\n let domProps = filterDOMProps(props, {global: true});\n let domPropOverrides = Object.fromEntries(Object.entries(domProps).map(([k]) => [k, undefined]));\n let {\n gridProps,\n labelProps,\n descriptionProps,\n errorMessageProps\n } = useTagGroup({\n ...props,\n ...domPropOverrides,\n label\n }, state, tagListRef);\n\n return (\n <div\n {...domProps}\n ref={ref}\n slot={props.slot || undefined}\n className={props.className ?? 'react-aria-TagGroup'}\n style={props.style}>\n <Provider\n values={[\n [LabelContext, {...labelProps, elementType: 'span', ref: labelRef}],\n [TagListContext, {...gridProps, ref: tagListRef}],\n [ListStateContext, state],\n [TextContext, {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }]\n ]}>\n {props.children}\n </Provider>\n </div>\n );\n}\n\n/**\n * A tag list is a container for tags within a TagGroup.\n */\nexport const TagList = /*#__PURE__*/ (forwardRef as forwardRefType)(function TagList<T extends object>(props: TagListProps<T>, ref: ForwardedRef<HTMLDivElement>): JSX.Element {\n let state = useContext(ListStateContext);\n return state\n ? <TagListInner props={props} forwardedRef={ref} />\n : <Collection {...props} />;\n});\n\ninterface TagListInnerProps<T> {\n props: TagListProps<T>,\n forwardedRef: ForwardedRef<HTMLDivElement>\n}\n\nfunction TagListInner<T extends object>({props, forwardedRef}: TagListInnerProps<T>) {\n let state = useContext(ListStateContext)!;\n let {CollectionRoot} = useContext(CollectionRendererContext);\n let [gridProps, ref] = useContextProps({}, forwardedRef, TagListContext);\n\n let {focusProps, isFocused, isFocusVisible} = useFocusRing();\n let renderValues = {\n isEmpty: state.collection.size === 0,\n isFocused,\n isFocusVisible,\n state\n };\n let renderProps = useRenderProps({\n className: props.className,\n style: props.style,\n defaultClassName: 'react-aria-TagList',\n values: renderValues\n });\n\n let persistedKeys = usePersistedKeys(state.selectionManager.focusedKey);\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <div\n {...mergeProps(DOMProps, renderProps, gridProps, focusProps)}\n ref={ref}\n data-empty={state.collection.size === 0 || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}>\n {state.collection.size === 0 && props.renderEmptyState\n ? props.renderEmptyState(renderValues)\n : <CollectionRoot collection={state.collection} persistedKeys={persistedKeys} />}\n </div>\n );\n}\n\nexport interface TagRenderProps extends Omit<ItemRenderProps, 'allowsDragging' | 'isDragging' | 'isDropTarget'> {\n /**\n * Whether the tag group allows items to be removed.\n * @selector [data-allows-removing]\n */\n allowsRemoving: boolean\n}\n\nexport interface TagProps extends RenderProps<TagRenderProps>, LinkDOMProps, HoverEvents, PressEvents, Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {\n /** A unique id for the tag. */\n id?: Key,\n /**\n * A string representation of the tags's contents, used for accessibility.\n * Required if children is not a plain text string.\n */\n textValue?: string,\n /** Whether the tag is disabled. */\n isDisabled?: boolean\n}\n\n/**\n * A Tag is an individual item within a TagList.\n */\nexport const Tag = /*#__PURE__*/ createLeafComponent('item', (props: TagProps, forwardedRef: ForwardedRef<HTMLDivElement>, item: Node<unknown>) => {\n let state = useContext(ListStateContext)!;\n let ref = useObjectRef<HTMLDivElement>(forwardedRef);\n let {focusProps, isFocusVisible} = useFocusRing({within: false});\n let {rowProps, gridCellProps, removeButtonProps, ...states} = useTag({item}, state, ref);\n\n let {hoverProps, isHovered} = useHover({\n isDisabled: !states.allowsSelection,\n onHoverStart: item.props.onHoverStart,\n onHoverChange: item.props.onHoverChange,\n onHoverEnd: item.props.onHoverEnd\n });\n\n let renderProps = useRenderProps({\n ...props,\n id: undefined,\n children: item.rendered,\n defaultClassName: 'react-aria-Tag',\n values: {\n ...states,\n isFocusVisible,\n isHovered,\n selectionMode: state.selectionManager.selectionMode,\n selectionBehavior: state.selectionManager.selectionBehavior\n }\n });\n\n useEffect(() => {\n if (!item.textValue && process.env.NODE_ENV !== 'production') {\n console.warn('A `textValue` prop is required for <Tag> elements with non-plain text children for accessibility.');\n }\n }, [item.textValue]);\n\n let DOMProps = filterDOMProps(props as any, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <div\n ref={ref}\n {...mergeProps(DOMProps, renderProps, rowProps, focusProps, hoverProps)}\n data-selected={states.isSelected || undefined}\n data-disabled={states.isDisabled || undefined}\n data-hovered={isHovered || undefined}\n data-focused={states.isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-pressed={states.isPressed || undefined}\n data-allows-removing={states.allowsRemoving || undefined}\n data-selection-mode={state.selectionManager.selectionMode === 'none' ? undefined : state.selectionManager.selectionMode}>\n <div {...gridCellProps} style={{display: 'contents'}}>\n <Provider\n values={[\n [ButtonContext, {\n slots: {\n remove: removeButtonProps\n }\n }],\n [CollectionRendererContext, DefaultCollectionRenderer]\n ]}>\n {renderProps.children}\n </Provider>\n </div>\n </div>\n );\n});\n"],"names":[],"version":3,"file":"TagGroup.module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;AA6CM,MAAM,0DAAkB,CAAA,GAAA,oBAAY,EAA+C;AACnF,MAAM,0DAAiB,CAAA,GAAA,oBAAY,EAAmD;AAKtF,MAAM,4CAAyB,AAAd,WAAW,GAAI,CAAA,GAAA,iBAAS,EAAqB,SAAS,SAAS,KAAoB,EAAE,GAAiC;IAC5I,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,qBACE,gCAAC,CAAA,GAAA,wBAAgB;QAAE,SAAS,MAAM,QAAQ;OACvC,CAAA,2BAAc,gCAAC;YAAc,OAAO;YAAO,cAAc;YAAK,YAAY;;AAGjF;AAQA,SAAS,oCAAc,SAAC,KAAK,EAAE,cAAc,GAAG,cAAE,UAAU,EAAqB;IAC/E,IAAI;IACJ,CAAC,aAAa,GAAG,CAAA,GAAA,yCAAc,EAAE,CAAC,GAAG,MAAM,CAAA,GAAA,yCAA0B;IACrE,IAAI,UAAC,MAAM,EAAE,GAAG,iBAAgB,GAAG;IACnC,6DAA6D;IAC7D,IAAI,yBAAC,qBAAqB,qBAAE,iBAAiB,EAAE,GAAG,oBAAmB,GAAG,mBAAmB,CAAC;IAC5F,IAAI,aAAa,CAAA,GAAA,aAAK,EAAkB;IACxC,IAAI,CAAC,UAAU,MAAM,GAAG,CAAA,GAAA,yCAAM,EAC5B,CAAC,KAAK,CAAC,aAAa,IAAI,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AO,UAAU,IAAI;QACpC,iBAAe,OAAO,UAAU,IAAI;QACpC,gBAAc,aAAa;QAC3B,gBAAc,OAAO,SAAS,IAAI;QAClC,sBAAoB,kBAAkB;QACtC,gBAAc,OAAO,SAAS,IAAI;QAClC,wBAAsB,OAAO,cAAc,IAAI;QAC/C,uBAAqB,MAAM,gBAAgB,CAAC,aAAa,KAAK,SAAS,YAAY,MAAM,gBAAgB,CAAC,aAAa;qBACvH,gCAAC;QAAK,GAAG,aAAa;QAAE,OAAO;YAAC,SAAS;QAAU;qBACjD,gCAAC,CAAA,GAAA,yCAAO;QACN,QAAQ;YACN;gBAAC,CAAA,GAAA,yCAAY;gBAAG;oBACd,OAAO;wBACL,QAAQ;oBACV;gBACF;aAAE;YACF;gBAAC,CAAA,GAAA,yCAAwB;gBAAG,CAAA,GAAA,yCAAwB;aAAE;SACvD;OACA,YAAY,QAAQ;AAK/B","sources":["packages/react-aria-components/src/TagGroup.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaTagGroupProps, useFocusRing, useHover, useTag, useTagGroup} from 'react-aria';\nimport {ButtonContext} from './Button';\nimport {Collection, CollectionBuilder, createLeafComponent, ItemNode} from '@react-aria/collections';\nimport {CollectionProps, CollectionRendererContext, DefaultCollectionRenderer, ItemRenderProps, usePersistedKeys} from './Collection';\nimport {ContextValue, DOMProps, Provider, RenderProps, SlotProps, StyleRenderProps, useContextProps, useRenderProps, useSlot} from './utils';\nimport {filterDOMProps, mergeProps, useObjectRef} from '@react-aria/utils';\nimport {forwardRefType, GlobalDOMAttributes, HoverEvents, Key, LinkDOMProps, PressEvents} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {ListState, Node, UNSTABLE_useFilteredListState, useListState} from 'react-stately';\nimport {ListStateContext} from './ListBox';\nimport React, {createContext, ForwardedRef, forwardRef, JSX, ReactNode, useContext, useEffect, useRef} from 'react';\nimport {SelectableCollectionContext} from './context';\nimport {TextContext} from './Text';\n\nexport interface TagGroupProps extends Omit<AriaTagGroupProps<unknown>, 'children' | 'items' | 'label' | 'description' | 'errorMessage' | 'keyboardDelegate'>, DOMProps, SlotProps, GlobalDOMAttributes<HTMLDivElement> {}\n\nexport interface TagListRenderProps {\n /**\n * Whether the tag list has no items and should display its empty state.\n * @selector [data-empty]\n */\n isEmpty: boolean,\n /**\n * Whether the tag list is currently focused.\n * @selector [data-focused]\n */\n isFocused: boolean,\n /**\n * Whether the tag list is currently keyboard focused.\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean,\n /**\n * State of the TagGroup.\n */\n state: ListState<unknown>\n}\n\nexport interface TagListProps<T> extends Omit<CollectionProps<T>, 'disabledKeys'>, StyleRenderProps<TagListRenderProps>, GlobalDOMAttributes<HTMLDivElement> {\n /** Provides content to display when there are no items in the tag list. */\n renderEmptyState?: (props: TagListRenderProps) => ReactNode\n}\n\nexport const TagGroupContext = createContext<ContextValue<TagGroupProps, HTMLDivElement>>(null);\nexport const TagListContext = createContext<ContextValue<TagListProps<any>, HTMLDivElement>>(null);\n\n/**\n * A tag group is a focusable list of labels, categories, keywords, filters, or other items, with support for keyboard navigation, selection, and removal.\n */\nexport const TagGroup = /*#__PURE__*/ (forwardRef as forwardRefType)(function TagGroup(props: TagGroupProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, TagGroupContext);\n return (\n <CollectionBuilder content={props.children}>\n {collection => <TagGroupInner props={props} forwardedRef={ref} collection={collection} />}\n </CollectionBuilder>\n );\n});\n\ninterface TagGroupInnerProps {\n props: TagGroupProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n collection\n}\n\nfunction TagGroupInner({props, forwardedRef: ref, collection}: TagGroupInnerProps) {\n let contextProps;\n [contextProps] = useContextProps({}, null, SelectableCollectionContext);\n let {filter, ...collectionProps} = contextProps;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n let {shouldUseVirtualFocus, disallowTypeAhead, ...DOMCollectionProps} = collectionProps || {};\n let tagListRef = useRef<HTMLDivElement>(null);\n let [labelRef, label] = useSlot(\n !props['aria-label'] && !props['aria-labelledby']\n );\n let tagGroupState = useListState({\n ...props,\n children: undefined,\n collection\n });\n\n let filteredState = UNSTABLE_useFilteredListState(tagGroupState, filter);\n\n // Prevent DOM props from going to two places.\n let domProps = filterDOMProps(props, {global: true});\n let domPropOverrides = Object.fromEntries(Object.entries(domProps).map(([k]) => [k, undefined]));\n let {\n gridProps,\n labelProps,\n descriptionProps,\n errorMessageProps\n } = useTagGroup({\n ...props,\n ...domPropOverrides,\n ...DOMCollectionProps,\n label\n }, filteredState, tagListRef);\n\n return (\n <div\n {...domProps}\n ref={ref}\n slot={props.slot || undefined}\n className={props.className ?? 'react-aria-TagGroup'}\n style={props.style}>\n <Provider\n values={[\n [LabelContext, {...labelProps, elementType: 'span', ref: labelRef}],\n [TagListContext, {...gridProps, ref: tagListRef}],\n [ListStateContext, filteredState],\n [TextContext, {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }]\n ]}>\n {props.children}\n </Provider>\n </div>\n );\n}\n\n/**\n * A tag list is a container for tags within a TagGroup.\n */\nexport const TagList = /*#__PURE__*/ (forwardRef as forwardRefType)(function TagList<T extends object>(props: TagListProps<T>, ref: ForwardedRef<HTMLDivElement>): JSX.Element {\n let state = useContext(ListStateContext);\n return state\n ? <TagListInner props={props} forwardedRef={ref} />\n : <Collection {...props} />;\n});\n\ninterface TagListInnerProps<T> {\n props: TagListProps<T>,\n forwardedRef: ForwardedRef<HTMLDivElement>\n}\n\nfunction TagListInner<T extends object>({props, forwardedRef}: TagListInnerProps<T>) {\n let state = useContext(ListStateContext)!;\n let {CollectionRoot} = useContext(CollectionRendererContext);\n let [gridProps, ref] = useContextProps({}, forwardedRef, TagListContext);\n\n let {focusProps, isFocused, isFocusVisible} = useFocusRing();\n let renderValues = {\n isEmpty: state.collection.size === 0,\n isFocused,\n isFocusVisible,\n state\n };\n let renderProps = useRenderProps({\n className: props.className,\n style: props.style,\n defaultClassName: 'react-aria-TagList',\n values: renderValues\n });\n\n let persistedKeys = usePersistedKeys(state.selectionManager.focusedKey);\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <div\n {...mergeProps(DOMProps, renderProps, gridProps, focusProps)}\n ref={ref}\n data-empty={state.collection.size === 0 || undefined}\n data-focused={isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}>\n {state.collection.size === 0 && props.renderEmptyState\n ? props.renderEmptyState(renderValues)\n : <CollectionRoot collection={state.collection} persistedKeys={persistedKeys} />}\n </div>\n );\n}\n\nexport interface TagRenderProps extends Omit<ItemRenderProps, 'allowsDragging' | 'isDragging' | 'isDropTarget'> {\n /**\n * Whether the tag group allows items to be removed.\n * @selector [data-allows-removing]\n */\n allowsRemoving: boolean\n}\n\nexport interface TagProps extends RenderProps<TagRenderProps>, LinkDOMProps, HoverEvents, PressEvents, Omit<GlobalDOMAttributes<HTMLDivElement>, 'onClick'> {\n /** A unique id for the tag. */\n id?: Key,\n /**\n * A string representation of the tags's contents, used for accessibility.\n * Required if children is not a plain text string.\n */\n textValue?: string,\n /** Whether the tag is disabled. */\n isDisabled?: boolean\n}\n\n/**\n * A Tag is an individual item within a TagList.\n */\nexport const Tag = /*#__PURE__*/ createLeafComponent(ItemNode, (props: TagProps, forwardedRef: ForwardedRef<HTMLDivElement>, item: Node<unknown>) => {\n let state = useContext(ListStateContext)!;\n let ref = useObjectRef<HTMLDivElement>(forwardedRef);\n let {focusProps, isFocusVisible} = useFocusRing({within: false});\n let {rowProps, gridCellProps, removeButtonProps, ...states} = useTag({item}, state, ref);\n\n let {hoverProps, isHovered} = useHover({\n isDisabled: !states.allowsSelection,\n onHoverStart: item.props.onHoverStart,\n onHoverChange: item.props.onHoverChange,\n onHoverEnd: item.props.onHoverEnd\n });\n\n let renderProps = useRenderProps({\n ...props,\n id: undefined,\n children: item.rendered,\n defaultClassName: 'react-aria-Tag',\n values: {\n ...states,\n isFocusVisible,\n isHovered,\n selectionMode: state.selectionManager.selectionMode,\n selectionBehavior: state.selectionManager.selectionBehavior\n }\n });\n\n useEffect(() => {\n if (!item.textValue && process.env.NODE_ENV !== 'production') {\n console.warn('A `textValue` prop is required for <Tag> elements with non-plain text children for accessibility.');\n }\n }, [item.textValue]);\n\n let DOMProps = filterDOMProps(props as any, {global: true});\n delete DOMProps.id;\n delete DOMProps.onClick;\n\n return (\n <div\n ref={ref}\n {...mergeProps(DOMProps, renderProps, rowProps, focusProps, hoverProps)}\n data-selected={states.isSelected || undefined}\n data-disabled={states.isDisabled || undefined}\n data-hovered={isHovered || undefined}\n data-focused={states.isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-pressed={states.isPressed || undefined}\n data-allows-removing={states.allowsRemoving || undefined}\n data-selection-mode={state.selectionManager.selectionMode === 'none' ? undefined : state.selectionManager.selectionMode}>\n <div {...gridCellProps} style={{display: 'contents'}}>\n <Provider\n values={[\n [ButtonContext, {\n slots: {\n remove: removeButtonProps\n }\n }],\n [CollectionRendererContext, DefaultCollectionRenderer]\n ]}>\n {renderProps.children}\n </Provider>\n </div>\n </div>\n );\n});\n"],"names":[],"version":3,"file":"TagGroup.module.js.map"}
|
package/dist/TextField.main.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
var $c5ccf687772c0422$exports = require("./utils.main.js");
|
|
2
2
|
var $846a838139f2ac6b$exports = require("./FieldError.main.js");
|
|
3
|
+
var $09cb5ee89bb327e1$exports = require("./context.main.js");
|
|
3
4
|
var $35157657e549736b$exports = require("./Form.main.js");
|
|
4
5
|
var $dcae72abc18c0045$exports = require("./Group.main.js");
|
|
5
6
|
var $1bcfcef5af644e13$exports = require("./Input.main.js");
|
|
@@ -44,6 +45,7 @@ $parcel$export(module.exports, "TextField", () => $3f2c5af9d7d8905b$export$2c732
|
|
|
44
45
|
|
|
45
46
|
|
|
46
47
|
|
|
48
|
+
|
|
47
49
|
const $3f2c5af9d7d8905b$export$2129e27b3ef0d483 = /*#__PURE__*/ (0, $1Ma1u$react.createContext)(null);
|
|
48
50
|
const $3f2c5af9d7d8905b$export$2c73285ae9390cec = /*#__PURE__*/ (0, $1Ma1u$reactariacollections.createHideableComponent)(function TextField(props, ref) {
|
|
49
51
|
[props, ref] = (0, $c5ccf687772c0422$exports.useContextProps)(props, ref, $3f2c5af9d7d8905b$export$2129e27b3ef0d483);
|
|
@@ -51,7 +53,7 @@ const $3f2c5af9d7d8905b$export$2c73285ae9390cec = /*#__PURE__*/ (0, $1Ma1u$react
|
|
|
51
53
|
var _props_validationBehavior, _ref;
|
|
52
54
|
let validationBehavior = (_ref = (_props_validationBehavior = props.validationBehavior) !== null && _props_validationBehavior !== void 0 ? _props_validationBehavior : formValidationBehavior) !== null && _ref !== void 0 ? _ref : 'native';
|
|
53
55
|
let inputRef = (0, $1Ma1u$react.useRef)(null);
|
|
54
|
-
|
|
56
|
+
[props, inputRef] = (0, $c5ccf687772c0422$exports.useContextProps)(props, inputRef, (0, $09cb5ee89bb327e1$exports.FieldInputContext));
|
|
55
57
|
let [labelRef, label] = (0, $c5ccf687772c0422$exports.useSlot)(!props['aria-label'] && !props['aria-labelledby']);
|
|
56
58
|
let [inputElementType, setInputElementType] = (0, $1Ma1u$react.useState)('input');
|
|
57
59
|
let { labelProps: labelProps, inputProps: inputProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps, ...validation } = (0, $1Ma1u$reactaria.useTextField)({
|
|
@@ -59,14 +61,14 @@ const $3f2c5af9d7d8905b$export$2c73285ae9390cec = /*#__PURE__*/ (0, $1Ma1u$react
|
|
|
59
61
|
inputElementType: inputElementType,
|
|
60
62
|
label: label,
|
|
61
63
|
validationBehavior: validationBehavior
|
|
62
|
-
},
|
|
64
|
+
}, inputRef);
|
|
63
65
|
// Intercept setting the input ref so we can determine what kind of element we have.
|
|
64
66
|
// useTextField uses this to determine what props to include.
|
|
65
67
|
let inputOrTextAreaRef = (0, $1Ma1u$react.useCallback)((el)=>{
|
|
66
|
-
|
|
68
|
+
inputRef.current = el;
|
|
67
69
|
if (el) setInputElementType(el instanceof HTMLTextAreaElement ? 'textarea' : 'input');
|
|
68
70
|
}, [
|
|
69
|
-
|
|
71
|
+
inputRef
|
|
70
72
|
]);
|
|
71
73
|
let renderProps = (0, $c5ccf687772c0422$exports.useRenderProps)({
|
|
72
74
|
...props,
|
|
@@ -103,7 +105,7 @@ const $3f2c5af9d7d8905b$export$2c73285ae9390cec = /*#__PURE__*/ (0, $1Ma1u$react
|
|
|
103
105
|
[
|
|
104
106
|
(0, $1bcfcef5af644e13$exports.InputContext),
|
|
105
107
|
{
|
|
106
|
-
...
|
|
108
|
+
...inputProps,
|
|
107
109
|
ref: inputOrTextAreaRef
|
|
108
110
|
}
|
|
109
111
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;AA6CM,MAAM,0DAAmB,CAAA,GAAA,0BAAY,EAAgD;AAKrF,MAAM,4CAAY,WAAW,GAAG,CAAA,GAAA,mDAAsB,EAAE,SAAS,UAAU,KAAqB,EAAE,GAAiC;IACxI,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,EAAC,oBAAoB,sBAAsB,EAAC,GAAG,CAAA,GAAA,2CAAgB,EAAE,CAAA,GAAA,qCAAU,MAAM,CAAC;QAC7D,2BAAA;IAAzB,IAAI,qBAAqB,CAAA,OAAA,CAAA,4BAAA,MAAM,kBAAkB,cAA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iBAAe,MAAM,UAAU,IAAI;qBACnC,0DAAC,CAAA,GAAA,kCAAO;QACN,QAAQ;YACN;gBAAC,CAAA,GAAA,sCAAW;gBAAG;oBAAC,GAAG,UAAU;oBAAE,KAAK;gBAAQ;aAAE;YAC9C;gBAAC,CAAA,GAAA,sCAAW;gBAAG;oBAAC,GAAG,UAAU;oBAAE,KAAK;gBAAkB;aAAE;YACxD;gBAAC,CAAA,GAAA,yCAAc;gBAAG;oBAAC,GAAG,UAAU;oBAAE,KAAK;gBAAkB;aAAE;YAC3D;gBAAC,CAAA,GAAA,sCAAW;gBAAG;oBAAC,MAAM;oBAAgB,WAAW,WAAW,SAAS;oBAAE,YAAY,MAAM,UAAU,IAAI;gBAAK;aAAE;YAC9G;gBAAC,CAAA,GAAA,qCAAU;gBAAG;oBACZ,OAAO;wBACL,aAAa;wBACb,cAAc;oBAChB;gBACF;aAAE;YACF;gBAAC,CAAA,GAAA,2CAAgB;gBAAG;aAAW;SAChC;OACA,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/TextField.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaTextFieldProps, useTextField} from 'react-aria';\nimport {ContextValue, DOMProps, Provider, RACValidation, removeDataAttributes, RenderProps, SlotProps, useContextProps, useRenderProps, useSlot, useSlottedContext} from './utils';\nimport {createHideableComponent} from '@react-aria/collections';\nimport {FieldErrorContext} from './FieldError';\nimport {FieldInputContext} from './context';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport {GroupContext} from './Group';\nimport {InputContext} from './Input';\nimport {LabelContext} from './Label';\nimport React, {createContext, ForwardedRef, useCallback, useRef, useState} from 'react';\nimport {TextAreaContext} from './TextArea';\nimport {TextContext} from './Text';\n\nexport interface TextFieldRenderProps {\n /**\n * Whether the text field is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean,\n /**\n * Whether the value is invalid.\n * @selector [data-invalid]\n */\n isInvalid: boolean,\n /**\n * Whether the text field is read only.\n * @selector [data-readonly]\n */\n isReadOnly: boolean,\n /**\n * Whether the text field is required.\n * @selector [data-required]\n */\n isRequired: boolean\n}\n\nexport interface TextFieldProps extends Omit<AriaTextFieldProps, 'label' | 'placeholder' | 'description' | 'errorMessage' | 'validationState' | 'validationBehavior'>, RACValidation, Omit<DOMProps, 'style' | 'className' | 'children'>, SlotProps, RenderProps<TextFieldRenderProps>, GlobalDOMAttributes<HTMLDivElement> {\n /** Whether the value is invalid. */\n isInvalid?: boolean\n}\n\nexport const TextFieldContext = createContext<ContextValue<TextFieldProps, HTMLDivElement>>(null);\n\n/**\n * A text field allows a user to enter a plain text value with a keyboard.\n */\nexport const TextField = /*#__PURE__*/ createHideableComponent(function TextField(props: TextFieldProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, TextFieldContext);\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let inputRef = useRef<HTMLInputElement>(null);\n [props, inputRef as unknown] = useContextProps(props, inputRef, FieldInputContext);\n let [labelRef, label] = useSlot(\n !props['aria-label'] && !props['aria-labelledby']\n );\n let [inputElementType, setInputElementType] = useState('input');\n let {labelProps, inputProps, descriptionProps, errorMessageProps, ...validation} = useTextField<any>({\n ...removeDataAttributes(props),\n inputElementType,\n label,\n validationBehavior\n }, inputRef);\n\n // Intercept setting the input ref so we can determine what kind of element we have.\n // useTextField uses this to determine what props to include.\n let inputOrTextAreaRef = useCallback((el) => {\n inputRef.current = el;\n if (el) {\n setInputElementType(el instanceof HTMLTextAreaElement ? 'textarea' : 'input');\n }\n }, [inputRef]);\n\n let renderProps = useRenderProps({\n ...props,\n values: {\n isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid,\n isReadOnly: props.isReadOnly || false,\n isRequired: props.isRequired || false\n },\n defaultClassName: 'react-aria-TextField'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n return (\n <div\n {...DOMProps}\n {...renderProps}\n ref={ref}\n slot={props.slot || undefined}\n data-disabled={props.isDisabled || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-readonly={props.isReadOnly || undefined}\n data-required={props.isRequired || undefined}>\n <Provider\n values={[\n [LabelContext, {...labelProps, ref: labelRef}],\n [InputContext, {...inputProps, ref: inputOrTextAreaRef}],\n [TextAreaContext, {...inputProps, ref: inputOrTextAreaRef}],\n [GroupContext, {role: 'presentation', isInvalid: validation.isInvalid, isDisabled: props.isDisabled || false}],\n [TextContext, {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }],\n [FieldErrorContext, validation]\n ]}>\n {renderProps.children}\n </Provider>\n </div>\n );\n});\n"],"names":[],"version":3,"file":"TextField.main.js.map"}
|
package/dist/TextField.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {Provider as $64fa3d84918910a7$export$2881499e37b75b9a, removeDataAttributes as $64fa3d84918910a7$export$ef03459518577ad4, useContextProps as $64fa3d84918910a7$export$29f1550f4b0d4415, useRenderProps as $64fa3d84918910a7$export$4d86445c2cf5e3, useSlot as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8, useSlottedContext as $64fa3d84918910a7$export$fabf2dc03a41866e} from "./utils.mjs";
|
|
2
2
|
import {FieldErrorContext as $ee014567cb39d3f0$export$ff05c3ac10437e03} from "./FieldError.mjs";
|
|
3
|
+
import {FieldInputContext as $8e6cc465cc68f603$export$698f465ec27e93df} from "./context.mjs";
|
|
3
4
|
import {FormContext as $d3e0e05bdfcf66bd$export$c24727297075ec6a} from "./Form.mjs";
|
|
4
5
|
import {GroupContext as $a049562f99e7db0e$export$f9c6924e160136d1} from "./Group.mjs";
|
|
5
6
|
import {InputContext as $3985021b0ad6602f$export$37fb8590cf2c088c} from "./Input.mjs";
|
|
@@ -8,7 +9,7 @@ import {TextAreaContext as $216918bed6669f72$export$2dc6166a7e65358c} from "./Te
|
|
|
8
9
|
import {TextContext as $514c0188e459b4c0$export$9afb8bc826b033ea} from "./Text.mjs";
|
|
9
10
|
import {useTextField as $jmnGn$useTextField} from "react-aria";
|
|
10
11
|
import {createHideableComponent as $jmnGn$createHideableComponent} from "@react-aria/collections";
|
|
11
|
-
import {filterDOMProps as $jmnGn$filterDOMProps
|
|
12
|
+
import {filterDOMProps as $jmnGn$filterDOMProps} from "@react-aria/utils";
|
|
12
13
|
import $jmnGn$react, {createContext as $jmnGn$createContext, useRef as $jmnGn$useRef, useState as $jmnGn$useState, useCallback as $jmnGn$useCallback} from "react";
|
|
13
14
|
|
|
14
15
|
/*
|
|
@@ -33,6 +34,7 @@ import $jmnGn$react, {createContext as $jmnGn$createContext, useRef as $jmnGn$us
|
|
|
33
34
|
|
|
34
35
|
|
|
35
36
|
|
|
37
|
+
|
|
36
38
|
const $bcdf0525bf22703d$export$2129e27b3ef0d483 = /*#__PURE__*/ (0, $jmnGn$createContext)(null);
|
|
37
39
|
const $bcdf0525bf22703d$export$2c73285ae9390cec = /*#__PURE__*/ (0, $jmnGn$createHideableComponent)(function TextField(props, ref) {
|
|
38
40
|
[props, ref] = (0, $64fa3d84918910a7$export$29f1550f4b0d4415)(props, ref, $bcdf0525bf22703d$export$2129e27b3ef0d483);
|
|
@@ -40,7 +42,7 @@ const $bcdf0525bf22703d$export$2c73285ae9390cec = /*#__PURE__*/ (0, $jmnGn$creat
|
|
|
40
42
|
var _props_validationBehavior, _ref;
|
|
41
43
|
let validationBehavior = (_ref = (_props_validationBehavior = props.validationBehavior) !== null && _props_validationBehavior !== void 0 ? _props_validationBehavior : formValidationBehavior) !== null && _ref !== void 0 ? _ref : 'native';
|
|
42
44
|
let inputRef = (0, $jmnGn$useRef)(null);
|
|
43
|
-
|
|
45
|
+
[props, inputRef] = (0, $64fa3d84918910a7$export$29f1550f4b0d4415)(props, inputRef, (0, $8e6cc465cc68f603$export$698f465ec27e93df));
|
|
44
46
|
let [labelRef, label] = (0, $64fa3d84918910a7$export$9d4c57ee4c6ffdd8)(!props['aria-label'] && !props['aria-labelledby']);
|
|
45
47
|
let [inputElementType, setInputElementType] = (0, $jmnGn$useState)('input');
|
|
46
48
|
let { labelProps: labelProps, inputProps: inputProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps, ...validation } = (0, $jmnGn$useTextField)({
|
|
@@ -48,14 +50,14 @@ const $bcdf0525bf22703d$export$2c73285ae9390cec = /*#__PURE__*/ (0, $jmnGn$creat
|
|
|
48
50
|
inputElementType: inputElementType,
|
|
49
51
|
label: label,
|
|
50
52
|
validationBehavior: validationBehavior
|
|
51
|
-
},
|
|
53
|
+
}, inputRef);
|
|
52
54
|
// Intercept setting the input ref so we can determine what kind of element we have.
|
|
53
55
|
// useTextField uses this to determine what props to include.
|
|
54
56
|
let inputOrTextAreaRef = (0, $jmnGn$useCallback)((el)=>{
|
|
55
|
-
|
|
57
|
+
inputRef.current = el;
|
|
56
58
|
if (el) setInputElementType(el instanceof HTMLTextAreaElement ? 'textarea' : 'input');
|
|
57
59
|
}, [
|
|
58
|
-
|
|
60
|
+
inputRef
|
|
59
61
|
]);
|
|
60
62
|
let renderProps = (0, $64fa3d84918910a7$export$4d86445c2cf5e3)({
|
|
61
63
|
...props,
|
|
@@ -92,7 +94,7 @@ const $bcdf0525bf22703d$export$2c73285ae9390cec = /*#__PURE__*/ (0, $jmnGn$creat
|
|
|
92
94
|
[
|
|
93
95
|
(0, $3985021b0ad6602f$export$37fb8590cf2c088c),
|
|
94
96
|
{
|
|
95
|
-
...
|
|
97
|
+
...inputProps,
|
|
96
98
|
ref: inputOrTextAreaRef
|
|
97
99
|
}
|
|
98
100
|
],
|
package/dist/TextField.module.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {Provider as $64fa3d84918910a7$export$2881499e37b75b9a, removeDataAttributes as $64fa3d84918910a7$export$ef03459518577ad4, useContextProps as $64fa3d84918910a7$export$29f1550f4b0d4415, useRenderProps as $64fa3d84918910a7$export$4d86445c2cf5e3, useSlot as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8, useSlottedContext as $64fa3d84918910a7$export$fabf2dc03a41866e} from "./utils.module.js";
|
|
2
2
|
import {FieldErrorContext as $ee014567cb39d3f0$export$ff05c3ac10437e03} from "./FieldError.module.js";
|
|
3
|
+
import {FieldInputContext as $8e6cc465cc68f603$export$698f465ec27e93df} from "./context.module.js";
|
|
3
4
|
import {FormContext as $d3e0e05bdfcf66bd$export$c24727297075ec6a} from "./Form.module.js";
|
|
4
5
|
import {GroupContext as $a049562f99e7db0e$export$f9c6924e160136d1} from "./Group.module.js";
|
|
5
6
|
import {InputContext as $3985021b0ad6602f$export$37fb8590cf2c088c} from "./Input.module.js";
|
|
@@ -8,7 +9,7 @@ import {TextAreaContext as $216918bed6669f72$export$2dc6166a7e65358c} from "./Te
|
|
|
8
9
|
import {TextContext as $514c0188e459b4c0$export$9afb8bc826b033ea} from "./Text.module.js";
|
|
9
10
|
import {useTextField as $jmnGn$useTextField} from "react-aria";
|
|
10
11
|
import {createHideableComponent as $jmnGn$createHideableComponent} from "@react-aria/collections";
|
|
11
|
-
import {filterDOMProps as $jmnGn$filterDOMProps
|
|
12
|
+
import {filterDOMProps as $jmnGn$filterDOMProps} from "@react-aria/utils";
|
|
12
13
|
import $jmnGn$react, {createContext as $jmnGn$createContext, useRef as $jmnGn$useRef, useState as $jmnGn$useState, useCallback as $jmnGn$useCallback} from "react";
|
|
13
14
|
|
|
14
15
|
/*
|
|
@@ -33,6 +34,7 @@ import $jmnGn$react, {createContext as $jmnGn$createContext, useRef as $jmnGn$us
|
|
|
33
34
|
|
|
34
35
|
|
|
35
36
|
|
|
37
|
+
|
|
36
38
|
const $bcdf0525bf22703d$export$2129e27b3ef0d483 = /*#__PURE__*/ (0, $jmnGn$createContext)(null);
|
|
37
39
|
const $bcdf0525bf22703d$export$2c73285ae9390cec = /*#__PURE__*/ (0, $jmnGn$createHideableComponent)(function TextField(props, ref) {
|
|
38
40
|
[props, ref] = (0, $64fa3d84918910a7$export$29f1550f4b0d4415)(props, ref, $bcdf0525bf22703d$export$2129e27b3ef0d483);
|
|
@@ -40,7 +42,7 @@ const $bcdf0525bf22703d$export$2c73285ae9390cec = /*#__PURE__*/ (0, $jmnGn$creat
|
|
|
40
42
|
var _props_validationBehavior, _ref;
|
|
41
43
|
let validationBehavior = (_ref = (_props_validationBehavior = props.validationBehavior) !== null && _props_validationBehavior !== void 0 ? _props_validationBehavior : formValidationBehavior) !== null && _ref !== void 0 ? _ref : 'native';
|
|
42
44
|
let inputRef = (0, $jmnGn$useRef)(null);
|
|
43
|
-
|
|
45
|
+
[props, inputRef] = (0, $64fa3d84918910a7$export$29f1550f4b0d4415)(props, inputRef, (0, $8e6cc465cc68f603$export$698f465ec27e93df));
|
|
44
46
|
let [labelRef, label] = (0, $64fa3d84918910a7$export$9d4c57ee4c6ffdd8)(!props['aria-label'] && !props['aria-labelledby']);
|
|
45
47
|
let [inputElementType, setInputElementType] = (0, $jmnGn$useState)('input');
|
|
46
48
|
let { labelProps: labelProps, inputProps: inputProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps, ...validation } = (0, $jmnGn$useTextField)({
|
|
@@ -48,14 +50,14 @@ const $bcdf0525bf22703d$export$2c73285ae9390cec = /*#__PURE__*/ (0, $jmnGn$creat
|
|
|
48
50
|
inputElementType: inputElementType,
|
|
49
51
|
label: label,
|
|
50
52
|
validationBehavior: validationBehavior
|
|
51
|
-
},
|
|
53
|
+
}, inputRef);
|
|
52
54
|
// Intercept setting the input ref so we can determine what kind of element we have.
|
|
53
55
|
// useTextField uses this to determine what props to include.
|
|
54
56
|
let inputOrTextAreaRef = (0, $jmnGn$useCallback)((el)=>{
|
|
55
|
-
|
|
57
|
+
inputRef.current = el;
|
|
56
58
|
if (el) setInputElementType(el instanceof HTMLTextAreaElement ? 'textarea' : 'input');
|
|
57
59
|
}, [
|
|
58
|
-
|
|
60
|
+
inputRef
|
|
59
61
|
]);
|
|
60
62
|
let renderProps = (0, $64fa3d84918910a7$export$4d86445c2cf5e3)({
|
|
61
63
|
...props,
|
|
@@ -92,7 +94,7 @@ const $bcdf0525bf22703d$export$2c73285ae9390cec = /*#__PURE__*/ (0, $jmnGn$creat
|
|
|
92
94
|
[
|
|
93
95
|
(0, $3985021b0ad6602f$export$37fb8590cf2c088c),
|
|
94
96
|
{
|
|
95
|
-
...
|
|
97
|
+
...inputProps,
|
|
96
98
|
ref: inputOrTextAreaRef
|
|
97
99
|
}
|
|
98
100
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;AA6CM,MAAM,0DAAmB,CAAA,GAAA,oBAAY,EAAgD;AAKrF,MAAM,4CAAY,WAAW,GAAG,CAAA,GAAA,8BAAsB,EAAE,SAAS,UAAU,KAAqB,EAAE,GAAiC;IACxI,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,EAAC,oBAAoB,sBAAsB,EAAC,GAAG,CAAA,GAAA,yCAAgB,EAAE,CAAA,GAAA,yCAAU,MAAM,CAAC;QAC7D,2BAAA;IAAzB,IAAI,qBAAqB,CAAA,OAAA,CAAA,4BAAA,MAAM,kBAAkB,cAAxB,uCAAA,4BAA4B,oCAA5B,kBAAA,OAAsD;IAC/E,IAAI,WAAW,CAAA,GAAA,aAAK,EAAoB;IACxC,CAAC,OAAO,SAAoB,GAAG,CAAA,GAA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BAAE,KAAK;gBAAQ;aAAE;YAC9C;gBAAC,CAAA,GAAA,yCAAW;gBAAG;oBAAC,GAAG,UAAU;oBAAE,KAAK;gBAAkB;aAAE;YACxD;gBAAC,CAAA,GAAA,yCAAc;gBAAG;oBAAC,GAAG,UAAU;oBAAE,KAAK;gBAAkB;aAAE;YAC3D;gBAAC,CAAA,GAAA,yCAAW;gBAAG;oBAAC,MAAM;oBAAgB,WAAW,WAAW,SAAS;oBAAE,YAAY,MAAM,UAAU,IAAI;gBAAK;aAAE;YAC9G;gBAAC,CAAA,GAAA,yCAAU;gBAAG;oBACZ,OAAO;wBACL,aAAa;wBACb,cAAc;oBAChB;gBACF;aAAE;YACF;gBAAC,CAAA,GAAA,yCAAgB;gBAAG;aAAW;SAChC;OACA,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/TextField.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaTextFieldProps, useTextField} from 'react-aria';\nimport {ContextValue, DOMProps, Provider, RACValidation, removeDataAttributes, RenderProps, SlotProps, useContextProps, useRenderProps, useSlot, useSlottedContext} from './utils';\nimport {createHideableComponent} from '@react-aria/collections';\nimport {FieldErrorContext} from './FieldError';\nimport {FieldInputContext} from './context';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport {GroupContext} from './Group';\nimport {InputContext} from './Input';\nimport {LabelContext} from './Label';\nimport React, {createContext, ForwardedRef, useCallback, useRef, useState} from 'react';\nimport {TextAreaContext} from './TextArea';\nimport {TextContext} from './Text';\n\nexport interface TextFieldRenderProps {\n /**\n * Whether the text field is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean,\n /**\n * Whether the value is invalid.\n * @selector [data-invalid]\n */\n isInvalid: boolean,\n /**\n * Whether the text field is read only.\n * @selector [data-readonly]\n */\n isReadOnly: boolean,\n /**\n * Whether the text field is required.\n * @selector [data-required]\n */\n isRequired: boolean\n}\n\nexport interface TextFieldProps extends Omit<AriaTextFieldProps, 'label' | 'placeholder' | 'description' | 'errorMessage' | 'validationState' | 'validationBehavior'>, RACValidation, Omit<DOMProps, 'style' | 'className' | 'children'>, SlotProps, RenderProps<TextFieldRenderProps>, GlobalDOMAttributes<HTMLDivElement> {\n /** Whether the value is invalid. */\n isInvalid?: boolean\n}\n\nexport const TextFieldContext = createContext<ContextValue<TextFieldProps, HTMLDivElement>>(null);\n\n/**\n * A text field allows a user to enter a plain text value with a keyboard.\n */\nexport const TextField = /*#__PURE__*/ createHideableComponent(function TextField(props: TextFieldProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, TextFieldContext);\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let inputRef = useRef<HTMLInputElement>(null);\n [props, inputRef as unknown] = useContextProps(props, inputRef, FieldInputContext);\n let [labelRef, label] = useSlot(\n !props['aria-label'] && !props['aria-labelledby']\n );\n let [inputElementType, setInputElementType] = useState('input');\n let {labelProps, inputProps, descriptionProps, errorMessageProps, ...validation} = useTextField<any>({\n ...removeDataAttributes(props),\n inputElementType,\n label,\n validationBehavior\n }, inputRef);\n\n // Intercept setting the input ref so we can determine what kind of element we have.\n // useTextField uses this to determine what props to include.\n let inputOrTextAreaRef = useCallback((el) => {\n inputRef.current = el;\n if (el) {\n setInputElementType(el instanceof HTMLTextAreaElement ? 'textarea' : 'input');\n }\n }, [inputRef]);\n\n let renderProps = useRenderProps({\n ...props,\n values: {\n isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid,\n isReadOnly: props.isReadOnly || false,\n isRequired: props.isRequired || false\n },\n defaultClassName: 'react-aria-TextField'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n return (\n <div\n {...DOMProps}\n {...renderProps}\n ref={ref}\n slot={props.slot || undefined}\n data-disabled={props.isDisabled || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-readonly={props.isReadOnly || undefined}\n data-required={props.isRequired || undefined}>\n <Provider\n values={[\n [LabelContext, {...labelProps, ref: labelRef}],\n [InputContext, {...inputProps, ref: inputOrTextAreaRef}],\n [TextAreaContext, {...inputProps, ref: inputOrTextAreaRef}],\n [GroupContext, {role: 'presentation', isInvalid: validation.isInvalid, isDisabled: props.isDisabled || false}],\n [TextContext, {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }],\n [FieldErrorContext, validation]\n ]}>\n {renderProps.children}\n </Provider>\n </div>\n );\n});\n"],"names":[],"version":3,"file":"TextField.module.js.map"}
|