@fluentui/react-spinner 9.1.12 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.json CHANGED
@@ -2,7 +2,42 @@
2
2
  "name": "@fluentui/react-spinner",
3
3
  "entries": [
4
4
  {
5
- "date": "Thu, 18 May 2023 00:35:45 GMT",
5
+ "date": "Wed, 24 May 2023 20:42:46 GMT",
6
+ "tag": "@fluentui/react-spinner_v9.2.0",
7
+ "version": "9.2.0",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "author": "kakrookaran@gmail.com",
12
+ "package": "@fluentui/react-spinner",
13
+ "commit": "5fe4247bc7ce2ff095b1f4c8f727e57293413601",
14
+ "comment": "feat: added delay prop to spinner"
15
+ },
16
+ {
17
+ "author": "beachball",
18
+ "package": "@fluentui/react-spinner",
19
+ "comment": "Bump @fluentui/react-label to v9.1.13",
20
+ "commit": "3f088b7b09988e7c05af1c953021acc94c273026"
21
+ },
22
+ {
23
+ "author": "beachball",
24
+ "package": "@fluentui/react-spinner",
25
+ "comment": "Bump @fluentui/react-shared-contexts to v9.5.0",
26
+ "commit": "3f088b7b09988e7c05af1c953021acc94c273026"
27
+ }
28
+ ],
29
+ "none": [
30
+ {
31
+ "author": "olfedias@microsoft.com",
32
+ "package": "@fluentui/react-spinner",
33
+ "commit": "69e0617a93cb44ef42f3bd19284b7dc5fe27fed3",
34
+ "comment": "chore: update test-ssr script"
35
+ }
36
+ ]
37
+ }
38
+ },
39
+ {
40
+ "date": "Thu, 18 May 2023 00:39:15 GMT",
6
41
  "tag": "@fluentui/react-spinner_v9.1.12",
7
42
  "version": "9.1.12",
8
43
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,23 @@
1
1
  # Change Log - @fluentui/react-spinner
2
2
 
3
- This log was last generated on Thu, 18 May 2023 00:35:45 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 24 May 2023 20:42:46 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.2.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-spinner_v9.2.0)
8
+
9
+ Wed, 24 May 2023 20:42:46 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-spinner_v9.1.12..@fluentui/react-spinner_v9.2.0)
11
+
12
+ ### Minor changes
13
+
14
+ - feat: added delay prop to spinner ([PR #27852](https://github.com/microsoft/fluentui/pull/27852) by kakrookaran@gmail.com)
15
+ - Bump @fluentui/react-label to v9.1.13 ([PR #27989](https://github.com/microsoft/fluentui/pull/27989) by beachball)
16
+ - Bump @fluentui/react-shared-contexts to v9.5.0 ([PR #27989](https://github.com/microsoft/fluentui/pull/27989) by beachball)
17
+
7
18
  ## [9.1.12](https://github.com/microsoft/fluentui/tree/@fluentui/react-spinner_v9.1.12)
8
19
 
9
- Thu, 18 May 2023 00:35:45 GMT
20
+ Thu, 18 May 2023 00:39:15 GMT
10
21
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-spinner_v9.1.11..@fluentui/react-spinner_v9.1.12)
11
22
 
12
23
  ### 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'>>;\n"],"mappings":"AAAA"}
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} />}\n {slots.spinner && <slots.spinner {...slotProps.spinner} />}\n {slots.label && (labelPosition === 'below' || labelPosition === 'after') && <slots.label {...slotProps.label} />}\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;EAAa,CAAE,GAAGH,KAAA;EAC1B,oBACEH,aAdJ,CAcKI,KAAA,CAAMG,IAAI,EAAKF,SAAA,CAAUE,IAAI,EAC3BH,KAAA,CAAMI,KAAK,KAAKF,aAAA,KAAkB,WAAWA,aAAA,KAAkB,QAAO,kBAAMN,aAfnF,CAeoFI,KAAA,CAAMI,KAAK,EAAKH,SAAA,CAAUG,KAAK,GAC5GJ,KAAA,CAAMK,OAAO,iBAAIT,aAhBxB,CAgByBI,KAAA,CAAMK,OAAO,EAAKJ,SAAA,CAAUI,OAAO,GACrDL,KAAA,CAAMI,KAAK,KAAKF,aAAA,KAAkB,WAAWA,aAAA,KAAkB,OAAM,kBAAMN,aAjBlF,CAiBmFI,KAAA,CAAMI,KAAK,EAAKH,SAAA,CAAUG,KAAK;AAGlH"}
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;AAE/D,SAASC,KAAK,QAAQ;AACtB,SAASC,UAAU,QAAQ;AAE3B;;;;;;;;;AASA,OAAO,MAAMC,mBAAA,GAAsBA,CAACC,KAAA,EAAqBC,GAAA,KAA8C;EACrG;EACA,MAAM;IAAEC,UAAA,GAAa;IAAWC,aAAA,GAAgB;IAASC,IAAA,GAAO;EAAQ,CAAE,GAAGJ,KAAA;EAC7E,MAAMK,MAAA,GAAST,KAAA,CAAM;EAErB,MAAM;IAAEU,IAAA,GAAO;IAAeC,QAAA;IAAU,GAAGC;EAAA,CAAM,GAAGR,KAAA;EACpD,MAAMS,UAAA,GAAaf,qBAAA,CAAsB,OAAO;IAAEO,GAAA;IAAKK,IAAA;IAAM,GAAGE;EAAK,GAAG,CAAC,OAAO;EAEhF,MAAME,cAAA,GAAiBf,gBAAA,CAAiBK,KAAA,CAAMW,KAAK,EAAE;IACnDC,YAAA,EAAc;MACZC,EAAA,EAAIR;IACN;IACAS,QAAA,EAAU;EACZ;EAEA,MAAMC,gBAAA,GAAmBpB,gBAAA,CAAiBK,KAAA,CAAMgB,OAAO,EAAE;IACvDF,QAAA,EAAU,IAAI;IACdF,YAAA,EAAc;MACZK,QAAA,eAAUxB,KAAA,CAAAyB,aAAA,CAACpB,UAAA;MACXS;IACF;EACF;EAEA,IAAIG,cAAA,IAAkBD,UAAA,IAAc,CAACA,UAAU,CAAC,kBAAkB,EAAE;IAClEA,UAAU,CAAC,kBAAkB,GAAGC,cAAA,CAAeG,EAAE;EACnD;EAEA,MAAMM,KAAA,GAAsB;IAC1BjB,UAAA;IACAC,aAAA;IACAC,IAAA;IACAgB,UAAA,EAAY;MACVC,IAAA,EAAM;MACNL,OAAA,EAAS;MACTL,KAAA,EAAOd;IACT;IACAwB,IAAA,EAAMZ,UAAA;IACNO,OAAA,EAASD,gBAAA;IACTJ,KAAA,EAAOD;EACT;EACA,OAAOS,KAAA;AACT"}
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;IAAWC,aAAA,GAAgB;IAASC,IAAA,GAAO;IAAUC,KAAA,GAAQ;EAAC,CAAE,GAAGL,KAAA;EACxF,MAAMM,MAAA,GAASX,KAAA,CAAM;EAErB,MAAM;IAAEY,IAAA,GAAO;IAAeC,QAAA;IAAU,GAAGC;EAAA,CAAM,GAAGT,KAAA;EACpD,MAAMU,UAAA,GAAajB,qBAAA,CAAsB,OAAO;IAAEQ,GAAA;IAAKM,IAAA;IAAM,GAAGE;EAAK,GAAG,CAAC,OAAO;EAEhF,MAAM,CAACE,SAAA,EAAWC,YAAA,CAAa,GAAGpB,KAAA,CAAMqB,QAAQ,CAAC,IAAI;EAErD,MAAM,CAACC,eAAA,EAAiBC,iBAAA,CAAkB,GAAGnB,UAAA;EAE7CJ,KAAA,CAAMwB,SAAS,CAAC,MAAM;IACpB,IAAIX,KAAA,IAAS,GAAG;MACd;IACF;IACAO,YAAA,CAAa,KAAK;IAClBE,eAAA,CAAgB,MAAM;MACpBF,YAAA,CAAa,IAAI;IACnB,GAAGP,KAAA;IAEH,OAAO,MAAM;MACXU,iBAAA;IACF;EACF,GAAG,CAACD,eAAA,EAAiBC,iBAAA,EAAmBV,KAAA,CAAM;EAE9C,MAAMY,cAAA,GAAiBvB,gBAAA,CAAiBM,KAAA,CAAMkB,KAAK,EAAE;IACnDC,YAAA,EAAc;MACZC,EAAA,EAAId;IACN;IACAe,QAAA,EAAU;EACZ;EAEA,MAAMC,gBAAA,GAAmB5B,gBAAA,CAAiBM,KAAA,CAAMuB,OAAO,EAAE;IACvDF,QAAA,EAAU,IAAI;IACdF,YAAA,EAAc;MACZK,QAAA,eAAUhC,KAAA,CAAAiC,aAAA,CAAC3B,UAAA;MACXU;IACF;EACF;EAEA,IAAIS,cAAA,IAAkBP,UAAA,IAAc,CAACA,UAAU,CAAC,kBAAkB,EAAE;IAClEA,UAAU,CAAC,kBAAkB,GAAGO,cAAA,CAAeG,EAAE;EACnD;EAEA,MAAMM,KAAA,GAAsB;IAC1BxB,UAAA;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,EACd,GAAGJ;IACJ,OAAO,WAAW,GAAEK,IAAAA,8BAAa,EAACJ,MAAMK,IAAI,EAAEJ,UAAUI,IAAI,EAAEL,MAAMM,KAAK,IAAKH,CAAAA,kBAAkB,WAAWA,kBAAkB,QAAO,KAAM,WAAW,GAAEC,IAAAA,8BAAa,EAACJ,MAAMM,KAAK,EAAEL,UAAUK,KAAK,GAAGN,MAAMO,OAAO,IAAI,WAAW,GAAEH,IAAAA,8BAAa,EAACJ,MAAMO,OAAO,EAAEN,UAAUM,OAAO,GAAGP,MAAMM,KAAK,IAAKH,CAAAA,kBAAkB,WAAWA,kBAAkB,OAAM,KAAM,WAAW,GAAEC,IAAAA,8BAAa,EAACJ,MAAMM,KAAK,EAAEL,UAAUK,KAAK;AACvZ,GACA,yCAAyC"}
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","React","createElement","DefaultSvg","state","components","root","Label"],"mappings":";;;;+BAaaA;;aAAAA;;;6DAbU;gCACwC;4BACzC;4BACK;AAUpB,MAAMA,sBAAsB,CAACC,OAAOC,MAAQ;IACjD,QAAQ;IACR,MAAM,EACJC,YAAa,UAAS,EACtBC,eAAgB,QAAO,EACvBC,MAAO,SAAQ,EAChB,GAAGJ;IACJ,MAAMK,SAASC,IAAAA,qBAAK,EAAC;IACrB,MAAM,EACJC,MAAO,cAAa,EACpBC,SAAQ,EACR,GAAGC,MACJ,GAAGT;IACJ,MAAMU,aAAaC,IAAAA,qCAAqB,EAAC,OAAO;QAC9CV;QACAM;QACA,GAAGE,IAAI;IACT,GAAG;QAAC;KAAO;IACX,MAAMG,iBAAiBC,IAAAA,gCAAgB,EAACb,MAAMc,KAAK,EAAE;QACnDC,cAAc;YACZC,IAAIX;QACN;QACAY,UAAU,KAAK;IACjB;IACA,MAAMC,mBAAmBL,IAAAA,gCAAgB,EAACb,MAAMmB,OAAO,EAAE;QACvDF,UAAU,IAAI;QACdF,cAAc;YACZK,UAAU,WAAW,GAAEC,OAAMC,aAAa,CAACC,sBAAU,EAAE,IAAI;YAC3Df;QACF;IACF;IACA,IAAII,kBAAkBF,cAAc,CAACA,UAAU,CAAC,kBAAkB,EAAE;QAClEA,UAAU,CAAC,kBAAkB,GAAGE,eAAeI,EAAE;IACnD,CAAC;IACD,MAAMQ,QAAQ;QACZtB;QACAC;QACAC;QACAqB,YAAY;YACVC,MAAM;YACNP,SAAS;YACTL,OAAOa,iBAAK;QACd;QACAD,MAAMhB;QACNS,SAASD;QACTJ,OAAOF;IACT;IACA,OAAOY;AACT,GACA,sCAAsC"}
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,MAAO,cAAa,EACpBC,SAAQ,EACR,GAAGC,MACJ,GAAGV;IACJ,MAAMW,aAAaC,IAAAA,qCAAqB,EAAC,OAAO;QAC9CX;QACAO;QACA,GAAGE,IAAI;IACT,GAAG;QAAC;KAAO;IACX,MAAM,CAACG,WAAWC,aAAa,GAAGC,OAAMC,QAAQ,CAAC,IAAI;IACrD,MAAM,CAACC,iBAAiBC,kBAAkB,GAAGC,IAAAA,0BAAU;IACvDJ,OAAMK,SAAS,CAAC,IAAM;QACpB,IAAIf,SAAS,GAAG;YACd;QACF,CAAC;QACDS,aAAa,KAAK;QAClBG,gBAAgB,IAAM;YACpBH,aAAa,IAAI;QACnB,GAAGT;QACH,OAAO,IAAM;YACXa;QACF;IACF,GAAG;QAACD;QAAiBC;QAAmBb;KAAM;IAC9C,MAAMgB,iBAAiBC,IAAAA,gCAAgB,EAACtB,MAAMuB,KAAK,EAAE;QACnDC,cAAc;YACZC,IAAInB;QACN;QACAoB,UAAU,KAAK;IACjB;IACA,MAAMC,mBAAmBL,IAAAA,gCAAgB,EAACtB,MAAM4B,OAAO,EAAE;QACvDF,UAAU,IAAI;QACdF,cAAc;YACZK,UAAU,WAAW,GAAEd,OAAMe,aAAa,CAACC,sBAAU,EAAE,IAAI;YAC3DtB;QACF;IACF;IACA,IAAIY,kBAAkBV,cAAc,CAACA,UAAU,CAAC,kBAAkB,EAAE;QAClEA,UAAU,CAAC,kBAAkB,GAAGU,eAAeI,EAAE;IACnD,CAAC;IACD,MAAMO,QAAQ;QACZ9B;QACAG;QACAF;QACAC;QACA6B,qBAAqBpB;QACrBqB,YAAY;YACVC,MAAM;YACNP,SAAS;YACTL,OAAOa,iBAAK;QACd;QACAD,MAAMxB;QACNiB,SAASD;QACTJ,OAAOF;IACT;IACA,OAAOW;AACT,GACA,sCAAsC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-spinner",
3
- "version": "9.1.12",
3
+ "version": "9.2.0",
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": "*",
@@ -34,8 +34,8 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@fluentui/react-jsx-runtime": "9.0.0-alpha.4",
37
- "@fluentui/react-label": "^9.1.12",
38
- "@fluentui/react-shared-contexts": "^9.4.0",
37
+ "@fluentui/react-label": "^9.1.13",
38
+ "@fluentui/react-shared-contexts": "^9.5.0",
39
39
  "@fluentui/react-theme": "^9.1.8",
40
40
  "@fluentui/react-utilities": "^9.9.0",
41
41
  "@griffel/react": "^1.5.2",