react-aria-components 1.3.4-nightly.5042 → 1.4.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/Breadcrumbs.main.js +4 -3
- package/dist/Breadcrumbs.main.js.map +1 -1
- package/dist/Breadcrumbs.mjs +4 -3
- package/dist/Breadcrumbs.module.js +4 -3
- package/dist/Breadcrumbs.module.js.map +1 -1
- package/dist/Button.main.js +27 -94
- package/dist/Button.main.js.map +1 -1
- package/dist/Button.mjs +31 -98
- package/dist/Button.module.js +31 -98
- package/dist/Button.module.js.map +1 -1
- package/dist/Disclosure.main.js +178 -0
- package/dist/Disclosure.main.js.map +1 -0
- package/dist/Disclosure.mjs +164 -0
- package/dist/Disclosure.module.js +164 -0
- package/dist/Disclosure.module.js.map +1 -0
- package/dist/GridList.main.js +3 -1
- package/dist/GridList.main.js.map +1 -1
- package/dist/GridList.mjs +3 -1
- package/dist/GridList.module.js +3 -1
- package/dist/GridList.module.js.map +1 -1
- package/dist/ListBox.main.js +5 -1
- package/dist/ListBox.main.js.map +1 -1
- package/dist/ListBox.mjs +5 -1
- package/dist/ListBox.module.js +5 -1
- package/dist/ListBox.module.js.map +1 -1
- package/dist/Tree.main.js +6 -2
- package/dist/Tree.main.js.map +1 -1
- package/dist/Tree.mjs +6 -2
- package/dist/Tree.module.js +6 -2
- package/dist/Tree.module.js.map +1 -1
- package/dist/Virtualizer.main.js +56 -38
- package/dist/Virtualizer.main.js.map +1 -1
- package/dist/Virtualizer.mjs +56 -38
- package/dist/Virtualizer.module.js +56 -38
- package/dist/Virtualizer.module.js.map +1 -1
- package/dist/import.mjs +3 -1
- package/dist/main.js +8 -0
- package/dist/main.js.map +1 -1
- package/dist/module.js +3 -1
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +85 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.main.js.map +1 -1
- package/dist/utils.module.js.map +1 -1
- package/package.json +32 -30
- package/src/Breadcrumbs.tsx +4 -3
- package/src/Button.tsx +40 -81
- package/src/Disclosure.tsx +239 -0
- package/src/GridList.tsx +3 -1
- package/src/ListBox.tsx +2 -1
- package/src/Tree.tsx +9 -3
- package/src/Virtualizer.tsx +65 -50
- package/src/index.ts +2 -0
- package/src/utils.tsx +1 -1
- package/LICENSE +0 -201
package/dist/Breadcrumbs.main.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
var $3114c2382242bdc0$exports = require("./Collection.main.js");
|
|
2
2
|
var $c5ccf687772c0422$exports = require("./utils.main.js");
|
|
3
3
|
var $c87397ee936d2bda$exports = require("./Link.main.js");
|
|
4
|
+
var $l7mU3$reactaria = require("react-aria");
|
|
4
5
|
var $l7mU3$reactariacollections = require("@react-aria/collections");
|
|
5
6
|
var $l7mU3$reactariautils = require("@react-aria/utils");
|
|
6
7
|
var $l7mU3$react = require("react");
|
|
@@ -33,19 +34,19 @@ $parcel$export(module.exports, "Breadcrumb", () => $afa44b644f65ed30$export$dabc
|
|
|
33
34
|
|
|
34
35
|
|
|
35
36
|
|
|
37
|
+
|
|
36
38
|
const $afa44b644f65ed30$export$65596d3621b0a4a0 = /*#__PURE__*/ (0, $l7mU3$react.createContext)(null);
|
|
37
39
|
function $afa44b644f65ed30$var$Breadcrumbs(props, ref) {
|
|
38
40
|
[props, ref] = (0, $c5ccf687772c0422$exports.useContextProps)(props, ref, $afa44b644f65ed30$export$65596d3621b0a4a0);
|
|
39
41
|
let { CollectionRoot: CollectionRoot } = (0, $l7mU3$react.useContext)((0, $3114c2382242bdc0$exports.CollectionRendererContext));
|
|
42
|
+
let { navProps: navProps } = (0, $l7mU3$reactaria.useBreadcrumbs)(props);
|
|
40
43
|
return /*#__PURE__*/ (0, ($parcel$interopDefault($l7mU3$react))).createElement((0, $l7mU3$reactariacollections.CollectionBuilder), {
|
|
41
44
|
content: /*#__PURE__*/ (0, ($parcel$interopDefault($l7mU3$react))).createElement((0, $l7mU3$reactariacollections.Collection), props)
|
|
42
45
|
}, (collection)=>/*#__PURE__*/ {
|
|
43
46
|
var _props_className;
|
|
44
47
|
return (0, ($parcel$interopDefault($l7mU3$react))).createElement("ol", {
|
|
45
48
|
ref: ref,
|
|
46
|
-
...
|
|
47
|
-
labelable: true
|
|
48
|
-
}),
|
|
49
|
+
...navProps,
|
|
49
50
|
slot: props.slot || undefined,
|
|
50
51
|
style: props.style,
|
|
51
52
|
className: (_props_className = props.className) !== null && _props_className !== void 0 ? _props_className : 'react-aria-Breadcrumbs'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAkBM,MAAM,0DAAqB,CAAA,GAAA,0BAAY,EAAyD;AAEvG,SAAS,kCAA8B,KAA0B,EAAE,GAAmC;IACpG,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,uBAAS,EAAE,CAAA,GAAA,mDAAwB;IAC1D,IAAI,YAAC,QAAQ,EAAC,GAAG,CAAA,GAAA,+BAAa,EAAE;IAEhC,qBACE,0DAAC,CAAA,GAAA,6CAAgB;QAAE,uBAAS,0DAAC,CAAA,GAAA,sCAAS,GAAM;OACzC,CAAA;YAMc;eALb,0DAAC;YACC,KAAK;YACJ,GAAG,QAAQ;YACZ,MAAM,MAAM,IAAI,IAAI;YACpB,OAAO,MAAM,KAAK;YAClB,WAAW,CAAA,mBAAA,MAAM,SAAS,cAAf,8BAAA,mBAAmB;yBAC9B,0DAAC,0CAAmB,QAAQ;YAAC,OAAO;yBAClC,0DAAC;YAAe,YAAY;;IAE5B;AAIZ;AAEA;;CAEC,GACD,MAAM,2CAA6B,AAAd,WAAW,GAAI,CAAA,GAAA,uBAAS,EAAqB;AAwB3D,MAAM,4CAAa,WAAW,GAAG,CAAA,GAAA,+CAAkB,EAAE,QAAQ,SAAS,WAAW,KAAsB,EAAE,GAAgC,EAAE,IAAmB;IACnK,sGAAsG;IACtG,IAAI,YAAY,KAAK,OAAO,IAAI;IAChC,IAAI,cAAC,UAAU,YAAE,QAAQ,EAAC,GAAG,CAAA,GAAA,2CAAgB,EAAE;IAC/C,IAAI,YAAY;QACd,gBAAgB,YAAY,SAAS;QACrC,YAAY,cAAc;QAC1B,SAAS,IAAM,qBAAA,+BAAA,SAAW,KAAK,GAAG;IACpC;IAEA,IAAI,cAAc,CAAA,GAAA,wCAAa,EAAE;QAC/B,GAAG,KAAK,KAAK;QACb,UAAU,KAAK,QAAQ;QACvB,QAAQ;YAAC,YAAY,cAAc;uBAAW;QAAS;QACvD,kBAAkB;IACpB;IAEA,qBACE,0DAAC;QACE,GAAG,CAAA,GAAA,oCAAa,EAAE,MAAa;QAC/B,GAAG,WAAW;QACf,KAAK;QACL,iBAAe,cAAc,aAAa;QAC1C,gBAAc,aAAa;qBAC3B,0DAAC,CAAA,GAAA,qCAAU,EAAE,QAAQ;QAAC,OAAO;OAC1B,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/Breadcrumbs.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 */\nimport {AriaBreadcrumbsProps, useBreadcrumbs} from 'react-aria';\nimport {Collection, CollectionBuilder, createLeafComponent} from '@react-aria/collections';\nimport {CollectionProps, CollectionRendererContext} from './Collection';\nimport {ContextValue, RenderProps, SlotProps, StyleProps, useContextProps, useRenderProps, useSlottedContext} from './utils';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {forwardRefType, Key} from '@react-types/shared';\nimport {LinkContext} from './Link';\nimport {Node} from 'react-stately';\nimport React, {createContext, ForwardedRef, forwardRef, useContext} from 'react';\n\nexport interface BreadcrumbsProps<T> extends Omit<CollectionProps<T>, 'disabledKeys'>, AriaBreadcrumbsProps, StyleProps, SlotProps {\n /** Whether the breadcrumbs are disabled. */\n isDisabled?: boolean,\n /** Handler that is called when a breadcrumb is clicked. */\n onAction?: (key: Key) => void\n}\n\nexport const BreadcrumbsContext = createContext<ContextValue<BreadcrumbsProps<any>, HTMLOListElement>>(null);\n\nfunction Breadcrumbs<T extends object>(props: BreadcrumbsProps<T>, ref: ForwardedRef<HTMLOListElement>) {\n [props, ref] = useContextProps(props, ref, BreadcrumbsContext);\n let {CollectionRoot} = useContext(CollectionRendererContext);\n let {navProps} = useBreadcrumbs(props);\n\n return (\n <CollectionBuilder content={<Collection {...props} />}>\n {collection => (\n <ol\n ref={ref}\n {...navProps}\n slot={props.slot || undefined}\n style={props.style}\n className={props.className ?? 'react-aria-Breadcrumbs'}>\n <BreadcrumbsContext.Provider value={props}>\n <CollectionRoot collection={collection} />\n </BreadcrumbsContext.Provider>\n </ol>\n )}\n </CollectionBuilder>\n );\n}\n\n/**\n * Breadcrumbs display a hierarchy of links to the current page or resource in an application.\n */\nconst _Breadcrumbs = /*#__PURE__*/ (forwardRef as forwardRefType)(Breadcrumbs);\nexport {_Breadcrumbs as Breadcrumbs};\n\nexport interface BreadcrumbRenderProps {\n /**\n * Whether the breadcrumb is for the current page.\n * @selector [data-current]\n */\n isCurrent: boolean,\n /**\n * Whether the breadcrumb is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean\n}\n\nexport interface BreadcrumbProps extends RenderProps<BreadcrumbRenderProps> {\n /** A unique id for the breadcrumb, which will be passed to `onAction` when the breadcrumb is pressed. */\n id?: Key\n}\n\n/**\n * A Breadcrumb represents an individual item in a `<Breadcrumbs>` list.\n */\nexport const Breadcrumb = /*#__PURE__*/ createLeafComponent('item', function Breadcrumb(props: BreadcrumbProps, ref: ForwardedRef<HTMLLIElement>, node: Node<unknown>) {\n // Recreating useBreadcrumbItem because we want to use composition instead of having the link builtin.\n let isCurrent = node.nextKey == null;\n let {isDisabled, onAction} = useSlottedContext(BreadcrumbsContext)!;\n let linkProps = {\n 'aria-current': isCurrent ? 'page' : null,\n isDisabled: isDisabled || isCurrent,\n onPress: () => onAction?.(node.key)\n };\n\n let renderProps = useRenderProps({\n ...node.props,\n children: node.rendered,\n values: {isDisabled: isDisabled || isCurrent, isCurrent},\n defaultClassName: 'react-aria-Breadcrumb'\n });\n\n return (\n <li\n {...filterDOMProps(props as any)}\n {...renderProps}\n ref={ref}\n data-disabled={isDisabled || isCurrent || undefined}\n data-current={isCurrent || undefined}>\n <LinkContext.Provider value={linkProps}>\n {renderProps.children}\n </LinkContext.Provider>\n </li>\n );\n});\n"],"names":[],"version":3,"file":"Breadcrumbs.main.js.map"}
|
package/dist/Breadcrumbs.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {CollectionRendererContext as $7135fc7d473fd974$export$4feb769f8ddf26c5} from "./Collection.mjs";
|
|
2
2
|
import {useContextProps as $64fa3d84918910a7$export$29f1550f4b0d4415, useRenderProps as $64fa3d84918910a7$export$4d86445c2cf5e3, useSlottedContext as $64fa3d84918910a7$export$fabf2dc03a41866e} from "./utils.mjs";
|
|
3
3
|
import {LinkContext as $4f118338184dc1d9$export$e2509388b49734e7} from "./Link.mjs";
|
|
4
|
+
import {useBreadcrumbs as $c5cc5$useBreadcrumbs} from "react-aria";
|
|
4
5
|
import {CollectionBuilder as $c5cc5$CollectionBuilder, Collection as $c5cc5$Collection, createLeafComponent as $c5cc5$createLeafComponent} from "@react-aria/collections";
|
|
5
6
|
import {filterDOMProps as $c5cc5$filterDOMProps} from "@react-aria/utils";
|
|
6
7
|
import $c5cc5$react, {createContext as $c5cc5$createContext, useContext as $c5cc5$useContext, forwardRef as $c5cc5$forwardRef} from "react";
|
|
@@ -21,19 +22,19 @@ import $c5cc5$react, {createContext as $c5cc5$createContext, useContext as $c5cc
|
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
|
|
25
|
+
|
|
24
26
|
const $778035c5624f61e7$export$65596d3621b0a4a0 = /*#__PURE__*/ (0, $c5cc5$createContext)(null);
|
|
25
27
|
function $778035c5624f61e7$var$Breadcrumbs(props, ref) {
|
|
26
28
|
[props, ref] = (0, $64fa3d84918910a7$export$29f1550f4b0d4415)(props, ref, $778035c5624f61e7$export$65596d3621b0a4a0);
|
|
27
29
|
let { CollectionRoot: CollectionRoot } = (0, $c5cc5$useContext)((0, $7135fc7d473fd974$export$4feb769f8ddf26c5));
|
|
30
|
+
let { navProps: navProps } = (0, $c5cc5$useBreadcrumbs)(props);
|
|
28
31
|
return /*#__PURE__*/ (0, $c5cc5$react).createElement((0, $c5cc5$CollectionBuilder), {
|
|
29
32
|
content: /*#__PURE__*/ (0, $c5cc5$react).createElement((0, $c5cc5$Collection), props)
|
|
30
33
|
}, (collection)=>/*#__PURE__*/ {
|
|
31
34
|
var _props_className;
|
|
32
35
|
return (0, $c5cc5$react).createElement("ol", {
|
|
33
36
|
ref: ref,
|
|
34
|
-
...
|
|
35
|
-
labelable: true
|
|
36
|
-
}),
|
|
37
|
+
...navProps,
|
|
37
38
|
slot: props.slot || undefined,
|
|
38
39
|
style: props.style,
|
|
39
40
|
className: (_props_className = props.className) !== null && _props_className !== void 0 ? _props_className : 'react-aria-Breadcrumbs'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {CollectionRendererContext as $7135fc7d473fd974$export$4feb769f8ddf26c5} from "./Collection.module.js";
|
|
2
2
|
import {useContextProps as $64fa3d84918910a7$export$29f1550f4b0d4415, useRenderProps as $64fa3d84918910a7$export$4d86445c2cf5e3, useSlottedContext as $64fa3d84918910a7$export$fabf2dc03a41866e} from "./utils.module.js";
|
|
3
3
|
import {LinkContext as $4f118338184dc1d9$export$e2509388b49734e7} from "./Link.module.js";
|
|
4
|
+
import {useBreadcrumbs as $c5cc5$useBreadcrumbs} from "react-aria";
|
|
4
5
|
import {CollectionBuilder as $c5cc5$CollectionBuilder, Collection as $c5cc5$Collection, createLeafComponent as $c5cc5$createLeafComponent} from "@react-aria/collections";
|
|
5
6
|
import {filterDOMProps as $c5cc5$filterDOMProps} from "@react-aria/utils";
|
|
6
7
|
import $c5cc5$react, {createContext as $c5cc5$createContext, useContext as $c5cc5$useContext, forwardRef as $c5cc5$forwardRef} from "react";
|
|
@@ -21,19 +22,19 @@ import $c5cc5$react, {createContext as $c5cc5$createContext, useContext as $c5cc
|
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
|
|
25
|
+
|
|
24
26
|
const $778035c5624f61e7$export$65596d3621b0a4a0 = /*#__PURE__*/ (0, $c5cc5$createContext)(null);
|
|
25
27
|
function $778035c5624f61e7$var$Breadcrumbs(props, ref) {
|
|
26
28
|
[props, ref] = (0, $64fa3d84918910a7$export$29f1550f4b0d4415)(props, ref, $778035c5624f61e7$export$65596d3621b0a4a0);
|
|
27
29
|
let { CollectionRoot: CollectionRoot } = (0, $c5cc5$useContext)((0, $7135fc7d473fd974$export$4feb769f8ddf26c5));
|
|
30
|
+
let { navProps: navProps } = (0, $c5cc5$useBreadcrumbs)(props);
|
|
28
31
|
return /*#__PURE__*/ (0, $c5cc5$react).createElement((0, $c5cc5$CollectionBuilder), {
|
|
29
32
|
content: /*#__PURE__*/ (0, $c5cc5$react).createElement((0, $c5cc5$Collection), props)
|
|
30
33
|
}, (collection)=>/*#__PURE__*/ {
|
|
31
34
|
var _props_className;
|
|
32
35
|
return (0, $c5cc5$react).createElement("ol", {
|
|
33
36
|
ref: ref,
|
|
34
|
-
...
|
|
35
|
-
labelable: true
|
|
36
|
-
}),
|
|
37
|
+
...navProps,
|
|
37
38
|
slot: props.slot || undefined,
|
|
38
39
|
style: props.style,
|
|
39
40
|
className: (_props_className = props.className) !== null && _props_className !== void 0 ? _props_className : 'react-aria-Breadcrumbs'
|
|
@@ -1 +1 @@
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,KAAK;QACb,UAAU,KAAK,QAAQ;QACvB,QAAQ;YAAC,YAAY,cAAc;uBAAW;QAAS;QACvD,kBAAkB;IACpB;IAEA,qBACE,gCAAC;QACE,GAAG,CAAA,GAAA,qBAAa,EAAE,MAAa;QAC/B,GAAG,WAAW;QACf,KAAK;QACL,iBAAe,cAAc,aAAa;QAC1C,gBAAc,aAAa;qBAC3B,gCAAC,CAAA,GAAA,yCAAU,EAAE,QAAQ;QAAC,OAAO;OAC1B,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/Breadcrumbs.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 */\nimport {AriaBreadcrumbsProps, useBreadcrumbs} from 'react-aria';\nimport {Collection, CollectionBuilder, createLeafComponent} from '@react-aria/collections';\nimport {CollectionProps, CollectionRendererContext} from './Collection';\nimport {ContextValue, RenderProps, SlotProps, StyleProps, useContextProps, useRenderProps, useSlottedContext} from './utils';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {forwardRefType, Key} from '@react-types/shared';\nimport {LinkContext} from './Link';\nimport {Node} from 'react-stately';\nimport React, {createContext, ForwardedRef, forwardRef, useContext} from 'react';\n\nexport interface BreadcrumbsProps<T> extends Omit<CollectionProps<T>, 'disabledKeys'>, AriaBreadcrumbsProps, StyleProps, SlotProps {\n /** Whether the breadcrumbs are disabled. */\n isDisabled?: boolean,\n /** Handler that is called when a breadcrumb is clicked. */\n onAction?: (key: Key) => void\n}\n\nexport const BreadcrumbsContext = createContext<ContextValue<BreadcrumbsProps<any>, HTMLOListElement>>(null);\n\nfunction Breadcrumbs<T extends object>(props: BreadcrumbsProps<T>, ref: ForwardedRef<HTMLOListElement>) {\n [props, ref] = useContextProps(props, ref, BreadcrumbsContext);\n let {CollectionRoot} = useContext(CollectionRendererContext);\n let {navProps} = useBreadcrumbs(props);\n\n return (\n <CollectionBuilder content={<Collection {...props} />}>\n {collection => (\n <ol\n ref={ref}\n {...navProps}\n slot={props.slot || undefined}\n style={props.style}\n className={props.className ?? 'react-aria-Breadcrumbs'}>\n <BreadcrumbsContext.Provider value={props}>\n <CollectionRoot collection={collection} />\n </BreadcrumbsContext.Provider>\n </ol>\n )}\n </CollectionBuilder>\n );\n}\n\n/**\n * Breadcrumbs display a hierarchy of links to the current page or resource in an application.\n */\nconst _Breadcrumbs = /*#__PURE__*/ (forwardRef as forwardRefType)(Breadcrumbs);\nexport {_Breadcrumbs as Breadcrumbs};\n\nexport interface BreadcrumbRenderProps {\n /**\n * Whether the breadcrumb is for the current page.\n * @selector [data-current]\n */\n isCurrent: boolean,\n /**\n * Whether the breadcrumb is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean\n}\n\nexport interface BreadcrumbProps extends RenderProps<BreadcrumbRenderProps> {\n /** A unique id for the breadcrumb, which will be passed to `onAction` when the breadcrumb is pressed. */\n id?: Key\n}\n\n/**\n * A Breadcrumb represents an individual item in a `<Breadcrumbs>` list.\n */\nexport const Breadcrumb = /*#__PURE__*/ createLeafComponent('item', function Breadcrumb(props: BreadcrumbProps, ref: ForwardedRef<HTMLLIElement>, node: Node<unknown>) {\n // Recreating useBreadcrumbItem because we want to use composition instead of having the link builtin.\n let isCurrent = node.nextKey == null;\n let {isDisabled, onAction} = useSlottedContext(BreadcrumbsContext)!;\n let linkProps = {\n 'aria-current': isCurrent ? 'page' : null,\n isDisabled: isDisabled || isCurrent,\n onPress: () => onAction?.(node.key)\n };\n\n let renderProps = useRenderProps({\n ...node.props,\n children: node.rendered,\n values: {isDisabled: isDisabled || isCurrent, isCurrent},\n defaultClassName: 'react-aria-Breadcrumb'\n });\n\n return (\n <li\n {...filterDOMProps(props as any)}\n {...renderProps}\n ref={ref}\n data-disabled={isDisabled || isCurrent || undefined}\n data-current={isCurrent || undefined}>\n <LinkContext.Provider value={linkProps}>\n {renderProps.children}\n </LinkContext.Provider>\n </li>\n );\n});\n"],"names":[],"version":3,"file":"Breadcrumbs.module.js.map"}
|
package/dist/Button.main.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
var $c5ccf687772c0422$exports = require("./utils.main.js");
|
|
2
2
|
var $0d6436f6a1b0b001$exports = require("./ProgressBar.main.js");
|
|
3
|
-
var $a8a589c28affdc40$exports = require("./Text.main.js");
|
|
4
3
|
var $3vfYa$reactarialiveannouncer = require("@react-aria/live-announcer");
|
|
5
4
|
var $3vfYa$reactaria = require("react-aria");
|
|
6
5
|
var $3vfYa$reactariacollections = require("@react-aria/collections");
|
|
@@ -35,7 +34,6 @@ $parcel$export(module.exports, "Button", () => $b856e6788a7ea5bf$export$353f5b6f
|
|
|
35
34
|
|
|
36
35
|
|
|
37
36
|
|
|
38
|
-
|
|
39
37
|
const $b856e6788a7ea5bf$var$additionalButtonHTMLAttributes = new Set([
|
|
40
38
|
'form',
|
|
41
39
|
'formAction',
|
|
@@ -48,53 +46,50 @@ const $b856e6788a7ea5bf$var$additionalButtonHTMLAttributes = new Set([
|
|
|
48
46
|
]);
|
|
49
47
|
const $b856e6788a7ea5bf$export$24d547caef80ccd1 = /*#__PURE__*/ (0, $3vfYa$react.createContext)({});
|
|
50
48
|
function $b856e6788a7ea5bf$var$Button(props, ref) {
|
|
51
|
-
var _buttonProps_arialabelledby;
|
|
52
49
|
[props, ref] = (0, $c5ccf687772c0422$exports.useContextProps)(props, ref, $b856e6788a7ea5bf$export$24d547caef80ccd1);
|
|
53
50
|
props = $b856e6788a7ea5bf$var$disablePendingProps(props);
|
|
54
51
|
let ctx = props;
|
|
55
52
|
let { isPending: isPending } = ctx;
|
|
56
53
|
let { buttonProps: buttonProps, isPressed: isPressed } = (0, $3vfYa$reactaria.useButton)(props, ref);
|
|
57
54
|
let { focusProps: focusProps, isFocused: isFocused, isFocusVisible: isFocusVisible } = (0, $3vfYa$reactaria.useFocusRing)(props);
|
|
58
|
-
let { hoverProps: hoverProps, isHovered: isHovered } = (0, $3vfYa$reactaria.useHover)(
|
|
55
|
+
let { hoverProps: hoverProps, isHovered: isHovered } = (0, $3vfYa$reactaria.useHover)({
|
|
56
|
+
...props,
|
|
57
|
+
isDisabled: props.isDisabled || isPending
|
|
58
|
+
});
|
|
59
59
|
let renderValues = {
|
|
60
60
|
isHovered: isHovered,
|
|
61
|
-
isPressed: isPressed,
|
|
61
|
+
isPressed: (ctx.isPressed || isPressed) && !isPending,
|
|
62
62
|
isFocused: isFocused,
|
|
63
63
|
isFocusVisible: isFocusVisible,
|
|
64
64
|
isDisabled: props.isDisabled || false,
|
|
65
|
-
isPending: isPending
|
|
65
|
+
isPending: isPending !== null && isPending !== void 0 ? isPending : false
|
|
66
66
|
};
|
|
67
67
|
let renderProps = (0, $c5ccf687772c0422$exports.useRenderProps)({
|
|
68
68
|
...props,
|
|
69
69
|
values: renderValues,
|
|
70
70
|
defaultClassName: 'react-aria-Button'
|
|
71
71
|
});
|
|
72
|
-
// an aria label will block children and their labels from being read, this is undesirable for pending state
|
|
73
|
-
let hasAriaLabel = !!buttonProps['aria-label'] || !!buttonProps['aria-labelledby'];
|
|
74
|
-
let safariDupeLabellingId = (0, $3vfYa$reactaria.useId)();
|
|
75
72
|
let buttonId = (0, $3vfYa$reactaria.useId)(buttonProps.id);
|
|
76
|
-
let contentId = (0, $3vfYa$reactaria.useId)();
|
|
77
73
|
let progressId = (0, $3vfYa$reactaria.useId)();
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
...props,
|
|
86
|
-
ref: ref
|
|
87
|
-
});
|
|
88
|
-
// Forcibly announce the pending state on Apple devices because otherwise it won't be announced
|
|
74
|
+
let ariaLabelledby = buttonProps['aria-labelledby'];
|
|
75
|
+
if (isPending) {
|
|
76
|
+
// aria-labelledby wins over aria-label
|
|
77
|
+
// https://www.w3.org/TR/accname-1.2/#computation-steps
|
|
78
|
+
if (ariaLabelledby) ariaLabelledby = `${ariaLabelledby} ${progressId}`;
|
|
79
|
+
else if (buttonProps['aria-label']) ariaLabelledby = `${buttonId} ${progressId}`;
|
|
80
|
+
}
|
|
89
81
|
let wasPending = (0, $3vfYa$react.useRef)(isPending);
|
|
90
82
|
(0, $3vfYa$react.useEffect)(()=>{
|
|
91
|
-
|
|
92
|
-
|
|
83
|
+
let message = {
|
|
84
|
+
'aria-labelledby': ariaLabelledby || buttonId
|
|
85
|
+
};
|
|
86
|
+
if (!wasPending.current && isFocused && isPending) (0, $3vfYa$reactarialiveannouncer.announce)(message, 'assertive');
|
|
87
|
+
else if (wasPending.current && isFocused && !isPending) (0, $3vfYa$reactarialiveannouncer.announce)(message, 'assertive');
|
|
93
88
|
wasPending.current = isPending;
|
|
94
89
|
}, [
|
|
95
90
|
isPending,
|
|
96
91
|
isFocused,
|
|
97
|
-
|
|
92
|
+
ariaLabelledby,
|
|
98
93
|
buttonId
|
|
99
94
|
]);
|
|
100
95
|
return /*#__PURE__*/ (0, ($parcel$interopDefault($3vfYa$react))).createElement("button", {
|
|
@@ -105,82 +100,20 @@ function $b856e6788a7ea5bf$var$Button(props, ref) {
|
|
|
105
100
|
...renderProps,
|
|
106
101
|
id: buttonId,
|
|
107
102
|
ref: ref,
|
|
108
|
-
"aria-
|
|
109
|
-
"aria-labelledby": isPending ? isPendingAriaLiveLabelledby : buttonProps['aria-labelledby'],
|
|
103
|
+
"aria-labelledby": ariaLabelledby,
|
|
110
104
|
slot: props.slot || undefined,
|
|
111
|
-
"aria-disabled": isPending ? 'true' :
|
|
105
|
+
"aria-disabled": isPending ? 'true' : buttonProps['aria-disabled'],
|
|
112
106
|
"data-disabled": props.isDisabled || undefined,
|
|
113
|
-
"data-pressed":
|
|
107
|
+
"data-pressed": renderValues.isPressed || undefined,
|
|
114
108
|
"data-hovered": isHovered || undefined,
|
|
115
109
|
"data-focused": isFocused || undefined,
|
|
116
110
|
"data-pending": isPending || undefined,
|
|
117
111
|
"data-focus-visible": isFocusVisible || undefined
|
|
118
|
-
}, /*#__PURE__*/ (0, ($parcel$interopDefault($3vfYa$react))).createElement((0, $
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
id: contentId,
|
|
124
|
-
ref: textCallbackRef
|
|
125
|
-
}
|
|
126
|
-
],
|
|
127
|
-
[
|
|
128
|
-
(0, $0d6436f6a1b0b001$exports.ProgressBarContext),
|
|
129
|
-
{
|
|
130
|
-
id: progressId,
|
|
131
|
-
style: {
|
|
132
|
-
display: isPending ? undefined : 'none'
|
|
133
|
-
},
|
|
134
|
-
isIndeterminate: true,
|
|
135
|
-
ref: progressCallbackRef
|
|
136
|
-
}
|
|
137
|
-
]
|
|
138
|
-
]
|
|
139
|
-
}, renderProps.children), /*#__PURE__*/ (0, ($parcel$interopDefault($3vfYa$react))).createElement((0, $3vfYa$reactaria.VisuallyHidden), null, /*#__PURE__*/ (0, ($parcel$interopDefault($3vfYa$react))).createElement("div", {
|
|
140
|
-
"aria-live": isFocused ? ariaLive : 'off'
|
|
141
|
-
}, isPending && /*#__PURE__*/ (0, ($parcel$interopDefault($3vfYa$react))).createElement("div", {
|
|
142
|
-
role: "img",
|
|
143
|
-
"aria-labelledby": isPendingAriaLiveLabelledby
|
|
144
|
-
})), /*#__PURE__*/ (0, ($parcel$interopDefault($3vfYa$react))).createElement("div", {
|
|
145
|
-
id: safariDupeLabellingId,
|
|
146
|
-
role: "img",
|
|
147
|
-
"aria-label": isPending ? isPendingAriaLiveLabel : undefined
|
|
148
|
-
})));
|
|
149
|
-
}
|
|
150
|
-
function $b856e6788a7ea5bf$var$useEnforcePendingComponents(props) {
|
|
151
|
-
let { isPending: isPending, ref: ref } = props;
|
|
152
|
-
let textRef = (0, $3vfYa$react.useRef)(null);
|
|
153
|
-
let progressRef = (0, $3vfYa$react.useRef)(null);
|
|
154
|
-
let textCallbackRef = (0, $3vfYa$react.useCallback)((node)=>{
|
|
155
|
-
textRef.current = node;
|
|
156
|
-
// use a microtask so the unmounting has time to complete before we throw an error
|
|
157
|
-
queueMicrotask(()=>{
|
|
158
|
-
if (!textRef.current && ref.current && isPending) throw new Error('Expected <Text> to be used with pending button');
|
|
159
|
-
});
|
|
160
|
-
}, [
|
|
161
|
-
isPending,
|
|
162
|
-
ref
|
|
163
|
-
]);
|
|
164
|
-
let progressCallbackRef = (0, $3vfYa$react.useCallback)((node)=>{
|
|
165
|
-
progressRef.current = node;
|
|
166
|
-
queueMicrotask(()=>{
|
|
167
|
-
if (!progressRef.current && ref.current && isPending) throw new Error('Expected <ProgressBar> to be used with pending button');
|
|
168
|
-
});
|
|
169
|
-
}, [
|
|
170
|
-
isPending,
|
|
171
|
-
ref
|
|
172
|
-
]);
|
|
173
|
-
(0, $3vfYa$react.useEffect)(()=>{
|
|
174
|
-
if (isPending && (!textRef.current || !progressRef.current)) throw new Error('Expected <Text> and <ProgressBar> to be used with pending button');
|
|
175
|
-
}, [
|
|
176
|
-
isPending,
|
|
177
|
-
textRef,
|
|
178
|
-
progressRef
|
|
179
|
-
]);
|
|
180
|
-
return {
|
|
181
|
-
textCallbackRef: textCallbackRef,
|
|
182
|
-
progressCallbackRef: progressCallbackRef
|
|
183
|
-
};
|
|
112
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($3vfYa$react))).createElement((0, $0d6436f6a1b0b001$exports.ProgressBarContext).Provider, {
|
|
113
|
+
value: {
|
|
114
|
+
id: progressId
|
|
115
|
+
}
|
|
116
|
+
}, renderProps.children));
|
|
184
117
|
}
|
|
185
118
|
function $b856e6788a7ea5bf$var$disablePendingProps(props) {
|
|
186
119
|
// Don't allow interaction while isPending is true
|
package/dist/Button.main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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D,GACvD,MAAM,IAAI,MAAM;IAEpB,GAAG;QAAC;QAAW;QAAS;KAAY;IACpC,OAAO;yBAAC;6BAAiB;IAAmB;AAC9C;AAEA,SAAS,0CAAoB,KAAK;IAChC,kDAAkD;IAClD,IAAI,MAAM,SAAS,EAAE;QACnB,MAAM,OAAO,GAAG;QAChB,MAAM,YAAY,GAAG;QACrB,MAAM,UAAU,GAAG;QACnB,MAAM,aAAa,GAAG;QACtB,MAAM,SAAS,GAAG;QAClB,MAAM,SAAS,GAAG;QAClB,MAAM,OAAO,GAAG;QAChB,MAAM,OAAO,GAAG;QAChB,MAAM,IAAI,GAAG;IACf;IACA,OAAO;AACT;AAEA;;CAEC,GACD,MAAM,4CAAU,WAAW,GAAG,CAAA,GAAA,mDAAsB,EAAE","sources":["packages/react-aria-components/src/Button.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 {announce} from '@react-aria/live-announcer';\nimport {\n AriaButtonProps,\n HoverEvents,\n mergeProps,\n useButton,\n useFocusRing,\n useHover,\n useId,\n VisuallyHidden\n} from 'react-aria';\nimport {\n ContextValue,\n Provider,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps\n} from './utils';\nimport {createHideableComponent} from '@react-aria/collections';\nimport {filterDOMProps, isAppleDevice, isFirefox} from '@react-aria/utils';\nimport {ProgressBarContext} from './ProgressBar';\nimport React, {createContext, ForwardedRef, useCallback, useEffect, useRef} from 'react';\nimport {TextContext} from './Text';\n\nexport interface ButtonRenderProps {\n /**\n * Whether the button is currently hovered with a mouse.\n * @selector [data-hovered]\n */\n isHovered: boolean,\n /**\n * Whether the button is currently in a pressed state.\n * @selector [data-pressed]\n */\n isPressed: boolean,\n /**\n * Whether the button is focused, either via a mouse or keyboard.\n * @selector [data-focused]\n */\n isFocused: boolean,\n /**\n * Whether the button is keyboard focused.\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean,\n /**\n * Whether the button is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean,\n /**\n * If the button is currently in the `isPending` state.\n * @selector [data-pending]\n */\n isPending?: boolean\n}\n\nexport interface ButtonProps extends Omit<AriaButtonProps, 'children' | 'href' | 'target' | 'rel' | 'elementType'>, HoverEvents, SlotProps, RenderProps<ButtonRenderProps> {\n /**\n * The `<form>` element to associate the button with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n */\n form?: string,\n /**\n * The URL that processes the information submitted by the button.\n * Overrides the action attribute of the button's form owner.\n */\n formAction?: string,\n /** Indicates how to encode the form data that is submitted. */\n formEncType?: string,\n /** Indicates the HTTP method used to submit the form. */\n formMethod?: string,\n /** Indicates that the form is not to be validated when it is submitted. */\n formNoValidate?: boolean,\n /** Overrides the target attribute of the button's form owner. */\n formTarget?: string,\n /** Submitted as a pair with the button's value as part of the form data. */\n name?: string,\n /** The value associated with the button's name when it's submitted with the form data. */\n value?: string,\n /**\n * Whether to disable events immediately and display the `ProgressBar`.\n */\n isPending?: boolean\n}\n\ninterface ButtonContextValue extends ButtonProps {\n isPressed?: boolean\n}\n\nconst additionalButtonHTMLAttributes = new Set(['form', 'formAction', 'formEncType', 'formMethod', 'formNoValidate', 'formTarget', 'name', 'value']);\n\nexport const ButtonContext = createContext<ContextValue<ButtonContextValue, HTMLButtonElement>>({});\n\nfunction Button(props: ButtonProps, ref: ForwardedRef<HTMLButtonElement>) {\n [props, ref] = useContextProps(props, ref, ButtonContext);\n props = disablePendingProps(props);\n let ctx = props as ButtonContextValue;\n let {isPending} = ctx;\n let {buttonProps, isPressed} = useButton(props, ref);\n let {focusProps, isFocused, isFocusVisible} = useFocusRing(props);\n let {hoverProps, isHovered} = useHover(props);\n let renderValues = {isHovered, isPressed, isFocused, isFocusVisible, isDisabled: props.isDisabled || false, isPending};\n let renderProps = useRenderProps({\n ...props,\n values: renderValues,\n defaultClassName: 'react-aria-Button'\n });\n\n // an aria label will block children and their labels from being read, this is undesirable for pending state\n let hasAriaLabel = !!buttonProps['aria-label'] || !!buttonProps['aria-labelledby'];\n let safariDupeLabellingId = useId();\n let buttonId = useId(buttonProps.id);\n let contentId = useId();\n let progressId = useId();\n\n const isPendingAriaLiveLabel = `${hasAriaLabel ? buttonProps['aria-label'] : ''}`.trim();\n let isPendingAriaLiveLabelledby = hasAriaLabel ? (buttonProps['aria-labelledby']?.replace(buttonId, safariDupeLabellingId) ?? safariDupeLabellingId) : `${contentId} ${safariDupeLabellingId}`.trim();\n isPendingAriaLiveLabelledby = isPendingAriaLiveLabelledby + ' ' + progressId;\n\n let ariaLive: 'off' | 'polite' | 'assertive' = 'polite';\n if (isAppleDevice() && (!hasAriaLabel || isFirefox())) {\n ariaLive = 'off';\n }\n\n let {textCallbackRef, progressCallbackRef} = useEnforcePendingComponents({...props, ref});\n\n // Forcibly announce the pending state on Apple devices because otherwise it won't be announced\n let wasPending = useRef(isPending);\n useEffect(() => {\n if (!wasPending.current && isFocused && isPending && isAppleDevice()) {\n announce(isPendingAriaLiveLabelledby, 'assertive', undefined, 'ids');\n } else if (wasPending.current && isFocused && !isPending && isAppleDevice()) {\n announce(buttonId, 'assertive', undefined, 'ids');\n }\n wasPending.current = isPending;\n }, [isPending, isFocused, isPendingAriaLiveLabelledby, buttonId]);\n\n return (\n <button\n {...filterDOMProps(props, {propNames: additionalButtonHTMLAttributes})}\n {...mergeProps(buttonProps, focusProps, hoverProps)}\n {...renderProps}\n id={buttonId}\n ref={ref}\n aria-label={isPending ? isPendingAriaLiveLabel : buttonProps['aria-label']}\n aria-labelledby={isPending ? isPendingAriaLiveLabelledby : buttonProps['aria-labelledby']}\n slot={props.slot || undefined}\n aria-disabled={isPending ? 'true' : undefined}\n data-disabled={props.isDisabled || undefined}\n data-pressed={ctx.isPressed || isPressed || undefined}\n data-hovered={isHovered || undefined}\n data-focused={isFocused || undefined}\n data-pending={isPending || undefined}\n data-focus-visible={isFocusVisible || undefined}>\n <Provider\n values={[\n [TextContext, {id: contentId, ref: textCallbackRef}],\n [ProgressBarContext, {id: progressId, style: {display: isPending ? undefined : 'none'}, isIndeterminate: true, ref: progressCallbackRef}]\n ]}>\n {renderProps.children}\n </Provider>\n <VisuallyHidden>\n <div aria-live={isFocused ? ariaLive : 'off'}>\n {isPending &&\n <div role=\"img\" aria-labelledby={isPendingAriaLiveLabelledby} />\n }\n </div>\n {/* Adding the element here with the same labels as the button itself causes aria-live to pick up the change in Safari.\n Safari with VO unfortunately doesn't announce changes to *all* of its labels specifically for button\n https://a11ysupport.io/tests/tech__html__button-name-change#assertion-aria-aria-label_attribute-convey_name_change-html-button_element-vo_macos-safari\n The aria-live may cause extra announcements in other browsers. */}\n <div id={safariDupeLabellingId} role=\"img\" aria-label={isPending ? isPendingAriaLiveLabel : undefined} />\n </VisuallyHidden>\n </button>\n );\n}\n\nfunction useEnforcePendingComponents(props) {\n let {isPending, ref} = props;\n let textRef = useRef(null);\n let progressRef = useRef(null);\n let textCallbackRef = useCallback(node => {\n textRef.current = node;\n // use a microtask so the unmounting has time to complete before we throw an error\n queueMicrotask(() => {\n if (!textRef.current && ref.current && isPending) {\n throw new Error('Expected <Text> to be used with pending button');\n }\n });\n }, [isPending, ref]);\n let progressCallbackRef = useCallback(node => {\n progressRef.current = node;\n queueMicrotask(() => {\n if (!progressRef.current && ref.current && isPending) {\n throw new Error('Expected <ProgressBar> to be used with pending button');\n }\n });\n }, [isPending, ref]);\n useEffect(() => {\n if (isPending && (!textRef.current || !progressRef.current)) {\n throw new Error('Expected <Text> and <ProgressBar> to be used with pending button');\n }\n }, [isPending, textRef, progressRef]);\n return {textCallbackRef, progressCallbackRef};\n}\n\nfunction disablePendingProps(props) {\n // Don't allow interaction while isPending is true\n if (props.isPending) {\n props.onPress = undefined;\n props.onPressStart = undefined;\n props.onPressEnd = undefined;\n props.onPressChange = undefined;\n props.onPressUp = undefined;\n props.onKeyDown = undefined;\n props.onKeyUp = undefined;\n props.onClick = undefined;\n props.href = undefined;\n }\n return props;\n}\n\n/**\n * A button allows a user to perform an action, with mouse, touch, and keyboard interactions.\n */\nconst _Button = /*#__PURE__*/ createHideableComponent(Button);\nexport {_Button as Button};\n"],"names":[],"version":3,"file":"Button.main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AA2FD,MAAM,uDAAiC,IAAI,IAAI;IAAC;IAAQ;IAAc;IAAe;IAAc;IAAkB;IAAc;IAAQ;CAAQ;AAE5I,MAAM,0DAAgB,CAAA,GAAA,0BAAY,EAAuD,CAAC;AAEjG,SAAS,6BAAO,KAAkB,EAAE,GAAoC;IACtE,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,QAAQ,0CAAoB;IAC5B,IAAI,MAAM;IACV,IAAI,aAAC,SAAS,EAAC,GAAG;IAClB,IAAI,eAAC,WAAW,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,0BAAQ,EAAE,OAAO;IAChD,IAAI,cAAC,UAAU,aAAE,SAAS,kBAAE,cAAc,EAAC,GAAG,CAAA,GAAA,6BAAW,EAAE;IAC3D,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,yBAAO,EAAE;QACrC,GAAG,KAAK;QACR,YAAY,MAAM,UAAU,IAAI;IAClC;IACA,IAAI,eAAe;mBACjB;QACA,WAAW,AAAC,CAAA,IAAI,SAAS,IAAI,SAAQ,KAAM,CAAC;mBAC5C;wBACA;QACA,YAAY,MAAM,UAAU,IAAI;QAChC,WAAW,sBAAA,uBAAA,YAAa;IAC1B;IAEA,IAAI,cAAc,CAAA,GAAA,wCAAa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YAAC,IAAI;QAAU;OAChD,YAAY,QAAQ;AAI7B;AAEA,SAAS,0CAAoB,KAAK;IAChC,kDAAkD;IAClD,IAAI,MAAM,SAAS,EAAE;QACnB,MAAM,OAAO,GAAG;QAChB,MAAM,YAAY,GAAG;QACrB,MAAM,UAAU,GAAG;QACnB,MAAM,aAAa,GAAG;QACtB,MAAM,SAAS,GAAG;QAClB,MAAM,SAAS,GAAG;QAClB,MAAM,OAAO,GAAG;QAChB,MAAM,OAAO,GAAG;QAChB,MAAM,IAAI,GAAG;IACf;IACA,OAAO;AACT;AAEA;;CAEC,GACD,MAAM,4CAAU,WAAW,GAAG,CAAA,GAAA,mDAAsB,EAAE","sources":["packages/react-aria-components/src/Button.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 {announce} from '@react-aria/live-announcer';\nimport {\n AriaButtonProps,\n HoverEvents,\n mergeProps,\n useButton,\n useFocusRing,\n useHover,\n useId\n} from 'react-aria';\nimport {\n ContextValue,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps\n} from './utils';\nimport {createHideableComponent} from '@react-aria/collections';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {ProgressBarContext} from './ProgressBar';\nimport React, {createContext, ForwardedRef, useEffect, useRef} from 'react';\n\nexport interface ButtonRenderProps {\n /**\n * Whether the button is currently hovered with a mouse.\n * @selector [data-hovered]\n */\n isHovered: boolean,\n /**\n * Whether the button is currently in a pressed state.\n * @selector [data-pressed]\n */\n isPressed: boolean,\n /**\n * Whether the button is focused, either via a mouse or keyboard.\n * @selector [data-focused]\n */\n isFocused: boolean,\n /**\n * Whether the button is keyboard focused.\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean,\n /**\n * Whether the button is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean,\n /**\n * Whether the button is currently in a pending state.\n * @selector [data-pending]\n */\n isPending: boolean\n}\n\nexport interface ButtonProps extends Omit<AriaButtonProps, 'children' | 'href' | 'target' | 'rel' | 'elementType'>, HoverEvents, SlotProps, RenderProps<ButtonRenderProps> {\n /**\n * The `<form>` element to associate the button with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n */\n form?: string,\n /**\n * The URL that processes the information submitted by the button.\n * Overrides the action attribute of the button's form owner.\n */\n formAction?: string,\n /** Indicates how to encode the form data that is submitted. */\n formEncType?: string,\n /** Indicates the HTTP method used to submit the form. */\n formMethod?: string,\n /** Indicates that the form is not to be validated when it is submitted. */\n formNoValidate?: boolean,\n /** Overrides the target attribute of the button's form owner. */\n formTarget?: string,\n /** Submitted as a pair with the button's value as part of the form data. */\n name?: string,\n /** The value associated with the button's name when it's submitted with the form data. */\n value?: string,\n /**\n * Whether the button is in a pending state. This disables press and hover events\n * while retaining focusability, and announces the pending state to screen readers.\n */\n isPending?: boolean\n}\n\ninterface ButtonContextValue extends ButtonProps {\n isPressed?: boolean\n}\n\nconst additionalButtonHTMLAttributes = new Set(['form', 'formAction', 'formEncType', 'formMethod', 'formNoValidate', 'formTarget', 'name', 'value']);\n\nexport const ButtonContext = createContext<ContextValue<ButtonContextValue, HTMLButtonElement>>({});\n\nfunction Button(props: ButtonProps, ref: ForwardedRef<HTMLButtonElement>) {\n [props, ref] = useContextProps(props, ref, ButtonContext);\n props = disablePendingProps(props);\n let ctx = props as ButtonContextValue;\n let {isPending} = ctx;\n let {buttonProps, isPressed} = useButton(props, ref);\n let {focusProps, isFocused, isFocusVisible} = useFocusRing(props);\n let {hoverProps, isHovered} = useHover({\n ...props,\n isDisabled: props.isDisabled || isPending\n });\n let renderValues = {\n isHovered,\n isPressed: (ctx.isPressed || isPressed) && !isPending,\n isFocused,\n isFocusVisible,\n isDisabled: props.isDisabled || false,\n isPending: isPending ?? false\n };\n\n let renderProps = useRenderProps({\n ...props,\n values: renderValues,\n defaultClassName: 'react-aria-Button'\n });\n\n let buttonId = useId(buttonProps.id);\n let progressId = useId();\n\n let ariaLabelledby = buttonProps['aria-labelledby'];\n if (isPending) {\n // aria-labelledby wins over aria-label\n // https://www.w3.org/TR/accname-1.2/#computation-steps\n if (ariaLabelledby) {\n ariaLabelledby = `${ariaLabelledby} ${progressId}`;\n } else if (buttonProps['aria-label']) {\n ariaLabelledby = `${buttonId} ${progressId}`;\n }\n }\n\n let wasPending = useRef(isPending);\n useEffect(() => {\n let message = {'aria-labelledby': ariaLabelledby || buttonId};\n if (!wasPending.current && isFocused && isPending) {\n announce(message, 'assertive');\n } else if (wasPending.current && isFocused && !isPending) {\n announce(message, 'assertive');\n }\n wasPending.current = isPending;\n }, [isPending, isFocused, ariaLabelledby, buttonId]);\n\n return (\n <button\n {...filterDOMProps(props, {propNames: additionalButtonHTMLAttributes})}\n {...mergeProps(buttonProps, focusProps, hoverProps)}\n {...renderProps}\n id={buttonId}\n ref={ref}\n aria-labelledby={ariaLabelledby}\n slot={props.slot || undefined}\n aria-disabled={isPending ? 'true' : buttonProps['aria-disabled']}\n data-disabled={props.isDisabled || undefined}\n data-pressed={renderValues.isPressed || undefined}\n data-hovered={isHovered || undefined}\n data-focused={isFocused || undefined}\n data-pending={isPending || undefined}\n data-focus-visible={isFocusVisible || undefined}>\n <ProgressBarContext.Provider value={{id: progressId}}>\n {renderProps.children}\n </ProgressBarContext.Provider>\n </button>\n );\n}\n\nfunction disablePendingProps(props) {\n // Don't allow interaction while isPending is true\n if (props.isPending) {\n props.onPress = undefined;\n props.onPressStart = undefined;\n props.onPressEnd = undefined;\n props.onPressChange = undefined;\n props.onPressUp = undefined;\n props.onKeyDown = undefined;\n props.onKeyUp = undefined;\n props.onClick = undefined;\n props.href = undefined;\n }\n return props;\n}\n\n/**\n * A button allows a user to perform an action, with mouse, touch, and keyboard interactions.\n */\nconst _Button = /*#__PURE__*/ createHideableComponent(Button);\nexport {_Button as Button};\n"],"names":[],"version":3,"file":"Button.main.js.map"}
|
package/dist/Button.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {useContextProps as $64fa3d84918910a7$export$29f1550f4b0d4415, useRenderProps as $64fa3d84918910a7$export$4d86445c2cf5e3} from "./utils.mjs";
|
|
2
2
|
import {ProgressBarContext as $0393f8ab869a0f1a$export$e9f3bf65a26ce129} from "./ProgressBar.mjs";
|
|
3
|
-
import {TextContext as $514c0188e459b4c0$export$9afb8bc826b033ea} from "./Text.mjs";
|
|
4
3
|
import {announce as $fM325$announce} from "@react-aria/live-announcer";
|
|
5
|
-
import {useButton as $fM325$useButton, useFocusRing as $fM325$useFocusRing, useHover as $fM325$useHover, useId as $fM325$useId, mergeProps as $fM325$mergeProps
|
|
4
|
+
import {useButton as $fM325$useButton, useFocusRing as $fM325$useFocusRing, useHover as $fM325$useHover, useId as $fM325$useId, mergeProps as $fM325$mergeProps} from "react-aria";
|
|
6
5
|
import {createHideableComponent as $fM325$createHideableComponent} from "@react-aria/collections";
|
|
7
|
-
import {
|
|
8
|
-
import $fM325$react, {createContext as $fM325$createContext, useRef as $fM325$useRef, useEffect as $fM325$useEffect
|
|
6
|
+
import {filterDOMProps as $fM325$filterDOMProps} from "@react-aria/utils";
|
|
7
|
+
import $fM325$react, {createContext as $fM325$createContext, useRef as $fM325$useRef, useEffect as $fM325$useEffect} from "react";
|
|
9
8
|
|
|
10
9
|
/*
|
|
11
10
|
* Copyright 2022 Adobe. All rights reserved.
|
|
@@ -24,7 +23,6 @@ import $fM325$react, {createContext as $fM325$createContext, useRef as $fM325$us
|
|
|
24
23
|
|
|
25
24
|
|
|
26
25
|
|
|
27
|
-
|
|
28
26
|
const $d2b4bc8c273e7be6$var$additionalButtonHTMLAttributes = new Set([
|
|
29
27
|
'form',
|
|
30
28
|
'formAction',
|
|
@@ -37,53 +35,50 @@ const $d2b4bc8c273e7be6$var$additionalButtonHTMLAttributes = new Set([
|
|
|
37
35
|
]);
|
|
38
36
|
const $d2b4bc8c273e7be6$export$24d547caef80ccd1 = /*#__PURE__*/ (0, $fM325$createContext)({});
|
|
39
37
|
function $d2b4bc8c273e7be6$var$Button(props, ref) {
|
|
40
|
-
var _buttonProps_arialabelledby;
|
|
41
38
|
[props, ref] = (0, $64fa3d84918910a7$export$29f1550f4b0d4415)(props, ref, $d2b4bc8c273e7be6$export$24d547caef80ccd1);
|
|
42
39
|
props = $d2b4bc8c273e7be6$var$disablePendingProps(props);
|
|
43
40
|
let ctx = props;
|
|
44
41
|
let { isPending: isPending } = ctx;
|
|
45
42
|
let { buttonProps: buttonProps, isPressed: isPressed } = (0, $fM325$useButton)(props, ref);
|
|
46
43
|
let { focusProps: focusProps, isFocused: isFocused, isFocusVisible: isFocusVisible } = (0, $fM325$useFocusRing)(props);
|
|
47
|
-
let { hoverProps: hoverProps, isHovered: isHovered } = (0, $fM325$useHover)(
|
|
44
|
+
let { hoverProps: hoverProps, isHovered: isHovered } = (0, $fM325$useHover)({
|
|
45
|
+
...props,
|
|
46
|
+
isDisabled: props.isDisabled || isPending
|
|
47
|
+
});
|
|
48
48
|
let renderValues = {
|
|
49
49
|
isHovered: isHovered,
|
|
50
|
-
isPressed: isPressed,
|
|
50
|
+
isPressed: (ctx.isPressed || isPressed) && !isPending,
|
|
51
51
|
isFocused: isFocused,
|
|
52
52
|
isFocusVisible: isFocusVisible,
|
|
53
53
|
isDisabled: props.isDisabled || false,
|
|
54
|
-
isPending: isPending
|
|
54
|
+
isPending: isPending !== null && isPending !== void 0 ? isPending : false
|
|
55
55
|
};
|
|
56
56
|
let renderProps = (0, $64fa3d84918910a7$export$4d86445c2cf5e3)({
|
|
57
57
|
...props,
|
|
58
58
|
values: renderValues,
|
|
59
59
|
defaultClassName: 'react-aria-Button'
|
|
60
60
|
});
|
|
61
|
-
// an aria label will block children and their labels from being read, this is undesirable for pending state
|
|
62
|
-
let hasAriaLabel = !!buttonProps['aria-label'] || !!buttonProps['aria-labelledby'];
|
|
63
|
-
let safariDupeLabellingId = (0, $fM325$useId)();
|
|
64
61
|
let buttonId = (0, $fM325$useId)(buttonProps.id);
|
|
65
|
-
let contentId = (0, $fM325$useId)();
|
|
66
62
|
let progressId = (0, $fM325$useId)();
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
...props,
|
|
75
|
-
ref: ref
|
|
76
|
-
});
|
|
77
|
-
// Forcibly announce the pending state on Apple devices because otherwise it won't be announced
|
|
63
|
+
let ariaLabelledby = buttonProps['aria-labelledby'];
|
|
64
|
+
if (isPending) {
|
|
65
|
+
// aria-labelledby wins over aria-label
|
|
66
|
+
// https://www.w3.org/TR/accname-1.2/#computation-steps
|
|
67
|
+
if (ariaLabelledby) ariaLabelledby = `${ariaLabelledby} ${progressId}`;
|
|
68
|
+
else if (buttonProps['aria-label']) ariaLabelledby = `${buttonId} ${progressId}`;
|
|
69
|
+
}
|
|
78
70
|
let wasPending = (0, $fM325$useRef)(isPending);
|
|
79
71
|
(0, $fM325$useEffect)(()=>{
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
let message = {
|
|
73
|
+
'aria-labelledby': ariaLabelledby || buttonId
|
|
74
|
+
};
|
|
75
|
+
if (!wasPending.current && isFocused && isPending) (0, $fM325$announce)(message, 'assertive');
|
|
76
|
+
else if (wasPending.current && isFocused && !isPending) (0, $fM325$announce)(message, 'assertive');
|
|
82
77
|
wasPending.current = isPending;
|
|
83
78
|
}, [
|
|
84
79
|
isPending,
|
|
85
80
|
isFocused,
|
|
86
|
-
|
|
81
|
+
ariaLabelledby,
|
|
87
82
|
buttonId
|
|
88
83
|
]);
|
|
89
84
|
return /*#__PURE__*/ (0, $fM325$react).createElement("button", {
|
|
@@ -94,82 +89,20 @@ function $d2b4bc8c273e7be6$var$Button(props, ref) {
|
|
|
94
89
|
...renderProps,
|
|
95
90
|
id: buttonId,
|
|
96
91
|
ref: ref,
|
|
97
|
-
"aria-
|
|
98
|
-
"aria-labelledby": isPending ? isPendingAriaLiveLabelledby : buttonProps['aria-labelledby'],
|
|
92
|
+
"aria-labelledby": ariaLabelledby,
|
|
99
93
|
slot: props.slot || undefined,
|
|
100
|
-
"aria-disabled": isPending ? 'true' :
|
|
94
|
+
"aria-disabled": isPending ? 'true' : buttonProps['aria-disabled'],
|
|
101
95
|
"data-disabled": props.isDisabled || undefined,
|
|
102
|
-
"data-pressed":
|
|
96
|
+
"data-pressed": renderValues.isPressed || undefined,
|
|
103
97
|
"data-hovered": isHovered || undefined,
|
|
104
98
|
"data-focused": isFocused || undefined,
|
|
105
99
|
"data-pending": isPending || undefined,
|
|
106
100
|
"data-focus-visible": isFocusVisible || undefined
|
|
107
|
-
}, /*#__PURE__*/ (0, $fM325$react).createElement((0, $
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
id: contentId,
|
|
113
|
-
ref: textCallbackRef
|
|
114
|
-
}
|
|
115
|
-
],
|
|
116
|
-
[
|
|
117
|
-
(0, $0393f8ab869a0f1a$export$e9f3bf65a26ce129),
|
|
118
|
-
{
|
|
119
|
-
id: progressId,
|
|
120
|
-
style: {
|
|
121
|
-
display: isPending ? undefined : 'none'
|
|
122
|
-
},
|
|
123
|
-
isIndeterminate: true,
|
|
124
|
-
ref: progressCallbackRef
|
|
125
|
-
}
|
|
126
|
-
]
|
|
127
|
-
]
|
|
128
|
-
}, renderProps.children), /*#__PURE__*/ (0, $fM325$react).createElement((0, $fM325$VisuallyHidden), null, /*#__PURE__*/ (0, $fM325$react).createElement("div", {
|
|
129
|
-
"aria-live": isFocused ? ariaLive : 'off'
|
|
130
|
-
}, isPending && /*#__PURE__*/ (0, $fM325$react).createElement("div", {
|
|
131
|
-
role: "img",
|
|
132
|
-
"aria-labelledby": isPendingAriaLiveLabelledby
|
|
133
|
-
})), /*#__PURE__*/ (0, $fM325$react).createElement("div", {
|
|
134
|
-
id: safariDupeLabellingId,
|
|
135
|
-
role: "img",
|
|
136
|
-
"aria-label": isPending ? isPendingAriaLiveLabel : undefined
|
|
137
|
-
})));
|
|
138
|
-
}
|
|
139
|
-
function $d2b4bc8c273e7be6$var$useEnforcePendingComponents(props) {
|
|
140
|
-
let { isPending: isPending, ref: ref } = props;
|
|
141
|
-
let textRef = (0, $fM325$useRef)(null);
|
|
142
|
-
let progressRef = (0, $fM325$useRef)(null);
|
|
143
|
-
let textCallbackRef = (0, $fM325$useCallback)((node)=>{
|
|
144
|
-
textRef.current = node;
|
|
145
|
-
// use a microtask so the unmounting has time to complete before we throw an error
|
|
146
|
-
queueMicrotask(()=>{
|
|
147
|
-
if (!textRef.current && ref.current && isPending) throw new Error('Expected <Text> to be used with pending button');
|
|
148
|
-
});
|
|
149
|
-
}, [
|
|
150
|
-
isPending,
|
|
151
|
-
ref
|
|
152
|
-
]);
|
|
153
|
-
let progressCallbackRef = (0, $fM325$useCallback)((node)=>{
|
|
154
|
-
progressRef.current = node;
|
|
155
|
-
queueMicrotask(()=>{
|
|
156
|
-
if (!progressRef.current && ref.current && isPending) throw new Error('Expected <ProgressBar> to be used with pending button');
|
|
157
|
-
});
|
|
158
|
-
}, [
|
|
159
|
-
isPending,
|
|
160
|
-
ref
|
|
161
|
-
]);
|
|
162
|
-
(0, $fM325$useEffect)(()=>{
|
|
163
|
-
if (isPending && (!textRef.current || !progressRef.current)) throw new Error('Expected <Text> and <ProgressBar> to be used with pending button');
|
|
164
|
-
}, [
|
|
165
|
-
isPending,
|
|
166
|
-
textRef,
|
|
167
|
-
progressRef
|
|
168
|
-
]);
|
|
169
|
-
return {
|
|
170
|
-
textCallbackRef: textCallbackRef,
|
|
171
|
-
progressCallbackRef: progressCallbackRef
|
|
172
|
-
};
|
|
101
|
+
}, /*#__PURE__*/ (0, $fM325$react).createElement((0, $0393f8ab869a0f1a$export$e9f3bf65a26ce129).Provider, {
|
|
102
|
+
value: {
|
|
103
|
+
id: progressId
|
|
104
|
+
}
|
|
105
|
+
}, renderProps.children));
|
|
173
106
|
}
|
|
174
107
|
function $d2b4bc8c273e7be6$var$disablePendingProps(props) {
|
|
175
108
|
// Don't allow interaction while isPending is true
|