@react-spectrum/s2 3.0.0-nightly-adae13c78-241218 → 3.0.0-nightly-50c7ada5d-241220
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/ActionBar.cjs +262 -0
- package/dist/ActionBar.cjs.map +1 -0
- package/dist/ActionBar.css +284 -0
- package/dist/ActionBar.css.map +1 -0
- package/dist/ActionBar.mjs +255 -0
- package/dist/ActionBar.mjs.map +1 -0
- package/dist/ActionButtonGroup.cjs.map +1 -1
- package/dist/ActionButtonGroup.css.map +1 -1
- package/dist/ActionButtonGroup.mjs.map +1 -1
- package/dist/Button.cjs +49 -9
- package/dist/Button.cjs.map +1 -1
- package/dist/Button.css +42 -18
- package/dist/Button.css.map +1 -1
- package/dist/Button.mjs +49 -9
- package/dist/Button.mjs.map +1 -1
- package/dist/CardView.cjs +33 -6
- package/dist/CardView.cjs.map +1 -1
- package/dist/CardView.css +28 -4
- package/dist/CardView.css.map +1 -1
- package/dist/CardView.mjs +35 -8
- package/dist/CardView.mjs.map +1 -1
- package/dist/CheckboxGroup.cjs +2 -1
- package/dist/CheckboxGroup.cjs.map +1 -1
- package/dist/CheckboxGroup.css.map +1 -1
- package/dist/CheckboxGroup.mjs +2 -1
- package/dist/CheckboxGroup.mjs.map +1 -1
- package/dist/CloseButton.cjs +9 -10
- package/dist/CloseButton.cjs.map +1 -1
- package/dist/CloseButton.css +4 -4
- package/dist/CloseButton.css.map +1 -1
- package/dist/CloseButton.mjs +9 -10
- package/dist/CloseButton.mjs.map +1 -1
- package/dist/TableView.cjs +54 -29
- package/dist/TableView.cjs.map +1 -1
- package/dist/TableView.css +12 -12
- package/dist/TableView.css.map +1 -1
- package/dist/TableView.mjs +55 -30
- package/dist/TableView.mjs.map +1 -1
- package/dist/ar-AE.cjs +10 -2
- package/dist/ar-AE.cjs.map +1 -1
- package/dist/ar-AE.mjs +10 -2
- package/dist/ar-AE.mjs.map +1 -1
- package/dist/bg-BG.cjs +11 -2
- package/dist/bg-BG.cjs.map +1 -1
- package/dist/bg-BG.mjs +11 -2
- package/dist/bg-BG.mjs.map +1 -1
- package/dist/cs-CZ.cjs +7 -2
- package/dist/cs-CZ.cjs.map +1 -1
- package/dist/cs-CZ.mjs +7 -2
- package/dist/cs-CZ.mjs.map +1 -1
- package/dist/da-DK.cjs +12 -4
- package/dist/da-DK.cjs.map +1 -1
- package/dist/da-DK.mjs +12 -4
- package/dist/da-DK.mjs.map +1 -1
- package/dist/de-DE.cjs +11 -2
- package/dist/de-DE.cjs.map +1 -1
- package/dist/de-DE.mjs +11 -2
- package/dist/de-DE.mjs.map +1 -1
- package/dist/el-GR.cjs +11 -2
- package/dist/el-GR.cjs.map +1 -1
- package/dist/el-GR.mjs +11 -2
- package/dist/el-GR.mjs.map +1 -1
- package/dist/en-US.cjs +8 -0
- package/dist/en-US.cjs.map +1 -1
- package/dist/en-US.mjs +8 -0
- package/dist/en-US.mjs.map +1 -1
- package/dist/es-ES.cjs +11 -2
- package/dist/es-ES.cjs.map +1 -1
- package/dist/es-ES.mjs +11 -2
- package/dist/es-ES.mjs.map +1 -1
- package/dist/et-EE.cjs +10 -2
- package/dist/et-EE.cjs.map +1 -1
- package/dist/et-EE.mjs +10 -2
- package/dist/et-EE.mjs.map +1 -1
- package/dist/fi-FI.cjs +10 -2
- package/dist/fi-FI.cjs.map +1 -1
- package/dist/fi-FI.mjs +10 -2
- package/dist/fi-FI.mjs.map +1 -1
- package/dist/fr-FR.cjs +11 -2
- package/dist/fr-FR.cjs.map +1 -1
- package/dist/fr-FR.mjs +11 -2
- package/dist/fr-FR.mjs.map +1 -1
- package/dist/he-IL.cjs +11 -2
- package/dist/he-IL.cjs.map +1 -1
- package/dist/he-IL.mjs +11 -2
- package/dist/he-IL.mjs.map +1 -1
- package/dist/hr-HR.cjs +7 -2
- package/dist/hr-HR.cjs.map +1 -1
- package/dist/hr-HR.mjs +7 -2
- package/dist/hr-HR.mjs.map +1 -1
- package/dist/hu-HU.cjs +10 -2
- package/dist/hu-HU.cjs.map +1 -1
- package/dist/hu-HU.mjs +10 -2
- package/dist/hu-HU.mjs.map +1 -1
- package/dist/it-IT.cjs +11 -2
- package/dist/it-IT.cjs.map +1 -1
- package/dist/it-IT.mjs +11 -2
- package/dist/it-IT.mjs.map +1 -1
- package/dist/ja-JP.cjs +10 -2
- package/dist/ja-JP.cjs.map +1 -1
- package/dist/ja-JP.mjs +10 -2
- package/dist/ja-JP.mjs.map +1 -1
- package/dist/ko-KR.cjs +12 -4
- package/dist/ko-KR.cjs.map +1 -1
- package/dist/ko-KR.mjs +12 -4
- package/dist/ko-KR.mjs.map +1 -1
- package/dist/lt-LT.cjs +9 -4
- package/dist/lt-LT.cjs.map +1 -1
- package/dist/lt-LT.mjs +9 -4
- package/dist/lt-LT.mjs.map +1 -1
- package/dist/lv-LV.cjs +11 -3
- package/dist/lv-LV.cjs.map +1 -1
- package/dist/lv-LV.mjs +11 -3
- package/dist/lv-LV.mjs.map +1 -1
- package/dist/main.cjs +4 -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 +9 -4
- package/dist/nb-NO.cjs.map +1 -1
- package/dist/nb-NO.mjs +9 -4
- package/dist/nb-NO.mjs.map +1 -1
- package/dist/nl-NL.cjs +10 -2
- package/dist/nl-NL.cjs.map +1 -1
- package/dist/nl-NL.mjs +10 -2
- package/dist/nl-NL.mjs.map +1 -1
- package/dist/pl-PL.cjs +8 -3
- package/dist/pl-PL.cjs.map +1 -1
- package/dist/pl-PL.mjs +8 -3
- package/dist/pl-PL.mjs.map +1 -1
- package/dist/pt-BR.cjs +11 -2
- package/dist/pt-BR.cjs.map +1 -1
- package/dist/pt-BR.mjs +11 -2
- package/dist/pt-BR.mjs.map +1 -1
- package/dist/pt-PT.cjs +11 -2
- package/dist/pt-PT.cjs.map +1 -1
- package/dist/pt-PT.mjs +11 -2
- package/dist/pt-PT.mjs.map +1 -1
- package/dist/ro-RO.cjs +12 -3
- package/dist/ro-RO.cjs.map +1 -1
- package/dist/ro-RO.mjs +12 -3
- package/dist/ro-RO.mjs.map +1 -1
- package/dist/ru-RU.cjs +7 -2
- package/dist/ru-RU.cjs.map +1 -1
- package/dist/ru-RU.mjs +7 -2
- package/dist/ru-RU.mjs.map +1 -1
- package/dist/sk-SK.cjs +7 -2
- package/dist/sk-SK.cjs.map +1 -1
- package/dist/sk-SK.mjs +7 -2
- package/dist/sk-SK.mjs.map +1 -1
- package/dist/sl-SI.cjs +7 -2
- package/dist/sl-SI.cjs.map +1 -1
- package/dist/sl-SI.mjs +7 -2
- package/dist/sl-SI.mjs.map +1 -1
- package/dist/sr-SP.cjs +7 -2
- package/dist/sr-SP.cjs.map +1 -1
- package/dist/sr-SP.mjs +7 -2
- package/dist/sr-SP.mjs.map +1 -1
- package/dist/sv-SE.cjs +11 -2
- package/dist/sv-SE.cjs.map +1 -1
- package/dist/sv-SE.mjs +11 -2
- package/dist/sv-SE.mjs.map +1 -1
- package/dist/tr-TR.cjs +10 -2
- package/dist/tr-TR.cjs.map +1 -1
- package/dist/tr-TR.mjs +10 -2
- package/dist/tr-TR.mjs.map +1 -1
- package/dist/types.d.ts +34 -18
- package/dist/types.d.ts.map +1 -1
- package/dist/uk-UA.cjs +7 -2
- package/dist/uk-UA.cjs.map +1 -1
- package/dist/uk-UA.mjs +7 -2
- package/dist/uk-UA.mjs.map +1 -1
- package/dist/zh-CN.cjs +10 -2
- package/dist/zh-CN.cjs.map +1 -1
- package/dist/zh-CN.mjs +10 -2
- package/dist/zh-CN.mjs.map +1 -1
- package/dist/zh-TW.cjs +10 -2
- package/dist/zh-TW.cjs.map +1 -1
- package/dist/zh-TW.mjs +10 -2
- package/dist/zh-TW.mjs.map +1 -1
- package/package.json +19 -18
- package/src/ActionBar.tsx +235 -0
- package/src/ActionButtonGroup.tsx +3 -2
- package/src/Button.tsx +56 -7
- package/src/CardView.tsx +35 -8
- package/src/CheckboxGroup.tsx +1 -1
- package/src/CloseButton.tsx +4 -5
- package/src/TableView.tsx +32 -18
- package/src/index.ts +2 -0
- package/style/dist/main.cjs +1 -0
- package/style/dist/main.cjs.map +1 -1
- package/style/dist/module.mjs +2 -2
- package/style/dist/module.mjs.map +1 -1
- package/style/dist/spectrum-theme.cjs +4 -0
- package/style/dist/spectrum-theme.cjs.map +1 -1
- package/style/dist/spectrum-theme.mjs +4 -1
- package/style/dist/spectrum-theme.mjs.map +1 -1
- package/style/dist/types.d.ts +1 -0
- package/style/dist/types.d.ts.map +1 -1
- package/style/index.ts +1 -1
- package/style/spectrum-theme.ts +4 -0
package/dist/Button.css
CHANGED
|
@@ -93,10 +93,6 @@
|
|
|
93
93
|
color: var(--lightningcss-light, #fff) var(--lightningcss-dark, #111);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
.ac {
|
|
97
|
-
color: #fff;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
96
|
.an {
|
|
101
97
|
color: var(--lightningcss-light, #292929) var(--lightningcss-dark, #dbdbdb);
|
|
102
98
|
}
|
|
@@ -113,6 +109,10 @@
|
|
|
113
109
|
color: lch(from var(--b, var(--s2-container-bg)) calc((49.44 - l) * infinity) 0 0 / 1);
|
|
114
110
|
}
|
|
115
111
|
|
|
112
|
+
.ac {
|
|
113
|
+
color: #fff;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
116
|
.a_____E {
|
|
117
117
|
color: lch(from var(--s2-container-bg) calc((49.44 - l) * infinity) 0 0 / .85);
|
|
118
118
|
}
|
|
@@ -202,22 +202,22 @@
|
|
|
202
202
|
border-bottom-width: var(--v);
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
.sa {
|
|
206
|
-
border-inline-start-width: 0;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
205
|
.sc {
|
|
210
206
|
border-inline-start-width: 2px;
|
|
211
207
|
}
|
|
212
208
|
|
|
213
|
-
.
|
|
214
|
-
border-inline-
|
|
209
|
+
.sa {
|
|
210
|
+
border-inline-start-width: 0;
|
|
215
211
|
}
|
|
216
212
|
|
|
217
213
|
.tc {
|
|
218
214
|
border-inline-end-width: 2px;
|
|
219
215
|
}
|
|
220
216
|
|
|
217
|
+
.ta {
|
|
218
|
+
border-inline-end-width: 0;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
221
|
.-_1gogtue_E--1dbqcch {
|
|
222
222
|
--labelPadding: calc((var(--o) - var(--u, 0px) - var(--v, 0px) - 1lh) / 2);
|
|
223
223
|
}
|
|
@@ -262,6 +262,26 @@
|
|
|
262
262
|
border-color: lch(from var(--s2-container-bg) calc((49.44 - l) * infinity) 0 0 / .17);
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
+
._B-riuwfd {
|
|
266
|
+
background-image: linear-gradient(96deg, var(--lightningcss-light, #b539c8) var(--lightningcss-dark, #d549eb) 0%, var(--lightningcss-light, #7155fa) var(--lightningcss-dark, #8077fe) 66%, var(--lightningcss-light, #3b63fb) var(--lightningcss-dark, #5681ff) 100%);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
._B-2xhv0x {
|
|
270
|
+
background-image: linear-gradient(96deg, var(--lightningcss-light, #9c28af) var(--lightningcss-dark, #e85bfd) 0%, var(--lightningcss-light, #6338ee) var(--lightningcss-dark, #8b8dfe) 66%, var(--lightningcss-light, #274dea) var(--lightningcss-dark, #6995fe) 100%);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
._B-u0nzys {
|
|
274
|
+
background-image: linear-gradient(96deg, var(--lightningcss-light, #d73220) var(--lightningcss-dark, #fc432e) 0%, var(--lightningcss-light, #d92361) var(--lightningcss-dark, #f37) 33%, var(--lightningcss-light, #7155fa) var(--lightningcss-dark, #8077fe) 100%);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
._B-1gcd5pl {
|
|
278
|
+
background-image: linear-gradient(96deg, var(--lightningcss-light, #b72818) var(--lightningcss-dark, #ff6756) 0%, var(--lightningcss-light, #ba1650) var(--lightningcss-dark, #ff6095) 33%, var(--lightningcss-light, #6338ee) var(--lightningcss-dark, #8b8dfe) 100%);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
._B-yknrp1 {
|
|
282
|
+
background-image: none;
|
|
283
|
+
}
|
|
284
|
+
|
|
265
285
|
.b-375toh {
|
|
266
286
|
background-color: var(--b);
|
|
267
287
|
}
|
|
@@ -298,24 +318,20 @@
|
|
|
298
318
|
--o: calc(3rem * var(--s2-scale));
|
|
299
319
|
}
|
|
300
320
|
|
|
301
|
-
.-_375tp0_u-a {
|
|
302
|
-
--u: 0px;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
321
|
.-_375tp0_u-c {
|
|
306
322
|
--u: 2px;
|
|
307
323
|
}
|
|
308
324
|
|
|
309
|
-
.-
|
|
310
|
-
--
|
|
325
|
+
.-_375tp0_u-a {
|
|
326
|
+
--u: 0px;
|
|
311
327
|
}
|
|
312
328
|
|
|
313
329
|
.-_375tp1_v-c {
|
|
314
330
|
--v: 2px;
|
|
315
331
|
}
|
|
316
332
|
|
|
317
|
-
.-
|
|
318
|
-
--
|
|
333
|
+
.-_375tp1_v-a {
|
|
334
|
+
--v: 0px;
|
|
319
335
|
}
|
|
320
336
|
|
|
321
337
|
.-_375toh_b-o {
|
|
@@ -358,6 +374,10 @@
|
|
|
358
374
|
--b: lch(from var(--s2-container-bg) calc((49.44 - l) * infinity) 0 0 / .14);
|
|
359
375
|
}
|
|
360
376
|
|
|
377
|
+
.-_375toh_b-n {
|
|
378
|
+
--b: var(--lightningcss-light, #292929) var(--lightningcss-dark, #dbdbdb);
|
|
379
|
+
}
|
|
380
|
+
|
|
361
381
|
.-_375toh_b-_____x {
|
|
362
382
|
--b: lch(from var(--s2-container-bg) calc((49.44 - l) * infinity) 0 0 / .11);
|
|
363
383
|
}
|
|
@@ -577,6 +597,10 @@
|
|
|
577
597
|
border-color: graytext;
|
|
578
598
|
}
|
|
579
599
|
|
|
600
|
+
._Ba-yknrp1 {
|
|
601
|
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tC;;;;EAAA;;;;EAAA;;;;EAAA;;;;;AAnUL;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;;;;;;AAqOK","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@import \"341672feb3593eb4\";\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, focusRing, fontRelative, style} from '../style' 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, getAllowedOverrides, staticColor, 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' | 'auto'\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 & {isStaticColor: boolean}>({\n ...focusRing(),\n ...staticColor(),\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 isStaticColor: {\n variant: {\n primary: baseColor('transparent-overlay-800'),\n secondary: baseColor('transparent-overlay-300')\n },\n isDisabled: 'transparent-overlay-300'\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 isStaticColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: baseColor('transparent-overlay-800'),\n secondary: baseColor('transparent-overlay-100')\n },\n isDisabled: 'transparent-overlay-100'\n },\n outline: {\n default: 'transparent',\n isHovered: 'transparent-overlay-100',\n isPressed: 'transparent-overlay-100',\n isFocusVisible: 'transparent-overlay-100',\n isDisabled: 'transparent'\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 isStaticColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'auto',\n secondary: baseColor('transparent-overlay-800')\n }\n },\n outline: baseColor('transparent-overlay-800')\n },\n isDisabled: 'transparent-overlay-400'\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 isStaticColor: 'transparent-overlay-1000',\n forcedColors: 'Highlight'\n },\n forcedColorAdjust: 'none',\n disableTapHighlight: true\n}, getAllowedOverrides());\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 */\nexport const Button = forwardRef(function 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 isStaticColor: !!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 <ProgressCircle\n isIndeterminate\n aria-label={stringFormatter.format('button.pending')}\n size=\"S\"\n staticColor={staticColor}\n styles={style({\n size: {\n size: {\n S: 14,\n M: 18,\n L: 20,\n XL: 24\n }\n }\n })({size})} />\n </div>\n }\n </Provider>\n </RACButton>\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 */\nexport const LinkButton = forwardRef(function 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 isStaticColor: !!props.staticColor,\n isPending: false\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"],"names":[],"version":3,"file":"Button.css.map"}
|
|
1
|
+
{"mappings":"ACmEe;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;;;;EAiTQ;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAeD;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EA8CF;;;;EAAA;;;;EAAA;;;;EAKsC;;;;EACtC;;;;EAAA;;;;EAAA;;;;EAAA;;;;;AApXL;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;;;;IAAA;;;;;;AAAA;EAAA;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;;;AAsRK","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@import \"341672feb3593eb4\";\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, focusRing, fontRelative, linearGradient, style} from '../style' 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, getAllowedOverrides, staticColor, 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' | 'premium' | 'genai',\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' | 'auto'\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 & {isStaticColor: boolean}>({\n ...focusRing(),\n ...staticColor(),\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 variant: {\n premium: 0,\n genai: 0\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 isStaticColor: {\n variant: {\n primary: baseColor('transparent-overlay-800'),\n secondary: baseColor('transparent-overlay-300')\n },\n isDisabled: 'transparent-overlay-300'\n },\n forcedColors: {\n default: 'ButtonBorder',\n isHovered: 'Highlight',\n isDisabled: 'GrayText'\n }\n },\n backgroundImage: {\n variant: {\n premium: {\n default: linearGradient('96deg', ['fuchsia-900', 0], ['indigo-900', 66], ['blue-900', 100]),\n isHovered: linearGradient('96deg', ['fuchsia-1000', 0], ['indigo-1000', 66], ['blue-1000', 100]),\n isPressed: linearGradient('96deg', ['fuchsia-1000', 0], ['indigo-1000', 66], ['blue-1000', 100]),\n isFocusVisible: linearGradient('96deg', ['fuchsia-1000', 0], ['indigo-1000', 66], ['blue-1000', 100])\n },\n genai: {\n default: linearGradient('96deg', ['red-900', 0], ['magenta-900', 33], ['indigo-900', 100]),\n isHovered: linearGradient('96deg', ['red-1000', 0], ['magenta-1000', 33], ['indigo-1000', 100]),\n isPressed: linearGradient('96deg', ['red-1000', 0], ['magenta-1000', 33], ['indigo-1000', 100]),\n isFocusVisible: linearGradient('96deg', ['red-1000', 0], ['magenta-1000', 33], ['indigo-1000', 100])\n }\n },\n isDisabled: 'none',\n isPending: 'none',\n forcedColors: 'none'\n },\n backgroundColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'neutral',\n secondary: baseColor('gray-100'),\n accent: 'accent',\n negative: 'negative',\n premium: 'gray-100',\n genai: 'gray-100'\n },\n isDisabled: 'disabled'\n },\n outline: {\n variant: {\n premium: 'gray-100',\n genai: 'gray-100'\n },\n default: 'transparent',\n isHovered: 'gray-100',\n isPressed: 'gray-100',\n isFocusVisible: 'gray-100',\n isDisabled: 'transparent'\n }\n },\n isStaticColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: baseColor('transparent-overlay-800'),\n secondary: baseColor('transparent-overlay-100'),\n premium: 'gray-800',\n genai: 'gray-800'\n },\n isDisabled: 'transparent-overlay-100'\n },\n outline: {\n variant: {\n premium: 'gray-800',\n genai: 'gray-800'\n },\n default: 'transparent',\n isHovered: 'transparent-overlay-100',\n isPressed: 'transparent-overlay-100',\n isFocusVisible: 'transparent-overlay-100',\n isDisabled: 'transparent'\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 premium: 'white',\n genai: 'white'\n },\n isDisabled: 'disabled'\n },\n outline: {\n default: 'neutral',\n variant: {\n premium: 'white',\n genai: 'white'\n },\n isDisabled: 'disabled'\n }\n },\n isStaticColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'auto',\n secondary: baseColor('transparent-overlay-800'),\n premium: 'white',\n genai: 'white'\n }\n },\n outline: {\n variant: {\n premium: 'white',\n genai: 'white'\n },\n default: baseColor('transparent-overlay-800')\n }\n },\n isDisabled: 'transparent-overlay-400'\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 isStaticColor: 'transparent-overlay-1000',\n forcedColors: 'Highlight'\n },\n forcedColorAdjust: 'none',\n disableTapHighlight: true\n}, getAllowedOverrides());\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 */\nexport const Button = forwardRef(function 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 isStaticColor: !!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 <ProgressCircle\n isIndeterminate\n aria-label={stringFormatter.format('button.pending')}\n size=\"S\"\n staticColor={staticColor}\n styles={style({\n size: {\n size: {\n S: 14,\n M: 18,\n L: 20,\n XL: 24\n }\n }\n })({size})} />\n </div>\n }\n </Provider>\n </RACButton>\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 */\nexport const LinkButton = forwardRef(function 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 isStaticColor: !!props.staticColor,\n isPending: false\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"],"names":[],"version":3,"file":"Button.css.map"}
|
package/dist/Button.mjs
CHANGED
|
@@ -111,12 +111,18 @@ const $067ea9f64ccd4e8e$var$button = function anonymous(props, overrides) {
|
|
|
111
111
|
if (props.isStaticColor) {
|
|
112
112
|
if (props.isDisabled) rules += ' a_____A';
|
|
113
113
|
else if (props.fillStyle === "outline") {
|
|
114
|
-
if (props.
|
|
115
|
-
else if (props.
|
|
116
|
-
else
|
|
117
|
-
|
|
114
|
+
if (props.variant === "genai") rules += ' ac';
|
|
115
|
+
else if (props.variant === "premium") rules += ' ac';
|
|
116
|
+
else {
|
|
117
|
+
if (props.isPressed) rules += ' a_____F';
|
|
118
|
+
else if (props.isFocusVisible) rules += ' a_____F';
|
|
119
|
+
else if (props.isHovered) rules += ' a_____F';
|
|
120
|
+
else rules += ' a_____E';
|
|
121
|
+
}
|
|
118
122
|
} else if (props.fillStyle === "fill") {
|
|
119
|
-
if (props.variant === "
|
|
123
|
+
if (props.variant === "genai") rules += ' ac';
|
|
124
|
+
else if (props.variant === "premium") rules += ' ac';
|
|
125
|
+
else if (props.variant === "secondary") {
|
|
120
126
|
if (props.isPressed) rules += ' a_____F';
|
|
121
127
|
else if (props.isFocusVisible) rules += ' a_____F';
|
|
122
128
|
else if (props.isHovered) rules += ' a_____F';
|
|
@@ -125,6 +131,8 @@ const $067ea9f64ccd4e8e$var$button = function anonymous(props, overrides) {
|
|
|
125
131
|
}
|
|
126
132
|
} else if (props.fillStyle === "outline") {
|
|
127
133
|
if (props.isDisabled) rules += ' aj';
|
|
134
|
+
else if (props.variant === "genai") rules += ' ac';
|
|
135
|
+
else if (props.variant === "premium") rules += ' ac';
|
|
128
136
|
else {
|
|
129
137
|
if (props.isPressed) rules += ' ao';
|
|
130
138
|
else if (props.isFocusVisible) rules += ' ao';
|
|
@@ -133,6 +141,8 @@ const $067ea9f64ccd4e8e$var$button = function anonymous(props, overrides) {
|
|
|
133
141
|
}
|
|
134
142
|
} else if (props.fillStyle === "fill") {
|
|
135
143
|
if (props.isDisabled) rules += ' aj';
|
|
144
|
+
else if (props.variant === "genai") rules += ' ac';
|
|
145
|
+
else if (props.variant === "premium") rules += ' ac';
|
|
136
146
|
else if (props.variant === "negative") rules += ' ac';
|
|
137
147
|
else if (props.variant === "accent") rules += ' ac';
|
|
138
148
|
else if (props.variant === "secondary") {
|
|
@@ -171,9 +181,13 @@ const $067ea9f64ccd4e8e$var$button = function anonymous(props, overrides) {
|
|
|
171
181
|
rules += ' wa';
|
|
172
182
|
rules += ' u-375tp0';
|
|
173
183
|
rules += ' v-375tp1';
|
|
174
|
-
if (props.
|
|
184
|
+
if (props.variant === "genai") rules += ' sa';
|
|
185
|
+
else if (props.variant === "premium") rules += ' sa';
|
|
186
|
+
else if (props.fillStyle === "outline") rules += ' sc';
|
|
175
187
|
else if (props.fillStyle === "fill") rules += ' sa';
|
|
176
|
-
if (props.
|
|
188
|
+
if (props.variant === "genai") rules += ' ta';
|
|
189
|
+
else if (props.variant === "premium") rules += ' ta';
|
|
190
|
+
else if (props.fillStyle === "outline") rules += ' tc';
|
|
177
191
|
else if (props.fillStyle === "fill") rules += ' ta';
|
|
178
192
|
rules += ' -_1gogtue_E--1dbqcch';
|
|
179
193
|
rules += ' -oelgqu_A--soocica';
|
|
@@ -206,6 +220,20 @@ const $067ea9f64ccd4e8e$var$button = function anonymous(props, overrides) {
|
|
|
206
220
|
else if (props.isHovered) rules += ' co';
|
|
207
221
|
else rules += ' cn';
|
|
208
222
|
}
|
|
223
|
+
rules += ' _Ba-yknrp1';
|
|
224
|
+
if (props.isPending) rules += ' _B-yknrp1';
|
|
225
|
+
else if (props.isDisabled) rules += ' _B-yknrp1';
|
|
226
|
+
else if (props.variant === "genai") {
|
|
227
|
+
if (props.isFocusVisible) rules += ' _B-1gcd5pl';
|
|
228
|
+
else if (props.isPressed) rules += ' _B-1gcd5pl';
|
|
229
|
+
else if (props.isHovered) rules += ' _B-1gcd5pl';
|
|
230
|
+
else rules += ' _B-u0nzys';
|
|
231
|
+
} else if (props.variant === "premium") {
|
|
232
|
+
if (props.isFocusVisible) rules += ' _B-2xhv0x';
|
|
233
|
+
else if (props.isPressed) rules += ' _B-2xhv0x';
|
|
234
|
+
else if (props.isHovered) rules += ' _B-2xhv0x';
|
|
235
|
+
else rules += ' _B-riuwfd';
|
|
236
|
+
}
|
|
209
237
|
rules += ' b-375toh';
|
|
210
238
|
rules += ' -rwx0fg_e-b';
|
|
211
239
|
rules += ' _zb';
|
|
@@ -215,9 +243,13 @@ const $067ea9f64ccd4e8e$var$button = function anonymous(props, overrides) {
|
|
|
215
243
|
else if (props.size === "S") rules += ' -_375tou_o-h';
|
|
216
244
|
else if (props.size === "XS") rules += ' -_375tou_o-g';
|
|
217
245
|
else rules += ' -_375tou_o-f';
|
|
218
|
-
if (props.
|
|
246
|
+
if (props.variant === "genai") rules += ' -_375tp0_u-a';
|
|
247
|
+
else if (props.variant === "premium") rules += ' -_375tp0_u-a';
|
|
248
|
+
else if (props.fillStyle === "outline") rules += ' -_375tp0_u-c';
|
|
219
249
|
else if (props.fillStyle === "fill") rules += ' -_375tp0_u-a';
|
|
220
|
-
if (props.
|
|
250
|
+
if (props.variant === "genai") rules += ' -_375tp1_v-a';
|
|
251
|
+
else if (props.variant === "premium") rules += ' -_375tp1_v-a';
|
|
252
|
+
else if (props.fillStyle === "outline") rules += ' -_375tp1_v-c';
|
|
221
253
|
else if (props.fillStyle === "fill") rules += ' -_375tp1_v-a';
|
|
222
254
|
if (props.fillStyle === "outline") rules += ' -_375toh_b-a_____J';
|
|
223
255
|
else if (props.fillStyle === "fill") {
|
|
@@ -231,9 +263,13 @@ const $067ea9f64ccd4e8e$var$button = function anonymous(props, overrides) {
|
|
|
231
263
|
else if (props.isFocusVisible) rules += ' -_375toh_b-_____x';
|
|
232
264
|
else if (props.isPressed) rules += ' -_375toh_b-_____x';
|
|
233
265
|
else if (props.isHovered) rules += ' -_375toh_b-_____x';
|
|
266
|
+
else if (props.variant === "genai") rules += ' -_375toh_b-n';
|
|
267
|
+
else if (props.variant === "premium") rules += ' -_375toh_b-n';
|
|
234
268
|
else rules += ' -_375toh_b-a';
|
|
235
269
|
} else if (props.fillStyle === "fill") {
|
|
236
270
|
if (props.isDisabled) rules += ' -_375toh_b-_____x';
|
|
271
|
+
else if (props.variant === "genai") rules += ' -_375toh_b-n';
|
|
272
|
+
else if (props.variant === "premium") rules += ' -_375toh_b-n';
|
|
237
273
|
else if (props.variant === "secondary") {
|
|
238
274
|
if (props.isPressed) rules += ' -_375toh_b-_____y';
|
|
239
275
|
else if (props.isFocusVisible) rules += ' -_375toh_b-_____y';
|
|
@@ -251,9 +287,13 @@ const $067ea9f64ccd4e8e$var$button = function anonymous(props, overrides) {
|
|
|
251
287
|
else if (props.isFocusVisible) rules += ' -_375toh_b-g';
|
|
252
288
|
else if (props.isPressed) rules += ' -_375toh_b-g';
|
|
253
289
|
else if (props.isHovered) rules += ' -_375toh_b-g';
|
|
290
|
+
else if (props.variant === "genai") rules += ' -_375toh_b-g';
|
|
291
|
+
else if (props.variant === "premium") rules += ' -_375toh_b-g';
|
|
254
292
|
else rules += ' -_375toh_b-a';
|
|
255
293
|
} else if (props.fillStyle === "fill") {
|
|
256
294
|
if (props.isDisabled) rules += ' -_375toh_b-g';
|
|
295
|
+
else if (props.variant === "genai") rules += ' -_375toh_b-g';
|
|
296
|
+
else if (props.variant === "premium") rules += ' -_375toh_b-g';
|
|
257
297
|
else if (props.variant === "negative") {
|
|
258
298
|
if (props.isPressed) rules += ' -_375toh_b-_____Y';
|
|
259
299
|
else if (props.isFocusVisible) rules += ' -_375toh_b-_____Y';
|
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,iCAAW;AACjB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgL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IAAI;gBAC1B,WAAW,MAAM,SAAS,IAAI;gBAC9B,MAAM,MAAM,IAAI,IAAI;gBACpB,aAAa,MAAM,WAAW;gBAC9B,eAAe,CAAC,CAAC,MAAM,WAAW;gBAClC,WAAW;YACb,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","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, focusRing, fontRelative, style} from '../style' 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, getAllowedOverrides, staticColor, 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' | 'auto'\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 & {isStaticColor: boolean}>({\n ...focusRing(),\n ...staticColor(),\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 isStaticColor: {\n variant: {\n primary: baseColor('transparent-overlay-800'),\n secondary: baseColor('transparent-overlay-300')\n },\n isDisabled: 'transparent-overlay-300'\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 isStaticColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: baseColor('transparent-overlay-800'),\n secondary: baseColor('transparent-overlay-100')\n },\n isDisabled: 'transparent-overlay-100'\n },\n outline: {\n default: 'transparent',\n isHovered: 'transparent-overlay-100',\n isPressed: 'transparent-overlay-100',\n isFocusVisible: 'transparent-overlay-100',\n isDisabled: 'transparent'\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 isStaticColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'auto',\n secondary: baseColor('transparent-overlay-800')\n }\n },\n outline: baseColor('transparent-overlay-800')\n },\n isDisabled: 'transparent-overlay-400'\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 isStaticColor: 'transparent-overlay-1000',\n forcedColors: 'Highlight'\n },\n forcedColorAdjust: 'none',\n disableTapHighlight: true\n}, getAllowedOverrides());\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 */\nexport const Button = forwardRef(function 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 isStaticColor: !!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 <ProgressCircle\n isIndeterminate\n aria-label={stringFormatter.format('button.pending')}\n size=\"S\"\n staticColor={staticColor}\n styles={style({\n size: {\n size: {\n S: 14,\n M: 18,\n L: 20,\n XL: 24\n }\n }\n })({size})} />\n </div>\n }\n </Provider>\n </RACButton>\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 */\nexport const LinkButton = forwardRef(function 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 isStaticColor: !!props.staticColor,\n isPending: false\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"],"names":[],"version":3,"file":"Button.mjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAqDM,MAAM,0DAAgB,CAAA,GAAA,oBAAY,EAAmE;AACrG,MAAM,0DAAoB,CAAA,GAAA,oBAAY,EAAmE;AAEhH,MAAM,iCAAW;AACjB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiOC,MAAM,0DAAS,CAAA,GAAA,iBAAS,EAAE,SAAS,OAAO,MAAkB,EAA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,IAAI;gBACpB,aAAa,MAAM,WAAW;gBAC9B,eAAe,CAAC,CAAC,MAAM,WAAW;gBAClC,WAAW;YACb,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","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, focusRing, fontRelative, linearGradient, style} from '../style' 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, getAllowedOverrides, staticColor, 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' | 'premium' | 'genai',\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' | 'auto'\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 & {isStaticColor: boolean}>({\n ...focusRing(),\n ...staticColor(),\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 variant: {\n premium: 0,\n genai: 0\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 isStaticColor: {\n variant: {\n primary: baseColor('transparent-overlay-800'),\n secondary: baseColor('transparent-overlay-300')\n },\n isDisabled: 'transparent-overlay-300'\n },\n forcedColors: {\n default: 'ButtonBorder',\n isHovered: 'Highlight',\n isDisabled: 'GrayText'\n }\n },\n backgroundImage: {\n variant: {\n premium: {\n default: linearGradient('96deg', ['fuchsia-900', 0], ['indigo-900', 66], ['blue-900', 100]),\n isHovered: linearGradient('96deg', ['fuchsia-1000', 0], ['indigo-1000', 66], ['blue-1000', 100]),\n isPressed: linearGradient('96deg', ['fuchsia-1000', 0], ['indigo-1000', 66], ['blue-1000', 100]),\n isFocusVisible: linearGradient('96deg', ['fuchsia-1000', 0], ['indigo-1000', 66], ['blue-1000', 100])\n },\n genai: {\n default: linearGradient('96deg', ['red-900', 0], ['magenta-900', 33], ['indigo-900', 100]),\n isHovered: linearGradient('96deg', ['red-1000', 0], ['magenta-1000', 33], ['indigo-1000', 100]),\n isPressed: linearGradient('96deg', ['red-1000', 0], ['magenta-1000', 33], ['indigo-1000', 100]),\n isFocusVisible: linearGradient('96deg', ['red-1000', 0], ['magenta-1000', 33], ['indigo-1000', 100])\n }\n },\n isDisabled: 'none',\n isPending: 'none',\n forcedColors: 'none'\n },\n backgroundColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'neutral',\n secondary: baseColor('gray-100'),\n accent: 'accent',\n negative: 'negative',\n premium: 'gray-100',\n genai: 'gray-100'\n },\n isDisabled: 'disabled'\n },\n outline: {\n variant: {\n premium: 'gray-100',\n genai: 'gray-100'\n },\n default: 'transparent',\n isHovered: 'gray-100',\n isPressed: 'gray-100',\n isFocusVisible: 'gray-100',\n isDisabled: 'transparent'\n }\n },\n isStaticColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: baseColor('transparent-overlay-800'),\n secondary: baseColor('transparent-overlay-100'),\n premium: 'gray-800',\n genai: 'gray-800'\n },\n isDisabled: 'transparent-overlay-100'\n },\n outline: {\n variant: {\n premium: 'gray-800',\n genai: 'gray-800'\n },\n default: 'transparent',\n isHovered: 'transparent-overlay-100',\n isPressed: 'transparent-overlay-100',\n isFocusVisible: 'transparent-overlay-100',\n isDisabled: 'transparent'\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 premium: 'white',\n genai: 'white'\n },\n isDisabled: 'disabled'\n },\n outline: {\n default: 'neutral',\n variant: {\n premium: 'white',\n genai: 'white'\n },\n isDisabled: 'disabled'\n }\n },\n isStaticColor: {\n fillStyle: {\n fill: {\n variant: {\n primary: 'auto',\n secondary: baseColor('transparent-overlay-800'),\n premium: 'white',\n genai: 'white'\n }\n },\n outline: {\n variant: {\n premium: 'white',\n genai: 'white'\n },\n default: baseColor('transparent-overlay-800')\n }\n },\n isDisabled: 'transparent-overlay-400'\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 isStaticColor: 'transparent-overlay-1000',\n forcedColors: 'Highlight'\n },\n forcedColorAdjust: 'none',\n disableTapHighlight: true\n}, getAllowedOverrides());\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 */\nexport const Button = forwardRef(function 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 isStaticColor: !!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 <ProgressCircle\n isIndeterminate\n aria-label={stringFormatter.format('button.pending')}\n size=\"S\"\n staticColor={staticColor}\n styles={style({\n size: {\n size: {\n S: 14,\n M: 18,\n L: 20,\n XL: 24\n }\n }\n })({size})} />\n </div>\n }\n </Provider>\n </RACButton>\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 */\nexport const LinkButton = forwardRef(function 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 isStaticColor: !!props.staticColor,\n isPending: false\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"],"names":[],"version":3,"file":"Button.mjs.map"}
|
package/dist/CardView.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require("./CardView.css");
|
|
2
2
|
var $230078a1c4ce81d8$exports = require("./Card.cjs");
|
|
3
3
|
var $a4f1585b527b9b7a$exports = require("./ImageCoordinator.cjs");
|
|
4
|
+
var $85bf454149fe9ddc$exports = require("./ActionBar.cjs");
|
|
4
5
|
var $ac757a4c2bd72aee$exports = require("../icons/useSpectrumContextProps.cjs");
|
|
5
6
|
var $gDulG$reactjsxruntime = require("react/jsx-runtime");
|
|
6
7
|
var $gDulG$reactariacomponents = require("react-aria-components");
|
|
@@ -35,6 +36,7 @@ $parcel$export(module.exports, "CardView", () => $1aaf8931044a97bd$export$7e52c8
|
|
|
35
36
|
|
|
36
37
|
|
|
37
38
|
|
|
39
|
+
|
|
38
40
|
class $1aaf8931044a97bd$var$FlexibleGridLayout extends (0, $gDulG$reactstatelyvirtualizer.Layout) {
|
|
39
41
|
update(invalidationContext) {
|
|
40
42
|
let { minItemSize: minItemSize = new (0, $gDulG$reactstatelyvirtualizer.Size)(200, 200), maxItemSize: maxItemSize = new (0, $gDulG$reactstatelyvirtualizer.Size)(Infinity, Infinity), minSpace: minSpace = new (0, $gDulG$reactstatelyvirtualizer.Size)(18, 18), maxColumns: maxColumns = Infinity } = invalidationContext.layoutOptions || {};
|
|
@@ -388,6 +390,7 @@ const $1aaf8931044a97bd$var$cardViewStyles = function anonymous(props, overrides
|
|
|
388
390
|
if (props.isLoading) rules += ' __wb';
|
|
389
391
|
else rules += ' __wa';
|
|
390
392
|
if (props.isEmpty) rules += ' _Zd';
|
|
393
|
+
rules += ' __na';
|
|
391
394
|
rules += ' _6b';
|
|
392
395
|
rules += ' _1c';
|
|
393
396
|
rules += ' _2d';
|
|
@@ -405,6 +408,8 @@ const $1aaf8931044a97bd$export$7e52c821f7b6f422 = /*#__PURE__*/ (0, $gDulG$react
|
|
|
405
408
|
[props, ref] = (0, $ac757a4c2bd72aee$exports.useSpectrumContextProps)(props, ref, $1aaf8931044a97bd$export$64992ac69f286e5c);
|
|
406
409
|
let { children: children, layout: layoutName = 'grid', size: sizeProp = 'M', density: density = 'regular', variant: variant = 'primary', selectionStyle: selectionStyle = 'checkbox', UNSAFE_className: UNSAFE_className = '', UNSAFE_style: UNSAFE_style, styles: styles, ...otherProps } = props;
|
|
407
410
|
let domRef = (0, $gDulG$reactspectrumutils.useDOMRef)(ref);
|
|
411
|
+
let innerRef = (0, $gDulG$react.useRef)(null);
|
|
412
|
+
let scrollRef = props.renderActionBar ? innerRef : domRef;
|
|
408
413
|
let layout = (0, $gDulG$react.useMemo)(()=>{
|
|
409
414
|
return layoutName === 'waterfall' ? new $1aaf8931044a97bd$var$WaterfallLayout() : new $1aaf8931044a97bd$var$FlexibleGridLayout();
|
|
410
415
|
}, [
|
|
@@ -413,7 +418,7 @@ const $1aaf8931044a97bd$export$7e52c821f7b6f422 = /*#__PURE__*/ (0, $gDulG$react
|
|
|
413
418
|
// This calculates the maximum t-shirt size where at least two columns fit in the available width.
|
|
414
419
|
let [maxSizeIndex, setMaxSizeIndex] = (0, $gDulG$react.useState)($1aaf8931044a97bd$var$SIZES.length - 1);
|
|
415
420
|
let updateSize = (0, $gDulG$reactariautils.useEffectEvent)(()=>{
|
|
416
|
-
let w =
|
|
421
|
+
let w = scrollRef.current?.clientWidth ?? 0;
|
|
417
422
|
let i = $1aaf8931044a97bd$var$SIZES.length - 1;
|
|
418
423
|
while(i > 0){
|
|
419
424
|
let opts = $1aaf8931044a97bd$var$layoutOptions[$1aaf8931044a97bd$var$SIZES[i]][density];
|
|
@@ -423,7 +428,7 @@ const $1aaf8931044a97bd$export$7e52c821f7b6f422 = /*#__PURE__*/ (0, $gDulG$react
|
|
|
423
428
|
setMaxSizeIndex(i);
|
|
424
429
|
});
|
|
425
430
|
(0, $gDulG$reactariautils.useResizeObserver)({
|
|
426
|
-
ref:
|
|
431
|
+
ref: scrollRef,
|
|
427
432
|
box: 'border-box',
|
|
428
433
|
onResize: updateSize
|
|
429
434
|
});
|
|
@@ -439,7 +444,7 @@ const $1aaf8931044a97bd$export$7e52c821f7b6f422 = /*#__PURE__*/ (0, $gDulG$react
|
|
|
439
444
|
isLoading: props.loadingState !== 'idle' && props.loadingState !== 'error',
|
|
440
445
|
items: props.items,
|
|
441
446
|
onLoadMore: props.onLoadMore
|
|
442
|
-
},
|
|
447
|
+
}, scrollRef);
|
|
443
448
|
let ctx = (0, $gDulG$react.useMemo)(()=>({
|
|
444
449
|
size: size,
|
|
445
450
|
variant: variant
|
|
@@ -447,7 +452,11 @@ const $1aaf8931044a97bd$export$7e52c821f7b6f422 = /*#__PURE__*/ (0, $gDulG$react
|
|
|
447
452
|
size,
|
|
448
453
|
variant
|
|
449
454
|
]);
|
|
450
|
-
|
|
455
|
+
let { selectedKeys: selectedKeys, onSelectionChange: onSelectionChange, actionBar: actionBar, actionBarHeight: actionBarHeight } = (0, $85bf454149fe9ddc$exports.useActionBarContainer)({
|
|
456
|
+
...props,
|
|
457
|
+
scrollRef: scrollRef
|
|
458
|
+
});
|
|
459
|
+
let cardView = /*#__PURE__*/ (0, $gDulG$reactjsxruntime.jsx)((0, $gDulG$reactariacomponents.UNSTABLE_Virtualizer), {
|
|
451
460
|
layout: layout,
|
|
452
461
|
layoutOptions: options,
|
|
453
462
|
children: /*#__PURE__*/ (0, $gDulG$reactjsxruntime.jsx)((0, $230078a1c4ce81d8$exports.InternalCardViewContext).Provider, {
|
|
@@ -456,13 +465,20 @@ const $1aaf8931044a97bd$export$7e52c821f7b6f422 = /*#__PURE__*/ (0, $gDulG$react
|
|
|
456
465
|
value: ctx,
|
|
457
466
|
children: /*#__PURE__*/ (0, $gDulG$reactjsxruntime.jsx)((0, $a4f1585b527b9b7a$exports.ImageCoordinator), {
|
|
458
467
|
children: /*#__PURE__*/ (0, $gDulG$reactjsxruntime.jsx)((0, $gDulG$reactariacomponents.GridList), {
|
|
459
|
-
ref:
|
|
468
|
+
ref: scrollRef,
|
|
460
469
|
...otherProps,
|
|
461
470
|
layout: "grid",
|
|
462
471
|
selectionBehavior: selectionStyle === 'highlight' ? 'replace' : 'toggle',
|
|
472
|
+
selectedKeys: selectedKeys,
|
|
473
|
+
defaultSelectedKeys: undefined,
|
|
474
|
+
onSelectionChange: onSelectionChange,
|
|
463
475
|
style: {
|
|
464
476
|
...UNSAFE_style,
|
|
465
|
-
|
|
477
|
+
// Add padding at the bottom when the action bar is visible so users can scroll to the last items.
|
|
478
|
+
// Also add scroll padding so keyboard navigating preserves the padding.
|
|
479
|
+
paddingBottom: actionBarHeight > 0 ? actionBarHeight + options.minSpace.height : 0,
|
|
480
|
+
scrollPadding: options.minSpace.height,
|
|
481
|
+
scrollPaddingBottom: actionBarHeight + options.minSpace.height
|
|
466
482
|
},
|
|
467
483
|
className: (renderProps)=>UNSAFE_className + $1aaf8931044a97bd$var$cardViewStyles({
|
|
468
484
|
...renderProps,
|
|
@@ -474,6 +490,17 @@ const $1aaf8931044a97bd$export$7e52c821f7b6f422 = /*#__PURE__*/ (0, $gDulG$react
|
|
|
474
490
|
})
|
|
475
491
|
})
|
|
476
492
|
});
|
|
493
|
+
// Add extra wrapper if there is an action bar so we can position relative to it.
|
|
494
|
+
// ActionBar cannot be inside the GridList due to ARIA and focus management requirements.
|
|
495
|
+
if (props.renderActionBar) return /*#__PURE__*/ (0, $gDulG$reactjsxruntime.jsxs)("div", {
|
|
496
|
+
ref: domRef,
|
|
497
|
+
className: " . Uc __vc __wc le ke",
|
|
498
|
+
children: [
|
|
499
|
+
cardView,
|
|
500
|
+
actionBar
|
|
501
|
+
]
|
|
502
|
+
});
|
|
503
|
+
return cardView;
|
|
477
504
|
});
|
|
478
505
|
|
|
479
506
|
|