@react-spectrum/s2 3.0.0-nightly-73414999f-240916 → 3.0.0-nightly-9e79420c1-240918

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.
@@ -1,7 +1,6 @@
1
1
  import "./ProgressCircle.css";
2
2
  import {useSpectrumContextProps as $5ce63c423902f47d$export$764f6146fadd77f7} from "./useSpectrumContextProps.mjs";
3
3
  import {jsx as $8ijGz$jsx, jsxs as $8ijGz$jsxs} from "react/jsx-runtime";
4
- import {clamp as $8ijGz$clamp} from "@react-aria/utils";
5
4
  import {ProgressBar as $8ijGz$ProgressBar} from "react-aria-components";
6
5
  import {createContext as $8ijGz$createContext, forwardRef as $8ijGz$forwardRef} from "react";
7
6
  import {useDOMRef as $8ijGz$useDOMRef} from "@react-spectrum/utils";
@@ -21,48 +20,17 @@ import {useDOMRef as $8ijGz$useDOMRef} from "@react-spectrum/utils";
21
20
 
22
21
 
23
22
 
24
-
25
23
  const $41ddd91dbbf0c389$export$afffa1e5edf12209 = /*#__PURE__*/ (0, $8ijGz$createContext)(null);
26
- const $41ddd91dbbf0c389$var$fillMask1Frames = "-_5slx9u";
27
- const $41ddd91dbbf0c389$var$fillMask2Frames = "-_36n5pc";
28
- const $41ddd91dbbf0c389$var$fillsRotate = "-nqh121";
29
- const $41ddd91dbbf0c389$var$circleDims = {
30
- height: {
31
- default: 32,
32
- size: {
33
- S: 16,
34
- L: 64
35
- }
36
- },
37
- width: {
38
- default: 32,
39
- size: {
40
- S: 16,
41
- L: 64
42
- }
43
- },
44
- aspectRatio: 'square'
45
- };
46
24
  // Double check the types passed to each style, may not need all for each
47
25
  const $41ddd91dbbf0c389$var$wrapper = function anonymous(props, overrides) {
48
26
  let rules = " .";
49
- 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) || [];
27
+ 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|k|o|p)[^\s]+/g) || [];
50
28
  rules += matches.join('');
51
29
  let $l = false;
52
- let $U = false;
30
+ let $k = false;
53
31
  for (let p of matches){
54
32
  if (/^\s*l/.test(p)) $l = true;
55
- if (/^\s*U/.test(p)) $U = true;
56
- }
57
- if (props.size === "L") {
58
- rules += ' kbC';
59
- rules += ' kB';
60
- } else if (props.size === "S") {
61
- rules += ' kbk';
62
- rules += ' kj';
63
- } else {
64
- rules += ' kbr';
65
- rules += ' kq';
33
+ if (/^\s*k/.test(p)) $k = true;
66
34
  }
67
35
  if (!$l) {
68
36
  if (props.size === "L") {
@@ -76,199 +44,52 @@ const $41ddd91dbbf0c389$var$wrapper = function anonymous(props, overrides) {
76
44
  rules += ' lq';
77
45
  }
78
46
  }
47
+ if (!$k) {
48
+ if (props.size === "L") {
49
+ rules += ' kbC';
50
+ rules += ' kB';
51
+ } else if (props.size === "S") {
52
+ rules += ' kbk';
53
+ rules += ' kj';
54
+ } else {
55
+ rules += ' kbr';
56
+ rules += ' kq';
57
+ }
58
+ }
79
59
  rules += ' _bb';
80
60
  rules += ' _Zb';
81
- if (!$U) rules += ' Uc';
82
61
  return rules;
83
62
  };
84
- const $41ddd91dbbf0c389$var$trackStyles = {
85
- ...$41ddd91dbbf0c389$var$circleDims,
86
- boxSizing: 'border-box',
87
- borderStyle: 'solid',
88
- borderWidth: {
89
- default: '[3px]',
90
- size: {
91
- S: 2,
92
- L: 4
93
- }
94
- },
95
- borderRadius: 'full'
96
- };
97
63
  const $41ddd91dbbf0c389$var$track = function anonymous(props) {
98
64
  let rules = " .";
99
- if (props.size === "L") {
100
- rules += ' kbC';
101
- rules += ' kB';
102
- } else if (props.size === "S") {
103
- rules += ' kbk';
104
- rules += ' kj';
105
- } else {
106
- rules += ' kbr';
107
- rules += ' kq';
108
- }
109
- if (props.size === "L") {
110
- rules += ' lbC';
111
- rules += ' lB';
112
- } else if (props.size === "S") {
113
- rules += ' lbk';
114
- rules += ' lj';
115
- } else {
116
- rules += ' lbr';
117
- rules += ' lq';
118
- }
119
- rules += ' _bb';
120
- rules += ' __na';
121
- rules += ' wa';
122
- if (props.size === "L") rules += ' ud';
123
- else if (props.size === "S") rules += ' uc';
124
- else rules += ' u-3760g0';
125
- if (props.size === "L") rules += ' vd';
126
- else if (props.size === "S") rules += ' vc';
127
- else rules += ' v-3760g0';
128
- if (props.size === "L") rules += ' sd';
129
- else if (props.size === "S") rules += ' sc';
130
- else rules += ' s-3760g0';
131
- if (props.size === "L") rules += ' td';
132
- else if (props.size === "S") rules += ' tc';
133
- else rules += ' t-3760g0';
134
- rules += ' _vf';
135
- rules += ' _wf';
136
- rules += ' _xf';
137
- rules += ' _yf';
138
- rules += ' ca_____u';
139
- if (props.staticColor === "black") {
140
- if (props.isPressed) rules += ' c_____n';
141
- else if (props.isFocusVisible) rules += ' c_____n';
142
- else if (props.isHovered) rules += ' c_____n';
143
- else rules += ' c_____m';
144
- } else if (props.staticColor === "white") {
145
- if (props.isPressed) rules += ' c_____a';
146
- else if (props.isFocusVisible) rules += ' c_____a';
147
- else if (props.isHovered) rules += ' c_____a';
148
- else rules += ' c____9';
149
- } else {
150
- if (props.isPressed) rules += ' cj';
151
- else if (props.isFocusVisible) rules += ' cj';
152
- else if (props.isHovered) rules += ' cj';
153
- else rules += ' ci';
154
- }
65
+ rules += ' fa_____w';
66
+ if (props.staticColor === "black") rules += ' f_____o';
67
+ else if (props.staticColor === "white") rules += ' f_____b';
68
+ else rules += ' fk';
155
69
  return rules;
156
70
  };
157
71
  const $41ddd91dbbf0c389$var$fill = function anonymous(props) {
158
72
  let rules = " .";
159
- if (props.size === "L") {
160
- rules += ' kbC';
161
- rules += ' kB';
162
- } else if (props.size === "S") {
163
- rules += ' kbk';
164
- rules += ' kj';
165
- } else {
166
- rules += ' kbr';
167
- rules += ' kq';
168
- }
169
- if (props.size === "L") {
170
- rules += ' lbC';
171
- rules += ' lB';
172
- } else if (props.size === "S") {
173
- rules += ' lbk';
174
- rules += ' lj';
175
- } else {
176
- rules += ' lbr';
177
- rules += ' lq';
178
- }
179
- rules += ' _bb';
180
- rules += ' __na';
181
- rules += ' wa';
182
- if (props.size === "L") rules += ' ud';
183
- else if (props.size === "S") rules += ' uc';
184
- else rules += ' u-3760g0';
185
- if (props.size === "L") rules += ' vd';
186
- else if (props.size === "S") rules += ' vc';
187
- else rules += ' v-3760g0';
188
- if (props.size === "L") rules += ' sd';
189
- else if (props.size === "S") rules += ' sc';
190
- else rules += ' s-3760g0';
191
- if (props.size === "L") rules += ' td';
192
- else if (props.size === "S") rules += ' tc';
193
- else rules += ' t-3760g0';
194
- rules += ' _vf';
195
- rules += ' _wf';
196
- rules += ' _xf';
197
- rules += ' _yf';
198
- rules += ' ca_____z';
199
- if (props.staticColor === "black") {
200
- if (props.isPressed) rules += ' c_____t';
201
- else if (props.isFocusVisible) rules += ' c_____t';
202
- else if (props.isHovered) rules += ' c_____t';
203
- else rules += ' c_____s';
204
- } else if (props.staticColor === "white") {
205
- if (props.isPressed) rules += ' c_____g';
206
- else if (props.isFocusVisible) rules += ' c_____g';
207
- else if (props.isHovered) rules += ' c_____g';
208
- else rules += ' c_____f';
209
- } else {
210
- if (props.isPressed) rules += ' cz';
211
- else if (props.isFocusVisible) rules += ' cz';
212
- else if (props.isHovered) rules += ' cz';
213
- else rules += ' cy';
214
- }
73
+ rules += ' fa_____B';
74
+ if (props.staticColor === "black") rules += ' f_____u';
75
+ else if (props.staticColor === "white") rules += ' f_____h';
76
+ else rules += ' fA';
77
+ rules += ' R-375ty3';
78
+ rules += ' __Ga';
215
79
  return rules;
216
80
  };
217
- const $41ddd91dbbf0c389$var$fillsWrapperStyles = {
218
- position: 'absolute',
219
- top: 0,
220
- left: 0,
221
- size: 'full'
222
- };
223
- const $41ddd91dbbf0c389$var$fillsWrapper = " . Ua Xa Ya l4 k4";
224
- const $41ddd91dbbf0c389$var$fillsWrapperIndeterminate = " . Ua Xa Ya l4 k4 __Pd T-1ecy9hq _S-157qd4d _T-yjb9nq _Y-1fqa2yh _X-twzmrf __Ga";
225
- const $41ddd91dbbf0c389$var$commonFillMask = {
226
- position: 'absolute',
227
- width: '[50%]',
228
- height: 'full',
229
- transformOrigin: '[100% center]',
230
- overflow: 'hidden'
231
- };
232
- const $41ddd91dbbf0c389$var$fillMask1 = " . Ua l-3760fj k4 __G-1gvo10c __vb __wb T-115o53i";
233
- const $41ddd91dbbf0c389$var$fillMask2 = " . Ua l-3760fj k4 __G-1gvo10c __vb __wb T-1gm38v9";
234
- const $41ddd91dbbf0c389$var$commonFillSubMask = {
235
- width: 'full',
236
- height: 'full',
237
- transformOrigin: '[100% center]',
238
- transform: 'rotate(-180deg)',
239
- overflow: 'hidden'
240
- };
241
- const $41ddd91dbbf0c389$var$commonFillSubMaskIndeterminate = {
242
- transform: 'translateZ(0)',
243
- willChange: 'transform',
244
- animationDuration: 1000,
245
- animationTimingFunction: 'linear',
246
- animationIterationCount: 'infinite'
247
- };
248
- const $41ddd91dbbf0c389$var$fillSubMask = " . l4 k4 __G-1gvo10c T-11akxcr __vb __wb";
249
- const $41ddd91dbbf0c389$var$fillSubMask1Indeterminate = " . l4 k4 __G-1gvo10c T-1ecy9hq __vb __wb _S-6p1wh7 _T-yjb9nq _Yb __Pd _X-twzmrf";
250
- const $41ddd91dbbf0c389$var$fillSubMask2Indeterminate = " . l4 k4 __G-1gvo10c T-1ecy9hq __vb __wb _S-47ds34 _T-yjb9nq _Yb __Pd _X-twzmrf";
81
+ const $41ddd91dbbf0c389$var$rotationAnimation = "-u41dq3";
82
+ // stroke-dashoffset represents `100 - percentage`. See below for how this works.
83
+ const $41ddd91dbbf0c389$var$dashoffsetAnimation = "-_1i5ccgk";
251
84
  function $41ddd91dbbf0c389$var$ProgressCircle(props, ref) {
252
85
  [props, ref] = (0, $5ce63c423902f47d$export$764f6146fadd77f7)(props, ref, $41ddd91dbbf0c389$export$afffa1e5edf12209);
253
- let { value: value = 0, minValue: minValue = 0, maxValue: maxValue = 100, size: size = 'M', staticColor: staticColor, isIndeterminate: isIndeterminate = false, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, UNSAFE_style: UNSAFE_style, UNSAFE_className: UNSAFE_className = '' } = props;
86
+ let { size: size = 'M', staticColor: staticColor, UNSAFE_style: UNSAFE_style, UNSAFE_className: UNSAFE_className = '' } = props;
254
87
  let domRef = (0, $8ijGz$useDOMRef)(ref);
255
- value = (0, $8ijGz$clamp)(value, minValue, maxValue);
256
- let subMask1Style = {};
257
- let subMask2Style = {};
258
- if (!isIndeterminate) {
259
- let percentage = (value - minValue) / (maxValue - minValue) * 100;
260
- let angle;
261
- if (percentage > 0 && percentage <= 50) {
262
- angle = -180 + percentage / 50 * 180;
263
- subMask1Style.transform = `rotate(${angle}deg)`;
264
- subMask2Style.transform = 'rotate(-180deg)';
265
- } else if (percentage > 50) {
266
- angle = -180 + (percentage - 50) / 50 * 180;
267
- subMask1Style.transform = 'rotate(0deg)';
268
- subMask2Style.transform = `rotate(${angle}deg)`;
269
- }
270
- }
271
- if (!ariaLabel && !ariaLabelledby) console.warn('ProgressCircle requires an aria-label or aria-labelledby attribute for accessibility');
88
+ let strokeWidth = 3;
89
+ if (size === 'S') strokeWidth = 2;
90
+ else if (size === 'L') strokeWidth = 4;
91
+ // SVG strokes are centered, so subtract half the stroke width from the radius to create an inner stroke.
92
+ let radius = `calc(50% - ${strokeWidth / 2}px)`;
272
93
  return /*#__PURE__*/ (0, $8ijGz$jsx)((0, $8ijGz$ProgressBar), {
273
94
  ...props,
274
95
  ref: domRef,
@@ -277,48 +98,42 @@ function $41ddd91dbbf0c389$var$ProgressCircle(props, ref) {
277
98
  ...renderProps,
278
99
  size: size
279
100
  }, props.styles),
280
- children: /*#__PURE__*/ (0, $8ijGz$jsxs)("div", {
281
- dir: "ltr",
282
- children: [
283
- /*#__PURE__*/ (0, $8ijGz$jsx)("div", {
284
- className: $41ddd91dbbf0c389$var$track({
285
- size: size,
286
- staticColor: staticColor
287
- })
288
- }),
289
- /*#__PURE__*/ (0, $8ijGz$jsxs)("div", {
290
- className: isIndeterminate ? $41ddd91dbbf0c389$var$fillsWrapperIndeterminate : $41ddd91dbbf0c389$var$fillsWrapper,
291
- children: [
292
- /*#__PURE__*/ (0, $8ijGz$jsx)("div", {
293
- className: $41ddd91dbbf0c389$var$fillMask1,
294
- children: /*#__PURE__*/ (0, $8ijGz$jsx)("div", {
295
- className: isIndeterminate ? $41ddd91dbbf0c389$var$fillSubMask1Indeterminate : $41ddd91dbbf0c389$var$fillSubMask,
296
- style: subMask1Style,
297
- children: /*#__PURE__*/ (0, $8ijGz$jsx)("div", {
298
- className: $41ddd91dbbf0c389$var$fill({
299
- size: size,
300
- staticColor: staticColor
301
- })
302
- })
303
- })
304
- }),
305
- /*#__PURE__*/ (0, $8ijGz$jsx)("div", {
306
- className: $41ddd91dbbf0c389$var$fillMask2,
307
- children: /*#__PURE__*/ (0, $8ijGz$jsx)("div", {
308
- className: isIndeterminate ? $41ddd91dbbf0c389$var$fillSubMask2Indeterminate : $41ddd91dbbf0c389$var$fillSubMask,
309
- style: subMask2Style,
310
- children: /*#__PURE__*/ (0, $8ijGz$jsx)("div", {
311
- className: $41ddd91dbbf0c389$var$fill({
312
- size: size,
313
- staticColor: staticColor
314
- })
315
- })
316
- })
101
+ children: ({ percentage: percentage, isIndeterminate: isIndeterminate })=>/*#__PURE__*/ (0, $8ijGz$jsxs)("svg", {
102
+ fill: "none",
103
+ width: "100%",
104
+ height: "100%",
105
+ children: [
106
+ /*#__PURE__*/ (0, $8ijGz$jsx)("circle", {
107
+ cx: "50%",
108
+ cy: "50%",
109
+ r: radius,
110
+ strokeWidth: strokeWidth,
111
+ className: $41ddd91dbbf0c389$var$track({
112
+ staticColor: staticColor
317
113
  })
318
- ]
319
- })
320
- ]
321
- })
114
+ }),
115
+ /*#__PURE__*/ (0, $8ijGz$jsx)("circle", {
116
+ cx: "50%",
117
+ cy: "50%",
118
+ r: radius,
119
+ strokeWidth: strokeWidth,
120
+ className: $41ddd91dbbf0c389$var$fill({
121
+ staticColor: staticColor
122
+ }),
123
+ style: {
124
+ // These cubic-bezier timing functions were derived from the previous animation keyframes
125
+ // using a best fit algorithm, and then manually adjusted to approximate the original animation.
126
+ animation: isIndeterminate ? `${$41ddd91dbbf0c389$var$rotationAnimation} 1s cubic-bezier(.6, .1, .3, .9) infinite, ${$41ddd91dbbf0c389$var$dashoffsetAnimation} 1s cubic-bezier(.25, .1, .25, 1.3) infinite` : undefined
127
+ },
128
+ // Normalize the path length to 100 so we can easily set stroke-dashoffset to a percentage.
129
+ pathLength: "100",
130
+ // Add extra gap between dashes so 0% works in Chrome.
131
+ strokeDasharray: "100 200",
132
+ strokeDashoffset: isIndeterminate || percentage == null ? undefined : 100 - percentage,
133
+ strokeLinecap: "round"
134
+ })
135
+ ]
136
+ })
322
137
  });
323
138
  }
324
139
  /**
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AA2BM,MAAM,0DAAwB,CAAA,GAAA,oBAAY,EAAkE;AAEnH,MAAM;AA0KN,MAAM;AAsFN,MAAM;AAKN,MAAM,mCAAa;IACjB,QAAQ;QACN,SAAS;QACT,MAAM;YACJ,GAAG;YACH,GAAG;QACL;IACF;IACA,OAAO;QACL,SAAS;QACT,MAAM;YACJ,GAAG;YACH,GAAG;QACL;IACF;IACA,aAAa;AACf;AAEA,yEAAyE;AACzE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMN,MAAM,oCAAc;IAClB,GAAG,gCAAU;IACb,WAAW;IACX,aAAa;IACb,aAAa;QACX,SAAS;QACT,MAAM;YACJ,GAAG;YACH,GAAG;QACL;IACF;IACA,cAAc;AAChB;AAEA,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBN,MAAM;;;;;;;;;;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A,aAAa,EAAC,IAAK,KAAK;YACxC,cAAc,SAAS,GAAG;YAC1B,cAAc,SAAS,GAAG,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;QACjD;IACF;IAEA,IAAI,CAAC,aAAa,CAAC,gBACjB,QAAQ,IAAI,CAAC;IAGf,qBACE,gBAAC,CAAA,GAAA,kBAAa;QACX,GAAG,KAAK;QACT,KAAK;QACL,OAAO;QACP,WAAW,CAAA,cAAe,mBAAmB,8BAAQ;gBACnD,GAAG,WAAW;sBACd;YACF,GAAG,MAAM,MAAM;kBACf,cAAA,iBAAC;YAAI,KAAI;;8BACP,gBAAC;oBAAI,WAAW,4BAAM;8BAAC;qCAAM;oBAAW;;8BACxC,iBAAC;oBAAI,WAAW,kBAAkB,kDAA4B;;sCAC5D,gBAAC;4BAAI,WAAW;sCACd,cAAA,gBAAC;gCACC,WAAW,kBAAkB,kDAA4B;gCACzD,OAAO;0CACP,cAAA,gBAAC;oCAAI,WAAW,2BAAK;8CAAC;qDAAM;oCAAW;;;;sCAG3C,gBAAC;4BAAI,WAAW;sCACd,cAAA,gBAAC;gCACC,WAAW,kBAAkB,kDAA4B;gCACzD,OAAO;0CACP,cAAA,gBAAC;oCAAI,WAAW,2BAAK;8CAAC;qDAAM;oCAAW;;;;;;;;;AAOrD;AAEA;;;CAGC,GACD,IAAI,4CAAkB,WAAW,GAAG,CAAA,GAAA,iBAAS,EAAE","sources":["packages/@react-spectrum/s2/src/ProgressCircle.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, style} from '../style/spectrum-theme' with {type: 'macro'};\nimport {clamp} from '@react-aria/utils';\nimport {ContextValue, ProgressBar as RACProgressBar, ProgressBarProps as RACProgressBarProps} from 'react-aria-components';\nimport {createContext, CSSProperties, forwardRef} from 'react';\nimport {DOMRef, DOMRefValue} from '@react-types/shared';\nimport {getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};\nimport {keyframes} from '../style/style-macro' with {type: 'macro'};\nimport {useDOMRef} from '@react-spectrum/utils';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\nexport interface ProgressCircleStyleProps {\n /**\n * The size of the ProgressCircle.\n *\n * @default 'M'\n */\n size?: 'S' | 'M' | 'L',\n /** The static color style to apply. Useful when the button appears over a color background. */\n staticColor?: 'black' | 'white',\n /**\n * Whether presentation is indeterminate when progress isn't known.\n */\n isIndeterminate?: boolean\n}\n\nexport const ProgressCircleContext = createContext<ContextValue<ProgressCircleProps, DOMRefValue<HTMLDivElement>>>(null);\n\nconst fillMask1Frames = keyframes(`\n0% {\n transform: rotate(90deg);\n}\n\n1.69% {\n transform: rotate(72.3deg);\n}\n\n3.39% {\n transform: rotate(55.5deg);\n}\n\n5.08% {\n transform: rotate(40.3deg);\n}\n\n6.78% {\n transform: rotate(25deg);\n}\n\n8.47% {\n transform: rotate(10.6deg);\n}\n\n10.17%, 40.68% {\n transform: rotate(0deg);\n}\n\n42.37% {\n transform: rotate(5.3deg);\n}\n\n44.07% {\n transform: rotate(13.4deg);\n}\n\n45.76% {\n transform: rotate(20.6deg);\n}\n\n47.46% {\n transform: rotate(29deg);\n}\n\n49.15% {\n transform: rotate(36.5deg);\n}\n\n50.85% {\n transform: rotate(42.6deg);\n}\n\n52.54% {\n transform: rotate(48.8deg);\n}\n\n54.24% {\n transform: rotate(54.2deg);\n}\n\n55.93% {\n transform: rotate(59.4deg);\n}\n\n57.63% {\n transform: rotate(63.2deg);\n}\n\n59.32% {\n transform: rotate(67.2deg);\n}\n\n61.02% {\n transform: rotate(70.8deg);\n}\n\n62.71% {\n transform: rotate(73.8deg);\n}\n\n64.41% {\n transform: rotate(76.2deg);\n}\n\n66.1% {\n transform: rotate(78.7deg);\n}\n\n67.8% {\n transform: rotate(80.6deg);\n}\n\n69.49% {\n transform: rotate(82.6deg);\n}\n\n71.19% {\n transform: rotate(83.7deg);\n}\n\n72.88% {\n transform: rotate(85deg);\n}\n\n74.58% {\n transform: rotate(86.3deg);\n}\n\n76.27% {\n transform: rotate(87deg);\n}\n\n77.97% {\n transform: rotate(87.7deg);\n}\n\n79.66% {\n transform: rotate(88.3deg);\n}\n\n81.36% {\n transform: rotate(88.6deg);\n}\n\n83.05% {\n transform: rotate(89.2deg);\n}\n\n84.75% {\n transform: rotate(89.2deg);\n}\n\n86.44% {\n transform: rotate(89.5deg);\n}\n\n88.14% {\n transform: rotate(89.9deg);\n}\n\n89.83% {\n transform: rotate(89.7deg);\n}\n\n91.53% {\n transform: rotate(90.1deg);\n}\n\n93.22% {\n transform: rotate(90.2deg);\n}\n\n94.92% {\n transform: rotate(90.1deg);\n}\n\n96.61% {\n transform: rotate(90deg);\n}\n\n98.31% {\n transform: rotate(89.8deg);\n}\n\n100% {\n transform: rotate(90deg);\n}\n`);\n\nconst fillMask2Frames = keyframes(`\n0%, 8.47% {\n transform: rotate(180deg);\n}\n\n10.17% {\n transform: rotate(179.2deg);\n}\n\n11.86% {\n transform: rotate(164deg);\n}\n\n13.56% {\n transform: rotate(151.8deg);\n}\n\n15.25% {\n transform: rotate(140.8deg);\n}\n\n16.95% {\n transform: rotate(130.3deg);\n}\n\n18.64% {\n transform: rotate(120.4deg);\n}\n\n20.34% {\n transform: rotate(110.8deg);\n}\n\n22.03% {\n transform: rotate(101.6deg);\n}\n\n23.73% {\n transform: rotate(93.5deg);\n}\n\n25.42% {\n transform: rotate(85.4deg);\n}\n\n27.12% {\n transform: rotate(78.1deg);\n}\n\n28.81% {\n transform: rotate(71.2deg);\n}\n\n30.51% {\n transform: rotate(89.1deg);\n}\n\n32.2% {\n transform: rotate(105.5deg);\n}\n\n33.9% {\n transform: rotate(121.3deg);\n}\n\n35.59% {\n transform: rotate(135.5deg);\n}\n\n37.29% {\n transform: rotate(148.4deg);\n}\n\n38.98% {\n transform: rotate(161deg);\n}\n\n40.68% {\n transform: rotate(173.5deg);\n}\n\n42.37%, 100% {\n transform: rotate(180deg);\n}\n`);\n\nconst fillsRotate = keyframes(`\n0% {transform: rotate(-90deg)}\n100% {transform: rotate(270deg)}\n`);\n\nconst circleDims = {\n height: {\n default: 32,\n size: {\n S: 16,\n L: 64\n }\n },\n width: {\n default: 32,\n size: {\n S: 16,\n L: 64\n }\n },\n aspectRatio: 'square'\n} as const;\n\n// Double check the types passed to each style, may not need all for each\nconst wrapper = style<ProgressCircleStyleProps>({\n ...circleDims,\n display: 'inline-block',\n position: 'relative'\n}, getAllowedOverrides());\n\nconst trackStyles = {\n ...circleDims,\n boxSizing: 'border-box',\n borderStyle: 'solid',\n borderWidth: {\n default: '[3px]',\n size: {\n S: 2,\n L: 4\n }\n },\n borderRadius: 'full'\n} as const;\n\nconst track = style<ProgressCircleStyleProps>({\n ...trackStyles,\n borderColor: {\n default: baseColor('gray-300'),\n staticColor: {\n white: {\n default: baseColor('transparent-white-300'),\n forcedColors: 'Background'\n },\n // TODO: no designs for this one\n black: {\n default: baseColor('transparent-black-300'),\n forcedColors: 'Background'\n }\n },\n forcedColors: 'Background'\n }\n});\n\nconst fill = style<ProgressCircleStyleProps>({\n ...trackStyles,\n borderColor: {\n default: baseColor('blue-900'),\n staticColor: {\n white: {\n default: baseColor('transparent-white-900'),\n forcedColors: 'Highlight'\n },\n // TODO: no designs for this one\n black: {\n default: baseColor('transparent-black-900'),\n forcedColors: 'Highlight'\n }\n },\n forcedColors: 'Highlight'\n }\n});\n\nconst fillsWrapperStyles = {\n position: 'absolute',\n top: 0,\n left: 0,\n size: 'full'\n} as const;\n\nconst fillsWrapper = style({\n ...fillsWrapperStyles\n});\n\nconst fillsWrapperIndeterminate = style({\n ...fillsWrapperStyles,\n willChange: 'transform',\n transform: 'translateZ(0)',\n animation: fillsRotate,\n animationDuration: 1000,\n animationTimingFunction: '[cubic-bezier(.25,.78,.48,.89)]',\n animationIterationCount: 'infinite',\n transformOrigin: 'center'\n});\n\nconst commonFillMask = {\n position: 'absolute',\n width: '[50%]',\n height: 'full',\n transformOrigin: '[100% center]',\n overflow: 'hidden'\n} as const;\n\nconst fillMask1 = style({\n ...commonFillMask,\n transform: 'rotate(180deg)'\n});\n\nconst fillMask2 = style({\n ...commonFillMask,\n transform: 'rotate(0deg)'\n});\n\nconst commonFillSubMask = {\n width: 'full',\n height: 'full',\n transformOrigin: '[100% center]',\n transform: 'rotate(-180deg)',\n overflow: 'hidden'\n} as const;\n\nconst commonFillSubMaskIndeterminate = {\n transform: 'translateZ(0)',\n willChange: 'transform',\n animationDuration: 1000,\n animationTimingFunction: 'linear',\n animationIterationCount: 'infinite'\n} as const;\n\nconst fillSubMask = style({\n ...commonFillSubMask\n});\n\nconst fillSubMask1Indeterminate = style({\n ...commonFillSubMask,\n animation: fillMask1Frames,\n ...commonFillSubMaskIndeterminate\n});\n\nconst fillSubMask2Indeterminate = style({\n ...commonFillSubMask,\n animation: fillMask2Frames,\n ...commonFillSubMaskIndeterminate\n});\n\nexport interface ProgressCircleProps extends Omit<RACProgressBarProps, 'children' | 'style' | 'valueLabel' | 'formatOptions' | 'label' | 'className'>, ProgressCircleStyleProps, StyleProps {}\n\nfunction ProgressCircle(props: ProgressCircleProps, ref: DOMRef<HTMLDivElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, ProgressCircleContext);\n let {\n value = 0,\n minValue = 0,\n maxValue = 100,\n size = 'M',\n staticColor,\n isIndeterminate = false,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n UNSAFE_style,\n UNSAFE_className = ''\n } = props;\n let domRef = useDOMRef(ref);\n\n value = clamp(value, minValue, maxValue);\n\n let subMask1Style: CSSProperties = {};\n let subMask2Style: CSSProperties = {};\n if (!isIndeterminate) {\n let percentage = (value - minValue) / (maxValue - minValue) * 100;\n let angle;\n if (percentage > 0 && percentage <= 50) {\n angle = -180 + (percentage / 50 * 180);\n subMask1Style.transform = `rotate(${angle}deg)`;\n subMask2Style.transform = 'rotate(-180deg)';\n } else if (percentage > 50) {\n angle = -180 + (percentage - 50) / 50 * 180;\n subMask1Style.transform = 'rotate(0deg)';\n subMask2Style.transform = `rotate(${angle}deg)`;\n }\n }\n\n if (!ariaLabel && !ariaLabelledby) {\n console.warn('ProgressCircle requires an aria-label or aria-labelledby attribute for accessibility');\n }\n\n return (\n <RACProgressBar\n {...props}\n ref={domRef}\n style={UNSAFE_style}\n className={renderProps => UNSAFE_className + wrapper({\n ...renderProps,\n size\n }, props.styles)}>\n <div dir=\"ltr\">\n <div className={track({size, staticColor})} />\n <div className={isIndeterminate ? fillsWrapperIndeterminate : fillsWrapper}>\n <div className={fillMask1}>\n <div\n className={isIndeterminate ? fillSubMask1Indeterminate : fillSubMask}\n style={subMask1Style}>\n <div className={fill({size, staticColor})} />\n </div>\n </div>\n <div className={fillMask2}>\n <div\n className={isIndeterminate ? fillSubMask2Indeterminate : fillSubMask}\n style={subMask2Style}>\n <div className={fill({size, staticColor})} />\n </div>\n </div>\n </div>\n </div>\n </RACProgressBar>\n );\n}\n\n/**\n * ProgressCircles show the progression of a system operation such as downloading, uploading, or processing, in a visual way.\n * They can represent determinate or indeterminate progress.\n */\nlet _ProgressCircle = /*#__PURE__*/ forwardRef(ProgressCircle);\nexport {_ProgressCircle as ProgressCircle};\n"],"names":[],"version":3,"file":"ProgressCircle.mjs.map"}
1
+ {"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA0BM,MAAM,0DAAwB,CAAA,GAAA,oBAAY,EAAkE;AAEnH,yEAAyE;AACzE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYN,MAAM;;;;;;;;AAWN,MAAM;;;;;;;;;;AAeN,MAAM;AAUN,iFAAiF;AACjF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Content":["/*\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, ProgressBar as RACProgressBar, ProgressBarProps as RACProgressBarProps} from 'react-aria-components';\nimport {createContext, forwardRef} from 'react';\nimport {DOMRef, DOMRefValue} from '@react-types/shared';\nimport {getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};\nimport {keyframes} from '../style/style-macro' with {type: 'macro'};\nimport {style} from '../style/spectrum-theme' with {type: 'macro'};\nimport {useDOMRef} from '@react-spectrum/utils';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\nexport interface ProgressCircleStyleProps {\n /**\n * The size of the ProgressCircle.\n *\n * @default 'M'\n */\n size?: 'S' | 'M' | 'L',\n /** The static color style to apply. Useful when the button appears over a color background. */\n staticColor?: 'black' | 'white',\n /**\n * Whether presentation is indeterminate when progress isn't known.\n */\n isIndeterminate?: boolean\n}\n\nexport const ProgressCircleContext = createContext<ContextValue<ProgressCircleProps, DOMRefValue<HTMLDivElement>>>(null);\n\n// Double check the types passed to each style, may not need all for each\nconst wrapper = style<ProgressCircleStyleProps>({\n size: {\n default: 32,\n size: {\n S: 16,\n L: 64\n }\n },\n aspectRatio: 'square',\n display: 'inline-block'\n}, getAllowedOverrides({height: true}));\n\nconst track = style<ProgressCircleStyleProps>({\n stroke: {\n default: 'gray-300',\n staticColor: {\n white: 'transparent-white-300',\n black: 'transparent-black-300'\n },\n forcedColors: 'Background'\n }\n});\n\nconst fill = style<ProgressCircleStyleProps>({\n stroke: {\n default: 'blue-900',\n staticColor: {\n white: 'transparent-white-900',\n black: 'transparent-black-900'\n },\n forcedColors: 'Highlight'\n },\n rotate: -90,\n transformOrigin: 'center'\n});\n\nexport interface ProgressCircleProps extends Omit<RACProgressBarProps, 'children' | 'style' | 'valueLabel' | 'formatOptions' | 'label' | 'className'>, ProgressCircleStyleProps, StyleProps {}\n\nconst rotationAnimation = keyframes(`\n 0% {\n transform: rotate(0deg);\n }\n\n 100% {\n transform: rotate(360deg);\n }\n`);\n\n// stroke-dashoffset represents `100 - percentage`. See below for how this works.\nconst dashoffsetAnimation = keyframes(`\n 0%, 100% {\n stroke-dashoffset: 75;\n }\n\n 30% {\n stroke-dashoffset: 20;\n }\n`);\n\nfunction ProgressCircle(props: ProgressCircleProps, ref: DOMRef<HTMLDivElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, ProgressCircleContext);\n let {\n size = 'M',\n staticColor,\n UNSAFE_style,\n UNSAFE_className = ''\n } = props;\n let domRef = useDOMRef(ref);\n\n let strokeWidth = 3;\n if (size === 'S') {\n strokeWidth = 2;\n } else if (size === 'L') {\n strokeWidth = 4;\n }\n\n // SVG strokes are centered, so subtract half the stroke width from the radius to create an inner stroke.\n let radius = `calc(50% - ${strokeWidth / 2}px)`;\n\n return (\n <RACProgressBar\n {...props}\n ref={domRef}\n style={UNSAFE_style}\n className={renderProps => UNSAFE_className + wrapper({\n ...renderProps,\n size\n }, props.styles)}>\n {({percentage, isIndeterminate}) => (\n <svg\n fill=\"none\"\n width=\"100%\"\n height=\"100%\">\n <circle\n cx=\"50%\"\n cy=\"50%\"\n r={radius}\n strokeWidth={strokeWidth}\n className={track({staticColor})} />\n <circle\n cx=\"50%\"\n cy=\"50%\"\n r={radius}\n strokeWidth={strokeWidth}\n className={fill({staticColor})}\n style={{\n // These cubic-bezier timing functions were derived from the previous animation keyframes\n // using a best fit algorithm, and then manually adjusted to approximate the original animation.\n animation: isIndeterminate ? `${rotationAnimation} 1s cubic-bezier(.6, .1, .3, .9) infinite, ${dashoffsetAnimation} 1s cubic-bezier(.25, .1, .25, 1.3) infinite` : undefined\n }}\n // Normalize the path length to 100 so we can easily set stroke-dashoffset to a percentage.\n pathLength=\"100\"\n // Add extra gap between dashes so 0% works in Chrome.\n strokeDasharray=\"100 200\"\n strokeDashoffset={isIndeterminate || percentage == null ? undefined : 100 - percentage}\n strokeLinecap=\"round\" />\n </svg>\n )}\n </RACProgressBar>\n );\n}\n\n/**\n * ProgressCircles show the progression of a system operation such as downloading, uploading, or processing, in a visual way.\n * They can represent determinate or indeterminate progress.\n */\nlet _ProgressCircle = /*#__PURE__*/ forwardRef(ProgressCircle);\nexport {_ProgressCircle as ProgressCircle};\n"],"names":[],"version":3,"file":"ProgressCircle.mjs.map"}
package/dist/types.d.ts CHANGED
@@ -535,9 +535,13 @@ export interface BreadcrumbProps extends Omit<AriaBreadcrumbItemProps, 'children
535
535
  }
536
536
  /** An individual Breadcrumb for Breadcrumbs. */
537
537
  export let Breadcrumb: (props: BreadcrumbProps & RefAttributes<DOMRefValue<HTMLLIElement>>) => ReactElement | null;
538
+ interface CardRenderProps {
539
+ /** The size of the Card. */
540
+ size: 'XS' | 'S' | 'M' | 'L' | 'XL';
541
+ }
538
542
  export interface CardProps extends Omit<GridListItemProps, 'className' | 'style' | 'children'>, StyleProps {
539
543
  /** The children of the Card. */
540
- children: ReactNode;
544
+ children: ReactNode | ((renderProps: CardRenderProps) => ReactNode);
541
545
  /**
542
546
  * The size of the Card.
543
547
  * @default 'M'
@@ -605,7 +609,7 @@ export interface CardViewProps<T> extends Omit<GridListProps<T>, 'layout' | 'key
605
609
  /** Spectrum-defined styles, returned by the `style()` macro. */
606
610
  styles?: StylesPropWithHeight;
607
611
  }
608
- export function CardView<T extends object>(props: CardViewProps<T>): JSX.Element;
612
+ export const CardView: <T extends object>(props: CardViewProps<T> & RefAttributes<DOMRefValue<HTMLDivElement>>) => ReactElement | null;
609
613
  export interface DialogTriggerProps extends _DialogTriggerProps1, Pick<_PopoverProps1, 'placement' | 'shouldFlip' | 'isKeyboardDismissDisabled' | 'containerPadding' | 'offset' | 'crossOffset'> {
610
614
  /**
611
615
  * The type of Dialog that should be rendered.