@react-spectrum/s2 3.0.0-nightly-5a0b4fabc-240924 → 3.0.0-nightly-a626c2596-240926
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/Accordion.cjs +1 -1
- package/dist/Accordion.cjs.map +1 -1
- package/dist/Accordion.css.map +1 -1
- package/dist/Accordion.mjs +2 -2
- package/dist/Accordion.mjs.map +1 -1
- package/dist/Button.cjs +5 -1
- package/dist/Button.cjs.map +1 -1
- package/dist/Button.css.map +1 -1
- package/dist/Button.mjs +5 -1
- package/dist/Button.mjs.map +1 -1
- package/dist/Card.cjs +1 -1
- package/dist/Card.cjs.map +1 -1
- package/dist/Card.css.map +1 -1
- package/dist/Card.mjs +1 -1
- package/dist/Card.mjs.map +1 -1
- package/dist/Checkbox.cjs +4 -1
- package/dist/Checkbox.cjs.map +1 -1
- package/dist/Checkbox.css +4 -0
- package/dist/Checkbox.css.map +1 -1
- package/dist/Checkbox.mjs +4 -1
- package/dist/Checkbox.mjs.map +1 -1
- package/dist/ComboBox.cjs +3 -0
- package/dist/ComboBox.cjs.map +1 -1
- package/dist/ComboBox.css.map +1 -1
- package/dist/ComboBox.mjs +3 -0
- package/dist/ComboBox.mjs.map +1 -1
- package/dist/Content.cjs +0 -2
- package/dist/Content.cjs.map +1 -1
- package/dist/Content.mjs +1 -2
- package/dist/Content.mjs.map +1 -1
- package/dist/Dialog.cjs +7 -5
- package/dist/Dialog.cjs.map +1 -1
- package/dist/Dialog.css.map +1 -1
- package/dist/Dialog.mjs +8 -6
- package/dist/Dialog.mjs.map +1 -1
- package/dist/Disclosure.cjs +2 -2
- package/dist/Disclosure.cjs.map +1 -1
- package/dist/Disclosure.css.map +1 -1
- package/dist/Disclosure.mjs +3 -3
- package/dist/Disclosure.mjs.map +1 -1
- package/dist/MoveHorizontalCircleTableWidget.cjs +33 -0
- package/dist/MoveHorizontalCircleTableWidget.cjs.map +1 -0
- package/dist/MoveHorizontalCircleTableWidget.mjs +28 -0
- package/dist/MoveHorizontalCircleTableWidget.mjs.map +1 -0
- package/dist/Picker.cjs +3 -0
- package/dist/Picker.cjs.map +1 -1
- package/dist/Picker.css.map +1 -1
- package/dist/Picker.mjs +3 -0
- package/dist/Picker.mjs.map +1 -1
- package/dist/Popover.cjs +1 -0
- package/dist/Popover.cjs.map +1 -1
- package/dist/Popover.css +4 -0
- package/dist/Popover.css.map +1 -1
- package/dist/Popover.mjs +1 -0
- package/dist/Popover.mjs.map +1 -1
- package/dist/SegmentedControl.cjs +11 -1
- package/dist/SegmentedControl.cjs.map +1 -1
- package/dist/SegmentedControl.css +24 -0
- package/dist/SegmentedControl.css.map +1 -1
- package/dist/SegmentedControl.mjs +11 -1
- package/dist/SegmentedControl.mjs.map +1 -1
- package/dist/Table.cjs +1093 -0
- package/dist/Table.cjs.map +1 -0
- package/dist/Table.css +821 -0
- package/dist/Table.css.map +1 -0
- package/dist/Table.mjs +1083 -0
- package/dist/Table.mjs.map +1 -0
- package/dist/TagGroup.cjs +5 -3
- package/dist/TagGroup.cjs.map +1 -1
- package/dist/TagGroup.css.map +1 -1
- package/dist/TagGroup.mjs +5 -3
- package/dist/TagGroup.mjs.map +1 -1
- package/dist/ar-AE.cjs +5 -0
- package/dist/ar-AE.cjs.map +1 -1
- package/dist/ar-AE.mjs +5 -0
- package/dist/ar-AE.mjs.map +1 -1
- package/dist/bg-BG.cjs +5 -0
- package/dist/bg-BG.cjs.map +1 -1
- package/dist/bg-BG.mjs +5 -0
- package/dist/bg-BG.mjs.map +1 -1
- package/dist/cs-CZ.cjs +5 -0
- package/dist/cs-CZ.cjs.map +1 -1
- package/dist/cs-CZ.mjs +5 -0
- package/dist/cs-CZ.mjs.map +1 -1
- package/dist/da-DK.cjs +5 -0
- package/dist/da-DK.cjs.map +1 -1
- package/dist/da-DK.mjs +5 -0
- package/dist/da-DK.mjs.map +1 -1
- package/dist/de-DE.cjs +5 -0
- package/dist/de-DE.cjs.map +1 -1
- package/dist/de-DE.mjs +5 -0
- package/dist/de-DE.mjs.map +1 -1
- package/dist/el-GR.cjs +5 -0
- package/dist/el-GR.cjs.map +1 -1
- package/dist/el-GR.mjs +5 -0
- package/dist/el-GR.mjs.map +1 -1
- package/dist/en-US.cjs +5 -0
- package/dist/en-US.cjs.map +1 -1
- package/dist/en-US.mjs +5 -0
- package/dist/en-US.mjs.map +1 -1
- package/dist/es-ES.cjs +5 -0
- package/dist/es-ES.cjs.map +1 -1
- package/dist/es-ES.mjs +5 -0
- package/dist/es-ES.mjs.map +1 -1
- package/dist/et-EE.cjs +5 -0
- package/dist/et-EE.cjs.map +1 -1
- package/dist/et-EE.mjs +5 -0
- package/dist/et-EE.mjs.map +1 -1
- package/dist/fi-FI.cjs +5 -0
- package/dist/fi-FI.cjs.map +1 -1
- package/dist/fi-FI.mjs +5 -0
- package/dist/fi-FI.mjs.map +1 -1
- package/dist/fr-FR.cjs +5 -0
- package/dist/fr-FR.cjs.map +1 -1
- package/dist/fr-FR.mjs +5 -0
- package/dist/fr-FR.mjs.map +1 -1
- package/dist/he-IL.cjs +5 -0
- package/dist/he-IL.cjs.map +1 -1
- package/dist/he-IL.mjs +5 -0
- package/dist/he-IL.mjs.map +1 -1
- package/dist/hr-HR.cjs +5 -0
- package/dist/hr-HR.cjs.map +1 -1
- package/dist/hr-HR.mjs +5 -0
- package/dist/hr-HR.mjs.map +1 -1
- package/dist/hu-HU.cjs +5 -0
- package/dist/hu-HU.cjs.map +1 -1
- package/dist/hu-HU.mjs +5 -0
- package/dist/hu-HU.mjs.map +1 -1
- package/dist/it-IT.cjs +5 -0
- package/dist/it-IT.cjs.map +1 -1
- package/dist/it-IT.mjs +5 -0
- package/dist/it-IT.mjs.map +1 -1
- package/dist/ja-JP.cjs +5 -0
- package/dist/ja-JP.cjs.map +1 -1
- package/dist/ja-JP.mjs +5 -0
- package/dist/ja-JP.mjs.map +1 -1
- package/dist/ko-KR.cjs +5 -0
- package/dist/ko-KR.cjs.map +1 -1
- package/dist/ko-KR.mjs +5 -0
- package/dist/ko-KR.mjs.map +1 -1
- package/dist/lt-LT.cjs +5 -0
- package/dist/lt-LT.cjs.map +1 -1
- package/dist/lt-LT.mjs +5 -0
- package/dist/lt-LT.mjs.map +1 -1
- package/dist/lv-LV.cjs +5 -0
- package/dist/lv-LV.cjs.map +1 -1
- package/dist/lv-LV.mjs +5 -0
- package/dist/lv-LV.mjs.map +1 -1
- package/dist/main.cjs +8 -0
- package/dist/main.cjs.map +1 -1
- package/dist/module.mjs +3 -1
- package/dist/module.mjs.map +1 -1
- package/dist/nb-NO.cjs +5 -0
- package/dist/nb-NO.cjs.map +1 -1
- package/dist/nb-NO.mjs +5 -0
- package/dist/nb-NO.mjs.map +1 -1
- package/dist/nl-NL.cjs +5 -0
- package/dist/nl-NL.cjs.map +1 -1
- package/dist/nl-NL.mjs +5 -0
- package/dist/nl-NL.mjs.map +1 -1
- package/dist/pl-PL.cjs +5 -0
- package/dist/pl-PL.cjs.map +1 -1
- package/dist/pl-PL.mjs +5 -0
- package/dist/pl-PL.mjs.map +1 -1
- package/dist/pt-BR.cjs +5 -0
- package/dist/pt-BR.cjs.map +1 -1
- package/dist/pt-BR.mjs +5 -0
- package/dist/pt-BR.mjs.map +1 -1
- package/dist/pt-PT.cjs +5 -0
- package/dist/pt-PT.cjs.map +1 -1
- package/dist/pt-PT.mjs +5 -0
- package/dist/pt-PT.mjs.map +1 -1
- package/dist/ro-RO.cjs +5 -0
- package/dist/ro-RO.cjs.map +1 -1
- package/dist/ro-RO.mjs +5 -0
- package/dist/ro-RO.mjs.map +1 -1
- package/dist/ru-RU.cjs +5 -0
- package/dist/ru-RU.cjs.map +1 -1
- package/dist/ru-RU.mjs +5 -0
- package/dist/ru-RU.mjs.map +1 -1
- package/dist/sk-SK.cjs +5 -0
- package/dist/sk-SK.cjs.map +1 -1
- package/dist/sk-SK.mjs +5 -0
- package/dist/sk-SK.mjs.map +1 -1
- package/dist/sl-SI.cjs +5 -0
- package/dist/sl-SI.cjs.map +1 -1
- package/dist/sl-SI.mjs +5 -0
- package/dist/sl-SI.mjs.map +1 -1
- package/dist/sr-SP.cjs +5 -0
- package/dist/sr-SP.cjs.map +1 -1
- package/dist/sr-SP.mjs +5 -0
- package/dist/sr-SP.mjs.map +1 -1
- package/dist/sv-SE.cjs +5 -0
- package/dist/sv-SE.cjs.map +1 -1
- package/dist/sv-SE.mjs +5 -0
- package/dist/sv-SE.mjs.map +1 -1
- package/dist/tr-TR.cjs +5 -0
- package/dist/tr-TR.cjs.map +1 -1
- package/dist/tr-TR.mjs +5 -0
- package/dist/tr-TR.mjs.map +1 -1
- package/dist/types.d.ts +93 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/uk-UA.cjs +5 -0
- package/dist/uk-UA.cjs.map +1 -1
- package/dist/uk-UA.mjs +5 -0
- package/dist/uk-UA.mjs.map +1 -1
- package/dist/utils.cjs +30 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.mjs +25 -0
- package/dist/utils.mjs.map +1 -0
- package/dist/zh-CN.cjs +5 -0
- package/dist/zh-CN.cjs.map +1 -1
- package/dist/zh-CN.mjs +5 -0
- package/dist/zh-CN.mjs.map +1 -1
- package/dist/zh-TW.cjs +5 -0
- package/dist/zh-TW.cjs.map +1 -1
- package/dist/zh-TW.mjs +5 -0
- package/dist/zh-TW.mjs.map +1 -1
- package/package.json +18 -16
- package/src/Accordion.tsx +2 -2
- package/src/Button.tsx +22 -14
- package/src/Card.tsx +1 -1
- package/src/Checkbox.tsx +1 -0
- package/src/ComboBox.tsx +3 -0
- package/src/Content.tsx +1 -3
- package/src/Dialog.tsx +3 -2
- package/src/Disclosure.tsx +3 -3
- package/src/Picker.tsx +3 -0
- package/src/Popover.tsx +4 -1
- package/src/SegmentedControl.tsx +14 -3
- package/src/Table.tsx +1084 -48
- package/src/TagGroup.tsx +3 -2
- package/src/index.ts +2 -0
- package/src/utils.ts +28 -0
- package/style/__tests__/mergeStyles.test.js +32 -0
- package/style/__tests__/style-macro.test.js +128 -0
- package/style/dist/main.cjs +1984 -0
- package/style/dist/main.cjs.map +1 -0
- package/style/dist/module.mjs +1973 -0
- package/style/dist/module.mjs.map +1 -0
- package/style/dist/style-macro.cjs +543 -0
- package/style/dist/style-macro.cjs.map +1 -0
- package/style/dist/style-macro.mjs +534 -0
- package/style/dist/style-macro.mjs.map +1 -0
- package/style/dist/types.d.ts +780 -0
- package/style/dist/types.d.ts.map +1 -0
- package/style/runtime.ts +103 -0
- package/style/spectrum-theme.ts +974 -0
- package/style/style-macro.ts +638 -0
- package/style/tokens.ts +68 -0
- package/style/types.ts +177 -0
package/dist/Accordion.cjs
CHANGED
|
@@ -48,7 +48,7 @@ function $152a25dfd79f123a$var$Accordion(props, ref) {
|
|
|
48
48
|
isQuiet: isQuiet,
|
|
49
49
|
density: density
|
|
50
50
|
},
|
|
51
|
-
children: /*#__PURE__*/ (0, $etdk1$reactjsxruntime.jsx)((0, $etdk1$reactariacomponents.
|
|
51
|
+
children: /*#__PURE__*/ (0, $etdk1$reactjsxruntime.jsx)((0, $etdk1$reactariacomponents.UNSTABLE_DisclosureGroup), {
|
|
52
52
|
...props,
|
|
53
53
|
ref: domRef,
|
|
54
54
|
style: UNSAFE_style,
|
package/dist/Accordion.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AA8BD,MAAM;;;;;;;;AAKC,MAAM,0DAAmB,CAAA,GAAA,0BAAY,EAA6D;AAEzG,SAAS,gCAAU,KAAqB,EAAE,GAA2B;IACnE,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,iDAAsB,EAAE,OAAO,KAAK;IACnD,IAAI,SAAS,CAAA,GAAA,mCAAQ,EAAE;IACvB,IAAI,gBACF,YAAY,oBACZ,mBAAmB,UACnB,OAAO,cACP,UAAU,oBACV,OAAO,EACR,GAAG;IACJ,qBACE,gCAAC,CAAA,GAAA,2CAAgB,EAAE,QAAQ;QAAC,OAAO;kBAAC;qBAAM;qBAAS;QAAO;kBACxD,cAAA,gCAAC,CAAA,GAAA,
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AA8BD,MAAM;;;;;;;;AAKC,MAAM,0DAAmB,CAAA,GAAA,0BAAY,EAA6D;AAEzG,SAAS,gCAAU,KAAqB,EAAE,GAA2B;IACnE,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,iDAAsB,EAAE,OAAO,KAAK;IACnD,IAAI,SAAS,CAAA,GAAA,mCAAQ,EAAE;IACvB,IAAI,gBACF,YAAY,oBACZ,mBAAmB,UACnB,OAAO,cACP,UAAU,oBACV,OAAO,EACR,GAAG;IACJ,qBACE,gCAAC,CAAA,GAAA,2CAAgB,EAAE,QAAQ;QAAC,OAAO;kBAAC;qBAAM;qBAAS;QAAO;kBACxD,cAAA,gCAAC,CAAA,GAAA,mDAAc;YACZ,GAAG,KAAK;YACT,KAAK;YACL,OAAO;YACP,WAAW,AAAC,CAAA,oBAAoB,EAAC,IAAK,gCAAU,MAAM,MAAM,MAAM;sBACjE,MAAM,QAAQ;;;AAIvB;AAEA;;CAEC,GACD,IAAI,0DAAa,CAAA,GAAA,uBAAS,EAAE","sources":["packages/@react-spectrum/s2/src/Accordion.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {ContextValue, UNSTABLE_DisclosureGroup as DisclosureGroup, DisclosureGroupProps, SlotProps} from 'react-aria-components';\nimport {DisclosureContext} from './Disclosure';\nimport {DOMProps, DOMRef, DOMRefValue} from '@react-types/shared';\nimport {getAllowedOverrides, StylesPropWithHeight, UnsafeStyles} from './style-utils' with { type: 'macro' };\nimport React, {createContext, forwardRef} from 'react';\nimport {style} from '../style/spectrum-theme' with { type: 'macro' };\nimport {useDOMRef} from '@react-spectrum/utils';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\nexport interface AccordionProps extends Omit<DisclosureGroupProps, 'className' | 'style' | 'children'>, UnsafeStyles, DOMProps, SlotProps {\n /** The disclosure elements in the accordion. */\n children: React.ReactNode,\n /** Spectrum-defined styles, returned by the `style()` macro. */\n styles?: StylesPropWithHeight,\n /**\n * The size of the accordion.\n * @default \"M\"\n */\n size?: 'S' | 'M' | 'L' | 'XL',\n /**\n * The amount of space between the disclosure items.\n * @default \"regular\"\n */\n density?: 'compact' | 'regular' | 'spacious',\n /** Whether the accordion should be displayed with a quiet style. */\n isQuiet?: boolean\n}\n\nconst accordion = style({\n display: 'flex',\n flexDirection: 'column'\n}, getAllowedOverrides({height: true}));\n\nexport const AccordionContext = createContext<ContextValue<AccordionProps, DOMRefValue<HTMLDivElement>>>(null);\n\nfunction Accordion(props: AccordionProps, ref: DOMRef<HTMLDivElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, AccordionContext);\n let domRef = useDOMRef(ref);\n let {\n UNSAFE_style,\n UNSAFE_className = '',\n size = 'M',\n density = 'regular',\n isQuiet\n } = props;\n return (\n <DisclosureContext.Provider value={{size, isQuiet, density}}>\n <DisclosureGroup\n {...props}\n ref={domRef}\n style={UNSAFE_style}\n className={(UNSAFE_className ?? '') + accordion(null, props.styles)}>\n {props.children}\n </DisclosureGroup>\n </DisclosureContext.Provider>\n );\n}\n\n/**\n * An accordion is a container for multiple disclosures.\n */\nlet _Accordion = forwardRef(Accordion);\nexport {_Accordion as Accordion};\n"],"names":[],"version":3,"file":"Accordion.cjs.map"}
|
package/dist/Accordion.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAwCkB;;;;AAAA;EAAA;;;;EAAA;;;;;AAAA","sources":["packages/@react-spectrum/s2/src/Accordion.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {ContextValue, DisclosureGroup, DisclosureGroupProps, SlotProps} from 'react-aria-components';\nimport {DisclosureContext} from './Disclosure';\nimport {DOMProps, DOMRef, DOMRefValue} from '@react-types/shared';\nimport {getAllowedOverrides, StylesPropWithHeight, UnsafeStyles} from './style-utils' with { type: 'macro' };\nimport React, {createContext, forwardRef} from 'react';\nimport {style} from '../style/spectrum-theme' with { type: 'macro' };\nimport {useDOMRef} from '@react-spectrum/utils';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\nexport interface AccordionProps extends DisclosureGroupProps, UnsafeStyles, DOMProps, SlotProps {\n /** The disclosure elements in the accordion. */\n children: React.ReactNode,\n /** Spectrum-defined styles, returned by the `style()` macro. */\n styles?: StylesPropWithHeight,\n /**\n * The size of the accordion.\n * @default \"M\"\n */\n size?: 'S' | 'M' | 'L' | 'XL',\n /**\n * The amount of space between the disclosure items.\n * @default \"regular\"\n */\n density?: 'compact' | 'regular' | 'spacious',\n /** Whether the accordion should be displayed with a quiet style. */\n isQuiet?: boolean\n}\n\nconst accordion = style({\n display: 'flex',\n flexDirection: 'column'\n}, getAllowedOverrides({height: true}));\n\nexport const AccordionContext = createContext<ContextValue<AccordionProps, DOMRefValue<HTMLDivElement>>>(null);\n\nfunction Accordion(props: AccordionProps, ref: DOMRef<HTMLDivElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, AccordionContext);\n let domRef = useDOMRef(ref);\n let {\n UNSAFE_style,\n UNSAFE_className = '',\n size = 'M',\n density = 'regular',\n isQuiet\n } = props;\n return (\n <DisclosureContext.Provider value={{size, isQuiet, density}}>\n <DisclosureGroup\n {...props}\n ref={domRef}\n style={UNSAFE_style}\n className={(UNSAFE_className ?? '') + accordion(null, props.styles)}>\n {props.children}\n </DisclosureGroup>\n </DisclosureContext.Provider>\n );\n}\n\n/**\n * An accordion is a container for multiple disclosures.\n */\nlet _Accordion = forwardRef(Accordion);\nexport {_Accordion as Accordion};\n"],"names":[],"version":3,"file":"Accordion.css.map"}
|
|
1
|
+
{"mappings":"AAwCkB;;;;AAAA;EAAA;;;;EAAA;;;;;AAAA","sources":["packages/@react-spectrum/s2/src/Accordion.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {ContextValue, UNSTABLE_DisclosureGroup as DisclosureGroup, DisclosureGroupProps, SlotProps} from 'react-aria-components';\nimport {DisclosureContext} from './Disclosure';\nimport {DOMProps, DOMRef, DOMRefValue} from '@react-types/shared';\nimport {getAllowedOverrides, StylesPropWithHeight, UnsafeStyles} from './style-utils' with { type: 'macro' };\nimport React, {createContext, forwardRef} from 'react';\nimport {style} from '../style/spectrum-theme' with { type: 'macro' };\nimport {useDOMRef} from '@react-spectrum/utils';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\nexport interface AccordionProps extends Omit<DisclosureGroupProps, 'className' | 'style' | 'children'>, UnsafeStyles, DOMProps, SlotProps {\n /** The disclosure elements in the accordion. */\n children: React.ReactNode,\n /** Spectrum-defined styles, returned by the `style()` macro. */\n styles?: StylesPropWithHeight,\n /**\n * The size of the accordion.\n * @default \"M\"\n */\n size?: 'S' | 'M' | 'L' | 'XL',\n /**\n * The amount of space between the disclosure items.\n * @default \"regular\"\n */\n density?: 'compact' | 'regular' | 'spacious',\n /** Whether the accordion should be displayed with a quiet style. */\n isQuiet?: boolean\n}\n\nconst accordion = style({\n display: 'flex',\n flexDirection: 'column'\n}, getAllowedOverrides({height: true}));\n\nexport const AccordionContext = createContext<ContextValue<AccordionProps, DOMRefValue<HTMLDivElement>>>(null);\n\nfunction Accordion(props: AccordionProps, ref: DOMRef<HTMLDivElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, AccordionContext);\n let domRef = useDOMRef(ref);\n let {\n UNSAFE_style,\n UNSAFE_className = '',\n size = 'M',\n density = 'regular',\n isQuiet\n } = props;\n return (\n <DisclosureContext.Provider value={{size, isQuiet, density}}>\n <DisclosureGroup\n {...props}\n ref={domRef}\n style={UNSAFE_style}\n className={(UNSAFE_className ?? '') + accordion(null, props.styles)}>\n {props.children}\n </DisclosureGroup>\n </DisclosureContext.Provider>\n );\n}\n\n/**\n * An accordion is a container for multiple disclosures.\n */\nlet _Accordion = forwardRef(Accordion);\nexport {_Accordion as Accordion};\n"],"names":[],"version":3,"file":"Accordion.css.map"}
|
package/dist/Accordion.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import "./Accordion.css";
|
|
|
2
2
|
import {DisclosureContext as $cf1d656285911959$export$d665dd135a51b28a} from "./Disclosure.mjs";
|
|
3
3
|
import {useSpectrumContextProps as $5ce63c423902f47d$export$764f6146fadd77f7} from "./useSpectrumContextProps.mjs";
|
|
4
4
|
import {jsx as $cFlas$jsx} from "react/jsx-runtime";
|
|
5
|
-
import {
|
|
5
|
+
import {UNSTABLE_DisclosureGroup as $cFlas$UNSTABLE_DisclosureGroup} from "react-aria-components";
|
|
6
6
|
import {createContext as $cFlas$createContext, forwardRef as $cFlas$forwardRef} from "react";
|
|
7
7
|
import {useDOMRef as $cFlas$useDOMRef} from "@react-spectrum/utils";
|
|
8
8
|
|
|
@@ -41,7 +41,7 @@ function $e0a5d45f488fa6ba$var$Accordion(props, ref) {
|
|
|
41
41
|
isQuiet: isQuiet,
|
|
42
42
|
density: density
|
|
43
43
|
},
|
|
44
|
-
children: /*#__PURE__*/ (0, $cFlas$jsx)((0, $cFlas$
|
|
44
|
+
children: /*#__PURE__*/ (0, $cFlas$jsx)((0, $cFlas$UNSTABLE_DisclosureGroup), {
|
|
45
45
|
...props,
|
|
46
46
|
ref: domRef,
|
|
47
47
|
style: UNSAFE_style,
|
package/dist/Accordion.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AA8BD,MAAM;;;;;;;;AAKC,MAAM,0DAAmB,CAAA,GAAA,oBAAY,EAA6D;AAEzG,SAAS,gCAAU,KAAqB,EAAE,GAA2B;IACnE,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAsB,EAAE,OAAO,KAAK;IACnD,IAAI,SAAS,CAAA,GAAA,gBAAQ,EAAE;IACvB,IAAI,gBACF,YAAY,oBACZ,mBAAmB,UACnB,OAAO,cACP,UAAU,oBACV,OAAO,EACR,GAAG;IACJ,qBACE,gBAAC,CAAA,GAAA,yCAAgB,EAAE,QAAQ;QAAC,OAAO;kBAAC;qBAAM;qBAAS;QAAO;kBACxD,cAAA,gBAAC,CAAA,GAAA
|
|
1
|
+
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AA8BD,MAAM;;;;;;;;AAKC,MAAM,0DAAmB,CAAA,GAAA,oBAAY,EAA6D;AAEzG,SAAS,gCAAU,KAAqB,EAAE,GAA2B;IACnE,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAsB,EAAE,OAAO,KAAK;IACnD,IAAI,SAAS,CAAA,GAAA,gBAAQ,EAAE;IACvB,IAAI,gBACF,YAAY,oBACZ,mBAAmB,UACnB,OAAO,cACP,UAAU,oBACV,OAAO,EACR,GAAG;IACJ,qBACE,gBAAC,CAAA,GAAA,yCAAgB,EAAE,QAAQ;QAAC,OAAO;kBAAC;qBAAM;qBAAS;QAAO;kBACxD,cAAA,gBAAC,CAAA,GAAA,+BAAc;YACZ,GAAG,KAAK;YACT,KAAK;YACL,OAAO;YACP,WAAW,AAAC,CAAA,oBAAoB,EAAC,IAAK,gCAAU,MAAM,MAAM,MAAM;sBACjE,MAAM,QAAQ;;;AAIvB;AAEA;;CAEC,GACD,IAAI,0DAAa,CAAA,GAAA,iBAAS,EAAE","sources":["packages/@react-spectrum/s2/src/Accordion.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {ContextValue, UNSTABLE_DisclosureGroup as DisclosureGroup, DisclosureGroupProps, SlotProps} from 'react-aria-components';\nimport {DisclosureContext} from './Disclosure';\nimport {DOMProps, DOMRef, DOMRefValue} from '@react-types/shared';\nimport {getAllowedOverrides, StylesPropWithHeight, UnsafeStyles} from './style-utils' with { type: 'macro' };\nimport React, {createContext, forwardRef} from 'react';\nimport {style} from '../style/spectrum-theme' with { type: 'macro' };\nimport {useDOMRef} from '@react-spectrum/utils';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\nexport interface AccordionProps extends Omit<DisclosureGroupProps, 'className' | 'style' | 'children'>, UnsafeStyles, DOMProps, SlotProps {\n /** The disclosure elements in the accordion. */\n children: React.ReactNode,\n /** Spectrum-defined styles, returned by the `style()` macro. */\n styles?: StylesPropWithHeight,\n /**\n * The size of the accordion.\n * @default \"M\"\n */\n size?: 'S' | 'M' | 'L' | 'XL',\n /**\n * The amount of space between the disclosure items.\n * @default \"regular\"\n */\n density?: 'compact' | 'regular' | 'spacious',\n /** Whether the accordion should be displayed with a quiet style. */\n isQuiet?: boolean\n}\n\nconst accordion = style({\n display: 'flex',\n flexDirection: 'column'\n}, getAllowedOverrides({height: true}));\n\nexport const AccordionContext = createContext<ContextValue<AccordionProps, DOMRefValue<HTMLDivElement>>>(null);\n\nfunction Accordion(props: AccordionProps, ref: DOMRef<HTMLDivElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, AccordionContext);\n let domRef = useDOMRef(ref);\n let {\n UNSAFE_style,\n UNSAFE_className = '',\n size = 'M',\n density = 'regular',\n isQuiet\n } = props;\n return (\n <DisclosureContext.Provider value={{size, isQuiet, density}}>\n <DisclosureGroup\n {...props}\n ref={domRef}\n style={UNSAFE_style}\n className={(UNSAFE_className ?? '') + accordion(null, props.styles)}>\n {props.children}\n </DisclosureGroup>\n </DisclosureContext.Provider>\n );\n}\n\n/**\n * An accordion is a container for multiple disclosures.\n */\nlet _Accordion = forwardRef(Accordion);\nexport {_Accordion as Accordion};\n"],"names":[],"version":3,"file":"Accordion.mjs.map"}
|
package/dist/Button.cjs
CHANGED
|
@@ -53,6 +53,7 @@ $parcel$export(module.exports, "LinkButton", () => $25d06cf8d4e72761$export$29d1
|
|
|
53
53
|
|
|
54
54
|
const $25d06cf8d4e72761$export$24d547caef80ccd1 = /*#__PURE__*/ (0, $8owBJ$react.createContext)(null);
|
|
55
55
|
const $25d06cf8d4e72761$export$1c1a176f3b9e48d3 = /*#__PURE__*/ (0, $8owBJ$react.createContext)(null);
|
|
56
|
+
const $25d06cf8d4e72761$var$iconOnly = ':has([slot=icon]):not(:has([data-rsp-slot=text]))';
|
|
56
57
|
const $25d06cf8d4e72761$var$button = function anonymous(props, overrides) {
|
|
57
58
|
let rules = " .";
|
|
58
59
|
let matches = (overrides || '').match(/(?:^|\s)(?:y|z|A|B|_9|_8|h|_5|_4|__A|__c|__d|__a|__b|U|__Q|X|Z|V|W|l|q|r)[^\s]+/g) || [];
|
|
@@ -412,6 +413,7 @@ function $25d06cf8d4e72761$var$Button(props1, ref) {
|
|
|
412
413
|
}({
|
|
413
414
|
isProgressVisible: isProgressVisible
|
|
414
415
|
}),
|
|
416
|
+
// @ts-ignore data-attributes allowed on all JSX elements, but adding to DOMProps has been problematic in the past
|
|
415
417
|
'data-rsp-slot': 'text'
|
|
416
418
|
}
|
|
417
419
|
],
|
|
@@ -501,7 +503,9 @@ function $25d06cf8d4e72761$var$LinkButton(props, ref) {
|
|
|
501
503
|
[
|
|
502
504
|
(0, $6367bc87eb7d24ad$exports.TextContext),
|
|
503
505
|
{
|
|
504
|
-
styles: " . E-1gogtue F-1gogtue __A-3t1y"
|
|
506
|
+
styles: " . E-1gogtue F-1gogtue __A-3t1y",
|
|
507
|
+
// @ts-ignore data-attributes allowed on all JSX elements, but adding to DOMProps has been problematic in the past
|
|
508
|
+
'data-rsp-slot': 'text'
|
|
505
509
|
}
|
|
506
510
|
],
|
|
507
511
|
[
|
package/dist/Button.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAqDM,MAAM,0DAAgB,CAAA,GAAA,0BAAY,EAAmE;AACrG,MAAM,0DAAoB,CAAA,GAAA,0BAAY,EAAmE;AAEhH,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AI;gBAC1B,WAAW,MAAM,SAAS,IAAI;gBAC9B,MAAM,MAAM,IAAI,IAAI;gBACpB,aAAa,MAAM,WAAW;YAChC,GAAG,MAAM,MAAM;kBACf,cAAA,gCAAC,CAAA,GAAA,mCAAO;YACN,QAAQ;gBACN;oBAAC,CAAA,GAAA,yCAAc;oBAAG;iBAAK;gBACvB;oBAAC,CAAA,GAAA,qCAAU;oBAAG;wBAAC,MAAM;oBAA+C;iBAAE;gBACtE;oBAAC,CAAA,GAAA,qCAAU;oBAAG;wBACZ,QAAQ,CAAA,GAAA,wCAAa,EAAE;4BAAC,MAAM;4BAAQ,MAAM;wBAAmB;wBAC/D,MAAM;oBACR;iBAAE;aACH;sBACA,OAAO,MAAM,QAAQ,KAAK,yBAAW,gCAAC,CAAA,GAAA,8BAAG;0BAAG,MAAM,QAAQ;iBAAW,MAAM,QAAQ;;;AAI5F;AAEA;;CAEC,GACD,IAAI,0DAAc,CAAA,GAAA,uBAAS,EAAE","sources":["packages/@react-spectrum/s2/src/Button.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {baseColor, fontRelative, style} from '../style/spectrum-theme' with {type: 'macro'};\nimport {ButtonRenderProps, ContextValue, Link, LinkProps, OverlayTriggerStateContext, Provider, Button as RACButton, ButtonProps as RACButtonProps} from 'react-aria-components';\nimport {centerBaseline} from './CenterBaseline';\nimport {centerPadding, focusRing, getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};\nimport {createContext, forwardRef, ReactNode, useContext, useEffect, useState} from 'react';\nimport {FocusableRef, FocusableRefValue} from '@react-types/shared';\nimport {IconContext} from './Icon';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {pressScale} from './pressScale';\nimport {ProgressCircle} from './ProgressCircle';\nimport {SkeletonContext} from './Skeleton';\nimport {Text, TextContext} from './Content';\nimport {useFocusableRef} from '@react-spectrum/utils';\nimport {useFormProps} from './Form';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\ninterface ButtonStyleProps {\n /**\n * The [visual style](https://spectrum.adobe.com/page/button/#Options) of the button.\n *\n * @default 'primary'\n */\n variant?: 'primary' | 'secondary' | 'accent' | 'negative',\n /**\n * The background style of the Button.\n *\n * @default 'fill'\n */\n fillStyle?: 'fill' | 'outline',\n /**\n * The size of the Button.\n *\n * @default 'M'\n */\n size?: 'S' | 'M' | 'L' | 'XL',\n /** The static color style to apply. Useful when the Button appears over a color background. */\n staticColor?: 'white' | 'black'\n}\n\nexport interface ButtonProps extends Omit<RACButtonProps, 'className' | 'style' | 'children' | 'onHover' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange'>, StyleProps, ButtonStyleProps {\n /** The content to display in the Button. */\n children?: ReactNode\n}\n\nexport interface LinkButtonProps extends Omit<LinkProps, 'className' | 'style' | 'children'>, StyleProps, ButtonStyleProps {\n /** The content to display in the Button. */\n children?: ReactNode\n}\n\nexport const ButtonContext = createContext<ContextValue<ButtonProps, FocusableRefValue<HTMLButtonElement>>>(null);\nexport const LinkButtonContext = createContext<ContextValue<ButtonProps, FocusableRefValue<HTMLAnchorElement>>>(null);\n\nconst button = style<ButtonRenderProps & ButtonStyleProps>({\n ...focusRing(),\n position: 'relative',\n display: 'flex',\n alignItems: {\n default: 'baseline',\n ':has([slot=icon]):not(:has([data-rsp-slot=text]))': 'center'\n },\n justifyContent: 'center',\n textAlign: 'start',\n columnGap: 'text-to-visual',\n font: 'control',\n fontWeight: 'bold',\n userSelect: 'none',\n minHeight: 'control',\n minWidth: {\n ':has([slot=icon]):not(:has([data-rsp-slot=text]))': 'control'\n },\n borderRadius: 'pill',\n boxSizing: 'border-box',\n width: 'fit',\n textDecoration: 'none', // for link buttons\n paddingX: {\n default: 'pill',\n ':has([slot=icon]):not(:has([data-rsp-slot=text]))': 0\n },\n paddingY: 0,\n aspectRatio: {\n ':has([slot=icon]):not(:has([data-rsp-slot=text]))': 'square'\n },\n transition: 'default',\n borderStyle: 'solid',\n borderWidth: {\n fillStyle: {\n fill: 0,\n outline: 2\n }\n },\n '--labelPadding': {\n type: 'paddingTop',\n value: centerPadding()\n },\n '--iconMargin': {\n type: 'marginTop',\n value: {\n default: fontRelative(-2),\n ':has([slot=icon]):not(:has([data-rsp-slot=text]))': 0\n }\n },\n borderColor: {\n variant: {\n primary: baseColor('gray-800'),\n secondary: baseColor('gray-300')\n },\n isDisabled: 'disabled',\n staticColor: {\n white: {\n variant: {\n primary: baseColor('transparent-white-800'),\n secondary: baseColor('transparent-white-300')\n },\n isDisabled: 'transparent-white-300'\n },\n black: {\n variant: {\n primary: baseColor('transparent-black-800'),\n secondary: baseColor('transparent-black-300')\n },\n isDisabled: 'transparent-black-300'\n }\n },\n forcedColors: {\n default: 'ButtonBorder',\n isHovered: 'Highlight',\n isDisabled: 'GrayText'\n }\n },\n backgroundColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'neutral',\n secondary: baseColor('gray-100'),\n accent: 'accent',\n negative: 'negative'\n },\n isDisabled: 'disabled'\n },\n outline: {\n default: 'transparent',\n isHovered: 'gray-100',\n isPressed: 'gray-100',\n isFocusVisible: 'gray-100',\n isDisabled: 'transparent'\n }\n },\n staticColor: {\n white: {\n fillStyle: {\n fill: {\n variant: {\n primary: baseColor('transparent-white-800'),\n secondary: baseColor('transparent-white-100')\n },\n isDisabled: 'transparent-white-100'\n },\n outline: {\n default: 'transparent',\n isHovered: 'transparent-white-100',\n isPressed: 'transparent-white-100',\n isFocusVisible: 'transparent-white-100',\n isDisabled: 'transparent'\n }\n }\n },\n black: {\n fillStyle: {\n fill: {\n variant: {\n primary: baseColor('transparent-black-800'),\n secondary: baseColor('transparent-black-100')\n },\n isDisabled: 'transparent-black-100'\n },\n outline: {\n default: 'transparent',\n isHovered: 'transparent-black-100',\n isPressed: 'transparent-black-100',\n isFocusVisible: 'transparent-black-100',\n isDisabled: 'transparent'\n }\n }\n }\n },\n forcedColors: {\n fillStyle: {\n fill: {\n default: 'ButtonText',\n isHovered: 'Highlight',\n isDisabled: 'GrayText'\n },\n outline: 'ButtonFace'\n }\n }\n },\n color: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'gray-25',\n secondary: 'neutral',\n accent: 'white',\n negative: 'white'\n },\n isDisabled: 'disabled'\n },\n outline: {\n default: 'neutral',\n isDisabled: 'disabled'\n }\n },\n staticColor: {\n white: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'black',\n secondary: baseColor('transparent-white-800')\n }\n },\n outline: baseColor('transparent-white-800')\n },\n isDisabled: 'transparent-white-400'\n },\n black: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'white',\n secondary: baseColor('transparent-black-800')\n }\n },\n outline: baseColor('transparent-black-800')\n },\n isDisabled: 'transparent-black-400'\n }\n },\n forcedColors: {\n fillStyle: {\n fill: {\n default: 'ButtonFace',\n isDisabled: 'HighlightText'\n },\n outline: {\n default: 'ButtonText',\n isDisabled: 'GrayText'\n }\n }\n }\n },\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n },\n outlineColor: {\n default: 'focus-ring',\n staticColor: {\n white: 'white',\n black: 'black'\n },\n forcedColors: 'Highlight'\n },\n forcedColorAdjust: 'none',\n disableTapHighlight: true\n}, getAllowedOverrides());\n\nfunction Button(props: ButtonProps, ref: FocusableRef<HTMLButtonElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, ButtonContext);\n props = useFormProps(props);\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/s2');\n let {\n isPending,\n variant = 'primary',\n fillStyle = 'fill',\n size = 'M',\n staticColor\n } = props;\n let domRef = useFocusableRef(ref);\n let overlayTriggerState = useContext(OverlayTriggerStateContext);\n\n let [isProgressVisible, setIsProgressVisible] = useState(false);\n useEffect(() => {\n let timeout: ReturnType<typeof setTimeout>;\n\n if (isPending) {\n // Start timer when isPending is set to true.\n timeout = setTimeout(() => {\n setIsProgressVisible(true);\n }, 1000);\n } else {\n // Exit loading state when isPending is set to false. */\n setIsProgressVisible(false);\n }\n return () => {\n // Clean up on unmount or when user removes isPending prop before entering loading state.\n clearTimeout(timeout);\n };\n }, [isPending]);\n\n return (\n <RACButton\n {...props}\n ref={domRef}\n style={pressScale(domRef, props.UNSAFE_style)}\n className={renderProps => (props.UNSAFE_className || '') + button({\n ...renderProps,\n // Retain hover styles when an overlay is open.\n isHovered: renderProps.isHovered || overlayTriggerState?.isOpen || false,\n isDisabled: renderProps.isDisabled || isProgressVisible,\n variant,\n fillStyle,\n size,\n staticColor\n }, props.styles)}>\n <Provider\n values={[\n [SkeletonContext, null],\n [TextContext, {styles: style({\n paddingY: '--labelPadding',\n order: 1,\n opacity: {\n default: 1,\n isProgressVisible: 0\n }\n // @ts-ignore data-attributes allowed on all JSX elements, but adding to DOMProps has been problematic in the past\n })({isProgressVisible}), 'data-rsp-slot': 'text'}],\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: style({order: 0})}),\n styles: style({\n size: fontRelative(20),\n marginStart: '--iconMargin',\n flexShrink: 0,\n opacity: {\n default: 1,\n isProgressVisible: 0\n }\n })({isProgressVisible})\n }]\n ]}>\n {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}\n {isPending &&\n <div\n className={style({\n position: 'absolute',\n top: '[50%]',\n left: '[50%]',\n transform: 'translate(-50%, -50%)',\n opacity: {\n default: 0,\n isProgressVisible: 1\n }\n })({isProgressVisible, isPending})}>\n {/* TODO: size based on t-shirt size once ProgressCircle supports custom sizes */}\n <ProgressCircle isIndeterminate aria-label={stringFormatter.format('button.pending')} size=\"S\" staticColor={staticColor} UNSAFE_style={{display: 'block'}} />\n </div>\n }\n </Provider>\n </RACButton>\n );\n}\n\n/**\n * Buttons allow users to perform an action.\n * They have multiple styles for various needs, and are ideal for calling attention to\n * where a user needs to do something in order to move forward in a flow.\n */\nlet _Button = forwardRef(Button);\nexport {_Button as Button};\n\nfunction LinkButton(props: LinkButtonProps, ref: FocusableRef<HTMLAnchorElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, LinkButtonContext);\n props = useFormProps(props);\n let domRef = useFocusableRef(ref);\n let overlayTriggerState = useContext(OverlayTriggerStateContext);\n\n return (\n <Link\n {...props}\n ref={domRef}\n style={pressScale(domRef, props.UNSAFE_style)}\n className={renderProps => (props.UNSAFE_className || '') + button({\n ...renderProps,\n // Retain hover styles when an overlay is open.\n isHovered: renderProps.isHovered || overlayTriggerState?.isOpen || false,\n variant: props.variant || 'primary',\n fillStyle: props.fillStyle || 'fill',\n size: props.size || 'M',\n staticColor: props.staticColor\n }, props.styles)}>\n <Provider\n values={[\n [SkeletonContext, null],\n [TextContext, {styles: style({paddingY: '--labelPadding', order: 1})}],\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: style({order: 0})}),\n styles: style({size: fontRelative(20), marginStart: '--iconMargin', flexShrink: 0})\n }]\n ]}>\n {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}\n </Provider>\n </Link>\n );\n}\n\n/**\n * A LinkButton combines the functionality of a link with the appearance of a button. Useful for allowing users to navigate to another page.\n */\nlet _LinkButton = forwardRef(LinkButton);\nexport {_LinkButton as LinkButton};\n"],"names":[],"version":3,"file":"Button.cjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAqDM,MAAM,0DAAgB,CAAA,GAAA,0BAAY,EAAmE;AACrG,MAAM,0DAAoB,CAAA,GAAA,0BAAY,EAAmE;AAEhH,MAAM,iCAAW;AACjB,MAAM;;;;;;;;;;;;;;;;;;;;;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9D,qBACE,gCAAC,CAAA,GAAA,+BAAG;QACD,GAAG,KAAK;QACT,KAAK;QACL,OAAO,CAAA,GAAA,oCAAS,EAAE,QAAQ,MAAM,YAAY;QAC5C,WAAW,CAAA,cAAe,AAAC,CAAA,MAAM,gBAAgB,IAAI,EAAC,IAAK,6BAAO;gBAChE,GAAG,WAAW;gBACd,+CAA+C;gBAC/C,WAAW,YAAY,SAAS,IAAI,qBAAqB,UAAU;gBACnE,SAAS,MAAM,OAAO,IAAI;gBAC1B,WAAW,MAAM,SAAS,IAAI;gBAC9B,MAAM,MAAM,IAAI,IAAI;gBACpB,aAAa,MAAM,WAAW;YAChC,GAAG,MAAM,MAAM;kBACf,cAAA,gCAAC,CAAA,GAAA,mCAAO;YACN,QAAQ;gBACN;oBAAC,CAAA,GAAA,yCAAc;oBAAG;iBAAK;gBACvB;oBAAC,CAAA,GAAA,qCAAU;oBAAG;wBACZ,MAAM;wBACN,kHAAkH;wBAClH,iBAAiB;oBACnB;iBAAE;gBACF;oBAAC,CAAA,GAAA,qCAAU;oBAAG;wBACZ,QAAQ,CAAA,GAAA,wCAAa,EAAE;4BAAC,MAAM;4BAAQ,MAAM;wBAAmB;wBAC/D,MAAM;oBACR;iBAAE;aACH;sBACA,OAAO,MAAM,QAAQ,KAAK,yBAAW,gCAAC,CAAA,GAAA,8BAAG;0BAAG,MAAM,QAAQ;iBAAW,MAAM,QAAQ;;;AAI5F;AAEA;;CAEC,GACD,IAAI,0DAAc,CAAA,GAAA,uBAAS,EAAE","sources":["packages/@react-spectrum/s2/src/Button.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {baseColor, fontRelative, style} from '../style/spectrum-theme' with {type: 'macro'};\nimport {ButtonRenderProps, ContextValue, Link, LinkProps, OverlayTriggerStateContext, Provider, Button as RACButton, ButtonProps as RACButtonProps} from 'react-aria-components';\nimport {centerBaseline} from './CenterBaseline';\nimport {centerPadding, focusRing, getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};\nimport {createContext, forwardRef, ReactNode, useContext, useEffect, useState} from 'react';\nimport {FocusableRef, FocusableRefValue} from '@react-types/shared';\nimport {IconContext} from './Icon';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {pressScale} from './pressScale';\nimport {ProgressCircle} from './ProgressCircle';\nimport {SkeletonContext} from './Skeleton';\nimport {Text, TextContext} from './Content';\nimport {useFocusableRef} from '@react-spectrum/utils';\nimport {useFormProps} from './Form';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\ninterface ButtonStyleProps {\n /**\n * The [visual style](https://spectrum.adobe.com/page/button/#Options) of the button.\n *\n * @default 'primary'\n */\n variant?: 'primary' | 'secondary' | 'accent' | 'negative',\n /**\n * The background style of the Button.\n *\n * @default 'fill'\n */\n fillStyle?: 'fill' | 'outline',\n /**\n * The size of the Button.\n *\n * @default 'M'\n */\n size?: 'S' | 'M' | 'L' | 'XL',\n /** The static color style to apply. Useful when the Button appears over a color background. */\n staticColor?: 'white' | 'black'\n}\n\nexport interface ButtonProps extends Omit<RACButtonProps, 'className' | 'style' | 'children' | 'onHover' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange'>, StyleProps, ButtonStyleProps {\n /** The content to display in the Button. */\n children?: ReactNode\n}\n\nexport interface LinkButtonProps extends Omit<LinkProps, 'className' | 'style' | 'children'>, StyleProps, ButtonStyleProps {\n /** The content to display in the Button. */\n children?: ReactNode\n}\n\nexport const ButtonContext = createContext<ContextValue<ButtonProps, FocusableRefValue<HTMLButtonElement>>>(null);\nexport const LinkButtonContext = createContext<ContextValue<ButtonProps, FocusableRefValue<HTMLAnchorElement>>>(null);\n\nconst iconOnly = ':has([slot=icon]):not(:has([data-rsp-slot=text]))';\nconst button = style<ButtonRenderProps & ButtonStyleProps>({\n ...focusRing(),\n position: 'relative',\n display: 'flex',\n alignItems: {\n default: 'baseline',\n [iconOnly]: 'center'\n },\n justifyContent: 'center',\n textAlign: 'start',\n columnGap: 'text-to-visual',\n font: 'control',\n fontWeight: 'bold',\n userSelect: 'none',\n minHeight: 'control',\n minWidth: {\n [iconOnly]: 'control'\n },\n borderRadius: 'pill',\n boxSizing: 'border-box',\n width: 'fit',\n textDecoration: 'none', // for link buttons\n paddingX: {\n default: 'pill',\n [iconOnly]: 0\n },\n paddingY: 0,\n aspectRatio: {\n [iconOnly]: 'square'\n },\n transition: 'default',\n borderStyle: 'solid',\n borderWidth: {\n fillStyle: {\n fill: 0,\n outline: 2\n }\n },\n '--labelPadding': {\n type: 'paddingTop',\n value: centerPadding()\n },\n '--iconMargin': {\n type: 'marginTop',\n value: {\n default: fontRelative(-2),\n [iconOnly]: 0\n }\n },\n borderColor: {\n variant: {\n primary: baseColor('gray-800'),\n secondary: baseColor('gray-300')\n },\n isDisabled: 'disabled',\n staticColor: {\n white: {\n variant: {\n primary: baseColor('transparent-white-800'),\n secondary: baseColor('transparent-white-300')\n },\n isDisabled: 'transparent-white-300'\n },\n black: {\n variant: {\n primary: baseColor('transparent-black-800'),\n secondary: baseColor('transparent-black-300')\n },\n isDisabled: 'transparent-black-300'\n }\n },\n forcedColors: {\n default: 'ButtonBorder',\n isHovered: 'Highlight',\n isDisabled: 'GrayText'\n }\n },\n backgroundColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'neutral',\n secondary: baseColor('gray-100'),\n accent: 'accent',\n negative: 'negative'\n },\n isDisabled: 'disabled'\n },\n outline: {\n default: 'transparent',\n isHovered: 'gray-100',\n isPressed: 'gray-100',\n isFocusVisible: 'gray-100',\n isDisabled: 'transparent'\n }\n },\n staticColor: {\n white: {\n fillStyle: {\n fill: {\n variant: {\n primary: baseColor('transparent-white-800'),\n secondary: baseColor('transparent-white-100')\n },\n isDisabled: 'transparent-white-100'\n },\n outline: {\n default: 'transparent',\n isHovered: 'transparent-white-100',\n isPressed: 'transparent-white-100',\n isFocusVisible: 'transparent-white-100',\n isDisabled: 'transparent'\n }\n }\n },\n black: {\n fillStyle: {\n fill: {\n variant: {\n primary: baseColor('transparent-black-800'),\n secondary: baseColor('transparent-black-100')\n },\n isDisabled: 'transparent-black-100'\n },\n outline: {\n default: 'transparent',\n isHovered: 'transparent-black-100',\n isPressed: 'transparent-black-100',\n isFocusVisible: 'transparent-black-100',\n isDisabled: 'transparent'\n }\n }\n }\n },\n forcedColors: {\n fillStyle: {\n fill: {\n default: 'ButtonText',\n isHovered: 'Highlight',\n isDisabled: 'GrayText'\n },\n outline: 'ButtonFace'\n }\n }\n },\n color: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'gray-25',\n secondary: 'neutral',\n accent: 'white',\n negative: 'white'\n },\n isDisabled: 'disabled'\n },\n outline: {\n default: 'neutral',\n isDisabled: 'disabled'\n }\n },\n staticColor: {\n white: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'black',\n secondary: baseColor('transparent-white-800')\n }\n },\n outline: baseColor('transparent-white-800')\n },\n isDisabled: 'transparent-white-400'\n },\n black: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'white',\n secondary: baseColor('transparent-black-800')\n }\n },\n outline: baseColor('transparent-black-800')\n },\n isDisabled: 'transparent-black-400'\n }\n },\n forcedColors: {\n fillStyle: {\n fill: {\n default: 'ButtonFace',\n isDisabled: 'HighlightText'\n },\n outline: {\n default: 'ButtonText',\n isDisabled: 'GrayText'\n }\n }\n }\n },\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n },\n outlineColor: {\n default: 'focus-ring',\n staticColor: {\n white: 'white',\n black: 'black'\n },\n forcedColors: 'Highlight'\n },\n forcedColorAdjust: 'none',\n disableTapHighlight: true\n}, getAllowedOverrides());\n\nfunction Button(props: ButtonProps, ref: FocusableRef<HTMLButtonElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, ButtonContext);\n props = useFormProps(props);\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/s2');\n let {\n isPending,\n variant = 'primary',\n fillStyle = 'fill',\n size = 'M',\n staticColor\n } = props;\n let domRef = useFocusableRef(ref);\n let overlayTriggerState = useContext(OverlayTriggerStateContext);\n\n let [isProgressVisible, setIsProgressVisible] = useState(false);\n useEffect(() => {\n let timeout: ReturnType<typeof setTimeout>;\n\n if (isPending) {\n // Start timer when isPending is set to true.\n timeout = setTimeout(() => {\n setIsProgressVisible(true);\n }, 1000);\n } else {\n // Exit loading state when isPending is set to false. */\n setIsProgressVisible(false);\n }\n return () => {\n // Clean up on unmount or when user removes isPending prop before entering loading state.\n clearTimeout(timeout);\n };\n }, [isPending]);\n\n return (\n <RACButton\n {...props}\n ref={domRef}\n style={pressScale(domRef, props.UNSAFE_style)}\n className={renderProps => (props.UNSAFE_className || '') + button({\n ...renderProps,\n // Retain hover styles when an overlay is open.\n isHovered: renderProps.isHovered || overlayTriggerState?.isOpen || false,\n isDisabled: renderProps.isDisabled || isProgressVisible,\n variant,\n fillStyle,\n size,\n staticColor\n }, props.styles)}>\n <Provider\n values={[\n [SkeletonContext, null],\n [TextContext, {\n styles: style({\n paddingY: '--labelPadding',\n order: 1,\n opacity: {\n default: 1,\n isProgressVisible: 0\n }\n })({isProgressVisible}),\n // @ts-ignore data-attributes allowed on all JSX elements, but adding to DOMProps has been problematic in the past\n 'data-rsp-slot': 'text'\n }],\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: style({order: 0})}),\n styles: style({\n size: fontRelative(20),\n marginStart: '--iconMargin',\n flexShrink: 0,\n opacity: {\n default: 1,\n isProgressVisible: 0\n }\n })({isProgressVisible})\n }]\n ]}>\n {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}\n {isPending &&\n <div\n className={style({\n position: 'absolute',\n top: '[50%]',\n left: '[50%]',\n transform: 'translate(-50%, -50%)',\n opacity: {\n default: 0,\n isProgressVisible: 1\n }\n })({isProgressVisible, isPending})}>\n {/* TODO: size based on t-shirt size once ProgressCircle supports custom sizes */}\n <ProgressCircle isIndeterminate aria-label={stringFormatter.format('button.pending')} size=\"S\" staticColor={staticColor} UNSAFE_style={{display: 'block'}} />\n </div>\n }\n </Provider>\n </RACButton>\n );\n}\n\n/**\n * Buttons allow users to perform an action.\n * They have multiple styles for various needs, and are ideal for calling attention to\n * where a user needs to do something in order to move forward in a flow.\n */\nlet _Button = forwardRef(Button);\nexport {_Button as Button};\n\nfunction LinkButton(props: LinkButtonProps, ref: FocusableRef<HTMLAnchorElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, LinkButtonContext);\n props = useFormProps(props);\n let domRef = useFocusableRef(ref);\n let overlayTriggerState = useContext(OverlayTriggerStateContext);\n\n return (\n <Link\n {...props}\n ref={domRef}\n style={pressScale(domRef, props.UNSAFE_style)}\n className={renderProps => (props.UNSAFE_className || '') + button({\n ...renderProps,\n // Retain hover styles when an overlay is open.\n isHovered: renderProps.isHovered || overlayTriggerState?.isOpen || false,\n variant: props.variant || 'primary',\n fillStyle: props.fillStyle || 'fill',\n size: props.size || 'M',\n staticColor: props.staticColor\n }, props.styles)}>\n <Provider\n values={[\n [SkeletonContext, null],\n [TextContext, {\n styles: style({paddingY: '--labelPadding', order: 1}),\n // @ts-ignore data-attributes allowed on all JSX elements, but adding to DOMProps has been problematic in the past\n 'data-rsp-slot': 'text'\n }],\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: style({order: 0})}),\n styles: style({size: fontRelative(20), marginStart: '--iconMargin', flexShrink: 0})\n }]\n ]}>\n {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}\n </Provider>\n </Link>\n );\n}\n\n/**\n * A LinkButton combines the functionality of a link with the appearance of a button. Useful for allowing users to navigate to another page.\n */\nlet _LinkButton = forwardRef(LinkButton);\nexport {_LinkButton as LinkButton};\n"],"names":[],"version":3,"file":"Button.cjs.map"}
|
package/dist/Button.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"ACkEe;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAoSQ;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAkDU;;;;EAAA;;;;EAAA;;;;EAEyB;;;;EACtC;;;;EAAA;;;;EAAA;;;;EAAA;;;;;AAzVL;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;;AAAA;EAAA;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;;;AAAA;EAAA;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;;;AAAA;EAAA;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;;;AA2QkB","sources":["47c518d02ef77298","packages/@react-spectrum/s2/src/Button.tsx"],"sourcesContent":["@import \"84fda4530d887d61\";\n@import \"58029840d81c849c\";\n@import \"741c49b4968f5e00\";\n@import \"d2d5d6a0faea83be\";\n@import \"7420f4e12e7ef59c\";\n@import \"b849e4ca63c3cc49\";\n@import \"36ff0e1e9ec0e357\";\n@import \"5ed629d4d0b8048c\";\n","/*\n * Copyright 2024 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 {baseColor, fontRelative, style} from '../style/spectrum-theme' with {type: 'macro'};\nimport {ButtonRenderProps, ContextValue, Link, LinkProps, OverlayTriggerStateContext, Provider, Button as RACButton, ButtonProps as RACButtonProps} from 'react-aria-components';\nimport {centerBaseline} from './CenterBaseline';\nimport {centerPadding, focusRing, getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};\nimport {createContext, forwardRef, ReactNode, useContext, useEffect, useState} from 'react';\nimport {FocusableRef, FocusableRefValue} from '@react-types/shared';\nimport {IconContext} from './Icon';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {pressScale} from './pressScale';\nimport {ProgressCircle} from './ProgressCircle';\nimport {SkeletonContext} from './Skeleton';\nimport {Text, TextContext} from './Content';\nimport {useFocusableRef} from '@react-spectrum/utils';\nimport {useFormProps} from './Form';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\ninterface ButtonStyleProps {\n /**\n * The [visual style](https://spectrum.adobe.com/page/button/#Options) of the button.\n *\n * @default 'primary'\n */\n variant?: 'primary' | 'secondary' | 'accent' | 'negative',\n /**\n * The background style of the Button.\n *\n * @default 'fill'\n */\n fillStyle?: 'fill' | 'outline',\n /**\n * The size of the Button.\n *\n * @default 'M'\n */\n size?: 'S' | 'M' | 'L' | 'XL',\n /** The static color style to apply. Useful when the Button appears over a color background. */\n staticColor?: 'white' | 'black'\n}\n\nexport interface ButtonProps extends Omit<RACButtonProps, 'className' | 'style' | 'children' | 'onHover' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange'>, StyleProps, ButtonStyleProps {\n /** The content to display in the Button. */\n children?: ReactNode\n}\n\nexport interface LinkButtonProps extends Omit<LinkProps, 'className' | 'style' | 'children'>, StyleProps, ButtonStyleProps {\n /** The content to display in the Button. */\n children?: ReactNode\n}\n\nexport const ButtonContext = createContext<ContextValue<ButtonProps, FocusableRefValue<HTMLButtonElement>>>(null);\nexport const LinkButtonContext = createContext<ContextValue<ButtonProps, FocusableRefValue<HTMLAnchorElement>>>(null);\n\nconst button = style<ButtonRenderProps & ButtonStyleProps>({\n ...focusRing(),\n position: 'relative',\n display: 'flex',\n alignItems: {\n default: 'baseline',\n ':has([slot=icon]):not(:has([data-rsp-slot=text]))': 'center'\n },\n justifyContent: 'center',\n textAlign: 'start',\n columnGap: 'text-to-visual',\n font: 'control',\n fontWeight: 'bold',\n userSelect: 'none',\n minHeight: 'control',\n minWidth: {\n ':has([slot=icon]):not(:has([data-rsp-slot=text]))': 'control'\n },\n borderRadius: 'pill',\n boxSizing: 'border-box',\n width: 'fit',\n textDecoration: 'none', // for link buttons\n paddingX: {\n default: 'pill',\n ':has([slot=icon]):not(:has([data-rsp-slot=text]))': 0\n },\n paddingY: 0,\n aspectRatio: {\n ':has([slot=icon]):not(:has([data-rsp-slot=text]))': 'square'\n },\n transition: 'default',\n borderStyle: 'solid',\n borderWidth: {\n fillStyle: {\n fill: 0,\n outline: 2\n }\n },\n '--labelPadding': {\n type: 'paddingTop',\n value: centerPadding()\n },\n '--iconMargin': {\n type: 'marginTop',\n value: {\n default: fontRelative(-2),\n ':has([slot=icon]):not(:has([data-rsp-slot=text]))': 0\n }\n },\n borderColor: {\n variant: {\n primary: baseColor('gray-800'),\n secondary: baseColor('gray-300')\n },\n isDisabled: 'disabled',\n staticColor: {\n white: {\n variant: {\n primary: baseColor('transparent-white-800'),\n secondary: baseColor('transparent-white-300')\n },\n isDisabled: 'transparent-white-300'\n },\n black: {\n variant: {\n primary: baseColor('transparent-black-800'),\n secondary: baseColor('transparent-black-300')\n },\n isDisabled: 'transparent-black-300'\n }\n },\n forcedColors: {\n default: 'ButtonBorder',\n isHovered: 'Highlight',\n isDisabled: 'GrayText'\n }\n },\n backgroundColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'neutral',\n secondary: baseColor('gray-100'),\n accent: 'accent',\n negative: 'negative'\n },\n isDisabled: 'disabled'\n },\n outline: {\n default: 'transparent',\n isHovered: 'gray-100',\n isPressed: 'gray-100',\n isFocusVisible: 'gray-100',\n isDisabled: 'transparent'\n }\n },\n staticColor: {\n white: {\n fillStyle: {\n fill: {\n variant: {\n primary: baseColor('transparent-white-800'),\n secondary: baseColor('transparent-white-100')\n },\n isDisabled: 'transparent-white-100'\n },\n outline: {\n default: 'transparent',\n isHovered: 'transparent-white-100',\n isPressed: 'transparent-white-100',\n isFocusVisible: 'transparent-white-100',\n isDisabled: 'transparent'\n }\n }\n },\n black: {\n fillStyle: {\n fill: {\n variant: {\n primary: baseColor('transparent-black-800'),\n secondary: baseColor('transparent-black-100')\n },\n isDisabled: 'transparent-black-100'\n },\n outline: {\n default: 'transparent',\n isHovered: 'transparent-black-100',\n isPressed: 'transparent-black-100',\n isFocusVisible: 'transparent-black-100',\n isDisabled: 'transparent'\n }\n }\n }\n },\n forcedColors: {\n fillStyle: {\n fill: {\n default: 'ButtonText',\n isHovered: 'Highlight',\n isDisabled: 'GrayText'\n },\n outline: 'ButtonFace'\n }\n }\n },\n color: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'gray-25',\n secondary: 'neutral',\n accent: 'white',\n negative: 'white'\n },\n isDisabled: 'disabled'\n },\n outline: {\n default: 'neutral',\n isDisabled: 'disabled'\n }\n },\n staticColor: {\n white: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'black',\n secondary: baseColor('transparent-white-800')\n }\n },\n outline: baseColor('transparent-white-800')\n },\n isDisabled: 'transparent-white-400'\n },\n black: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'white',\n secondary: baseColor('transparent-black-800')\n }\n },\n outline: baseColor('transparent-black-800')\n },\n isDisabled: 'transparent-black-400'\n }\n },\n forcedColors: {\n fillStyle: {\n fill: {\n default: 'ButtonFace',\n isDisabled: 'HighlightText'\n },\n outline: {\n default: 'ButtonText',\n isDisabled: 'GrayText'\n }\n }\n }\n },\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n },\n outlineColor: {\n default: 'focus-ring',\n staticColor: {\n white: 'white',\n black: 'black'\n },\n forcedColors: 'Highlight'\n },\n forcedColorAdjust: 'none',\n disableTapHighlight: true\n}, getAllowedOverrides());\n\nfunction Button(props: ButtonProps, ref: FocusableRef<HTMLButtonElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, ButtonContext);\n props = useFormProps(props);\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/s2');\n let {\n isPending,\n variant = 'primary',\n fillStyle = 'fill',\n size = 'M',\n staticColor\n } = props;\n let domRef = useFocusableRef(ref);\n let overlayTriggerState = useContext(OverlayTriggerStateContext);\n\n let [isProgressVisible, setIsProgressVisible] = useState(false);\n useEffect(() => {\n let timeout: ReturnType<typeof setTimeout>;\n\n if (isPending) {\n // Start timer when isPending is set to true.\n timeout = setTimeout(() => {\n setIsProgressVisible(true);\n }, 1000);\n } else {\n // Exit loading state when isPending is set to false. */\n setIsProgressVisible(false);\n }\n return () => {\n // Clean up on unmount or when user removes isPending prop before entering loading state.\n clearTimeout(timeout);\n };\n }, [isPending]);\n\n return (\n <RACButton\n {...props}\n ref={domRef}\n style={pressScale(domRef, props.UNSAFE_style)}\n className={renderProps => (props.UNSAFE_className || '') + button({\n ...renderProps,\n // Retain hover styles when an overlay is open.\n isHovered: renderProps.isHovered || overlayTriggerState?.isOpen || false,\n isDisabled: renderProps.isDisabled || isProgressVisible,\n variant,\n fillStyle,\n size,\n staticColor\n }, props.styles)}>\n <Provider\n values={[\n [SkeletonContext, null],\n [TextContext, {styles: style({\n paddingY: '--labelPadding',\n order: 1,\n opacity: {\n default: 1,\n isProgressVisible: 0\n }\n // @ts-ignore data-attributes allowed on all JSX elements, but adding to DOMProps has been problematic in the past\n })({isProgressVisible}), 'data-rsp-slot': 'text'}],\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: style({order: 0})}),\n styles: style({\n size: fontRelative(20),\n marginStart: '--iconMargin',\n flexShrink: 0,\n opacity: {\n default: 1,\n isProgressVisible: 0\n }\n })({isProgressVisible})\n }]\n ]}>\n {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}\n {isPending &&\n <div\n className={style({\n position: 'absolute',\n top: '[50%]',\n left: '[50%]',\n transform: 'translate(-50%, -50%)',\n opacity: {\n default: 0,\n isProgressVisible: 1\n }\n })({isProgressVisible, isPending})}>\n {/* TODO: size based on t-shirt size once ProgressCircle supports custom sizes */}\n <ProgressCircle isIndeterminate aria-label={stringFormatter.format('button.pending')} size=\"S\" staticColor={staticColor} UNSAFE_style={{display: 'block'}} />\n </div>\n }\n </Provider>\n </RACButton>\n );\n}\n\n/**\n * Buttons allow users to perform an action.\n * They have multiple styles for various needs, and are ideal for calling attention to\n * where a user needs to do something in order to move forward in a flow.\n */\nlet _Button = forwardRef(Button);\nexport {_Button as Button};\n\nfunction LinkButton(props: LinkButtonProps, ref: FocusableRef<HTMLAnchorElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, LinkButtonContext);\n props = useFormProps(props);\n let domRef = useFocusableRef(ref);\n let overlayTriggerState = useContext(OverlayTriggerStateContext);\n\n return (\n <Link\n {...props}\n ref={domRef}\n style={pressScale(domRef, props.UNSAFE_style)}\n className={renderProps => (props.UNSAFE_className || '') + button({\n ...renderProps,\n // Retain hover styles when an overlay is open.\n isHovered: renderProps.isHovered || overlayTriggerState?.isOpen || false,\n variant: props.variant || 'primary',\n fillStyle: props.fillStyle || 'fill',\n size: props.size || 'M',\n staticColor: props.staticColor\n }, props.styles)}>\n <Provider\n values={[\n [SkeletonContext, null],\n [TextContext, {styles: style({paddingY: '--labelPadding', order: 1})}],\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: style({order: 0})}),\n styles: style({size: fontRelative(20), marginStart: '--iconMargin', flexShrink: 0})\n }]\n ]}>\n {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}\n </Provider>\n </Link>\n );\n}\n\n/**\n * A LinkButton combines the functionality of a link with the appearance of a button. Useful for allowing users to navigate to another page.\n */\nlet _LinkButton = forwardRef(LinkButton);\nexport {_LinkButton as LinkButton};\n"],"names":[],"version":3,"file":"Button.css.map"}
|
|
1
|
+
{"mappings":"ACmEe;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;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EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;;AAAA;EAAA;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;;;AAAA;EAAA;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;;;AAAA;EAAA;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;;;AA4QK","sources":["47c518d02ef77298","packages/@react-spectrum/s2/src/Button.tsx"],"sourcesContent":["@import \"84fda4530d887d61\";\n@import \"58029840d81c849c\";\n@import \"741c49b4968f5e00\";\n@import \"d2d5d6a0faea83be\";\n@import \"7420f4e12e7ef59c\";\n@import \"b849e4ca63c3cc49\";\n@import \"36ff0e1e9ec0e357\";\n@import \"5ed629d4d0b8048c\";\n","/*\n * Copyright 2024 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 {baseColor, fontRelative, style} from '../style/spectrum-theme' with {type: 'macro'};\nimport {ButtonRenderProps, ContextValue, Link, LinkProps, OverlayTriggerStateContext, Provider, Button as RACButton, ButtonProps as RACButtonProps} from 'react-aria-components';\nimport {centerBaseline} from './CenterBaseline';\nimport {centerPadding, focusRing, getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};\nimport {createContext, forwardRef, ReactNode, useContext, useEffect, useState} from 'react';\nimport {FocusableRef, FocusableRefValue} from '@react-types/shared';\nimport {IconContext} from './Icon';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {pressScale} from './pressScale';\nimport {ProgressCircle} from './ProgressCircle';\nimport {SkeletonContext} from './Skeleton';\nimport {Text, TextContext} from './Content';\nimport {useFocusableRef} from '@react-spectrum/utils';\nimport {useFormProps} from './Form';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\ninterface ButtonStyleProps {\n /**\n * The [visual style](https://spectrum.adobe.com/page/button/#Options) of the button.\n *\n * @default 'primary'\n */\n variant?: 'primary' | 'secondary' | 'accent' | 'negative',\n /**\n * The background style of the Button.\n *\n * @default 'fill'\n */\n fillStyle?: 'fill' | 'outline',\n /**\n * The size of the Button.\n *\n * @default 'M'\n */\n size?: 'S' | 'M' | 'L' | 'XL',\n /** The static color style to apply. Useful when the Button appears over a color background. */\n staticColor?: 'white' | 'black'\n}\n\nexport interface ButtonProps extends Omit<RACButtonProps, 'className' | 'style' | 'children' | 'onHover' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange'>, StyleProps, ButtonStyleProps {\n /** The content to display in the Button. */\n children?: ReactNode\n}\n\nexport interface LinkButtonProps extends Omit<LinkProps, 'className' | 'style' | 'children'>, StyleProps, ButtonStyleProps {\n /** The content to display in the Button. */\n children?: ReactNode\n}\n\nexport const ButtonContext = createContext<ContextValue<ButtonProps, FocusableRefValue<HTMLButtonElement>>>(null);\nexport const LinkButtonContext = createContext<ContextValue<ButtonProps, FocusableRefValue<HTMLAnchorElement>>>(null);\n\nconst iconOnly = ':has([slot=icon]):not(:has([data-rsp-slot=text]))';\nconst button = style<ButtonRenderProps & ButtonStyleProps>({\n ...focusRing(),\n position: 'relative',\n display: 'flex',\n alignItems: {\n default: 'baseline',\n [iconOnly]: 'center'\n },\n justifyContent: 'center',\n textAlign: 'start',\n columnGap: 'text-to-visual',\n font: 'control',\n fontWeight: 'bold',\n userSelect: 'none',\n minHeight: 'control',\n minWidth: {\n [iconOnly]: 'control'\n },\n borderRadius: 'pill',\n boxSizing: 'border-box',\n width: 'fit',\n textDecoration: 'none', // for link buttons\n paddingX: {\n default: 'pill',\n [iconOnly]: 0\n },\n paddingY: 0,\n aspectRatio: {\n [iconOnly]: 'square'\n },\n transition: 'default',\n borderStyle: 'solid',\n borderWidth: {\n fillStyle: {\n fill: 0,\n outline: 2\n }\n },\n '--labelPadding': {\n type: 'paddingTop',\n value: centerPadding()\n },\n '--iconMargin': {\n type: 'marginTop',\n value: {\n default: fontRelative(-2),\n [iconOnly]: 0\n }\n },\n borderColor: {\n variant: {\n primary: baseColor('gray-800'),\n secondary: baseColor('gray-300')\n },\n isDisabled: 'disabled',\n staticColor: {\n white: {\n variant: {\n primary: baseColor('transparent-white-800'),\n secondary: baseColor('transparent-white-300')\n },\n isDisabled: 'transparent-white-300'\n },\n black: {\n variant: {\n primary: baseColor('transparent-black-800'),\n secondary: baseColor('transparent-black-300')\n },\n isDisabled: 'transparent-black-300'\n }\n },\n forcedColors: {\n default: 'ButtonBorder',\n isHovered: 'Highlight',\n isDisabled: 'GrayText'\n }\n },\n backgroundColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'neutral',\n secondary: baseColor('gray-100'),\n accent: 'accent',\n negative: 'negative'\n },\n isDisabled: 'disabled'\n },\n outline: {\n default: 'transparent',\n isHovered: 'gray-100',\n isPressed: 'gray-100',\n isFocusVisible: 'gray-100',\n isDisabled: 'transparent'\n }\n },\n staticColor: {\n white: {\n fillStyle: {\n fill: {\n variant: {\n primary: baseColor('transparent-white-800'),\n secondary: baseColor('transparent-white-100')\n },\n isDisabled: 'transparent-white-100'\n },\n outline: {\n default: 'transparent',\n isHovered: 'transparent-white-100',\n isPressed: 'transparent-white-100',\n isFocusVisible: 'transparent-white-100',\n isDisabled: 'transparent'\n }\n }\n },\n black: {\n fillStyle: {\n fill: {\n variant: {\n primary: baseColor('transparent-black-800'),\n secondary: baseColor('transparent-black-100')\n },\n isDisabled: 'transparent-black-100'\n },\n outline: {\n default: 'transparent',\n isHovered: 'transparent-black-100',\n isPressed: 'transparent-black-100',\n isFocusVisible: 'transparent-black-100',\n isDisabled: 'transparent'\n }\n }\n }\n },\n forcedColors: {\n fillStyle: {\n fill: {\n default: 'ButtonText',\n isHovered: 'Highlight',\n isDisabled: 'GrayText'\n },\n outline: 'ButtonFace'\n }\n }\n },\n color: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'gray-25',\n secondary: 'neutral',\n accent: 'white',\n negative: 'white'\n },\n isDisabled: 'disabled'\n },\n outline: {\n default: 'neutral',\n isDisabled: 'disabled'\n }\n },\n staticColor: {\n white: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'black',\n secondary: baseColor('transparent-white-800')\n }\n },\n outline: baseColor('transparent-white-800')\n },\n isDisabled: 'transparent-white-400'\n },\n black: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'white',\n secondary: baseColor('transparent-black-800')\n }\n },\n outline: baseColor('transparent-black-800')\n },\n isDisabled: 'transparent-black-400'\n }\n },\n forcedColors: {\n fillStyle: {\n fill: {\n default: 'ButtonFace',\n isDisabled: 'HighlightText'\n },\n outline: {\n default: 'ButtonText',\n isDisabled: 'GrayText'\n }\n }\n }\n },\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n },\n outlineColor: {\n default: 'focus-ring',\n staticColor: {\n white: 'white',\n black: 'black'\n },\n forcedColors: 'Highlight'\n },\n forcedColorAdjust: 'none',\n disableTapHighlight: true\n}, getAllowedOverrides());\n\nfunction Button(props: ButtonProps, ref: FocusableRef<HTMLButtonElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, ButtonContext);\n props = useFormProps(props);\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/s2');\n let {\n isPending,\n variant = 'primary',\n fillStyle = 'fill',\n size = 'M',\n staticColor\n } = props;\n let domRef = useFocusableRef(ref);\n let overlayTriggerState = useContext(OverlayTriggerStateContext);\n\n let [isProgressVisible, setIsProgressVisible] = useState(false);\n useEffect(() => {\n let timeout: ReturnType<typeof setTimeout>;\n\n if (isPending) {\n // Start timer when isPending is set to true.\n timeout = setTimeout(() => {\n setIsProgressVisible(true);\n }, 1000);\n } else {\n // Exit loading state when isPending is set to false. */\n setIsProgressVisible(false);\n }\n return () => {\n // Clean up on unmount or when user removes isPending prop before entering loading state.\n clearTimeout(timeout);\n };\n }, [isPending]);\n\n return (\n <RACButton\n {...props}\n ref={domRef}\n style={pressScale(domRef, props.UNSAFE_style)}\n className={renderProps => (props.UNSAFE_className || '') + button({\n ...renderProps,\n // Retain hover styles when an overlay is open.\n isHovered: renderProps.isHovered || overlayTriggerState?.isOpen || false,\n isDisabled: renderProps.isDisabled || isProgressVisible,\n variant,\n fillStyle,\n size,\n staticColor\n }, props.styles)}>\n <Provider\n values={[\n [SkeletonContext, null],\n [TextContext, {\n styles: style({\n paddingY: '--labelPadding',\n order: 1,\n opacity: {\n default: 1,\n isProgressVisible: 0\n }\n })({isProgressVisible}),\n // @ts-ignore data-attributes allowed on all JSX elements, but adding to DOMProps has been problematic in the past\n 'data-rsp-slot': 'text'\n }],\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: style({order: 0})}),\n styles: style({\n size: fontRelative(20),\n marginStart: '--iconMargin',\n flexShrink: 0,\n opacity: {\n default: 1,\n isProgressVisible: 0\n }\n })({isProgressVisible})\n }]\n ]}>\n {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}\n {isPending &&\n <div\n className={style({\n position: 'absolute',\n top: '[50%]',\n left: '[50%]',\n transform: 'translate(-50%, -50%)',\n opacity: {\n default: 0,\n isProgressVisible: 1\n }\n })({isProgressVisible, isPending})}>\n {/* TODO: size based on t-shirt size once ProgressCircle supports custom sizes */}\n <ProgressCircle isIndeterminate aria-label={stringFormatter.format('button.pending')} size=\"S\" staticColor={staticColor} UNSAFE_style={{display: 'block'}} />\n </div>\n }\n </Provider>\n </RACButton>\n );\n}\n\n/**\n * Buttons allow users to perform an action.\n * They have multiple styles for various needs, and are ideal for calling attention to\n * where a user needs to do something in order to move forward in a flow.\n */\nlet _Button = forwardRef(Button);\nexport {_Button as Button};\n\nfunction LinkButton(props: LinkButtonProps, ref: FocusableRef<HTMLAnchorElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, LinkButtonContext);\n props = useFormProps(props);\n let domRef = useFocusableRef(ref);\n let overlayTriggerState = useContext(OverlayTriggerStateContext);\n\n return (\n <Link\n {...props}\n ref={domRef}\n style={pressScale(domRef, props.UNSAFE_style)}\n className={renderProps => (props.UNSAFE_className || '') + button({\n ...renderProps,\n // Retain hover styles when an overlay is open.\n isHovered: renderProps.isHovered || overlayTriggerState?.isOpen || false,\n variant: props.variant || 'primary',\n fillStyle: props.fillStyle || 'fill',\n size: props.size || 'M',\n staticColor: props.staticColor\n }, props.styles)}>\n <Provider\n values={[\n [SkeletonContext, null],\n [TextContext, {\n styles: style({paddingY: '--labelPadding', order: 1}),\n // @ts-ignore data-attributes allowed on all JSX elements, but adding to DOMProps has been problematic in the past\n 'data-rsp-slot': 'text'\n }],\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: style({order: 0})}),\n styles: style({size: fontRelative(20), marginStart: '--iconMargin', flexShrink: 0})\n }]\n ]}>\n {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}\n </Provider>\n </Link>\n );\n}\n\n/**\n * A LinkButton combines the functionality of a link with the appearance of a button. Useful for allowing users to navigate to another page.\n */\nlet _LinkButton = forwardRef(LinkButton);\nexport {_LinkButton as LinkButton};\n"],"names":[],"version":3,"file":"Button.css.map"}
|
package/dist/Button.mjs
CHANGED
|
@@ -44,6 +44,7 @@ function $parcel$interopDefault(a) {
|
|
|
44
44
|
|
|
45
45
|
const $067ea9f64ccd4e8e$export$24d547caef80ccd1 = /*#__PURE__*/ (0, $7BBHC$createContext)(null);
|
|
46
46
|
const $067ea9f64ccd4e8e$export$1c1a176f3b9e48d3 = /*#__PURE__*/ (0, $7BBHC$createContext)(null);
|
|
47
|
+
const $067ea9f64ccd4e8e$var$iconOnly = ':has([slot=icon]):not(:has([data-rsp-slot=text]))';
|
|
47
48
|
const $067ea9f64ccd4e8e$var$button = function anonymous(props, overrides) {
|
|
48
49
|
let rules = " .";
|
|
49
50
|
let matches = (overrides || '').match(/(?:^|\s)(?:y|z|A|B|_9|_8|h|_5|_4|__A|__c|__d|__a|__b|U|__Q|X|Z|V|W|l|q|r)[^\s]+/g) || [];
|
|
@@ -403,6 +404,7 @@ function $067ea9f64ccd4e8e$var$Button(props1, ref) {
|
|
|
403
404
|
}({
|
|
404
405
|
isProgressVisible: isProgressVisible
|
|
405
406
|
}),
|
|
407
|
+
// @ts-ignore data-attributes allowed on all JSX elements, but adding to DOMProps has been problematic in the past
|
|
406
408
|
'data-rsp-slot': 'text'
|
|
407
409
|
}
|
|
408
410
|
],
|
|
@@ -492,7 +494,9 @@ function $067ea9f64ccd4e8e$var$LinkButton(props, ref) {
|
|
|
492
494
|
[
|
|
493
495
|
(0, $8e847109a6ab556d$export$9afb8bc826b033ea),
|
|
494
496
|
{
|
|
495
|
-
styles: " . E-1gogtue F-1gogtue __A-3t1y"
|
|
497
|
+
styles: " . E-1gogtue F-1gogtue __A-3t1y",
|
|
498
|
+
// @ts-ignore data-attributes allowed on all JSX elements, but adding to DOMProps has been problematic in the past
|
|
499
|
+
'data-rsp-slot': 'text'
|
|
496
500
|
}
|
|
497
501
|
],
|
|
498
502
|
[
|
package/dist/Button.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAqDM,MAAM,0DAAgB,CAAA,GAAA,oBAAY,EAAmE;AACrG,MAAM,0DAAoB,CAAA,GAAA,oBAAY,EAAmE;AAEhH,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAW,CAAA,cAAe,AAAC,CAAA,MAAM,gBAAgB,IAAI,EAAC,IAAK,6BAAO;gBAChE,GAAG,WAAW;gBACd,+CAA+C;gBAC/C,WAAW,YAAY,SAAS,IAAI,qBAAqB,UAAU;gBACnE,SAAS,MAAM,OAAO,IAAI;gBAC1B,WAAW,MAAM,SAAS,IAAI;gBAC9B,MAAM,MAAM,IAAI,IAAI;gBACpB,aAAa,MAAM,WAAW;YAChC,GAAG,MAAM,MAAM;kBACf,cAAA,gBAAC,CAAA,GAAA,eAAO;YACN,QAAQ;gBACN;oBAAC,CAAA,GAAA,yCAAc;oBAAG;iBAAK;gBACvB;oBAAC,CAAA,GAAA,yCAAU;oBAAG;wBAAC,MAAM;oBAA+C;iBAAE;gBACtE;oBAAC,CAAA,GAAA,yCAAU;oBAAG;wBACZ,QAAQ,CAAA,GAAA,yCAAa,EAAE;4BAAC,MAAM;4BAAQ,MAAM;wBAAmB;wBAC/D,MAAM;oBACR;iBAAE;aACH;sBACA,OAAO,MAAM,QAAQ,KAAK,yBAAW,gBAAC,CAAA,GAAA,yCAAG;0BAAG,MAAM,QAAQ;iBAAW,MAAM,QAAQ;;;AAI5F;AAEA;;CAEC,GACD,IAAI,0DAAc,CAAA,GAAA,iBAAS,EAAE","sources":["packages/@react-spectrum/s2/src/Button.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {baseColor, fontRelative, style} from '../style/spectrum-theme' with {type: 'macro'};\nimport {ButtonRenderProps, ContextValue, Link, LinkProps, OverlayTriggerStateContext, Provider, Button as RACButton, ButtonProps as RACButtonProps} from 'react-aria-components';\nimport {centerBaseline} from './CenterBaseline';\nimport {centerPadding, focusRing, getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};\nimport {createContext, forwardRef, ReactNode, useContext, useEffect, useState} from 'react';\nimport {FocusableRef, FocusableRefValue} from '@react-types/shared';\nimport {IconContext} from './Icon';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {pressScale} from './pressScale';\nimport {ProgressCircle} from './ProgressCircle';\nimport {SkeletonContext} from './Skeleton';\nimport {Text, TextContext} from './Content';\nimport {useFocusableRef} from '@react-spectrum/utils';\nimport {useFormProps} from './Form';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\ninterface ButtonStyleProps {\n /**\n * The [visual style](https://spectrum.adobe.com/page/button/#Options) of the button.\n *\n * @default 'primary'\n */\n variant?: 'primary' | 'secondary' | 'accent' | 'negative',\n /**\n * The background style of the Button.\n *\n * @default 'fill'\n */\n fillStyle?: 'fill' | 'outline',\n /**\n * The size of the Button.\n *\n * @default 'M'\n */\n size?: 'S' | 'M' | 'L' | 'XL',\n /** The static color style to apply. Useful when the Button appears over a color background. */\n staticColor?: 'white' | 'black'\n}\n\nexport interface ButtonProps extends Omit<RACButtonProps, 'className' | 'style' | 'children' | 'onHover' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange'>, StyleProps, ButtonStyleProps {\n /** The content to display in the Button. */\n children?: ReactNode\n}\n\nexport interface LinkButtonProps extends Omit<LinkProps, 'className' | 'style' | 'children'>, StyleProps, ButtonStyleProps {\n /** The content to display in the Button. */\n children?: ReactNode\n}\n\nexport const ButtonContext = createContext<ContextValue<ButtonProps, FocusableRefValue<HTMLButtonElement>>>(null);\nexport const LinkButtonContext = createContext<ContextValue<ButtonProps, FocusableRefValue<HTMLAnchorElement>>>(null);\n\nconst button = style<ButtonRenderProps & ButtonStyleProps>({\n ...focusRing(),\n position: 'relative',\n display: 'flex',\n alignItems: {\n default: 'baseline',\n ':has([slot=icon]):not(:has([data-rsp-slot=text]))': 'center'\n },\n justifyContent: 'center',\n textAlign: 'start',\n columnGap: 'text-to-visual',\n font: 'control',\n fontWeight: 'bold',\n userSelect: 'none',\n minHeight: 'control',\n minWidth: {\n ':has([slot=icon]):not(:has([data-rsp-slot=text]))': 'control'\n },\n borderRadius: 'pill',\n boxSizing: 'border-box',\n width: 'fit',\n textDecoration: 'none', // for link buttons\n paddingX: {\n default: 'pill',\n ':has([slot=icon]):not(:has([data-rsp-slot=text]))': 0\n },\n paddingY: 0,\n aspectRatio: {\n ':has([slot=icon]):not(:has([data-rsp-slot=text]))': 'square'\n },\n transition: 'default',\n borderStyle: 'solid',\n borderWidth: {\n fillStyle: {\n fill: 0,\n outline: 2\n }\n },\n '--labelPadding': {\n type: 'paddingTop',\n value: centerPadding()\n },\n '--iconMargin': {\n type: 'marginTop',\n value: {\n default: fontRelative(-2),\n ':has([slot=icon]):not(:has([data-rsp-slot=text]))': 0\n }\n },\n borderColor: {\n variant: {\n primary: baseColor('gray-800'),\n secondary: baseColor('gray-300')\n },\n isDisabled: 'disabled',\n staticColor: {\n white: {\n variant: {\n primary: baseColor('transparent-white-800'),\n secondary: baseColor('transparent-white-300')\n },\n isDisabled: 'transparent-white-300'\n },\n black: {\n variant: {\n primary: baseColor('transparent-black-800'),\n secondary: baseColor('transparent-black-300')\n },\n isDisabled: 'transparent-black-300'\n }\n },\n forcedColors: {\n default: 'ButtonBorder',\n isHovered: 'Highlight',\n isDisabled: 'GrayText'\n }\n },\n backgroundColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'neutral',\n secondary: baseColor('gray-100'),\n accent: 'accent',\n negative: 'negative'\n },\n isDisabled: 'disabled'\n },\n outline: {\n default: 'transparent',\n isHovered: 'gray-100',\n isPressed: 'gray-100',\n isFocusVisible: 'gray-100',\n isDisabled: 'transparent'\n }\n },\n staticColor: {\n white: {\n fillStyle: {\n fill: {\n variant: {\n primary: baseColor('transparent-white-800'),\n secondary: baseColor('transparent-white-100')\n },\n isDisabled: 'transparent-white-100'\n },\n outline: {\n default: 'transparent',\n isHovered: 'transparent-white-100',\n isPressed: 'transparent-white-100',\n isFocusVisible: 'transparent-white-100',\n isDisabled: 'transparent'\n }\n }\n },\n black: {\n fillStyle: {\n fill: {\n variant: {\n primary: baseColor('transparent-black-800'),\n secondary: baseColor('transparent-black-100')\n },\n isDisabled: 'transparent-black-100'\n },\n outline: {\n default: 'transparent',\n isHovered: 'transparent-black-100',\n isPressed: 'transparent-black-100',\n isFocusVisible: 'transparent-black-100',\n isDisabled: 'transparent'\n }\n }\n }\n },\n forcedColors: {\n fillStyle: {\n fill: {\n default: 'ButtonText',\n isHovered: 'Highlight',\n isDisabled: 'GrayText'\n },\n outline: 'ButtonFace'\n }\n }\n },\n color: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'gray-25',\n secondary: 'neutral',\n accent: 'white',\n negative: 'white'\n },\n isDisabled: 'disabled'\n },\n outline: {\n default: 'neutral',\n isDisabled: 'disabled'\n }\n },\n staticColor: {\n white: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'black',\n secondary: baseColor('transparent-white-800')\n }\n },\n outline: baseColor('transparent-white-800')\n },\n isDisabled: 'transparent-white-400'\n },\n black: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'white',\n secondary: baseColor('transparent-black-800')\n }\n },\n outline: baseColor('transparent-black-800')\n },\n isDisabled: 'transparent-black-400'\n }\n },\n forcedColors: {\n fillStyle: {\n fill: {\n default: 'ButtonFace',\n isDisabled: 'HighlightText'\n },\n outline: {\n default: 'ButtonText',\n isDisabled: 'GrayText'\n }\n }\n }\n },\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n },\n outlineColor: {\n default: 'focus-ring',\n staticColor: {\n white: 'white',\n black: 'black'\n },\n forcedColors: 'Highlight'\n },\n forcedColorAdjust: 'none',\n disableTapHighlight: true\n}, getAllowedOverrides());\n\nfunction Button(props: ButtonProps, ref: FocusableRef<HTMLButtonElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, ButtonContext);\n props = useFormProps(props);\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/s2');\n let {\n isPending,\n variant = 'primary',\n fillStyle = 'fill',\n size = 'M',\n staticColor\n } = props;\n let domRef = useFocusableRef(ref);\n let overlayTriggerState = useContext(OverlayTriggerStateContext);\n\n let [isProgressVisible, setIsProgressVisible] = useState(false);\n useEffect(() => {\n let timeout: ReturnType<typeof setTimeout>;\n\n if (isPending) {\n // Start timer when isPending is set to true.\n timeout = setTimeout(() => {\n setIsProgressVisible(true);\n }, 1000);\n } else {\n // Exit loading state when isPending is set to false. */\n setIsProgressVisible(false);\n }\n return () => {\n // Clean up on unmount or when user removes isPending prop before entering loading state.\n clearTimeout(timeout);\n };\n }, [isPending]);\n\n return (\n <RACButton\n {...props}\n ref={domRef}\n style={pressScale(domRef, props.UNSAFE_style)}\n className={renderProps => (props.UNSAFE_className || '') + button({\n ...renderProps,\n // Retain hover styles when an overlay is open.\n isHovered: renderProps.isHovered || overlayTriggerState?.isOpen || false,\n isDisabled: renderProps.isDisabled || isProgressVisible,\n variant,\n fillStyle,\n size,\n staticColor\n }, props.styles)}>\n <Provider\n values={[\n [SkeletonContext, null],\n [TextContext, {styles: style({\n paddingY: '--labelPadding',\n order: 1,\n opacity: {\n default: 1,\n isProgressVisible: 0\n }\n // @ts-ignore data-attributes allowed on all JSX elements, but adding to DOMProps has been problematic in the past\n })({isProgressVisible}), 'data-rsp-slot': 'text'}],\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: style({order: 0})}),\n styles: style({\n size: fontRelative(20),\n marginStart: '--iconMargin',\n flexShrink: 0,\n opacity: {\n default: 1,\n isProgressVisible: 0\n }\n })({isProgressVisible})\n }]\n ]}>\n {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}\n {isPending &&\n <div\n className={style({\n position: 'absolute',\n top: '[50%]',\n left: '[50%]',\n transform: 'translate(-50%, -50%)',\n opacity: {\n default: 0,\n isProgressVisible: 1\n }\n })({isProgressVisible, isPending})}>\n {/* TODO: size based on t-shirt size once ProgressCircle supports custom sizes */}\n <ProgressCircle isIndeterminate aria-label={stringFormatter.format('button.pending')} size=\"S\" staticColor={staticColor} UNSAFE_style={{display: 'block'}} />\n </div>\n }\n </Provider>\n </RACButton>\n );\n}\n\n/**\n * Buttons allow users to perform an action.\n * They have multiple styles for various needs, and are ideal for calling attention to\n * where a user needs to do something in order to move forward in a flow.\n */\nlet _Button = forwardRef(Button);\nexport {_Button as Button};\n\nfunction LinkButton(props: LinkButtonProps, ref: FocusableRef<HTMLAnchorElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, LinkButtonContext);\n props = useFormProps(props);\n let domRef = useFocusableRef(ref);\n let overlayTriggerState = useContext(OverlayTriggerStateContext);\n\n return (\n <Link\n {...props}\n ref={domRef}\n style={pressScale(domRef, props.UNSAFE_style)}\n className={renderProps => (props.UNSAFE_className || '') + button({\n ...renderProps,\n // Retain hover styles when an overlay is open.\n isHovered: renderProps.isHovered || overlayTriggerState?.isOpen || false,\n variant: props.variant || 'primary',\n fillStyle: props.fillStyle || 'fill',\n size: props.size || 'M',\n staticColor: props.staticColor\n }, props.styles)}>\n <Provider\n values={[\n [SkeletonContext, null],\n [TextContext, {styles: style({paddingY: '--labelPadding', order: 1})}],\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: style({order: 0})}),\n styles: style({size: fontRelative(20), marginStart: '--iconMargin', flexShrink: 0})\n }]\n ]}>\n {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}\n </Provider>\n </Link>\n );\n}\n\n/**\n * A LinkButton combines the functionality of a link with the appearance of a button. Useful for allowing users to navigate to another page.\n */\nlet _LinkButton = forwardRef(LinkButton);\nexport {_LinkButton as LinkButton};\n"],"names":[],"version":3,"file":"Button.mjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;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O,KAAK;IACnD,QAAQ,CAAA,GAAA,yCAAW,EAAE;IACrB,IAAI,SAAS,CAAA,GAAA,sBAAc,EAAE;IAC7B,IAAI,sBAAsB,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,iCAAyB;IAE9D,qBACE,gBAAC,CAAA,GAAA,WAAG;QACD,GAAG,KAAK;QACT,KAAK;QACL,OAAO,CAAA,GAAA,yCAAS,EAAE,QAAQ,MAAM,YAAY;QAC5C,WAAW,CAAA,cAAe,AAAC,CAAA,MAAM,gBAAgB,IAAI,EAAC,IAAK,6BAAO;gBAChE,GAAG,WAAW;gBACd,+CAA+C;gBAC/C,WAAW,YAAY,SAAS,IAAI,qBAAqB,UAAU;gBACnE,SAAS,MAAM,OAAO,IAAI;gBAC1B,WAAW,MAAM,SAAS,IAAI;gBAC9B,MAAM,MAAM,IAAI,IAAI;gBACpB,aAAa,MAAM,WAAW;YAChC,GAAG,MAAM,MAAM;kBACf,cAAA,gBAAC,CAAA,GAAA,eAAO;YACN,QAAQ;gBACN;oBAAC,CAAA,GAAA,yCAAc;oBAAG;iBAAK;gBACvB;oBAAC,CAAA,GAAA,yCAAU;oBAAG;wBACZ,MAAM;wBACN,kHAAkH;wBAClH,iBAAiB;oBACnB;iBAAE;gBACF;oBAAC,CAAA,GAAA,yCAAU;oBAAG;wBACZ,QAAQ,CAAA,GAAA,yCAAa,EAAE;4BAAC,MAAM;4BAAQ,MAAM;wBAAmB;wBAC/D,MAAM;oBACR;iBAAE;aACH;sBACA,OAAO,MAAM,QAAQ,KAAK,yBAAW,gBAAC,CAAA,GAAA,yCAAG;0BAAG,MAAM,QAAQ;iBAAW,MAAM,QAAQ;;;AAI5F;AAEA;;CAEC,GACD,IAAI,0DAAc,CAAA,GAAA,iBAAS,EAAE","sources":["packages/@react-spectrum/s2/src/Button.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {baseColor, fontRelative, style} from '../style/spectrum-theme' with {type: 'macro'};\nimport {ButtonRenderProps, ContextValue, Link, LinkProps, OverlayTriggerStateContext, Provider, Button as RACButton, ButtonProps as RACButtonProps} from 'react-aria-components';\nimport {centerBaseline} from './CenterBaseline';\nimport {centerPadding, focusRing, getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};\nimport {createContext, forwardRef, ReactNode, useContext, useEffect, useState} from 'react';\nimport {FocusableRef, FocusableRefValue} from '@react-types/shared';\nimport {IconContext} from './Icon';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {pressScale} from './pressScale';\nimport {ProgressCircle} from './ProgressCircle';\nimport {SkeletonContext} from './Skeleton';\nimport {Text, TextContext} from './Content';\nimport {useFocusableRef} from '@react-spectrum/utils';\nimport {useFormProps} from './Form';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\ninterface ButtonStyleProps {\n /**\n * The [visual style](https://spectrum.adobe.com/page/button/#Options) of the button.\n *\n * @default 'primary'\n */\n variant?: 'primary' | 'secondary' | 'accent' | 'negative',\n /**\n * The background style of the Button.\n *\n * @default 'fill'\n */\n fillStyle?: 'fill' | 'outline',\n /**\n * The size of the Button.\n *\n * @default 'M'\n */\n size?: 'S' | 'M' | 'L' | 'XL',\n /** The static color style to apply. Useful when the Button appears over a color background. */\n staticColor?: 'white' | 'black'\n}\n\nexport interface ButtonProps extends Omit<RACButtonProps, 'className' | 'style' | 'children' | 'onHover' | 'onHoverStart' | 'onHoverEnd' | 'onHoverChange'>, StyleProps, ButtonStyleProps {\n /** The content to display in the Button. */\n children?: ReactNode\n}\n\nexport interface LinkButtonProps extends Omit<LinkProps, 'className' | 'style' | 'children'>, StyleProps, ButtonStyleProps {\n /** The content to display in the Button. */\n children?: ReactNode\n}\n\nexport const ButtonContext = createContext<ContextValue<ButtonProps, FocusableRefValue<HTMLButtonElement>>>(null);\nexport const LinkButtonContext = createContext<ContextValue<ButtonProps, FocusableRefValue<HTMLAnchorElement>>>(null);\n\nconst iconOnly = ':has([slot=icon]):not(:has([data-rsp-slot=text]))';\nconst button = style<ButtonRenderProps & ButtonStyleProps>({\n ...focusRing(),\n position: 'relative',\n display: 'flex',\n alignItems: {\n default: 'baseline',\n [iconOnly]: 'center'\n },\n justifyContent: 'center',\n textAlign: 'start',\n columnGap: 'text-to-visual',\n font: 'control',\n fontWeight: 'bold',\n userSelect: 'none',\n minHeight: 'control',\n minWidth: {\n [iconOnly]: 'control'\n },\n borderRadius: 'pill',\n boxSizing: 'border-box',\n width: 'fit',\n textDecoration: 'none', // for link buttons\n paddingX: {\n default: 'pill',\n [iconOnly]: 0\n },\n paddingY: 0,\n aspectRatio: {\n [iconOnly]: 'square'\n },\n transition: 'default',\n borderStyle: 'solid',\n borderWidth: {\n fillStyle: {\n fill: 0,\n outline: 2\n }\n },\n '--labelPadding': {\n type: 'paddingTop',\n value: centerPadding()\n },\n '--iconMargin': {\n type: 'marginTop',\n value: {\n default: fontRelative(-2),\n [iconOnly]: 0\n }\n },\n borderColor: {\n variant: {\n primary: baseColor('gray-800'),\n secondary: baseColor('gray-300')\n },\n isDisabled: 'disabled',\n staticColor: {\n white: {\n variant: {\n primary: baseColor('transparent-white-800'),\n secondary: baseColor('transparent-white-300')\n },\n isDisabled: 'transparent-white-300'\n },\n black: {\n variant: {\n primary: baseColor('transparent-black-800'),\n secondary: baseColor('transparent-black-300')\n },\n isDisabled: 'transparent-black-300'\n }\n },\n forcedColors: {\n default: 'ButtonBorder',\n isHovered: 'Highlight',\n isDisabled: 'GrayText'\n }\n },\n backgroundColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'neutral',\n secondary: baseColor('gray-100'),\n accent: 'accent',\n negative: 'negative'\n },\n isDisabled: 'disabled'\n },\n outline: {\n default: 'transparent',\n isHovered: 'gray-100',\n isPressed: 'gray-100',\n isFocusVisible: 'gray-100',\n isDisabled: 'transparent'\n }\n },\n staticColor: {\n white: {\n fillStyle: {\n fill: {\n variant: {\n primary: baseColor('transparent-white-800'),\n secondary: baseColor('transparent-white-100')\n },\n isDisabled: 'transparent-white-100'\n },\n outline: {\n default: 'transparent',\n isHovered: 'transparent-white-100',\n isPressed: 'transparent-white-100',\n isFocusVisible: 'transparent-white-100',\n isDisabled: 'transparent'\n }\n }\n },\n black: {\n fillStyle: {\n fill: {\n variant: {\n primary: baseColor('transparent-black-800'),\n secondary: baseColor('transparent-black-100')\n },\n isDisabled: 'transparent-black-100'\n },\n outline: {\n default: 'transparent',\n isHovered: 'transparent-black-100',\n isPressed: 'transparent-black-100',\n isFocusVisible: 'transparent-black-100',\n isDisabled: 'transparent'\n }\n }\n }\n },\n forcedColors: {\n fillStyle: {\n fill: {\n default: 'ButtonText',\n isHovered: 'Highlight',\n isDisabled: 'GrayText'\n },\n outline: 'ButtonFace'\n }\n }\n },\n color: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'gray-25',\n secondary: 'neutral',\n accent: 'white',\n negative: 'white'\n },\n isDisabled: 'disabled'\n },\n outline: {\n default: 'neutral',\n isDisabled: 'disabled'\n }\n },\n staticColor: {\n white: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'black',\n secondary: baseColor('transparent-white-800')\n }\n },\n outline: baseColor('transparent-white-800')\n },\n isDisabled: 'transparent-white-400'\n },\n black: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'white',\n secondary: baseColor('transparent-black-800')\n }\n },\n outline: baseColor('transparent-black-800')\n },\n isDisabled: 'transparent-black-400'\n }\n },\n forcedColors: {\n fillStyle: {\n fill: {\n default: 'ButtonFace',\n isDisabled: 'HighlightText'\n },\n outline: {\n default: 'ButtonText',\n isDisabled: 'GrayText'\n }\n }\n }\n },\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n },\n outlineColor: {\n default: 'focus-ring',\n staticColor: {\n white: 'white',\n black: 'black'\n },\n forcedColors: 'Highlight'\n },\n forcedColorAdjust: 'none',\n disableTapHighlight: true\n}, getAllowedOverrides());\n\nfunction Button(props: ButtonProps, ref: FocusableRef<HTMLButtonElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, ButtonContext);\n props = useFormProps(props);\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/s2');\n let {\n isPending,\n variant = 'primary',\n fillStyle = 'fill',\n size = 'M',\n staticColor\n } = props;\n let domRef = useFocusableRef(ref);\n let overlayTriggerState = useContext(OverlayTriggerStateContext);\n\n let [isProgressVisible, setIsProgressVisible] = useState(false);\n useEffect(() => {\n let timeout: ReturnType<typeof setTimeout>;\n\n if (isPending) {\n // Start timer when isPending is set to true.\n timeout = setTimeout(() => {\n setIsProgressVisible(true);\n }, 1000);\n } else {\n // Exit loading state when isPending is set to false. */\n setIsProgressVisible(false);\n }\n return () => {\n // Clean up on unmount or when user removes isPending prop before entering loading state.\n clearTimeout(timeout);\n };\n }, [isPending]);\n\n return (\n <RACButton\n {...props}\n ref={domRef}\n style={pressScale(domRef, props.UNSAFE_style)}\n className={renderProps => (props.UNSAFE_className || '') + button({\n ...renderProps,\n // Retain hover styles when an overlay is open.\n isHovered: renderProps.isHovered || overlayTriggerState?.isOpen || false,\n isDisabled: renderProps.isDisabled || isProgressVisible,\n variant,\n fillStyle,\n size,\n staticColor\n }, props.styles)}>\n <Provider\n values={[\n [SkeletonContext, null],\n [TextContext, {\n styles: style({\n paddingY: '--labelPadding',\n order: 1,\n opacity: {\n default: 1,\n isProgressVisible: 0\n }\n })({isProgressVisible}),\n // @ts-ignore data-attributes allowed on all JSX elements, but adding to DOMProps has been problematic in the past\n 'data-rsp-slot': 'text'\n }],\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: style({order: 0})}),\n styles: style({\n size: fontRelative(20),\n marginStart: '--iconMargin',\n flexShrink: 0,\n opacity: {\n default: 1,\n isProgressVisible: 0\n }\n })({isProgressVisible})\n }]\n ]}>\n {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}\n {isPending &&\n <div\n className={style({\n position: 'absolute',\n top: '[50%]',\n left: '[50%]',\n transform: 'translate(-50%, -50%)',\n opacity: {\n default: 0,\n isProgressVisible: 1\n }\n })({isProgressVisible, isPending})}>\n {/* TODO: size based on t-shirt size once ProgressCircle supports custom sizes */}\n <ProgressCircle isIndeterminate aria-label={stringFormatter.format('button.pending')} size=\"S\" staticColor={staticColor} UNSAFE_style={{display: 'block'}} />\n </div>\n }\n </Provider>\n </RACButton>\n );\n}\n\n/**\n * Buttons allow users to perform an action.\n * They have multiple styles for various needs, and are ideal for calling attention to\n * where a user needs to do something in order to move forward in a flow.\n */\nlet _Button = forwardRef(Button);\nexport {_Button as Button};\n\nfunction LinkButton(props: LinkButtonProps, ref: FocusableRef<HTMLAnchorElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, LinkButtonContext);\n props = useFormProps(props);\n let domRef = useFocusableRef(ref);\n let overlayTriggerState = useContext(OverlayTriggerStateContext);\n\n return (\n <Link\n {...props}\n ref={domRef}\n style={pressScale(domRef, props.UNSAFE_style)}\n className={renderProps => (props.UNSAFE_className || '') + button({\n ...renderProps,\n // Retain hover styles when an overlay is open.\n isHovered: renderProps.isHovered || overlayTriggerState?.isOpen || false,\n variant: props.variant || 'primary',\n fillStyle: props.fillStyle || 'fill',\n size: props.size || 'M',\n staticColor: props.staticColor\n }, props.styles)}>\n <Provider\n values={[\n [SkeletonContext, null],\n [TextContext, {\n styles: style({paddingY: '--labelPadding', order: 1}),\n // @ts-ignore data-attributes allowed on all JSX elements, but adding to DOMProps has been problematic in the past\n 'data-rsp-slot': 'text'\n }],\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: style({order: 0})}),\n styles: style({size: fontRelative(20), marginStart: '--iconMargin', flexShrink: 0})\n }]\n ]}>\n {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}\n </Provider>\n </Link>\n );\n}\n\n/**\n * A LinkButton combines the functionality of a link with the appearance of a button. Useful for allowing users to navigate to another page.\n */\nlet _LinkButton = forwardRef(LinkButton);\nexport {_LinkButton as LinkButton};\n"],"names":[],"version":3,"file":"Button.mjs.map"}
|
package/dist/Card.cjs
CHANGED
|
@@ -476,7 +476,7 @@ const $230078a1c4ce81d8$export$60332b2344f7fe41 = /*#__PURE__*/ (0, $1B7TP$react
|
|
|
476
476
|
let ElementType = (0, $1B7TP$react.useContext)($230078a1c4ce81d8$export$64992ac69f286e5c);
|
|
477
477
|
if (ElementType === 'div' || isSkeleton) return /*#__PURE__*/ (0, $1B7TP$reactjsxruntime.jsx)("div", {
|
|
478
478
|
...(0, $1B7TP$reactariautils.filterDOMProps)(otherProps),
|
|
479
|
-
id: String(id),
|
|
479
|
+
id: id != null ? String(id) : undefined,
|
|
480
480
|
// @ts-ignore - React < 19 compat
|
|
481
481
|
inert: isSkeleton ? 'true' : undefined,
|
|
482
482
|
ref: domRef,
|
package/dist/Card.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;AAiDD,MAAM,qCAAe;IACnB,SAAS;IACT,MAAM;QACJ,IAAI;QACJ,GAAG;IACL;AACF;AAEA,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsIJ,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBJ,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BJ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F;wBACF;qBAAE;oBACF;wBAAC,CAAA,GAAA,uCAAY;wBAAG;4BACd,QAAQ,CAAA,GAAA,qCAAU,EAAE;wBAGtB;qBAAE;oBACF;wBAAC,CAAA,GAAA,uCAAY;wBAAG;4BAAC,MAAM,gCAAU,CAAC,KAAK;wBAAA;qBAAE;oBACzC;wBAAC,CAAA,GAAA,2CAAgB;wBAAG;4BAAC,MAAM,gCAAU,CAAC,KAAK;wBAAA;qBAAE;iBAC9C;0BACA;;;AAKX","sources":["packages/@react-spectrum/s2/src/Card.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {ActionMenuContext} from './ActionMenu';\nimport {AvatarContext} from './Avatar';\nimport {ButtonContext, LinkButtonContext} from './Button';\nimport {Checkbox} from './Checkbox';\nimport {colorToken} from '../style/tokens' with {type: 'macro'};\nimport {composeRenderProps, ContextValue, DEFAULT_SLOT, type GridListItem, GridListItemProps, Provider} from 'react-aria-components';\nimport {ContentContext, FooterContext, TextContext} from './Content';\nimport {createContext, CSSProperties, forwardRef, ReactNode, useContext} from 'react';\nimport {DividerContext} from './Divider';\nimport {DOMProps, DOMRef, DOMRefValue} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {focusRing, getAllowedOverrides, StyleProps, UnsafeStyles} from './style-utils' with {type: 'macro'};\nimport {IllustrationContext} from './Icon';\nimport {ImageContext} from './Image';\nimport {ImageCoordinator} from './ImageCoordinator';\nimport {lightDark, size, style} from '../style/spectrum-theme' with {type: 'macro'};\nimport {mergeStyles} from '../style/runtime';\nimport {pressScale} from './pressScale';\nimport {SkeletonContext, SkeletonWrapper, useIsSkeleton} from './Skeleton';\nimport {useDOMRef} from '@react-spectrum/utils';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\ninterface CardRenderProps {\n /** The size of the Card. */\n size: 'XS' | 'S' | 'M' | 'L' | 'XL'\n}\n\nexport interface CardProps extends Omit<GridListItemProps, 'className' | 'style' | 'children'>, StyleProps {\n /** The children of the Card. */\n children: ReactNode | ((renderProps: CardRenderProps) => ReactNode),\n /**\n * The size of the Card.\n * @default 'M'\n */\n size?: 'XS' | 'S' | 'M' | 'L' | 'XL',\n /**\n * The amount of internal padding within the Card.\n * @default 'regular'\n */\n density?: 'compact' | 'regular' | 'spacious',\n /**\n * The visual style of the Card.\n * @default 'primary'\n */\n variant?: 'primary' | 'secondary' | 'tertiary' | 'quiet'\n}\n\nconst borderRadius = {\n default: 'lg',\n size: {\n XS: 'default',\n S: 'default'\n }\n} as const;\n\nlet card = style({\n display: 'flex',\n flexDirection: 'column',\n position: 'relative',\n borderRadius,\n '--s2-container-bg': {\n type: 'backgroundColor',\n value: {\n variant: {\n primary: 'elevated',\n secondary: 'layer-1'\n },\n forcedColors: 'ButtonFace'\n }\n },\n backgroundColor: {\n default: '--s2-container-bg',\n variant: {\n tertiary: 'transparent',\n quiet: 'transparent'\n }\n },\n boxShadow: {\n default: 'emphasized',\n isHovered: 'elevated',\n isFocusVisible: 'elevated',\n isSelected: 'elevated',\n forcedColors: '[0 0 0 1px ButtonBorder]',\n variant: {\n tertiary: {\n // Render border with box-shadow to avoid affecting layout.\n default: `[0 0 0 1px ${colorToken('gray-100')}]`,\n isHovered: `[0 0 0 1px ${colorToken('gray-200')}]`,\n isFocusVisible: `[0 0 0 1px ${colorToken('gray-200')}]`,\n isSelected: 'none',\n forcedColors: '[0 0 0 1px ButtonBorder]'\n },\n quiet: 'none'\n }\n },\n forcedColorAdjust: 'none',\n transition: 'default',\n fontFamily: 'sans',\n overflow: {\n default: 'clip',\n variant: {\n quiet: 'visible'\n }\n },\n contain: 'layout',\n disableTapHighlight: true,\n userSelect: {\n isCardView: 'none'\n },\n cursor: {\n isLink: 'pointer'\n },\n width: {\n size: {\n XS: 112,\n S: 192,\n M: 240,\n L: 320,\n XL: size(400)\n },\n isCardView: 'full'\n },\n height: 'full',\n '--card-spacing': {\n type: 'paddingTop',\n value: {\n density: {\n compact: {\n size: {\n XS: size(6),\n S: 8,\n M: 12,\n L: 16,\n XL: 20\n }\n },\n regular: {\n size: {\n XS: 8,\n S: 12,\n M: 16,\n L: 20,\n XL: 24\n }\n },\n spacious: {\n size: {\n XS: 12,\n S: 16,\n M: 20,\n L: 24,\n XL: 28\n }\n }\n }\n }\n },\n '--card-padding-y': {\n type: 'paddingTop',\n value: {\n default: '--card-spacing',\n variant: {\n quiet: 0\n }\n }\n },\n '--card-padding-x': {\n type: 'paddingStart',\n value: {\n default: '--card-spacing',\n variant: {\n quiet: 0\n }\n }\n },\n paddingY: '--card-padding-y',\n paddingX: '--card-padding-x',\n boxSizing: 'border-box',\n ...focusRing(),\n outlineStyle: {\n default: 'none',\n isFocusVisible: 'solid',\n // Focus ring moves to preview when quiet.\n variant: {\n quiet: 'none'\n }\n }\n}, getAllowedOverrides());\n\nlet selectionIndicator = style({\n position: 'absolute',\n inset: 0,\n zIndex: 2,\n borderRadius,\n pointerEvents: 'none',\n borderWidth: 2,\n borderStyle: 'solid',\n borderColor: 'gray-1000',\n transition: 'default',\n opacity: {\n default: 0,\n isSelected: 1\n },\n // Quiet cards with no checkbox have an extra inner stroke\n // to distinguish the selection indicator from the preview.\n outlineColor: lightDark('transparent-white-600', 'transparent-black-600'),\n outlineOffset: -4,\n outlineStyle: {\n default: 'none',\n isStrokeInner: 'solid'\n },\n outlineWidth: 2\n});\n\nlet preview = style({\n position: 'relative',\n transition: 'default',\n overflow: 'clip',\n marginX: '[calc(var(--card-padding-x) * -1)]',\n marginTop: '[calc(var(--card-padding-y) * -1)]',\n marginBottom: {\n ':last-child': '[calc(var(--card-padding-y) * -1)]'\n },\n borderRadius: {\n isQuiet: borderRadius\n },\n boxShadow: {\n isQuiet: {\n isHovered: 'elevated',\n isFocusVisible: 'elevated',\n isSelected: 'elevated'\n }\n },\n ...focusRing(),\n outlineStyle: {\n default: 'none',\n isQuiet: {\n isFocusVisible: 'solid'\n }\n }\n});\n\nconst image = style({\n width: 'full',\n aspectRatio: '[3/2]',\n objectFit: 'cover',\n userSelect: 'none',\n pointerEvents: 'none'\n});\n\nlet title = style({\n font: 'title',\n fontSize: {\n size: {\n XS: 'title-xs',\n S: 'title-xs',\n M: 'title-sm',\n L: 'title',\n XL: 'title-lg'\n }\n },\n lineClamp: 3,\n gridArea: 'title'\n});\n\nlet description = style({\n font: 'body',\n fontSize: {\n size: {\n XS: 'body-2xs',\n S: 'body-2xs',\n M: 'body-xs',\n L: 'body-sm',\n XL: 'body'\n }\n },\n lineClamp: 3,\n gridArea: 'description'\n});\n\nlet content = style({\n display: 'grid',\n // By default, all elements are displayed in a stack.\n // If an action menu is present, place it next to the title.\n gridTemplateColumns: {\n default: ['1fr'],\n ':has([data-slot=menu])': ['minmax(0, 1fr)', 'auto']\n },\n gridTemplateAreas: {\n default: [\n 'title',\n 'description'\n ],\n ':has([data-slot=menu])': [\n 'title menu',\n 'description description'\n ]\n },\n columnGap: 4,\n flexGrow: 1,\n alignItems: 'baseline',\n alignContent: 'space-between',\n rowGap: {\n size: {\n XS: 4,\n S: 4,\n M: size(6),\n L: size(6),\n XL: 8\n }\n },\n paddingTop: {\n default: '--card-spacing',\n ':first-child': 0\n },\n paddingBottom: {\n default: '[calc(var(--card-spacing) * 1.5 / 2)]',\n ':last-child': 0\n }\n});\n\nlet actionMenu = style({\n gridArea: 'menu',\n // Don't cause the row to expand, preserve gap between title and description text.\n // Would use -100% here but it doesn't work in Firefox.\n marginY: '[calc(-1 * self(height))]'\n});\n\nlet footer = style({\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'end',\n justifyContent: 'space-between',\n gap: 8,\n paddingTop: '[calc(var(--card-spacing) * 1.5 / 2)]'\n});\n\nexport const CardViewContext = createContext<'div' | typeof GridListItem>('div');\nexport const CardContext = createContext<ContextValue<Partial<CardProps>, DOMRefValue<HTMLDivElement>>>(null);\n\ninterface InternalCardContextValue {\n isQuiet: boolean,\n size: 'XS' | 'S' | 'M' | 'L' | 'XL',\n isSelected: boolean,\n isHovered: boolean,\n isFocusVisible: boolean,\n isPressed: boolean,\n isCheckboxSelection: boolean\n}\n\nconst InternalCardContext = createContext<InternalCardContextValue>({\n isQuiet: false,\n size: 'M',\n isSelected: false,\n isHovered: false,\n isFocusVisible: false,\n isPressed: false,\n isCheckboxSelection: true\n});\n\nconst actionButtonSize = {\n XS: 'XS',\n S: 'XS',\n M: 'S',\n L: 'M',\n XL: 'L'\n} as const;\n\nexport const Card = forwardRef(function Card(props: CardProps, ref: DOMRef<HTMLDivElement>) {\n [props] = useSpectrumContextProps(props, ref, CardContext);\n let domRef = useDOMRef(ref);\n let {density = 'regular', size = 'M', variant = 'primary', UNSAFE_className = '', UNSAFE_style, styles, id, ...otherProps} = props;\n let isQuiet = variant === 'quiet';\n let isSkeleton = useIsSkeleton();\n let children = (\n <Provider\n values={[\n [ImageContext, {alt: '', styles: image}],\n [TextContext, {\n slots: {\n [DEFAULT_SLOT]: {},\n title: {styles: title({size})},\n description: {styles: description({size})}\n }\n }],\n [ContentContext, {styles: content({size})}],\n [DividerContext, {size: 'S'}],\n [FooterContext, {styles: footer}],\n [ActionMenuContext, {\n isQuiet: true,\n size: actionButtonSize[size],\n isDisabled: isSkeleton,\n // @ts-ignore\n 'data-slot': 'menu',\n styles: actionMenu\n }],\n [SkeletonContext, isSkeleton]\n ]}>\n <ImageCoordinator>\n {typeof props.children === 'function' ? props.children({size}) : props.children}\n </ImageCoordinator>\n </Provider>\n );\n\n let ElementType = useContext(CardViewContext);\n if (ElementType === 'div' || isSkeleton) {\n return (\n <div\n {...filterDOMProps(otherProps)}\n id={String(id)}\n // @ts-ignore - React < 19 compat\n inert={isSkeleton ? 'true' : undefined}\n ref={domRef}\n className={UNSAFE_className + card({size, density, variant, isCardView: ElementType !== 'div'}, styles)}\n style={UNSAFE_style}>\n <InternalCardContext.Provider value={{size, isQuiet, isCheckboxSelection: false, isHovered: false, isFocusVisible: false, isSelected: false, isPressed: false}}>\n {children}\n </InternalCardContext.Provider>\n </div>\n );\n }\n\n let press = pressScale(domRef, UNSAFE_style);\n return (\n <ElementType\n {...props}\n ref={domRef}\n className={renderProps => UNSAFE_className + card({...renderProps, isCardView: true, isLink: !!props.href, size, density, variant}, styles)}\n style={renderProps => \n // Only the preview in quiet cards scales down on press\n variant === 'quiet' ? UNSAFE_style : press(renderProps) \n }>\n {({selectionMode, selectionBehavior, isHovered, isFocusVisible, isSelected, isPressed}) => (\n <InternalCardContext.Provider value={{size, isQuiet, isCheckboxSelection: selectionMode !== 'none' && selectionBehavior === 'toggle', isHovered, isFocusVisible, isSelected, isPressed}}>\n {/* Selection indicator and checkbox move inside the preview for quiet cards */}\n {!isQuiet && <SelectionIndicator />}\n {!isQuiet && selectionMode !== 'none' && selectionBehavior === 'toggle' &&\n <CardCheckbox />\n }\n {/* this makes the :first-child selector work even with the checkbox */}\n <div className={style({display: 'contents'})}>\n {children}\n </div>\n </InternalCardContext.Provider>\n )}\n </ElementType>\n );\n});\n\nfunction SelectionIndicator() {\n let {size, isSelected, isQuiet, isCheckboxSelection} = useContext(InternalCardContext);\n return (\n <div\n className={selectionIndicator({\n size,\n isSelected,\n // Add an inner stroke only for quiet cards with no checkbox to \n // help distinguish the selected state from the preview.\n isStrokeInner: isQuiet && !isCheckboxSelection\n })} />\n );\n}\n\nfunction CardCheckbox() {\n let {size} = useContext(InternalCardContext);\n return (\n <div\n className={style({\n position: 'absolute',\n top: '--card-spacing',\n insetStart: '--card-spacing',\n zIndex: 2,\n padding: 4,\n backgroundColor: lightDark('transparent-white-600', 'transparent-black-600'),\n borderRadius: 'default',\n boxShadow: 'emphasized'\n })}>\n <Checkbox\n slot=\"selection\"\n excludeFromTabOrder\n size={size === 'XS' ? 'S' : size} />\n </div>\n );\n}\n\nexport interface CardPreviewProps extends UnsafeStyles, DOMProps {\n children: ReactNode\n}\n\nexport const CardPreview = forwardRef(function CardPreview(props: CardPreviewProps, ref: DOMRef<HTMLDivElement>) {\n let {size, isQuiet, isHovered, isFocusVisible, isSelected, isPressed, isCheckboxSelection} = useContext(InternalCardContext);\n let {UNSAFE_className, UNSAFE_style} = props;\n let domRef = useDOMRef(ref);\n return (\n <div\n {...filterDOMProps(props)}\n slot=\"preview\"\n ref={domRef}\n className={UNSAFE_className + preview({size, isQuiet, isHovered, isFocusVisible, isSelected})}\n style={isQuiet ? pressScale(domRef)({isPressed}) : UNSAFE_style}>\n {isQuiet && <SelectionIndicator />}\n {isQuiet && isCheckboxSelection && <CardCheckbox />}\n <div className={style({borderRadius: '[inherit]', overflow: 'clip'})}>\n {props.children}\n </div>\n </div>\n );\n});\n\nconst collection = style({\n display: 'grid',\n gridTemplateColumns: 'repeat(3, 1fr)',\n gap: {\n default: 4,\n size: {\n XS: 2,\n S: 2\n }\n }\n});\n\nconst collectionImage = style({\n width: 'full',\n aspectRatio: {\n default: 'square',\n ':nth-last-child(4):first-child': '[3/2]'\n },\n gridColumnEnd: {\n ':nth-last-child(4):first-child': 'span 3'\n },\n objectFit: 'cover',\n pointerEvents: 'none',\n userSelect: 'none'\n});\n\nexport const CollectionCardPreview = forwardRef(function CollectionCardPreview(props: CardPreviewProps, ref: DOMRef<HTMLDivElement>) {\n let {size} = useContext(InternalCardContext)!;\n return (\n <CardPreview {...props} ref={ref}>\n <div className={collection({size})}>\n <ImageContext.Provider value={{styles: collectionImage}}>\n {props.children}\n </ImageContext.Provider>\n </div>\n </CardPreview>\n );\n});\n\nexport interface AssetCardProps extends Omit<CardProps, 'density'> {}\n\nexport const AssetCard = forwardRef(function AssetCard(props: AssetCardProps, ref: DOMRef<HTMLDivElement>) {\n return (\n <Card {...props} ref={ref} density=\"regular\">\n {composeRenderProps(props.children, children => (\n <Provider\n values={[\n [ImageContext, {\n alt: '',\n styles: style({\n width: 'full',\n aspectRatio: 'square',\n objectFit: 'contain',\n pointerEvents: 'none',\n userSelect: 'none'\n })\n }],\n [IllustrationContext, {\n render(icon) {\n return (\n <SkeletonWrapper>\n <div\n className={style({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: 'gray-100',\n aspectRatio: 'square'\n })}>\n {icon}\n </div>\n </SkeletonWrapper>\n );\n },\n styles: style({\n height: 'auto',\n maxSize: 160,\n // TODO: this is made up.\n width: '[50%]'\n })\n }]\n ]}>\n {children}\n </Provider>\n ))}\n </Card>\n );\n});\n\nconst avatarSize = {\n XS: 24,\n S: 48,\n M: 64,\n L: 64,\n XL: 80\n} as const;\n\nexport interface UserCardProps extends Omit<CardProps, 'density' | 'variant'> {\n // Quiet is not supported due to lack of indent between preview and avatar.\n variant?: 'primary' | 'secondary' | 'tertiary'\n}\n\nexport const UserCard = forwardRef(function UserCard(props: CardProps, ref: DOMRef<HTMLDivElement>) {\n let {size = 'M'} = props;\n return (\n <Card {...props} ref={ref} density=\"spacious\">\n {composeRenderProps(props.children, children => (\n <Provider\n values={[\n [ImageContext, {\n alt: '',\n styles: style({\n width: 'full',\n aspectRatio: '[3/1]',\n objectFit: 'cover',\n pointerEvents: 'none',\n userSelect: 'none'\n })\n }],\n [AvatarContext, {\n size: avatarSize[size],\n UNSAFE_style: {\n '--size': avatarSize[size] + 'px'\n } as CSSProperties,\n styles: style({\n position: 'relative',\n marginTop: {\n default: 0,\n ':is([slot=preview] + &)': '[calc(var(--size) / -2)]'\n }\n }),\n isOverBackground: true\n }]\n ]}>\n {children}\n </Provider>\n ))}\n </Card>\n );\n});\n\nconst buttonSize = {\n XS: 'S',\n S: 'S',\n M: 'M',\n L: 'L',\n XL: 'XL'\n} as const;\n\nexport interface ProductCardProps extends Omit<CardProps, 'density' | 'variant'> {\n // Quiet is not supported due to lack of indent between preview and thumbnail.\n variant?: 'primary' | 'secondary' | 'tertiary'\n}\n\nexport const ProductCard = forwardRef(function ProductCard(props: ProductCardProps, ref: DOMRef<HTMLDivElement>) {\n let {size = 'M'} = props;\n return (\n <Card {...props} ref={ref} density=\"spacious\">\n {composeRenderProps(props.children, children => (\n <Provider\n values={[\n [ImageContext, {\n slots: {\n preview: {\n alt: '',\n styles: style({\n width: 'full',\n aspectRatio: '[5/1]',\n objectFit: 'cover',\n pointerEvents: 'none',\n userSelect: 'none'\n })\n },\n thumbnail: {\n alt: '',\n styles: style({\n position: 'relative',\n pointerEvents: 'none',\n userSelect: 'none',\n size: {\n size: {\n XS: 24,\n S: 36,\n M: 40,\n L: 44,\n XL: 56\n }\n },\n borderRadius: {\n default: 'default',\n size: {\n XS: 'sm',\n S: 'sm'\n }\n },\n objectFit: 'cover',\n marginTop: {\n default: 0,\n ':is([slot=preview] + &)': '[calc(self(height) / -2)]'\n },\n outlineStyle: 'solid',\n outlineWidth: {\n default: 2,\n size: {\n XS: 1\n }\n },\n outlineColor: '--s2-container-bg'\n })({size})\n }\n }\n }],\n [FooterContext, {\n styles: mergeStyles(footer, style({\n justifyContent: 'end'\n }))\n }],\n [ButtonContext, {size: buttonSize[size]}],\n [LinkButtonContext, {size: buttonSize[size]}]\n ]}>\n {children}\n </Provider>\n ))}\n </Card>\n );\n});\n"],"names":[],"version":3,"file":"Card.cjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;AAiDD,MAAM,qCAAe;IACnB,SAAS;IACT,MAAM;QACJ,IAAI;QACJ,GAAG;IACL;AACF;AAEA,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsIJ,IAAI;;;;;;;;;;;;;;;;;;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KAAK;oCACL,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sCAiCL;8CAAC;oCAAI;gCACV;4BACF;wBACF;qBAAE;oBACF;wBAAC,CAAA,GAAA,uCAAY;wBAAG;4BACd,QAAQ,CAAA,GAAA,qCAAU,EAAE;wBAGtB;qBAAE;oBACF;wBAAC,CAAA,GAAA,uCAAY;wBAAG;4BAAC,MAAM,gCAAU,CAAC,KAAK;wBAAA;qBAAE;oBACzC;wBAAC,CAAA,GAAA,2CAAgB;wBAAG;4BAAC,MAAM,gCAAU,CAAC,KAAK;wBAAA;qBAAE;iBAC9C;0BACA;;;AAKX","sources":["packages/@react-spectrum/s2/src/Card.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {ActionMenuContext} from './ActionMenu';\nimport {AvatarContext} from './Avatar';\nimport {ButtonContext, LinkButtonContext} from './Button';\nimport {Checkbox} from './Checkbox';\nimport {colorToken} from '../style/tokens' with {type: 'macro'};\nimport {composeRenderProps, ContextValue, DEFAULT_SLOT, type GridListItem, GridListItemProps, Provider} from 'react-aria-components';\nimport {ContentContext, FooterContext, TextContext} from './Content';\nimport {createContext, CSSProperties, forwardRef, ReactNode, useContext} from 'react';\nimport {DividerContext} from './Divider';\nimport {DOMProps, DOMRef, DOMRefValue} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport {focusRing, getAllowedOverrides, StyleProps, UnsafeStyles} from './style-utils' with {type: 'macro'};\nimport {IllustrationContext} from './Icon';\nimport {ImageContext} from './Image';\nimport {ImageCoordinator} from './ImageCoordinator';\nimport {lightDark, size, style} from '../style/spectrum-theme' with {type: 'macro'};\nimport {mergeStyles} from '../style/runtime';\nimport {pressScale} from './pressScale';\nimport {SkeletonContext, SkeletonWrapper, useIsSkeleton} from './Skeleton';\nimport {useDOMRef} from '@react-spectrum/utils';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\ninterface CardRenderProps {\n /** The size of the Card. */\n size: 'XS' | 'S' | 'M' | 'L' | 'XL'\n}\n\nexport interface CardProps extends Omit<GridListItemProps, 'className' | 'style' | 'children'>, StyleProps {\n /** The children of the Card. */\n children: ReactNode | ((renderProps: CardRenderProps) => ReactNode),\n /**\n * The size of the Card.\n * @default 'M'\n */\n size?: 'XS' | 'S' | 'M' | 'L' | 'XL',\n /**\n * The amount of internal padding within the Card.\n * @default 'regular'\n */\n density?: 'compact' | 'regular' | 'spacious',\n /**\n * The visual style of the Card.\n * @default 'primary'\n */\n variant?: 'primary' | 'secondary' | 'tertiary' | 'quiet'\n}\n\nconst borderRadius = {\n default: 'lg',\n size: {\n XS: 'default',\n S: 'default'\n }\n} as const;\n\nlet card = style({\n display: 'flex',\n flexDirection: 'column',\n position: 'relative',\n borderRadius,\n '--s2-container-bg': {\n type: 'backgroundColor',\n value: {\n variant: {\n primary: 'elevated',\n secondary: 'layer-1'\n },\n forcedColors: 'ButtonFace'\n }\n },\n backgroundColor: {\n default: '--s2-container-bg',\n variant: {\n tertiary: 'transparent',\n quiet: 'transparent'\n }\n },\n boxShadow: {\n default: 'emphasized',\n isHovered: 'elevated',\n isFocusVisible: 'elevated',\n isSelected: 'elevated',\n forcedColors: '[0 0 0 1px ButtonBorder]',\n variant: {\n tertiary: {\n // Render border with box-shadow to avoid affecting layout.\n default: `[0 0 0 1px ${colorToken('gray-100')}]`,\n isHovered: `[0 0 0 1px ${colorToken('gray-200')}]`,\n isFocusVisible: `[0 0 0 1px ${colorToken('gray-200')}]`,\n isSelected: 'none',\n forcedColors: '[0 0 0 1px ButtonBorder]'\n },\n quiet: 'none'\n }\n },\n forcedColorAdjust: 'none',\n transition: 'default',\n fontFamily: 'sans',\n overflow: {\n default: 'clip',\n variant: {\n quiet: 'visible'\n }\n },\n contain: 'layout',\n disableTapHighlight: true,\n userSelect: {\n isCardView: 'none'\n },\n cursor: {\n isLink: 'pointer'\n },\n width: {\n size: {\n XS: 112,\n S: 192,\n M: 240,\n L: 320,\n XL: size(400)\n },\n isCardView: 'full'\n },\n height: 'full',\n '--card-spacing': {\n type: 'paddingTop',\n value: {\n density: {\n compact: {\n size: {\n XS: size(6),\n S: 8,\n M: 12,\n L: 16,\n XL: 20\n }\n },\n regular: {\n size: {\n XS: 8,\n S: 12,\n M: 16,\n L: 20,\n XL: 24\n }\n },\n spacious: {\n size: {\n XS: 12,\n S: 16,\n M: 20,\n L: 24,\n XL: 28\n }\n }\n }\n }\n },\n '--card-padding-y': {\n type: 'paddingTop',\n value: {\n default: '--card-spacing',\n variant: {\n quiet: 0\n }\n }\n },\n '--card-padding-x': {\n type: 'paddingStart',\n value: {\n default: '--card-spacing',\n variant: {\n quiet: 0\n }\n }\n },\n paddingY: '--card-padding-y',\n paddingX: '--card-padding-x',\n boxSizing: 'border-box',\n ...focusRing(),\n outlineStyle: {\n default: 'none',\n isFocusVisible: 'solid',\n // Focus ring moves to preview when quiet.\n variant: {\n quiet: 'none'\n }\n }\n}, getAllowedOverrides());\n\nlet selectionIndicator = style({\n position: 'absolute',\n inset: 0,\n zIndex: 2,\n borderRadius,\n pointerEvents: 'none',\n borderWidth: 2,\n borderStyle: 'solid',\n borderColor: 'gray-1000',\n transition: 'default',\n opacity: {\n default: 0,\n isSelected: 1\n },\n // Quiet cards with no checkbox have an extra inner stroke\n // to distinguish the selection indicator from the preview.\n outlineColor: lightDark('transparent-white-600', 'transparent-black-600'),\n outlineOffset: -4,\n outlineStyle: {\n default: 'none',\n isStrokeInner: 'solid'\n },\n outlineWidth: 2\n});\n\nlet preview = style({\n position: 'relative',\n transition: 'default',\n overflow: 'clip',\n marginX: '[calc(var(--card-padding-x) * -1)]',\n marginTop: '[calc(var(--card-padding-y) * -1)]',\n marginBottom: {\n ':last-child': '[calc(var(--card-padding-y) * -1)]'\n },\n borderRadius: {\n isQuiet: borderRadius\n },\n boxShadow: {\n isQuiet: {\n isHovered: 'elevated',\n isFocusVisible: 'elevated',\n isSelected: 'elevated'\n }\n },\n ...focusRing(),\n outlineStyle: {\n default: 'none',\n isQuiet: {\n isFocusVisible: 'solid'\n }\n }\n});\n\nconst image = style({\n width: 'full',\n aspectRatio: '[3/2]',\n objectFit: 'cover',\n userSelect: 'none',\n pointerEvents: 'none'\n});\n\nlet title = style({\n font: 'title',\n fontSize: {\n size: {\n XS: 'title-xs',\n S: 'title-xs',\n M: 'title-sm',\n L: 'title',\n XL: 'title-lg'\n }\n },\n lineClamp: 3,\n gridArea: 'title'\n});\n\nlet description = style({\n font: 'body',\n fontSize: {\n size: {\n XS: 'body-2xs',\n S: 'body-2xs',\n M: 'body-xs',\n L: 'body-sm',\n XL: 'body'\n }\n },\n lineClamp: 3,\n gridArea: 'description'\n});\n\nlet content = style({\n display: 'grid',\n // By default, all elements are displayed in a stack.\n // If an action menu is present, place it next to the title.\n gridTemplateColumns: {\n default: ['1fr'],\n ':has([data-slot=menu])': ['minmax(0, 1fr)', 'auto']\n },\n gridTemplateAreas: {\n default: [\n 'title',\n 'description'\n ],\n ':has([data-slot=menu])': [\n 'title menu',\n 'description description'\n ]\n },\n columnGap: 4,\n flexGrow: 1,\n alignItems: 'baseline',\n alignContent: 'space-between',\n rowGap: {\n size: {\n XS: 4,\n S: 4,\n M: size(6),\n L: size(6),\n XL: 8\n }\n },\n paddingTop: {\n default: '--card-spacing',\n ':first-child': 0\n },\n paddingBottom: {\n default: '[calc(var(--card-spacing) * 1.5 / 2)]',\n ':last-child': 0\n }\n});\n\nlet actionMenu = style({\n gridArea: 'menu',\n // Don't cause the row to expand, preserve gap between title and description text.\n // Would use -100% here but it doesn't work in Firefox.\n marginY: '[calc(-1 * self(height))]'\n});\n\nlet footer = style({\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'end',\n justifyContent: 'space-between',\n gap: 8,\n paddingTop: '[calc(var(--card-spacing) * 1.5 / 2)]'\n});\n\nexport const CardViewContext = createContext<'div' | typeof GridListItem>('div');\nexport const CardContext = createContext<ContextValue<Partial<CardProps>, DOMRefValue<HTMLDivElement>>>(null);\n\ninterface InternalCardContextValue {\n isQuiet: boolean,\n size: 'XS' | 'S' | 'M' | 'L' | 'XL',\n isSelected: boolean,\n isHovered: boolean,\n isFocusVisible: boolean,\n isPressed: boolean,\n isCheckboxSelection: boolean\n}\n\nconst InternalCardContext = createContext<InternalCardContextValue>({\n isQuiet: false,\n size: 'M',\n isSelected: false,\n isHovered: false,\n isFocusVisible: false,\n isPressed: false,\n isCheckboxSelection: true\n});\n\nconst actionButtonSize = {\n XS: 'XS',\n S: 'XS',\n M: 'S',\n L: 'M',\n XL: 'L'\n} as const;\n\nexport const Card = forwardRef(function Card(props: CardProps, ref: DOMRef<HTMLDivElement>) {\n [props] = useSpectrumContextProps(props, ref, CardContext);\n let domRef = useDOMRef(ref);\n let {density = 'regular', size = 'M', variant = 'primary', UNSAFE_className = '', UNSAFE_style, styles, id, ...otherProps} = props;\n let isQuiet = variant === 'quiet';\n let isSkeleton = useIsSkeleton();\n let children = (\n <Provider\n values={[\n [ImageContext, {alt: '', styles: image}],\n [TextContext, {\n slots: {\n [DEFAULT_SLOT]: {},\n title: {styles: title({size})},\n description: {styles: description({size})}\n }\n }],\n [ContentContext, {styles: content({size})}],\n [DividerContext, {size: 'S'}],\n [FooterContext, {styles: footer}],\n [ActionMenuContext, {\n isQuiet: true,\n size: actionButtonSize[size],\n isDisabled: isSkeleton,\n // @ts-ignore\n 'data-slot': 'menu',\n styles: actionMenu\n }],\n [SkeletonContext, isSkeleton]\n ]}>\n <ImageCoordinator>\n {typeof props.children === 'function' ? props.children({size}) : props.children}\n </ImageCoordinator>\n </Provider>\n );\n\n let ElementType = useContext(CardViewContext);\n if (ElementType === 'div' || isSkeleton) {\n return (\n <div\n {...filterDOMProps(otherProps)}\n id={id != null ? String(id) : undefined}\n // @ts-ignore - React < 19 compat\n inert={isSkeleton ? 'true' : undefined}\n ref={domRef}\n className={UNSAFE_className + card({size, density, variant, isCardView: ElementType !== 'div'}, styles)}\n style={UNSAFE_style}>\n <InternalCardContext.Provider value={{size, isQuiet, isCheckboxSelection: false, isHovered: false, isFocusVisible: false, isSelected: false, isPressed: false}}>\n {children}\n </InternalCardContext.Provider>\n </div>\n );\n }\n\n let press = pressScale(domRef, UNSAFE_style);\n return (\n <ElementType\n {...props}\n ref={domRef}\n className={renderProps => UNSAFE_className + card({...renderProps, isCardView: true, isLink: !!props.href, size, density, variant}, styles)}\n style={renderProps => \n // Only the preview in quiet cards scales down on press\n variant === 'quiet' ? UNSAFE_style : press(renderProps) \n }>\n {({selectionMode, selectionBehavior, isHovered, isFocusVisible, isSelected, isPressed}) => (\n <InternalCardContext.Provider value={{size, isQuiet, isCheckboxSelection: selectionMode !== 'none' && selectionBehavior === 'toggle', isHovered, isFocusVisible, isSelected, isPressed}}>\n {/* Selection indicator and checkbox move inside the preview for quiet cards */}\n {!isQuiet && <SelectionIndicator />}\n {!isQuiet && selectionMode !== 'none' && selectionBehavior === 'toggle' &&\n <CardCheckbox />\n }\n {/* this makes the :first-child selector work even with the checkbox */}\n <div className={style({display: 'contents'})}>\n {children}\n </div>\n </InternalCardContext.Provider>\n )}\n </ElementType>\n );\n});\n\nfunction SelectionIndicator() {\n let {size, isSelected, isQuiet, isCheckboxSelection} = useContext(InternalCardContext);\n return (\n <div\n className={selectionIndicator({\n size,\n isSelected,\n // Add an inner stroke only for quiet cards with no checkbox to \n // help distinguish the selected state from the preview.\n isStrokeInner: isQuiet && !isCheckboxSelection\n })} />\n );\n}\n\nfunction CardCheckbox() {\n let {size} = useContext(InternalCardContext);\n return (\n <div\n className={style({\n position: 'absolute',\n top: '--card-spacing',\n insetStart: '--card-spacing',\n zIndex: 2,\n padding: 4,\n backgroundColor: lightDark('transparent-white-600', 'transparent-black-600'),\n borderRadius: 'default',\n boxShadow: 'emphasized'\n })}>\n <Checkbox\n slot=\"selection\"\n excludeFromTabOrder\n size={size === 'XS' ? 'S' : size} />\n </div>\n );\n}\n\nexport interface CardPreviewProps extends UnsafeStyles, DOMProps {\n children: ReactNode\n}\n\nexport const CardPreview = forwardRef(function CardPreview(props: CardPreviewProps, ref: DOMRef<HTMLDivElement>) {\n let {size, isQuiet, isHovered, isFocusVisible, isSelected, isPressed, isCheckboxSelection} = useContext(InternalCardContext);\n let {UNSAFE_className, UNSAFE_style} = props;\n let domRef = useDOMRef(ref);\n return (\n <div\n {...filterDOMProps(props)}\n slot=\"preview\"\n ref={domRef}\n className={UNSAFE_className + preview({size, isQuiet, isHovered, isFocusVisible, isSelected})}\n style={isQuiet ? pressScale(domRef)({isPressed}) : UNSAFE_style}>\n {isQuiet && <SelectionIndicator />}\n {isQuiet && isCheckboxSelection && <CardCheckbox />}\n <div className={style({borderRadius: '[inherit]', overflow: 'clip'})}>\n {props.children}\n </div>\n </div>\n );\n});\n\nconst collection = style({\n display: 'grid',\n gridTemplateColumns: 'repeat(3, 1fr)',\n gap: {\n default: 4,\n size: {\n XS: 2,\n S: 2\n }\n }\n});\n\nconst collectionImage = style({\n width: 'full',\n aspectRatio: {\n default: 'square',\n ':nth-last-child(4):first-child': '[3/2]'\n },\n gridColumnEnd: {\n ':nth-last-child(4):first-child': 'span 3'\n },\n objectFit: 'cover',\n pointerEvents: 'none',\n userSelect: 'none'\n});\n\nexport const CollectionCardPreview = forwardRef(function CollectionCardPreview(props: CardPreviewProps, ref: DOMRef<HTMLDivElement>) {\n let {size} = useContext(InternalCardContext)!;\n return (\n <CardPreview {...props} ref={ref}>\n <div className={collection({size})}>\n <ImageContext.Provider value={{styles: collectionImage}}>\n {props.children}\n </ImageContext.Provider>\n </div>\n </CardPreview>\n );\n});\n\nexport interface AssetCardProps extends Omit<CardProps, 'density'> {}\n\nexport const AssetCard = forwardRef(function AssetCard(props: AssetCardProps, ref: DOMRef<HTMLDivElement>) {\n return (\n <Card {...props} ref={ref} density=\"regular\">\n {composeRenderProps(props.children, children => (\n <Provider\n values={[\n [ImageContext, {\n alt: '',\n styles: style({\n width: 'full',\n aspectRatio: 'square',\n objectFit: 'contain',\n pointerEvents: 'none',\n userSelect: 'none'\n })\n }],\n [IllustrationContext, {\n render(icon) {\n return (\n <SkeletonWrapper>\n <div\n className={style({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: 'gray-100',\n aspectRatio: 'square'\n })}>\n {icon}\n </div>\n </SkeletonWrapper>\n );\n },\n styles: style({\n height: 'auto',\n maxSize: 160,\n // TODO: this is made up.\n width: '[50%]'\n })\n }]\n ]}>\n {children}\n </Provider>\n ))}\n </Card>\n );\n});\n\nconst avatarSize = {\n XS: 24,\n S: 48,\n M: 64,\n L: 64,\n XL: 80\n} as const;\n\nexport interface UserCardProps extends Omit<CardProps, 'density' | 'variant'> {\n // Quiet is not supported due to lack of indent between preview and avatar.\n variant?: 'primary' | 'secondary' | 'tertiary'\n}\n\nexport const UserCard = forwardRef(function UserCard(props: CardProps, ref: DOMRef<HTMLDivElement>) {\n let {size = 'M'} = props;\n return (\n <Card {...props} ref={ref} density=\"spacious\">\n {composeRenderProps(props.children, children => (\n <Provider\n values={[\n [ImageContext, {\n alt: '',\n styles: style({\n width: 'full',\n aspectRatio: '[3/1]',\n objectFit: 'cover',\n pointerEvents: 'none',\n userSelect: 'none'\n })\n }],\n [AvatarContext, {\n size: avatarSize[size],\n UNSAFE_style: {\n '--size': avatarSize[size] + 'px'\n } as CSSProperties,\n styles: style({\n position: 'relative',\n marginTop: {\n default: 0,\n ':is([slot=preview] + &)': '[calc(var(--size) / -2)]'\n }\n }),\n isOverBackground: true\n }]\n ]}>\n {children}\n </Provider>\n ))}\n </Card>\n );\n});\n\nconst buttonSize = {\n XS: 'S',\n S: 'S',\n M: 'M',\n L: 'L',\n XL: 'XL'\n} as const;\n\nexport interface ProductCardProps extends Omit<CardProps, 'density' | 'variant'> {\n // Quiet is not supported due to lack of indent between preview and thumbnail.\n variant?: 'primary' | 'secondary' | 'tertiary'\n}\n\nexport const ProductCard = forwardRef(function ProductCard(props: ProductCardProps, ref: DOMRef<HTMLDivElement>) {\n let {size = 'M'} = props;\n return (\n <Card {...props} ref={ref} density=\"spacious\">\n {composeRenderProps(props.children, children => (\n <Provider\n values={[\n [ImageContext, {\n slots: {\n preview: {\n alt: '',\n styles: style({\n width: 'full',\n aspectRatio: '[5/1]',\n objectFit: 'cover',\n pointerEvents: 'none',\n userSelect: 'none'\n })\n },\n thumbnail: {\n alt: '',\n styles: style({\n position: 'relative',\n pointerEvents: 'none',\n userSelect: 'none',\n size: {\n size: {\n XS: 24,\n S: 36,\n M: 40,\n L: 44,\n XL: 56\n }\n },\n borderRadius: {\n default: 'default',\n size: {\n XS: 'sm',\n S: 'sm'\n }\n },\n objectFit: 'cover',\n marginTop: {\n default: 0,\n ':is([slot=preview] + &)': '[calc(self(height) / -2)]'\n },\n outlineStyle: 'solid',\n outlineWidth: {\n default: 2,\n size: {\n XS: 1\n }\n },\n outlineColor: '--s2-container-bg'\n })({size})\n }\n }\n }],\n [FooterContext, {\n styles: mergeStyles(footer, style({\n justifyContent: 'end'\n }))\n }],\n [ButtonContext, {size: buttonSize[size]}],\n [LinkButtonContext, {size: buttonSize[size]}]\n ]}>\n {children}\n </Provider>\n ))}\n </Card>\n );\n});\n"],"names":[],"version":3,"file":"Card.cjs.map"}
|