@fluentui/react-switch 9.0.0-nightly.d730088d7f.0 → 9.0.0-rc.10

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.
Files changed (64) hide show
  1. package/CHANGELOG.json +658 -29
  2. package/CHANGELOG.md +209 -43
  3. package/MIGRATION.md +89 -22
  4. package/Spec.md +179 -84
  5. package/dist/index.d.ts +107 -0
  6. package/{lib → dist}/tsdoc-metadata.json +0 -0
  7. package/lib/Switch.js.map +1 -1
  8. package/lib/components/Switch/Switch.js +8 -8
  9. package/lib/components/Switch/Switch.js.map +1 -1
  10. package/lib/components/Switch/Switch.types.js.map +1 -1
  11. package/lib/components/Switch/index.js.map +1 -1
  12. package/lib/components/Switch/renderSwitch.js +15 -9
  13. package/lib/components/Switch/renderSwitch.js.map +1 -1
  14. package/lib/components/Switch/useSwitch.js +70 -54
  15. package/lib/components/Switch/useSwitch.js.map +1 -1
  16. package/lib/components/Switch/useSwitchStyles.js +156 -248
  17. package/lib/components/Switch/useSwitchStyles.js.map +1 -1
  18. package/lib/index.js +2 -1
  19. package/lib/index.js.map +1 -1
  20. package/lib-commonjs/Switch.js +1 -1
  21. package/lib-commonjs/Switch.js.map +1 -1
  22. package/lib-commonjs/components/Switch/Switch.js +9 -9
  23. package/lib-commonjs/components/Switch/Switch.js.map +1 -1
  24. package/lib-commonjs/components/Switch/Switch.types.js.map +1 -1
  25. package/lib-commonjs/components/Switch/index.js +1 -1
  26. package/lib-commonjs/components/Switch/index.js.map +1 -1
  27. package/lib-commonjs/components/Switch/renderSwitch.js +19 -15
  28. package/lib-commonjs/components/Switch/renderSwitch.js.map +1 -1
  29. package/lib-commonjs/components/Switch/useSwitch.js +73 -56
  30. package/lib-commonjs/components/Switch/useSwitch.js.map +1 -1
  31. package/lib-commonjs/components/Switch/useSwitchStyles.js +161 -252
  32. package/lib-commonjs/components/Switch/useSwitchStyles.js.map +1 -1
  33. package/lib-commonjs/index.js +39 -2
  34. package/lib-commonjs/index.js.map +1 -1
  35. package/package.json +21 -27
  36. package/dist/react-switch.d.ts +0 -92
  37. package/lib/Switch.d.ts +0 -1
  38. package/lib/common/isConformant.d.ts +0 -4
  39. package/lib/common/isConformant.js +0 -12
  40. package/lib/common/isConformant.js.map +0 -1
  41. package/lib/components/Switch/Switch.d.ts +0 -6
  42. package/lib/components/Switch/Switch.types.d.ts +0 -58
  43. package/lib/components/Switch/index.d.ts +0 -5
  44. package/lib/components/Switch/renderSwitch.d.ts +0 -5
  45. package/lib/components/Switch/useSwitch.d.ts +0 -10
  46. package/lib/components/Switch/useSwitchState.d.ts +0 -2
  47. package/lib/components/Switch/useSwitchState.js +0 -152
  48. package/lib/components/Switch/useSwitchState.js.map +0 -1
  49. package/lib/components/Switch/useSwitchStyles.d.ts +0 -5
  50. package/lib/index.d.ts +0 -2
  51. package/lib-commonjs/Switch.d.ts +0 -1
  52. package/lib-commonjs/common/isConformant.d.ts +0 -4
  53. package/lib-commonjs/common/isConformant.js +0 -23
  54. package/lib-commonjs/common/isConformant.js.map +0 -1
  55. package/lib-commonjs/components/Switch/Switch.d.ts +0 -6
  56. package/lib-commonjs/components/Switch/Switch.types.d.ts +0 -58
  57. package/lib-commonjs/components/Switch/index.d.ts +0 -5
  58. package/lib-commonjs/components/Switch/renderSwitch.d.ts +0 -5
  59. package/lib-commonjs/components/Switch/useSwitch.d.ts +0 -10
  60. package/lib-commonjs/components/Switch/useSwitchState.d.ts +0 -2
  61. package/lib-commonjs/components/Switch/useSwitchState.js +0 -164
  62. package/lib-commonjs/components/Switch/useSwitchState.js.map +0 -1
  63. package/lib-commonjs/components/Switch/useSwitchStyles.d.ts +0 -5
  64. package/lib-commonjs/index.d.ts +0 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Switch/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,UAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,aAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA,OAAA","sourceRoot":""}
1
+ {"version":3,"sources":["components/Switch/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,UAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,aAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './Switch';\nexport * from './Switch.types';\nexport * from './renderSwitch';\nexport * from './useSwitch';\nexport * from './useSwitchStyles';\n"],"sourceRoot":"../src/"}
@@ -3,27 +3,31 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.renderSwitch = void 0;
6
+ exports.renderSwitch_unstable = void 0;
7
7
 
8
- var tslib_1 = /*#__PURE__*/require("tslib");
8
+ const React = /*#__PURE__*/require("react");
9
9
 
10
- var React = /*#__PURE__*/require("react");
11
-
12
- var react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
13
-
14
- var useSwitch_1 = /*#__PURE__*/require("./useSwitch");
10
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
15
11
  /**
16
- * Render the final JSX of Switch
12
+ * Render a Switch component by passing the state defined props to the appropriate slots.
17
13
  */
18
14
 
19
15
 
20
- var renderSwitch = function (state) {
21
- var _a = react_utilities_1.getSlots(state, useSwitch_1.switchShorthandProps),
22
- slots = _a.slots,
23
- slotProps = _a.slotProps;
24
-
25
- return React.createElement(slots.root, tslib_1.__assign({}, slotProps.root), React.createElement(slots.track, tslib_1.__assign({}, slotProps.track)), React.createElement(slots.thumbWrapper, tslib_1.__assign({}, slotProps.thumbWrapper), React.createElement(slots.thumb, tslib_1.__assign({}, slotProps.thumb))), React.createElement(slots.input, tslib_1.__assign({}, slotProps.input)), React.createElement(slots.activeRail, tslib_1.__assign({}, slotProps.activeRail)));
16
+ const renderSwitch_unstable = state => {
17
+ const {
18
+ slots,
19
+ slotProps
20
+ } = react_utilities_1.getSlots(state);
21
+ const {
22
+ labelPosition
23
+ } = state;
24
+ return React.createElement(slots.root, { ...slotProps.root
25
+ }, React.createElement(slots.input, { ...slotProps.input
26
+ }), labelPosition !== 'after' && slots.label && React.createElement(slots.label, { ...slotProps.label
27
+ }), React.createElement(slots.indicator, { ...slotProps.indicator
28
+ }), labelPosition === 'after' && slots.label && React.createElement(slots.label, { ...slotProps.label
29
+ }));
26
30
  };
27
31
 
28
- exports.renderSwitch = renderSwitch;
32
+ exports.renderSwitch_unstable = renderSwitch_unstable;
29
33
  //# sourceMappingURL=renderSwitch.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Switch/renderSwitch.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,IAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,IAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,IAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;AAGA;;AAEG;;;AACI,IAAM,YAAY,GAAG,UAAC,KAAD,EAAmB;AACvC,MAAA,EAAA,GAAuB,iBAAA,CAAA,QAAA,CAAsB,KAAtB,EAA6B,WAAA,CAAA,oBAA7B,CAAvB;AAAA,MAAE,KAAK,GAAA,EAAA,CAAA,KAAP;AAAA,MAAS,SAAS,GAAA,EAAA,CAAA,SAAl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AAf,GAAX,EACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;AAAf,GAAZ,CADF,EAEG,aAAa,KAAK,OAAlB,IAA6B,KAAK,CAAC,KAAnC,IAA4C,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;AAAf,GAAZ,CAF/C,EAGE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,SAAP,EAAgB,EAAA,GAAK,SAAS,CAAC;AAAf,GAAhB,CAHF,EAIG,aAAa,KAAK,OAAlB,IAA6B,KAAK,CAAC,KAAnC,IAA4C,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;AAAf,GAAZ,CAJ/C,CADF;AAQD,CAZM;;AAAM,OAAA,CAAA,qBAAA,GAAqB,qBAArB","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { SwitchState, SwitchSlots } from './Switch.types';\n\n/**\n * Render a Switch component by passing the state defined props to the appropriate slots.\n */\nexport const renderSwitch_unstable = (state: SwitchState) => {\n const { slots, slotProps } = getSlots<SwitchSlots>(state);\n const { labelPosition } = state;\n\n return (\n <slots.root {...slotProps.root}>\n <slots.input {...slotProps.input} />\n {labelPosition !== 'after' && slots.label && <slots.label {...slotProps.label} />}\n <slots.indicator {...slotProps.indicator} />\n {labelPosition === 'after' && slots.label && <slots.label {...slotProps.label} />}\n </slots.root>\n );\n};\n"],"sourceRoot":"../src/"}
@@ -3,73 +3,90 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useSwitch = exports.switchShorthandProps = void 0;
6
+ exports.useSwitch_unstable = void 0;
7
7
 
8
- var tslib_1 = /*#__PURE__*/require("tslib");
8
+ const React = /*#__PURE__*/require("react");
9
9
 
10
- var react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
11
-
12
- var useSwitchState_1 = /*#__PURE__*/require("./useSwitchState");
13
- /**
14
- * Array of all shorthand properties listed in SwitchSlots
15
- */
10
+ const react_icons_1 = /*#__PURE__*/require("@fluentui/react-icons");
16
11
 
12
+ const react_label_1 = /*#__PURE__*/require("@fluentui/react-label");
17
13
 
18
- exports.switchShorthandProps = ['root', 'track', 'thumbWrapper', 'thumb', 'activeRail', 'input'];
14
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
19
15
  /**
20
- * Given user props, returns state and render function for a Switch.
16
+ * Create the state required to render Switch.
17
+ *
18
+ * The returned state can be modified with hooks such as useSwitchStyles_unstable,
19
+ * before being passed to renderSwitch_unstable.
20
+ *
21
+ * @param props - props from this instance of Switch
22
+ * @param ref - reference to `<input>` element of Switch
21
23
  */
22
24
 
23
- var useSwitch = function (props, ref) {
24
- var track = props.track,
25
- thumbWrapper = props.thumbWrapper,
26
- thumb = props.thumb,
27
- activeRail = props.activeRail,
28
- input = props.input,
29
- defaultChecked = props.defaultChecked,
30
- checked = props.checked,
31
- disabled = props.disabled,
32
- onChange = props.onChange;
33
- var state = {
34
- defaultChecked: defaultChecked,
35
- checked: checked,
36
- disabled: disabled,
37
- onChange: onChange,
38
- root: react_utilities_1.getNativeElementProps('span', tslib_1.__assign(tslib_1.__assign({
39
- ref: ref
40
- }, props), {
41
- id: react_utilities_1.useId('switch-', props.id)
42
- })),
25
+
26
+ const useSwitch_unstable = (props, ref) => {
27
+ const {
28
+ checked,
29
+ defaultChecked,
30
+ disabled,
31
+ labelPosition = 'after',
32
+ onChange,
33
+ required
34
+ } = props;
35
+ const nativeProps = react_utilities_1.getPartitionedNativeProps({
36
+ props,
37
+ primarySlotTagName: 'input',
38
+ excludedPropNames: ['checked', 'defaultChecked', 'onChange']
39
+ });
40
+ const id = react_utilities_1.useId('switch-', nativeProps.primary.id);
41
+ const root = react_utilities_1.resolveShorthand(props.root, {
42
+ defaultProps: nativeProps.root,
43
+ required: true
44
+ });
45
+ const indicator = react_utilities_1.resolveShorthand(props.indicator, {
46
+ defaultProps: {
47
+ 'aria-hidden': true,
48
+ children: React.createElement(react_icons_1.CircleFilled, null)
49
+ },
50
+ required: true
51
+ });
52
+ const input = react_utilities_1.resolveShorthand(props.input, {
53
+ defaultProps: {
54
+ checked,
55
+ defaultChecked,
56
+ id,
57
+ ref,
58
+ role: 'switch',
59
+ type: 'checkbox',
60
+ ...nativeProps.primary
61
+ },
62
+ required: true
63
+ });
64
+ input.onChange = react_utilities_1.useMergedEventCallbacks(input.onChange, ev => onChange === null || onChange === void 0 ? void 0 : onChange(ev, {
65
+ checked: ev.currentTarget.checked
66
+ }));
67
+ const label = react_utilities_1.resolveShorthand(props.label, {
68
+ defaultProps: {
69
+ disabled,
70
+ htmlFor: id,
71
+ required,
72
+ size: 'medium'
73
+ }
74
+ });
75
+ return {
76
+ labelPosition,
77
+ //Slots definition
43
78
  components: {
44
79
  root: 'div',
45
- track: 'div',
46
- thumbWrapper: 'div',
47
- thumb: 'div',
48
- activeRail: 'div',
49
- input: 'input'
80
+ indicator: 'div',
81
+ input: 'input',
82
+ label: react_label_1.Label
50
83
  },
51
- track: react_utilities_1.resolveShorthand(track, {
52
- required: true
53
- }),
54
- thumbWrapper: react_utilities_1.resolveShorthand(thumbWrapper, {
55
- required: true
56
- }),
57
- thumb: react_utilities_1.resolveShorthand(thumb, {
58
- required: true
59
- }),
60
- activeRail: react_utilities_1.resolveShorthand(activeRail, {
61
- required: true
62
- }),
63
- input: react_utilities_1.resolveShorthand(input, {
64
- required: true,
65
- defaultProps: {
66
- type: 'checkbox'
67
- }
68
- })
84
+ root,
85
+ indicator,
86
+ input,
87
+ label
69
88
  };
70
- useSwitchState_1.useSwitchState(state);
71
- return state;
72
89
  };
73
90
 
74
- exports.useSwitch = useSwitch;
91
+ exports.useSwitch_unstable = useSwitch_unstable;
75
92
  //# sourceMappingURL=useSwitch.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Switch/useSwitch.ts"],"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B,CAAd;AAYA,EAAA,KAAK,CAAC,QAAN,GAAiB,iBAAA,CAAA,uBAAA,CAAwB,KAAK,CAAC,QAA9B,EAAwC,EAAE,IAAI,QAAQ,KAAA,IAAR,IAAA,QAAQ,KAAA,KAAA,CAAR,GAAQ,KAAA,CAAR,GAAA,QAAQ,CAAG,EAAH,EAAO;AAAE,IAAA,OAAO,EAAE,EAAE,CAAC,aAAH,CAAiB;AAA5B,GAAP,CAAtD,CAAjB;AAEA,QAAM,KAAK,GAAG,iBAAA,CAAA,gBAAA,CAAiB,KAAK,CAAC,KAAvB,EAA8B;AAC1C,IAAA,YAAY,EAAE;AACZ,MAAA,QADY;AAEZ,MAAA,OAAO,EAAE,EAFG;AAGZ,MAAA,QAHY;AAIZ,MAAA,IAAI,EAAE;AAJM;AAD4B,GAA9B,CAAd;AASA,SAAO;AACL,IAAA,aADK;AAGL;AACA,IAAA,UAAU,EAAE;AACV,MAAA,IAAI,EAAE,KADI;AAEV,MAAA,SAAS,EAAE,KAFD;AAGV,MAAA,KAAK,EAAE,OAHG;AAIV,MAAA,KAAK,EAAE,aAAA,CAAA;AAJG,KAJP;AAWL,IAAA,IAXK;AAYL,IAAA,SAZK;AAaL,IAAA,KAbK;AAcL,IAAA;AAdK,GAAP;AAgBD,CA/DM;;AAAM,OAAA,CAAA,kBAAA,GAAkB,kBAAlB","sourcesContent":["import * as React from 'react';\nimport { CircleFilled } from '@fluentui/react-icons';\nimport { Label } from '@fluentui/react-label';\nimport { getPartitionedNativeProps, resolveShorthand, useId, useMergedEventCallbacks } from '@fluentui/react-utilities';\nimport type { SwitchProps, SwitchState } from './Switch.types';\n\n/**\n * Create the state required to render Switch.\n *\n * The returned state can be modified with hooks such as useSwitchStyles_unstable,\n * before being passed to renderSwitch_unstable.\n *\n * @param props - props from this instance of Switch\n * @param ref - reference to `<input>` element of Switch\n */\nexport const useSwitch_unstable = (props: SwitchProps, ref: React.Ref<HTMLInputElement>): SwitchState => {\n const { checked, defaultChecked, disabled, labelPosition = 'after', onChange, required } = props;\n\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['checked', 'defaultChecked', 'onChange'],\n });\n\n const id = useId('switch-', nativeProps.primary.id);\n\n const root = resolveShorthand(props.root, {\n defaultProps: nativeProps.root,\n required: true,\n });\n\n const indicator = resolveShorthand(props.indicator, {\n defaultProps: {\n 'aria-hidden': true,\n children: <CircleFilled />,\n },\n required: true,\n });\n\n const input = resolveShorthand(props.input, {\n defaultProps: {\n checked,\n defaultChecked,\n id,\n ref,\n role: 'switch',\n type: 'checkbox',\n ...nativeProps.primary,\n },\n required: true,\n });\n input.onChange = useMergedEventCallbacks(input.onChange, ev => onChange?.(ev, { checked: ev.currentTarget.checked }));\n\n const label = resolveShorthand(props.label, {\n defaultProps: {\n disabled,\n htmlFor: id,\n required,\n size: 'medium',\n },\n });\n\n return {\n labelPosition,\n\n //Slots definition\n components: {\n root: 'div',\n indicator: 'div',\n input: 'input',\n label: Label,\n },\n\n root,\n indicator,\n input,\n label,\n };\n};\n"],"sourceRoot":"../src/"}