@fluentui/react-spinner 9.1.12 → 9.2.1
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/CHANGELOG.json +63 -1
- package/CHANGELOG.md +24 -2
- package/dist/index.d.ts +11 -1
- package/lib/components/Spinner/Spinner.types.js.map +1 -1
- package/lib/components/Spinner/renderSpinner.js +3 -2
- package/lib/components/Spinner/renderSpinner.js.map +1 -1
- package/lib/components/Spinner/useSpinner.js +19 -2
- package/lib/components/Spinner/useSpinner.js.map +1 -1
- package/lib-commonjs/components/Spinner/renderSpinner.js +2 -2
- package/lib-commonjs/components/Spinner/renderSpinner.js.map +1 -1
- package/lib-commonjs/components/Spinner/useSpinner.js +21 -1
- package/lib-commonjs/components/Spinner/useSpinner.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,69 @@
|
|
|
2
2
|
"name": "@fluentui/react-spinner",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "Thu,
|
|
5
|
+
"date": "Thu, 25 May 2023 09:57:45 GMT",
|
|
6
|
+
"tag": "@fluentui/react-spinner_v9.2.1",
|
|
7
|
+
"version": "9.2.1",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "beachball",
|
|
12
|
+
"package": "@fluentui/react-spinner",
|
|
13
|
+
"comment": "Bump @fluentui/react-jsx-runtime to v9.0.0-alpha.5",
|
|
14
|
+
"commit": "8f7c1b7591b3e665ae39e1b22ab0f0b28fb795c4"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "beachball",
|
|
18
|
+
"package": "@fluentui/react-spinner",
|
|
19
|
+
"comment": "Bump @fluentui/react-label to v9.1.14",
|
|
20
|
+
"commit": "8f7c1b7591b3e665ae39e1b22ab0f0b28fb795c4"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"author": "beachball",
|
|
24
|
+
"package": "@fluentui/react-spinner",
|
|
25
|
+
"comment": "Bump @fluentui/react-utilities to v9.9.1",
|
|
26
|
+
"commit": "8f7c1b7591b3e665ae39e1b22ab0f0b28fb795c4"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"date": "Wed, 24 May 2023 20:45:33 GMT",
|
|
33
|
+
"tag": "@fluentui/react-spinner_v9.2.0",
|
|
34
|
+
"version": "9.2.0",
|
|
35
|
+
"comments": {
|
|
36
|
+
"minor": [
|
|
37
|
+
{
|
|
38
|
+
"author": "kakrookaran@gmail.com",
|
|
39
|
+
"package": "@fluentui/react-spinner",
|
|
40
|
+
"commit": "5fe4247bc7ce2ff095b1f4c8f727e57293413601",
|
|
41
|
+
"comment": "feat: added delay prop to spinner"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"author": "beachball",
|
|
45
|
+
"package": "@fluentui/react-spinner",
|
|
46
|
+
"comment": "Bump @fluentui/react-label to v9.1.13",
|
|
47
|
+
"commit": "3f088b7b09988e7c05af1c953021acc94c273026"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"author": "beachball",
|
|
51
|
+
"package": "@fluentui/react-spinner",
|
|
52
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.5.0",
|
|
53
|
+
"commit": "3f088b7b09988e7c05af1c953021acc94c273026"
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"none": [
|
|
57
|
+
{
|
|
58
|
+
"author": "olfedias@microsoft.com",
|
|
59
|
+
"package": "@fluentui/react-spinner",
|
|
60
|
+
"commit": "69e0617a93cb44ef42f3bd19284b7dc5fe27fed3",
|
|
61
|
+
"comment": "chore: update test-ssr script"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"date": "Thu, 18 May 2023 00:39:15 GMT",
|
|
6
68
|
"tag": "@fluentui/react-spinner_v9.1.12",
|
|
7
69
|
"version": "9.1.12",
|
|
8
70
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,34 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-spinner
|
|
2
2
|
|
|
3
|
-
This log was last generated on Thu,
|
|
3
|
+
This log was last generated on Thu, 25 May 2023 09:57:45 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.2.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-spinner_v9.2.1)
|
|
8
|
+
|
|
9
|
+
Thu, 25 May 2023 09:57:45 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-spinner_v9.2.0..@fluentui/react-spinner_v9.2.1)
|
|
11
|
+
|
|
12
|
+
### Patches
|
|
13
|
+
|
|
14
|
+
- Bump @fluentui/react-jsx-runtime to v9.0.0-alpha.5 ([PR #27988](https://github.com/microsoft/fluentui/pull/27988) by beachball)
|
|
15
|
+
- Bump @fluentui/react-label to v9.1.14 ([PR #27988](https://github.com/microsoft/fluentui/pull/27988) by beachball)
|
|
16
|
+
- Bump @fluentui/react-utilities to v9.9.1 ([PR #27988](https://github.com/microsoft/fluentui/pull/27988) by beachball)
|
|
17
|
+
|
|
18
|
+
## [9.2.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-spinner_v9.2.0)
|
|
19
|
+
|
|
20
|
+
Wed, 24 May 2023 20:45:33 GMT
|
|
21
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-spinner_v9.1.12..@fluentui/react-spinner_v9.2.0)
|
|
22
|
+
|
|
23
|
+
### Minor changes
|
|
24
|
+
|
|
25
|
+
- feat: added delay prop to spinner ([PR #27852](https://github.com/microsoft/fluentui/pull/27852) by kakrookaran@gmail.com)
|
|
26
|
+
- Bump @fluentui/react-label to v9.1.13 ([PR #27989](https://github.com/microsoft/fluentui/pull/27989) by beachball)
|
|
27
|
+
- Bump @fluentui/react-shared-contexts to v9.5.0 ([PR #27989](https://github.com/microsoft/fluentui/pull/27989) by beachball)
|
|
28
|
+
|
|
7
29
|
## [9.1.12](https://github.com/microsoft/fluentui/tree/@fluentui/react-spinner_v9.1.12)
|
|
8
30
|
|
|
9
|
-
Thu, 18 May 2023 00:
|
|
31
|
+
Thu, 18 May 2023 00:39:15 GMT
|
|
10
32
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-spinner_v9.1.11..@fluentui/react-spinner_v9.1.12)
|
|
11
33
|
|
|
12
34
|
### Patches
|
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,11 @@ export declare type SpinnerProps = Omit<ComponentProps<SpinnerSlots>, 'size'> &
|
|
|
27
27
|
* @default 'primary'
|
|
28
28
|
*/
|
|
29
29
|
appearance?: 'primary' | 'inverted';
|
|
30
|
+
/**
|
|
31
|
+
* Time in milliseconds after component mount before spinner is visible.
|
|
32
|
+
* @default 0
|
|
33
|
+
*/
|
|
34
|
+
delay?: number;
|
|
30
35
|
/**
|
|
31
36
|
* Where the label is positioned relative to the Spinner
|
|
32
37
|
* @default 'after'
|
|
@@ -61,7 +66,12 @@ export declare type SpinnerSlots = {
|
|
|
61
66
|
/**
|
|
62
67
|
* State used in rendering Spinner
|
|
63
68
|
*/
|
|
64
|
-
export declare type SpinnerState = ComponentState<SpinnerSlots> & Required<Pick<SpinnerProps, 'appearance' | 'labelPosition' | 'size'
|
|
69
|
+
export declare type SpinnerState = ComponentState<SpinnerSlots> & Required<Pick<SpinnerProps, 'appearance' | 'delay' | 'labelPosition' | 'size'>> & {
|
|
70
|
+
/**
|
|
71
|
+
* Should the spinner be rendered in the DOM
|
|
72
|
+
*/
|
|
73
|
+
shouldRenderSpinner: boolean;
|
|
74
|
+
};
|
|
65
75
|
|
|
66
76
|
/**
|
|
67
77
|
* Create the state required to render Spinner.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../../src/components/Spinner/Spinner.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport { Label } from '@fluentui/react-label';\n\nexport type SpinnerSlots = {\n /**\n * The root of the Spinner.\n * The root slot receives the `className` and `style` specified directly on the `<Spinner>`.\n */\n root: NonNullable<Slot<'div'>>;\n /**\n * The slot for the animated svg.\n * The spinner slot receives the `className` and `style` that handles the spinning animation.\n * An svg is also rendered as a child of this slot\n */\n spinner?: Slot<'span'>;\n /**\n * The label of the Slider.\n * The label slot receives the styling related to the text associated with the Spinner.\n */\n label?: Slot<typeof Label>;\n};\n\n/**\n * Spinner Props\n */\nexport type SpinnerProps = Omit<ComponentProps<SpinnerSlots>, 'size'> & {\n /**\n * The appearance of the Spinner.\n * @default 'primary'\n */\n appearance?: 'primary' | 'inverted';\n\n /**\n * Where the label is positioned relative to the Spinner\n * @default 'after'\n */\n labelPosition?: 'above' | 'below' | 'before' | 'after';\n\n /**\n * The size of the spinner.\n * @default 'medium'\n */\n size?: 'tiny' | 'extra-small' | 'small' | 'medium' | 'large' | 'extra-large' | 'huge';\n};\n\n/**\n * State used in rendering Spinner\n */\nexport type SpinnerState = ComponentState<SpinnerSlots> &\n Required<Pick<SpinnerProps, 'appearance' | 'labelPosition' | 'size'
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/components/Spinner/Spinner.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport { Label } from '@fluentui/react-label';\n\nexport type SpinnerSlots = {\n /**\n * The root of the Spinner.\n * The root slot receives the `className` and `style` specified directly on the `<Spinner>`.\n */\n root: NonNullable<Slot<'div'>>;\n /**\n * The slot for the animated svg.\n * The spinner slot receives the `className` and `style` that handles the spinning animation.\n * An svg is also rendered as a child of this slot\n */\n spinner?: Slot<'span'>;\n /**\n * The label of the Slider.\n * The label slot receives the styling related to the text associated with the Spinner.\n */\n label?: Slot<typeof Label>;\n};\n\n/**\n * Spinner Props\n */\nexport type SpinnerProps = Omit<ComponentProps<SpinnerSlots>, 'size'> & {\n /**\n * The appearance of the Spinner.\n * @default 'primary'\n */\n appearance?: 'primary' | 'inverted';\n\n /**\n * Time in milliseconds after component mount before spinner is visible.\n * @default 0\n */\n delay?: number;\n\n /**\n * Where the label is positioned relative to the Spinner\n * @default 'after'\n */\n labelPosition?: 'above' | 'below' | 'before' | 'after';\n\n /**\n * The size of the spinner.\n * @default 'medium'\n */\n size?: 'tiny' | 'extra-small' | 'small' | 'medium' | 'large' | 'extra-large' | 'huge';\n};\n\n/**\n * State used in rendering Spinner\n */\nexport type SpinnerState = ComponentState<SpinnerSlots> &\n Required<Pick<SpinnerProps, 'appearance' | 'delay' | 'labelPosition' | 'size'>> & {\n /**\n * Should the spinner be rendered in the DOM\n */\n shouldRenderSpinner: boolean;\n };\n"],"mappings":"AAAA"}
|
|
@@ -9,8 +9,9 @@ export const renderSpinner_unstable = state => {
|
|
|
9
9
|
slotProps
|
|
10
10
|
} = getSlotsNext(state);
|
|
11
11
|
const {
|
|
12
|
-
labelPosition
|
|
12
|
+
labelPosition,
|
|
13
|
+
shouldRenderSpinner
|
|
13
14
|
} = state;
|
|
14
|
-
return /*#__PURE__*/createElement(slots.root, slotProps.root, slots.label && (labelPosition === 'above' || labelPosition === 'before') && /*#__PURE__*/createElement(slots.label, slotProps.label), slots.spinner && /*#__PURE__*/createElement(slots.spinner, slotProps.spinner), slots.label && (labelPosition === 'below' || labelPosition === 'after') && /*#__PURE__*/createElement(slots.label, slotProps.label));
|
|
15
|
+
return /*#__PURE__*/createElement(slots.root, slotProps.root, slots.label && shouldRenderSpinner && (labelPosition === 'above' || labelPosition === 'before') && /*#__PURE__*/createElement(slots.label, slotProps.label), slots.spinner && shouldRenderSpinner && /*#__PURE__*/createElement(slots.spinner, slotProps.spinner), slots.label && shouldRenderSpinner && (labelPosition === 'below' || labelPosition === 'after') && /*#__PURE__*/createElement(slots.label, slotProps.label));
|
|
15
16
|
};
|
|
16
17
|
//# sourceMappingURL=renderSpinner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createElement","getSlotsNext","renderSpinner_unstable","state","slots","slotProps","labelPosition","root","label","spinner"],"sources":["../../../src/components/Spinner/renderSpinner.tsx"],"sourcesContent":["/** @jsxRuntime classic */\n/** @jsx createElement */\n\nimport { createElement } from '@fluentui/react-jsx-runtime';\n\nimport { getSlotsNext } from '@fluentui/react-utilities';\nimport type { SpinnerState, SpinnerSlots } from './Spinner.types';\n\n/**\n * Render the final JSX of Spinner\n */\nexport const renderSpinner_unstable = (state: SpinnerState) => {\n const { slots, slotProps } = getSlotsNext<SpinnerSlots>(state);\n const { labelPosition } = state;\n return (\n <slots.root {...slotProps.root}>\n {slots.label && (labelPosition === 'above' || labelPosition === 'before') && <slots.label {...slotProps.label}
|
|
1
|
+
{"version":3,"names":["createElement","getSlotsNext","renderSpinner_unstable","state","slots","slotProps","labelPosition","shouldRenderSpinner","root","label","spinner"],"sources":["../../../src/components/Spinner/renderSpinner.tsx"],"sourcesContent":["/** @jsxRuntime classic */\n/** @jsx createElement */\n\nimport { createElement } from '@fluentui/react-jsx-runtime';\n\nimport { getSlotsNext } from '@fluentui/react-utilities';\nimport type { SpinnerState, SpinnerSlots } from './Spinner.types';\n\n/**\n * Render the final JSX of Spinner\n */\nexport const renderSpinner_unstable = (state: SpinnerState) => {\n const { slots, slotProps } = getSlotsNext<SpinnerSlots>(state);\n const { labelPosition, shouldRenderSpinner } = state;\n return (\n <slots.root {...slotProps.root}>\n {slots.label && shouldRenderSpinner && (labelPosition === 'above' || labelPosition === 'before') && (\n <slots.label {...slotProps.label} />\n )}\n {slots.spinner && shouldRenderSpinner && <slots.spinner {...slotProps.spinner} />}\n {slots.label && shouldRenderSpinner && (labelPosition === 'below' || labelPosition === 'after') && (\n <slots.label {...slotProps.label} />\n )}\n </slots.root>\n );\n};\n"],"mappings":"AAAA,2BACA,yBAEA,SAASA,aAAa,QAAQ;AAE9B,SAASC,YAAY,QAAQ;AAG7B;;;AAGA,OAAO,MAAMC,sBAAA,GAA0BC,KAAA,IAAwB;EAC7D,MAAM;IAAEC,KAAA;IAAOC;EAAS,CAAE,GAAGJ,YAAA,CAA2BE,KAAA;EACxD,MAAM;IAAEG,aAAA;IAAeC;EAAmB,CAAE,GAAGJ,KAAA;EAC/C,oBACEH,aAdJ,CAcKI,KAAA,CAAMI,IAAI,EAAKH,SAAA,CAAUG,IAAI,EAC3BJ,KAAA,CAAMK,KAAK,IAAIF,mBAAA,KAAwBD,aAAA,KAAkB,WAAWA,aAAA,KAAkB,QAAO,kBAC5FN,aAhBR,CAgBSI,KAAA,CAAMK,KAAK,EAAKJ,SAAA,CAAUI,KAAK,GAEjCL,KAAA,CAAMM,OAAO,IAAIH,mBAAA,iBAAuBP,aAlB/C,CAkBgDI,KAAA,CAAMM,OAAO,EAAKL,SAAA,CAAUK,OAAO,GAC5EN,KAAA,CAAMK,KAAK,IAAIF,mBAAA,KAAwBD,aAAA,KAAkB,WAAWA,aAAA,KAAkB,OAAM,kBAC3FN,aApBR,CAoBSI,KAAA,CAAMK,KAAK,EAAKJ,SAAA,CAAUI,KAAK;AAIxC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { getNativeElementProps, resolveShorthand, useId } from '@fluentui/react-utilities';
|
|
2
|
+
import { getNativeElementProps, resolveShorthand, useId, useTimeout } from '@fluentui/react-utilities';
|
|
3
3
|
import { Label } from '@fluentui/react-label';
|
|
4
4
|
import { DefaultSvg } from './DefaultSvg';
|
|
5
5
|
/**
|
|
@@ -16,7 +16,8 @@ export const useSpinner_unstable = (props, ref) => {
|
|
|
16
16
|
const {
|
|
17
17
|
appearance = 'primary',
|
|
18
18
|
labelPosition = 'after',
|
|
19
|
-
size = 'medium'
|
|
19
|
+
size = 'medium',
|
|
20
|
+
delay = 0
|
|
20
21
|
} = props;
|
|
21
22
|
const baseId = useId('spinner');
|
|
22
23
|
const {
|
|
@@ -29,6 +30,20 @@ export const useSpinner_unstable = (props, ref) => {
|
|
|
29
30
|
role,
|
|
30
31
|
...rest
|
|
31
32
|
}, ['size']);
|
|
33
|
+
const [isVisible, setIsVisible] = React.useState(true);
|
|
34
|
+
const [setDelayTimeout, clearDelayTimeout] = useTimeout();
|
|
35
|
+
React.useEffect(() => {
|
|
36
|
+
if (delay <= 0) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
setIsVisible(false);
|
|
40
|
+
setDelayTimeout(() => {
|
|
41
|
+
setIsVisible(true);
|
|
42
|
+
}, delay);
|
|
43
|
+
return () => {
|
|
44
|
+
clearDelayTimeout();
|
|
45
|
+
};
|
|
46
|
+
}, [setDelayTimeout, clearDelayTimeout, delay]);
|
|
32
47
|
const labelShorthand = resolveShorthand(props.label, {
|
|
33
48
|
defaultProps: {
|
|
34
49
|
id: baseId
|
|
@@ -47,8 +62,10 @@ export const useSpinner_unstable = (props, ref) => {
|
|
|
47
62
|
}
|
|
48
63
|
const state = {
|
|
49
64
|
appearance,
|
|
65
|
+
delay,
|
|
50
66
|
labelPosition,
|
|
51
67
|
size,
|
|
68
|
+
shouldRenderSpinner: isVisible,
|
|
52
69
|
components: {
|
|
53
70
|
root: 'div',
|
|
54
71
|
spinner: 'span',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","getNativeElementProps","resolveShorthand","useId","Label","DefaultSvg","useSpinner_unstable","props","ref","appearance","labelPosition","size","baseId","role","tabIndex","rest","nativeRoot","labelShorthand","label","defaultProps","id","required","spinnerShortHand","spinner","children","createElement","state","components","root"],"sources":["../../../src/components/Spinner/useSpinner.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, resolveShorthand, useId } from '@fluentui/react-utilities';\nimport type { SpinnerProps, SpinnerState } from './Spinner.types';\nimport { Label } from '@fluentui/react-label';\nimport { DefaultSvg } from './DefaultSvg';\n\n/**\n * Create the state required to render Spinner.\n *\n * The returned state can be modified with hooks such as useSpinnerStyles_unstable,\n * before being passed to renderSpinner_unstable.\n *\n * @param props - props from this instance of Spinner\n * @param ref - reference to root HTMLElement of Spinner\n */\nexport const useSpinner_unstable = (props: SpinnerProps, ref: React.Ref<HTMLElement>): SpinnerState => {\n // Props\n const { appearance = 'primary', labelPosition = 'after', size = 'medium' } = props;\n const baseId = useId('spinner');\n\n const { role = 'progressbar', tabIndex, ...rest } = props;\n const nativeRoot = getNativeElementProps('div', { ref, role, ...rest }, ['size']);\n\n const labelShorthand = resolveShorthand(props.label, {\n defaultProps: {\n id: baseId,\n },\n required: false,\n });\n\n const spinnerShortHand = resolveShorthand(props.spinner, {\n required: true,\n defaultProps: {\n children: <DefaultSvg />,\n tabIndex,\n },\n });\n\n if (labelShorthand && nativeRoot && !nativeRoot['aria-labelledby']) {\n nativeRoot['aria-labelledby'] = labelShorthand.id;\n }\n\n const state: SpinnerState = {\n appearance,\n labelPosition,\n size,\n components: {\n root: 'div',\n spinner: 'span',\n label: Label,\n },\n root: nativeRoot,\n spinner: spinnerShortHand,\n label: labelShorthand,\n };\n return state;\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,qBAAqB,EAAEC,gBAAgB,EAAEC,KAAK,QAAQ;
|
|
1
|
+
{"version":3,"names":["React","getNativeElementProps","resolveShorthand","useId","useTimeout","Label","DefaultSvg","useSpinner_unstable","props","ref","appearance","labelPosition","size","delay","baseId","role","tabIndex","rest","nativeRoot","isVisible","setIsVisible","useState","setDelayTimeout","clearDelayTimeout","useEffect","labelShorthand","label","defaultProps","id","required","spinnerShortHand","spinner","children","createElement","state","shouldRenderSpinner","components","root"],"sources":["../../../src/components/Spinner/useSpinner.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, resolveShorthand, useId, useTimeout } from '@fluentui/react-utilities';\nimport type { SpinnerProps, SpinnerState } from './Spinner.types';\nimport { Label } from '@fluentui/react-label';\nimport { DefaultSvg } from './DefaultSvg';\n\n/**\n * Create the state required to render Spinner.\n *\n * The returned state can be modified with hooks such as useSpinnerStyles_unstable,\n * before being passed to renderSpinner_unstable.\n *\n * @param props - props from this instance of Spinner\n * @param ref - reference to root HTMLElement of Spinner\n */\nexport const useSpinner_unstable = (props: SpinnerProps, ref: React.Ref<HTMLElement>): SpinnerState => {\n // Props\n const { appearance = 'primary', labelPosition = 'after', size = 'medium', delay = 0 } = props;\n const baseId = useId('spinner');\n\n const { role = 'progressbar', tabIndex, ...rest } = props;\n const nativeRoot = getNativeElementProps('div', { ref, role, ...rest }, ['size']);\n\n const [isVisible, setIsVisible] = React.useState(true);\n\n const [setDelayTimeout, clearDelayTimeout] = useTimeout();\n\n React.useEffect(() => {\n if (delay <= 0) {\n return;\n }\n setIsVisible(false);\n setDelayTimeout(() => {\n setIsVisible(true);\n }, delay);\n\n return () => {\n clearDelayTimeout();\n };\n }, [setDelayTimeout, clearDelayTimeout, delay]);\n\n const labelShorthand = resolveShorthand(props.label, {\n defaultProps: {\n id: baseId,\n },\n required: false,\n });\n\n const spinnerShortHand = resolveShorthand(props.spinner, {\n required: true,\n defaultProps: {\n children: <DefaultSvg />,\n tabIndex,\n },\n });\n\n if (labelShorthand && nativeRoot && !nativeRoot['aria-labelledby']) {\n nativeRoot['aria-labelledby'] = labelShorthand.id;\n }\n\n const state: SpinnerState = {\n appearance,\n delay,\n labelPosition,\n size,\n shouldRenderSpinner: isVisible,\n components: {\n root: 'div',\n spinner: 'span',\n label: Label,\n },\n root: nativeRoot,\n spinner: spinnerShortHand,\n label: labelShorthand,\n };\n return state;\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,qBAAqB,EAAEC,gBAAgB,EAAEC,KAAK,EAAEC,UAAU,QAAQ;AAE3E,SAASC,KAAK,QAAQ;AACtB,SAASC,UAAU,QAAQ;AAE3B;;;;;;;;;AASA,OAAO,MAAMC,mBAAA,GAAsBA,CAACC,KAAA,EAAqBC,GAAA,KAA8C;EACrG;EACA,MAAM;IAAEC,UAAA,GAAa;IAA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;IACAG,KAAA;IACAF,aAAA;IACAC,IAAA;IACAuB,mBAAA,EAAqBhB,SAAA;IACrBiB,UAAA,EAAY;MACVC,IAAA,EAAM;MACNN,OAAA,EAAS;MACTL,KAAA,EAAOrB;IACT;IACAgC,IAAA,EAAMnB,UAAA;IACNa,OAAA,EAASD,gBAAA;IACTJ,KAAA,EAAOD;EACT;EACA,OAAOS,KAAA;AACT"}
|
|
@@ -10,8 +10,8 @@ const _reactJsxRuntime = require("@fluentui/react-jsx-runtime");
|
|
|
10
10
|
const _reactUtilities = require("@fluentui/react-utilities");
|
|
11
11
|
const renderSpinner_unstable = (state)=>{
|
|
12
12
|
const { slots , slotProps } = (0, _reactUtilities.getSlotsNext)(state);
|
|
13
|
-
const { labelPosition } = state;
|
|
14
|
-
return /*#__PURE__*/ (0, _reactJsxRuntime.createElement)(slots.root, slotProps.root, slots.label && (labelPosition === 'above' || labelPosition === 'before') && /*#__PURE__*/ (0, _reactJsxRuntime.createElement)(slots.label, slotProps.label), slots.spinner && /*#__PURE__*/ (0, _reactJsxRuntime.createElement)(slots.spinner, slotProps.spinner), slots.label && (labelPosition === 'below' || labelPosition === 'after') && /*#__PURE__*/ (0, _reactJsxRuntime.createElement)(slots.label, slotProps.label));
|
|
13
|
+
const { labelPosition , shouldRenderSpinner } = state;
|
|
14
|
+
return /*#__PURE__*/ (0, _reactJsxRuntime.createElement)(slots.root, slotProps.root, slots.label && shouldRenderSpinner && (labelPosition === 'above' || labelPosition === 'before') && /*#__PURE__*/ (0, _reactJsxRuntime.createElement)(slots.label, slotProps.label), slots.spinner && shouldRenderSpinner && /*#__PURE__*/ (0, _reactJsxRuntime.createElement)(slots.spinner, slotProps.spinner), slots.label && shouldRenderSpinner && (labelPosition === 'below' || labelPosition === 'after') && /*#__PURE__*/ (0, _reactJsxRuntime.createElement)(slots.label, slotProps.label));
|
|
15
15
|
}; //# sourceMappingURL=renderSpinner.js.map
|
|
16
16
|
|
|
17
17
|
//# sourceMappingURL=renderSpinner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../lib/components/Spinner/renderSpinner.js"],"sourcesContent":["/** @jsxRuntime classic */ /** @jsx createElement */import { createElement } from '@fluentui/react-jsx-runtime';\nimport { getSlotsNext } from '@fluentui/react-utilities';\n/**\n * Render the final JSX of Spinner\n */\nexport const renderSpinner_unstable = state => {\n const {\n slots,\n slotProps\n } = getSlotsNext(state);\n const {\n labelPosition\n } = state;\n return /*#__PURE__*/createElement(slots.root, slotProps.root, slots.label && (labelPosition === 'above' || labelPosition === 'before') && /*#__PURE__*/createElement(slots.label, slotProps.label), slots.spinner && /*#__PURE__*/createElement(slots.spinner, slotProps.spinner), slots.label && (labelPosition === 'below' || labelPosition === 'after') && /*#__PURE__*/createElement(slots.label, slotProps.label));\n};\n//# sourceMappingURL=renderSpinner.js.map"],"names":["renderSpinner_unstable","state","slots","slotProps","getSlotsNext","labelPosition","createElement","root","label","spinner"],"mappings":"AAAA,wBAAwB,GAAG,uBAAuB;;;;+BAKrCA;;aAAAA;;iCALqE;gCACrD;AAItB,MAAMA,yBAAyBC,CAAAA,QAAS;IAC7C,MAAM,EACJC,MAAK,EACLC,UAAS,EACV,GAAGC,IAAAA,4BAAY,EAACH;IACjB,MAAM,EACJI,cAAa,
|
|
1
|
+
{"version":3,"sources":["../../../lib/components/Spinner/renderSpinner.js"],"sourcesContent":["/** @jsxRuntime classic */ /** @jsx createElement */import { createElement } from '@fluentui/react-jsx-runtime';\nimport { getSlotsNext } from '@fluentui/react-utilities';\n/**\n * Render the final JSX of Spinner\n */\nexport const renderSpinner_unstable = state => {\n const {\n slots,\n slotProps\n } = getSlotsNext(state);\n const {\n labelPosition,\n shouldRenderSpinner\n } = state;\n return /*#__PURE__*/createElement(slots.root, slotProps.root, slots.label && shouldRenderSpinner && (labelPosition === 'above' || labelPosition === 'before') && /*#__PURE__*/createElement(slots.label, slotProps.label), slots.spinner && shouldRenderSpinner && /*#__PURE__*/createElement(slots.spinner, slotProps.spinner), slots.label && shouldRenderSpinner && (labelPosition === 'below' || labelPosition === 'after') && /*#__PURE__*/createElement(slots.label, slotProps.label));\n};\n//# sourceMappingURL=renderSpinner.js.map"],"names":["renderSpinner_unstable","state","slots","slotProps","getSlotsNext","labelPosition","shouldRenderSpinner","createElement","root","label","spinner"],"mappings":"AAAA,wBAAwB,GAAG,uBAAuB;;;;+BAKrCA;;aAAAA;;iCALqE;gCACrD;AAItB,MAAMA,yBAAyBC,CAAAA,QAAS;IAC7C,MAAM,EACJC,MAAK,EACLC,UAAS,EACV,GAAGC,IAAAA,4BAAY,EAACH;IACjB,MAAM,EACJI,cAAa,EACbC,oBAAmB,EACpB,GAAGL;IACJ,OAAO,WAAW,GAAEM,IAAAA,8BAAa,EAACL,MAAMM,IAAI,EAAEL,UAAUK,IAAI,EAAEN,MAAMO,KAAK,IAAIH,uBAAwBD,CAAAA,kBAAkB,WAAWA,kBAAkB,QAAO,KAAM,WAAW,GAAEE,IAAAA,8BAAa,EAACL,MAAMO,KAAK,EAAEN,UAAUM,KAAK,GAAGP,MAAMQ,OAAO,IAAIJ,uBAAuB,WAAW,GAAEC,IAAAA,8BAAa,EAACL,MAAMQ,OAAO,EAAEP,UAAUO,OAAO,GAAGR,MAAMO,KAAK,IAAIH,uBAAwBD,CAAAA,kBAAkB,WAAWA,kBAAkB,OAAM,KAAM,WAAW,GAAEE,IAAAA,8BAAa,EAACL,MAAMO,KAAK,EAAEN,UAAUM,KAAK;AAC5d,GACA,yCAAyC"}
|
|
@@ -13,7 +13,7 @@ const _reactLabel = require("@fluentui/react-label");
|
|
|
13
13
|
const _defaultSvg = require("./DefaultSvg");
|
|
14
14
|
const useSpinner_unstable = (props, ref)=>{
|
|
15
15
|
// Props
|
|
16
|
-
const { appearance ='primary' , labelPosition ='after' , size ='medium' } = props;
|
|
16
|
+
const { appearance ='primary' , labelPosition ='after' , size ='medium' , delay =0 } = props;
|
|
17
17
|
const baseId = (0, _reactUtilities.useId)('spinner');
|
|
18
18
|
const { role ='progressbar' , tabIndex , ...rest } = props;
|
|
19
19
|
const nativeRoot = (0, _reactUtilities.getNativeElementProps)('div', {
|
|
@@ -23,6 +23,24 @@ const useSpinner_unstable = (props, ref)=>{
|
|
|
23
23
|
}, [
|
|
24
24
|
'size'
|
|
25
25
|
]);
|
|
26
|
+
const [isVisible, setIsVisible] = _react.useState(true);
|
|
27
|
+
const [setDelayTimeout, clearDelayTimeout] = (0, _reactUtilities.useTimeout)();
|
|
28
|
+
_react.useEffect(()=>{
|
|
29
|
+
if (delay <= 0) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
setIsVisible(false);
|
|
33
|
+
setDelayTimeout(()=>{
|
|
34
|
+
setIsVisible(true);
|
|
35
|
+
}, delay);
|
|
36
|
+
return ()=>{
|
|
37
|
+
clearDelayTimeout();
|
|
38
|
+
};
|
|
39
|
+
}, [
|
|
40
|
+
setDelayTimeout,
|
|
41
|
+
clearDelayTimeout,
|
|
42
|
+
delay
|
|
43
|
+
]);
|
|
26
44
|
const labelShorthand = (0, _reactUtilities.resolveShorthand)(props.label, {
|
|
27
45
|
defaultProps: {
|
|
28
46
|
id: baseId
|
|
@@ -41,8 +59,10 @@ const useSpinner_unstable = (props, ref)=>{
|
|
|
41
59
|
}
|
|
42
60
|
const state = {
|
|
43
61
|
appearance,
|
|
62
|
+
delay,
|
|
44
63
|
labelPosition,
|
|
45
64
|
size,
|
|
65
|
+
shouldRenderSpinner: isVisible,
|
|
46
66
|
components: {
|
|
47
67
|
root: 'div',
|
|
48
68
|
spinner: 'span',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../lib/components/Spinner/useSpinner.js"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, resolveShorthand, useId } from '@fluentui/react-utilities';\nimport { Label } from '@fluentui/react-label';\nimport { DefaultSvg } from './DefaultSvg';\n/**\n * Create the state required to render Spinner.\n *\n * The returned state can be modified with hooks such as useSpinnerStyles_unstable,\n * before being passed to renderSpinner_unstable.\n *\n * @param props - props from this instance of Spinner\n * @param ref - reference to root HTMLElement of Spinner\n */\nexport const useSpinner_unstable = (props, ref) => {\n // Props\n const {\n appearance = 'primary',\n labelPosition = 'after',\n size = 'medium'\n } = props;\n const baseId = useId('spinner');\n const {\n role = 'progressbar',\n tabIndex,\n ...rest\n } = props;\n const nativeRoot = getNativeElementProps('div', {\n ref,\n role,\n ...rest\n }, ['size']);\n const labelShorthand = resolveShorthand(props.label, {\n defaultProps: {\n id: baseId\n },\n required: false\n });\n const spinnerShortHand = resolveShorthand(props.spinner, {\n required: true,\n defaultProps: {\n children: /*#__PURE__*/React.createElement(DefaultSvg, null),\n tabIndex\n }\n });\n if (labelShorthand && nativeRoot && !nativeRoot['aria-labelledby']) {\n nativeRoot['aria-labelledby'] = labelShorthand.id;\n }\n const state = {\n appearance,\n labelPosition,\n size,\n components: {\n root: 'div',\n spinner: 'span',\n label: Label\n },\n root: nativeRoot,\n spinner: spinnerShortHand,\n label: labelShorthand\n };\n return state;\n};\n//# sourceMappingURL=useSpinner.js.map"],"names":["useSpinner_unstable","props","ref","appearance","labelPosition","size","baseId","useId","role","tabIndex","rest","nativeRoot","getNativeElementProps","labelShorthand","resolveShorthand","label","defaultProps","id","required","spinnerShortHand","spinner","children","
|
|
1
|
+
{"version":3,"sources":["../../../lib/components/Spinner/useSpinner.js"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, resolveShorthand, useId, useTimeout } from '@fluentui/react-utilities';\nimport { Label } from '@fluentui/react-label';\nimport { DefaultSvg } from './DefaultSvg';\n/**\n * Create the state required to render Spinner.\n *\n * The returned state can be modified with hooks such as useSpinnerStyles_unstable,\n * before being passed to renderSpinner_unstable.\n *\n * @param props - props from this instance of Spinner\n * @param ref - reference to root HTMLElement of Spinner\n */\nexport const useSpinner_unstable = (props, ref) => {\n // Props\n const {\n appearance = 'primary',\n labelPosition = 'after',\n size = 'medium',\n delay = 0\n } = props;\n const baseId = useId('spinner');\n const {\n role = 'progressbar',\n tabIndex,\n ...rest\n } = props;\n const nativeRoot = getNativeElementProps('div', {\n ref,\n role,\n ...rest\n }, ['size']);\n const [isVisible, setIsVisible] = React.useState(true);\n const [setDelayTimeout, clearDelayTimeout] = useTimeout();\n React.useEffect(() => {\n if (delay <= 0) {\n return;\n }\n setIsVisible(false);\n setDelayTimeout(() => {\n setIsVisible(true);\n }, delay);\n return () => {\n clearDelayTimeout();\n };\n }, [setDelayTimeout, clearDelayTimeout, delay]);\n const labelShorthand = resolveShorthand(props.label, {\n defaultProps: {\n id: baseId\n },\n required: false\n });\n const spinnerShortHand = resolveShorthand(props.spinner, {\n required: true,\n defaultProps: {\n children: /*#__PURE__*/React.createElement(DefaultSvg, null),\n tabIndex\n }\n });\n if (labelShorthand && nativeRoot && !nativeRoot['aria-labelledby']) {\n nativeRoot['aria-labelledby'] = labelShorthand.id;\n }\n const state = {\n appearance,\n delay,\n labelPosition,\n size,\n shouldRenderSpinner: isVisible,\n components: {\n root: 'div',\n spinner: 'span',\n label: Label\n },\n root: nativeRoot,\n spinner: spinnerShortHand,\n label: labelShorthand\n };\n return state;\n};\n//# sourceMappingURL=useSpinner.js.map"],"names":["useSpinner_unstable","props","ref","appearance","labelPosition","size","delay","baseId","useId","role","tabIndex","rest","nativeRoot","getNativeElementProps","isVisible","setIsVisible","React","useState","setDelayTimeout","clearDelayTimeout","useTimeout","useEffect","labelShorthand","resolveShorthand","label","defaultProps","id","required","spinnerShortHand","spinner","children","createElement","DefaultSvg","state","shouldRenderSpinner","components","root","Label"],"mappings":";;;;+BAaaA;;aAAAA;;;6DAbU;gCACoD;4BACrD;4BACK;AAUpB,MAAMA,sBAAsB,CAACC,OAAOC,MAAQ;IACjD,QAAQ;IACR,MAAM,EACJC,YAAa,UAAS,EACtBC,eAAgB,QAAO,EACvBC,MAAO,SAAQ,EACfC,OAAQ,EAAC,EACV,GAAGL;IACJ,MAAMM,SAASC,IAAAA,qBAAK,EAAC;IACrB,MAAM,EACJC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
|
|
3
|
+
"version": "9.2.1",
|
|
4
4
|
"description": "Spinner component for Fluent UI React",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"storybook": "start-storybook",
|
|
24
24
|
"type-check": "tsc -b tsconfig.json",
|
|
25
25
|
"generate-api": "just-scripts generate-api",
|
|
26
|
-
"test-ssr": "test-ssr ./stories/**/*.stories.tsx"
|
|
26
|
+
"test-ssr": "test-ssr \"./stories/**/*.stories.tsx\""
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@fluentui/eslint-plugin": "*",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"@fluentui/scripts-tasks": "*"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@fluentui/react-jsx-runtime": "9.0.0-alpha.
|
|
37
|
-
"@fluentui/react-label": "^9.1.
|
|
38
|
-
"@fluentui/react-shared-contexts": "^9.
|
|
36
|
+
"@fluentui/react-jsx-runtime": "9.0.0-alpha.5",
|
|
37
|
+
"@fluentui/react-label": "^9.1.14",
|
|
38
|
+
"@fluentui/react-shared-contexts": "^9.5.0",
|
|
39
39
|
"@fluentui/react-theme": "^9.1.8",
|
|
40
|
-
"@fluentui/react-utilities": "^9.9.
|
|
40
|
+
"@fluentui/react-utilities": "^9.9.1",
|
|
41
41
|
"@griffel/react": "^1.5.2",
|
|
42
42
|
"@swc/helpers": "^0.4.14"
|
|
43
43
|
},
|