@fluentui/react-switch 0.0.0-nightly-20230317-0436.1 → 0.0.0-nightly-20230317-1454.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.
Files changed (48) hide show
  1. package/.swcrc +39 -0
  2. package/CHANGELOG.json +17 -17
  3. package/CHANGELOG.md +11 -11
  4. package/lib/Switch.js +1 -1
  5. package/lib/Switch.js.map +1 -1
  6. package/lib/SwitchField.js +1 -1
  7. package/lib/SwitchField.js.map +1 -1
  8. package/lib/components/Switch/Switch.js +6 -6
  9. package/lib/components/Switch/Switch.js.map +1 -1
  10. package/lib/components/Switch/Switch.types.js +1 -1
  11. package/lib/components/Switch/Switch.types.js.map +1 -1
  12. package/lib/components/Switch/index.js +5 -5
  13. package/lib/components/Switch/index.js.map +1 -1
  14. package/lib/components/Switch/renderSwitch.js +3 -13
  15. package/lib/components/Switch/renderSwitch.js.map +1 -1
  16. package/lib/components/Switch/useSwitch.js +17 -17
  17. package/lib/components/Switch/useSwitch.js.map +1 -1
  18. package/lib/components/Switch/useSwitchStyles.js +9 -9
  19. package/lib/components/Switch/useSwitchStyles.js.map +1 -1
  20. package/lib/components/SwitchField/SwitchField.js +2 -3
  21. package/lib/components/SwitchField/SwitchField.js.map +1 -1
  22. package/lib/components/SwitchField/index.js +1 -1
  23. package/lib/components/SwitchField/index.js.map +1 -1
  24. package/lib/index.js +2 -2
  25. package/lib/index.js.map +1 -1
  26. package/lib-commonjs/Switch.js +5 -4
  27. package/lib-commonjs/Switch.js.map +1 -1
  28. package/lib-commonjs/SwitchField.js +5 -4
  29. package/lib-commonjs/SwitchField.js.map +1 -1
  30. package/lib-commonjs/components/Switch/Switch.js +19 -20
  31. package/lib-commonjs/components/Switch/Switch.js.map +1 -1
  32. package/lib-commonjs/components/Switch/Switch.types.js +5 -2
  33. package/lib-commonjs/components/Switch/Switch.types.js.map +1 -1
  34. package/lib-commonjs/components/Switch/index.js +9 -8
  35. package/lib-commonjs/components/Switch/index.js.map +1 -1
  36. package/lib-commonjs/components/Switch/renderSwitch.js +14 -29
  37. package/lib-commonjs/components/Switch/renderSwitch.js.map +1 -1
  38. package/lib-commonjs/components/Switch/useSwitch.js +76 -85
  39. package/lib-commonjs/components/Switch/useSwitch.js.map +1 -1
  40. package/lib-commonjs/components/Switch/useSwitchStyles.js +176 -89
  41. package/lib-commonjs/components/Switch/useSwitchStyles.js.map +1 -1
  42. package/lib-commonjs/components/SwitchField/SwitchField.js +17 -11
  43. package/lib-commonjs/components/SwitchField/SwitchField.js.map +1 -1
  44. package/lib-commonjs/components/SwitchField/index.js +5 -4
  45. package/lib-commonjs/components/SwitchField/index.js.map +1 -1
  46. package/lib-commonjs/index.js +23 -56
  47. package/lib-commonjs/index.js.map +1 -1
  48. package/package.json +10 -10
@@ -1,25 +1,24 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "Switch", {
6
+ enumerable: true,
7
+ get: ()=>Switch
5
8
  });
6
- exports.Switch = void 0;
7
- const React = /*#__PURE__*/require("react");
8
- const useSwitch_1 = /*#__PURE__*/require("./useSwitch");
9
- const renderSwitch_1 = /*#__PURE__*/require("./renderSwitch");
10
- const useSwitchStyles_1 = /*#__PURE__*/require("./useSwitchStyles");
11
- const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
12
- /**
13
- * Switches enable users to trigger an option on or off through pressing the component.
14
- */
15
- exports.Switch = /*#__PURE__*/React.forwardRef((props, ref) => {
16
- const state = useSwitch_1.useSwitch_unstable(props, ref);
17
- useSwitchStyles_1.useSwitchStyles_unstable(state);
18
- const {
19
- useSwitchStyles_unstable: useCustomStyles
20
- } = react_shared_contexts_1.useCustomStyleHooks_unstable();
21
- useCustomStyles(state);
22
- return renderSwitch_1.renderSwitch_unstable(state);
9
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
+ const _useSwitch = require("./useSwitch");
12
+ const _renderSwitch = require("./renderSwitch");
13
+ const _useSwitchStyles = require("./useSwitchStyles");
14
+ const _reactSharedContexts = require("@fluentui/react-shared-contexts");
15
+ const Switch = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
16
+ const state = (0, _useSwitch.useSwitch_unstable)(props, ref);
17
+ (0, _useSwitchStyles.useSwitchStyles_unstable)(state);
18
+ const { useSwitchStyles_unstable: useCustomStyles } = (0, _reactSharedContexts.useCustomStyleHooks_unstable)();
19
+ useCustomStyles(state);
20
+ return (0, _renderSwitch.renderSwitch_unstable)(state);
23
21
  });
24
- exports.Switch.displayName = 'Switch';
22
+ Switch.displayName = "Switch"; //# sourceMappingURL=Switch.js.map
23
+
25
24
  //# sourceMappingURL=Switch.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","require","useSwitch_1","renderSwitch_1","useSwitchStyles_1","react_shared_contexts_1","exports","Switch","forwardRef","props","ref","state","useSwitch_unstable","useSwitchStyles_unstable","useCustomStyles","useCustomStyleHooks_unstable","renderSwitch_unstable","displayName"],"sources":["../../../../../../../../../packages/react-components/react-switch/src/components/Switch/Switch.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useSwitch_unstable } from './useSwitch';\nimport { renderSwitch_unstable } from './renderSwitch';\nimport { useSwitchStyles_unstable } from './useSwitchStyles';\nimport type { SwitchProps } from './Switch.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useCustomStyleHooks_unstable } from '@fluentui/react-shared-contexts';\n\n/**\n * Switches enable users to trigger an option on or off through pressing the component.\n */\nexport const Switch: ForwardRefComponent<SwitchProps> = React.forwardRef((props, ref) => {\n const state = useSwitch_unstable(props, ref);\n\n useSwitchStyles_unstable(state);\n\n const { useSwitchStyles_unstable: useCustomStyles } = useCustomStyleHooks_unstable();\n useCustomStyles(state);\n\n return renderSwitch_unstable(state);\n});\n\nSwitch.displayName = 'Switch';\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AACA,MAAAC,WAAA,gBAAAD,OAAA;AACA,MAAAE,cAAA,gBAAAF,OAAA;AACA,MAAAG,iBAAA,gBAAAH,OAAA;AAGA,MAAAI,uBAAA,gBAAAJ,OAAA;AAEA;;;AAGaK,OAAA,CAAAC,MAAM,gBAAqCP,KAAK,CAACQ,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAI;EACtF,MAAMC,KAAK,GAAGT,WAAA,CAAAU,kBAAkB,CAACH,KAAK,EAAEC,GAAG,CAAC;EAE5CN,iBAAA,CAAAS,wBAAwB,CAACF,KAAK,CAAC;EAE/B,MAAM;IAAEE,wBAAwB,EAAEC;EAAe,CAAE,GAAGT,uBAAA,CAAAU,4BAA4B,EAAE;EACpFD,eAAe,CAACH,KAAK,CAAC;EAEtB,OAAOR,cAAA,CAAAa,qBAAqB,CAACL,KAAK,CAAC;AACrC,CAAC,CAAC;AAEFL,OAAA,CAAAC,MAAM,CAACU,WAAW,GAAG,QAAQ"}
1
+ {"version":3,"sources":["../../../lib/components/Switch/Switch.js"],"sourcesContent":["import * as React from \"react\";\nimport { useSwitch_unstable } from \"./useSwitch\";\nimport { renderSwitch_unstable } from \"./renderSwitch\";\nimport { useSwitchStyles_unstable } from \"./useSwitchStyles\";\nimport { useCustomStyleHooks_unstable } from \"@fluentui/react-shared-contexts\";\n/**\n * Switches enable users to trigger an option on or off through pressing the component.\n */\nexport const Switch = /*#__PURE__*/React.forwardRef((props, ref) => {\n const state = useSwitch_unstable(props, ref);\n useSwitchStyles_unstable(state);\n const {\n useSwitchStyles_unstable: useCustomStyles\n } = useCustomStyleHooks_unstable();\n useCustomStyles(state);\n return renderSwitch_unstable(state);\n});\nSwitch.displayName = \"Switch\";\n//# sourceMappingURL=Switch.js.map"],"names":["Switch","React","forwardRef","props","ref","state","useSwitch_unstable","useSwitchStyles_unstable","useCustomStyles","useCustomStyleHooks_unstable","renderSwitch_unstable","displayName"],"mappings":";;;;+BAQaA;;aAAAA;;;6DARU;2BACY;8BACG;iCACG;qCACI;AAItC,MAAMA,SAAS,WAAW,GAAEC,OAAMC,UAAU,CAAC,CAACC,OAAOC,MAAQ;IAClE,MAAMC,QAAQC,IAAAA,6BAAkB,EAACH,OAAOC;IACxCG,IAAAA,yCAAwB,EAACF;IACzB,MAAM,EACJE,0BAA0BC,gBAAe,EAC1C,GAAGC,IAAAA,iDAA4B;IAChCD,gBAAgBH;IAChB,OAAOK,IAAAA,mCAAqB,EAACL;AAC/B;AACAL,OAAOW,WAAW,GAAG,UACrB,kCAAkC"}
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
5
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
6
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
7
+ //# sourceMappingURL=Switch.types.js.map
8
+
6
9
  //# sourceMappingURL=Switch.types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../../../../../../../../../packages/react-components/react-switch/src/components/Switch/Switch.types.ts"],"sourcesContent":["import * as React from 'react';\nimport { Label } from '@fluentui/react-label';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type SwitchSlots = {\n /**\n * The root element of the Switch.\n *\n * The root slot receives the `className` and `style` specified directly on the `<Switch>` tag.\n * All other native props will be applied to the primary slot: `input`.\n */\n root: NonNullable<Slot<'div'>>;\n\n /**\n * The track and the thumb sliding over it indicating the on and off status of the Switch.\n */\n indicator: NonNullable<Slot<'div'>>;\n\n /**\n * Hidden input that handles the Switch's functionality.\n *\n * This is the PRIMARY slot: all native properties specified directly on the `<Switch>` tag will be applied to this\n * slot, except `className` and `style`, which remain on the root slot.\n */\n input: NonNullable<Slot<'input'>>;\n\n /**\n * The Switch's label.\n */\n label?: Slot<typeof Label>;\n};\n\nexport type SwitchOnChangeData = {\n checked: boolean;\n};\n\n/**\n * Switch Props\n */\nexport type SwitchProps = Omit<\n ComponentProps<Partial<SwitchSlots>, 'input'>,\n 'checked' | 'defaultChecked' | 'onChange'\n> & {\n /**\n * Defines the controlled checked state of the Switch.\n * If passed, Switch ignores the `defaultChecked` property.\n * This should only be used if the checked state is to be controlled at a higher level and there is a plan to pass the\n * correct value based on handling `onChange` events and re-rendering.\n *\n * @default false\n */\n checked?: boolean;\n\n /**\n * Defines whether the Switch is initially in a checked state or not when rendered.\n *\n * @default false\n */\n defaultChecked?: boolean;\n\n /**\n * The position of the label relative to the Switch.\n *\n * @default after\n */\n labelPosition?: 'above' | 'after' | 'before';\n\n /**\n * Callback to be called when the checked state value changes.\n */\n onChange?: (ev: React.ChangeEvent<HTMLInputElement>, data: SwitchOnChangeData) => void;\n};\n\n/**\n * State used in rendering Switch\n */\nexport type SwitchState = ComponentState<SwitchSlots> & Required<Pick<SwitchProps, 'labelPosition'>>;\n"],"mappings":""}
1
+ {"version":3,"sources":["../../../lib/components/Switch/Switch.types.js"],"sourcesContent":["import * as React from \"react\";\n//# sourceMappingURL=Switch.types.js.map"],"names":[],"mappings":";;;;;6DAAuB;CACvB,wCAAwC"}
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- const tslib_1 = /*#__PURE__*/require("tslib");
7
- tslib_1.__exportStar(require("./Switch"), exports);
8
- tslib_1.__exportStar(require("./Switch.types"), exports);
9
- tslib_1.__exportStar(require("./renderSwitch"), exports);
10
- tslib_1.__exportStar(require("./useSwitch"), exports);
11
- tslib_1.__exportStar(require("./useSwitchStyles"), exports);
5
+ const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
6
+ _exportStar(require("./Switch"), exports);
7
+ _exportStar(require("./Switch.types"), exports);
8
+ _exportStar(require("./renderSwitch"), exports);
9
+ _exportStar(require("./useSwitch"), exports);
10
+ _exportStar(require("./useSwitchStyles"), exports);
11
+ //# sourceMappingURL=index.js.map
12
+
12
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["tslib_1","__exportStar","require","exports"],"sources":["../../../../../../../../../packages/react-components/react-switch/src/components/Switch/index.ts"],"sourcesContent":["export * from './Switch';\nexport * from './Switch.types';\nexport * from './renderSwitch';\nexport * from './useSwitch';\nexport * from './useSwitchStyles';\n"],"mappings":";;;;;;AAAAA,OAAA,CAAAC,YAAA,CAAAC,OAAA,cAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,oBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,oBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,iBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,uBAAAC,OAAA"}
1
+ {"version":3,"sources":["../../../lib/components/Switch/index.js"],"sourcesContent":["export * from \"./Switch\";\nexport * from \"./Switch.types\";\nexport * from \"./renderSwitch\";\nexport * from \"./useSwitch\";\nexport * from \"./useSwitchStyles\";\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA;oBACA;oBACA;CACd,iCAAiC"}
@@ -1,33 +1,18 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "renderSwitch_unstable", {
6
+ enumerable: true,
7
+ get: ()=>renderSwitch_unstable
5
8
  });
6
- exports.renderSwitch_unstable = void 0;
7
- const React = /*#__PURE__*/require("react");
8
- const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
9
- /**
10
- * Render a Switch component by passing the state defined props to the appropriate slots.
11
- */
12
- const renderSwitch_unstable = state => {
13
- const {
14
- slots,
15
- slotProps
16
- } = react_utilities_1.getSlots(state);
17
- const {
18
- labelPosition
19
- } = state;
20
- return React.createElement(slots.root, {
21
- ...slotProps.root
22
- }, React.createElement(slots.input, {
23
- ...slotProps.input
24
- }), labelPosition !== 'after' && slots.label && React.createElement(slots.label, {
25
- ...slotProps.label
26
- }), React.createElement(slots.indicator, {
27
- ...slotProps.indicator
28
- }), labelPosition === 'after' && slots.label && React.createElement(slots.label, {
29
- ...slotProps.label
30
- }));
31
- };
32
- exports.renderSwitch_unstable = renderSwitch_unstable;
9
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
+ const _reactUtilities = require("@fluentui/react-utilities");
12
+ const renderSwitch_unstable = (state)=>{
13
+ const { slots , slotProps } = (0, _reactUtilities.getSlots)(state);
14
+ const { labelPosition } = state;
15
+ return /*#__PURE__*/ _react.createElement(slots.root, slotProps.root, /*#__PURE__*/ _react.createElement(slots.input, slotProps.input), labelPosition !== "after" && slots.label && /*#__PURE__*/ _react.createElement(slots.label, slotProps.label), /*#__PURE__*/ _react.createElement(slots.indicator, slotProps.indicator), labelPosition === "after" && slots.label && /*#__PURE__*/ _react.createElement(slots.label, slotProps.label));
16
+ }; //# sourceMappingURL=renderSwitch.js.map
17
+
33
18
  //# sourceMappingURL=renderSwitch.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","require","react_utilities_1","renderSwitch_unstable","state","slots","slotProps","getSlots","labelPosition","createElement","root","input","label","indicator","exports"],"sources":["../../../../../../../../../packages/react-components/react-switch/src/components/Switch/renderSwitch.tsx"],"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"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AACA,MAAAC,iBAAA,gBAAAD,OAAA;AAGA;;;AAGO,MAAME,qBAAqB,GAAIC,KAAkB,IAAI;EAC1D,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAE,GAAGJ,iBAAA,CAAAK,QAAQ,CAAcH,KAAK,CAAC;EACzD,MAAM;IAAEI;EAAa,CAAE,GAAGJ,KAAK;EAE/B,OACEJ,KAAA,CAAAS,aAAA,CAACJ,KAAK,CAACK,IAAI;IAAA,GAAKJ,SAAS,CAACI;EAAI,GAC5BV,KAAA,CAAAS,aAAA,CAACJ,KAAK,CAACM,KAAK;IAAA,GAAKL,SAAS,CAACK;EAAK,EAAI,EACnCH,aAAa,KAAK,OAAO,IAAIH,KAAK,CAACO,KAAK,IAAIZ,KAAA,CAAAS,aAAA,CAACJ,KAAK,CAACO,KAAK;IAAA,GAAKN,SAAS,CAACM;EAAK,EAAI,EACjFZ,KAAA,CAAAS,aAAA,CAACJ,KAAK,CAACQ,SAAS;IAAA,GAAKP,SAAS,CAACO;EAAS,EAAI,EAC3CL,aAAa,KAAK,OAAO,IAAIH,KAAK,CAACO,KAAK,IAAIZ,KAAA,CAAAS,aAAA,CAACJ,KAAK,CAACO,KAAK;IAAA,GAAKN,SAAS,CAACM;EAAK,EAAI,CACtE;AAEjB,CAAC;AAZYE,OAAA,CAAAX,qBAAqB,GAAAA,qBAAA"}
1
+ {"version":3,"sources":["../../../lib/components/Switch/renderSwitch.js"],"sourcesContent":["import * as React from \"react\";\nimport { getSlots } from \"@fluentui/react-utilities\";\n/**\n * Render a Switch component by passing the state defined props to the appropriate slots.\n */\nexport const renderSwitch_unstable = state => {\n const {\n slots,\n slotProps\n } = getSlots(state);\n const {\n labelPosition\n } = state;\n return /*#__PURE__*/React.createElement(slots.root, slotProps.root, /*#__PURE__*/React.createElement(slots.input, slotProps.input), labelPosition !== \"after\" && slots.label && /*#__PURE__*/React.createElement(slots.label, slotProps.label), /*#__PURE__*/React.createElement(slots.indicator, slotProps.indicator), labelPosition === \"after\" && slots.label && /*#__PURE__*/React.createElement(slots.label, slotProps.label));\n};\n//# sourceMappingURL=renderSwitch.js.map"],"names":["renderSwitch_unstable","state","slots","slotProps","getSlots","labelPosition","React","createElement","root","input","label","indicator"],"mappings":";;;;+BAKaA;;aAAAA;;;6DALU;gCACE;AAIlB,MAAMA,wBAAwBC,CAAAA,QAAS;IAC5C,MAAM,EACJC,MAAK,EACLC,UAAS,EACV,GAAGC,IAAAA,wBAAQ,EAACH;IACb,MAAM,EACJI,cAAa,EACd,GAAGJ;IACJ,OAAO,WAAW,GAAEK,OAAMC,aAAa,CAACL,MAAMM,IAAI,EAAEL,UAAUK,IAAI,EAAE,WAAW,GAAEF,OAAMC,aAAa,CAACL,MAAMO,KAAK,EAAEN,UAAUM,KAAK,GAAGJ,kBAAkB,WAAWH,MAAMQ,KAAK,IAAI,WAAW,GAAEJ,OAAMC,aAAa,CAACL,MAAMQ,KAAK,EAAEP,UAAUO,KAAK,GAAG,WAAW,GAAEJ,OAAMC,aAAa,CAACL,MAAMS,SAAS,EAAER,UAAUQ,SAAS,GAAGN,kBAAkB,WAAWH,MAAMQ,KAAK,IAAI,WAAW,GAAEJ,OAAMC,aAAa,CAACL,MAAMQ,KAAK,EAAEP,UAAUO,KAAK;AACna,GACA,wCAAwC"}
@@ -1,89 +1,80 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useSwitch_unstable", {
6
+ enumerable: true,
7
+ get: ()=>useSwitch_unstable
5
8
  });
6
- exports.useSwitch_unstable = void 0;
7
- const React = /*#__PURE__*/require("react");
8
- const react_icons_1 = /*#__PURE__*/require("@fluentui/react-icons");
9
- const react_label_1 = /*#__PURE__*/require("@fluentui/react-label");
10
- const react_tabster_1 = /*#__PURE__*/require("@fluentui/react-tabster");
11
- const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
12
- /**
13
- * Create the state required to render Switch.
14
- *
15
- * The returned state can be modified with hooks such as useSwitchStyles_unstable,
16
- * before being passed to renderSwitch_unstable.
17
- *
18
- * @param props - props from this instance of Switch
19
- * @param ref - reference to `<input>` element of Switch
20
- */
21
- const useSwitch_unstable = (props, ref) => {
22
- const {
23
- checked,
24
- defaultChecked,
25
- disabled,
26
- labelPosition = 'after',
27
- onChange,
28
- required
29
- } = props;
30
- const nativeProps = react_utilities_1.getPartitionedNativeProps({
31
- props,
32
- primarySlotTagName: 'input',
33
- excludedPropNames: ['checked', 'defaultChecked', 'onChange']
34
- });
35
- const id = react_utilities_1.useId('switch-', nativeProps.primary.id);
36
- const root = react_utilities_1.resolveShorthand(props.root, {
37
- defaultProps: {
38
- ref: react_tabster_1.useFocusWithin(),
39
- ...nativeProps.root
40
- },
41
- required: true
42
- });
43
- const indicator = react_utilities_1.resolveShorthand(props.indicator, {
44
- defaultProps: {
45
- 'aria-hidden': true,
46
- children: React.createElement(react_icons_1.CircleFilled, null)
47
- },
48
- required: true
49
- });
50
- const input = react_utilities_1.resolveShorthand(props.input, {
51
- defaultProps: {
52
- checked,
53
- defaultChecked,
54
- id,
55
- ref,
56
- role: 'switch',
57
- type: 'checkbox',
58
- ...nativeProps.primary
59
- },
60
- required: true
61
- });
62
- input.onChange = react_utilities_1.mergeCallbacks(input.onChange, ev => onChange === null || onChange === void 0 ? void 0 : onChange(ev, {
63
- checked: ev.currentTarget.checked
64
- }));
65
- const label = react_utilities_1.resolveShorthand(props.label, {
66
- defaultProps: {
67
- disabled,
68
- htmlFor: id,
69
- required,
70
- size: 'medium'
71
- }
72
- });
73
- return {
74
- labelPosition,
75
- //Slots definition
76
- components: {
77
- root: 'div',
78
- indicator: 'div',
79
- input: 'input',
80
- label: react_label_1.Label
81
- },
82
- root,
83
- indicator,
84
- input,
85
- label
86
- };
87
- };
88
- exports.useSwitch_unstable = useSwitch_unstable;
9
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
+ const _reactIcons = require("@fluentui/react-icons");
12
+ const _reactLabel = require("@fluentui/react-label");
13
+ const _reactTabster = require("@fluentui/react-tabster");
14
+ const _reactUtilities = require("@fluentui/react-utilities");
15
+ const useSwitch_unstable = (props, ref)=>{
16
+ const { checked , defaultChecked , disabled , labelPosition ="after" , onChange , required } = props;
17
+ const nativeProps = (0, _reactUtilities.getPartitionedNativeProps)({
18
+ props,
19
+ primarySlotTagName: "input",
20
+ excludedPropNames: [
21
+ "checked",
22
+ "defaultChecked",
23
+ "onChange"
24
+ ]
25
+ });
26
+ const id = (0, _reactUtilities.useId)("switch-", nativeProps.primary.id);
27
+ const root = (0, _reactUtilities.resolveShorthand)(props.root, {
28
+ defaultProps: {
29
+ ref: (0, _reactTabster.useFocusWithin)(),
30
+ ...nativeProps.root
31
+ },
32
+ required: true
33
+ });
34
+ const indicator = (0, _reactUtilities.resolveShorthand)(props.indicator, {
35
+ defaultProps: {
36
+ "aria-hidden": true,
37
+ children: /*#__PURE__*/ _react.createElement(_reactIcons.CircleFilled, null)
38
+ },
39
+ required: true
40
+ });
41
+ const input = (0, _reactUtilities.resolveShorthand)(props.input, {
42
+ defaultProps: {
43
+ checked,
44
+ defaultChecked,
45
+ id,
46
+ ref,
47
+ role: "switch",
48
+ type: "checkbox",
49
+ ...nativeProps.primary
50
+ },
51
+ required: true
52
+ });
53
+ input.onChange = (0, _reactUtilities.mergeCallbacks)(input.onChange, (ev)=>onChange?.(ev, {
54
+ checked: ev.currentTarget.checked
55
+ }));
56
+ const label = (0, _reactUtilities.resolveShorthand)(props.label, {
57
+ defaultProps: {
58
+ disabled,
59
+ htmlFor: id,
60
+ required,
61
+ size: "medium"
62
+ }
63
+ });
64
+ return {
65
+ labelPosition,
66
+ //Slots definition
67
+ components: {
68
+ root: "div",
69
+ indicator: "div",
70
+ input: "input",
71
+ label: _reactLabel.Label
72
+ },
73
+ root,
74
+ indicator,
75
+ input,
76
+ label
77
+ };
78
+ }; //# sourceMappingURL=useSwitch.js.map
79
+
89
80
  //# sourceMappingURL=useSwitch.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","require","react_icons_1","react_label_1","react_tabster_1","react_utilities_1","useSwitch_unstable","props","ref","checked","defaultChecked","disabled","labelPosition","onChange","required","nativeProps","getPartitionedNativeProps","primarySlotTagName","excludedPropNames","id","useId","primary","root","resolveShorthand","defaultProps","useFocusWithin","indicator","children","createElement","CircleFilled","input","role","type","mergeCallbacks","ev","currentTarget","label","htmlFor","size","components","Label","exports"],"sources":["../../../../../../../../../packages/react-components/react-switch/src/components/Switch/useSwitch.tsx"],"sourcesContent":["import * as React from 'react';\nimport { CircleFilled } from '@fluentui/react-icons';\nimport { Label } from '@fluentui/react-label';\nimport { useFocusWithin } from '@fluentui/react-tabster';\nimport { getPartitionedNativeProps, mergeCallbacks, resolveShorthand, useId } 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: { ref: useFocusWithin<HTMLDivElement>(), ...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 = mergeCallbacks(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"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AACA,MAAAC,aAAA,gBAAAD,OAAA;AACA,MAAAE,aAAA,gBAAAF,OAAA;AACA,MAAAG,eAAA,gBAAAH,OAAA;AACA,MAAAI,iBAAA,gBAAAJ,OAAA;AAGA;;;;;;;;;AASO,MAAMK,kBAAkB,GAAGA,CAACC,KAAkB,EAAEC,GAAgC,KAAiB;EACtG,MAAM;IAAEC,OAAO;IAAEC,cAAc;IAAEC,QAAQ;IAAEC,aAAa,GAAG,OAAO;IAAEC,QAAQ;IAAEC;EAAQ,CAAE,GAAGP,KAAK;EAEhG,MAAMQ,WAAW,GAAGV,iBAAA,CAAAW,yBAAyB,CAAC;IAC5CT,KAAK;IACLU,kBAAkB,EAAE,OAAO;IAC3BC,iBAAiB,EAAE,CAAC,SAAS,EAAE,gBAAgB,EAAE,UAAU;GAC5D,CAAC;EAEF,MAAMC,EAAE,GAAGd,iBAAA,CAAAe,KAAK,CAAC,SAAS,EAAEL,WAAW,CAACM,OAAO,CAACF,EAAE,CAAC;EAEnD,MAAMG,IAAI,GAAGjB,iBAAA,CAAAkB,gBAAgB,CAAChB,KAAK,CAACe,IAAI,EAAE;IACxCE,YAAY,EAAE;MAAEhB,GAAG,EAAEJ,eAAA,CAAAqB,cAAc,EAAkB;MAAE,GAAGV,WAAW,CAACO;IAAI,CAAE;IAC5ER,QAAQ,EAAE;GACX,CAAC;EAEF,MAAMY,SAAS,GAAGrB,iBAAA,CAAAkB,gBAAgB,CAAChB,KAAK,CAACmB,SAAS,EAAE;IAClDF,YAAY,EAAE;MACZ,aAAa,EAAE,IAAI;MACnBG,QAAQ,EAAE3B,KAAA,CAAA4B,aAAA,CAAC1B,aAAA,CAAA2B,YAAY;KACxB;IACDf,QAAQ,EAAE;GACX,CAAC;EAEF,MAAMgB,KAAK,GAAGzB,iBAAA,CAAAkB,gBAAgB,CAAChB,KAAK,CAACuB,KAAK,EAAE;IAC1CN,YAAY,EAAE;MACZf,OAAO;MACPC,cAAc;MACdS,EAAE;MACFX,GAAG;MACHuB,IAAI,EAAE,QAAQ;MACdC,IAAI,EAAE,UAAU;MAChB,GAAGjB,WAAW,CAACM;KAChB;IACDP,QAAQ,EAAE;GACX,CAAC;EACFgB,KAAK,CAACjB,QAAQ,GAAGR,iBAAA,CAAA4B,cAAc,CAACH,KAAK,CAACjB,QAAQ,EAAEqB,EAAE,IAAIrB,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAGqB,EAAE,EAAE;IAAEzB,OAAO,EAAEyB,EAAE,CAACC,aAAa,CAAC1B;EAAO,CAAE,CAAC,CAAC;EAE5G,MAAM2B,KAAK,GAAG/B,iBAAA,CAAAkB,gBAAgB,CAAChB,KAAK,CAAC6B,KAAK,EAAE;IAC1CZ,YAAY,EAAE;MACZb,QAAQ;MACR0B,OAAO,EAAElB,EAAE;MACXL,QAAQ;MACRwB,IAAI,EAAE;;GAET,CAAC;EAEF,OAAO;IACL1B,aAAa;IAEb;IACA2B,UAAU,EAAE;MACVjB,IAAI,EAAE,KAAK;MACXI,SAAS,EAAE,KAAK;MAChBI,KAAK,EAAE,OAAO;MACdM,KAAK,EAAEjC,aAAA,CAAAqC;KACR;IAEDlB,IAAI;IACJI,SAAS;IACTI,KAAK;IACLM;GACD;AACH,CAAC;AA/DYK,OAAA,CAAAnC,kBAAkB,GAAAA,kBAAA"}
1
+ {"version":3,"sources":["../../../lib/components/Switch/useSwitch.js"],"sourcesContent":["import * as React from \"react\";\nimport { CircleFilled } from \"@fluentui/react-icons\";\nimport { Label } from \"@fluentui/react-label\";\nimport { useFocusWithin } from \"@fluentui/react-tabster\";\nimport { getPartitionedNativeProps, mergeCallbacks, resolveShorthand, useId } from \"@fluentui/react-utilities\";\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, ref) => {\n const {\n checked,\n defaultChecked,\n disabled,\n labelPosition = \"after\",\n onChange,\n required\n } = props;\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: \"input\",\n excludedPropNames: [\"checked\", \"defaultChecked\", \"onChange\"]\n });\n const id = useId(\"switch-\", nativeProps.primary.id);\n const root = resolveShorthand(props.root, {\n defaultProps: {\n ref: useFocusWithin(),\n ...nativeProps.root\n },\n required: true\n });\n const indicator = resolveShorthand(props.indicator, {\n defaultProps: {\n \"aria-hidden\": true,\n children: /*#__PURE__*/React.createElement(CircleFilled, null)\n },\n required: true\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 = mergeCallbacks(input.onChange, ev => onChange?.(ev, {\n 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 return {\n labelPosition,\n //Slots definition\n components: {\n root: \"div\",\n indicator: \"div\",\n input: \"input\",\n label: Label\n },\n root,\n indicator,\n input,\n label\n };\n};\n//# sourceMappingURL=useSwitch.js.map"],"names":["useSwitch_unstable","props","ref","checked","defaultChecked","disabled","labelPosition","onChange","required","nativeProps","getPartitionedNativeProps","primarySlotTagName","excludedPropNames","id","useId","primary","root","resolveShorthand","defaultProps","useFocusWithin","indicator","children","React","createElement","CircleFilled","input","role","type","mergeCallbacks","ev","currentTarget","label","htmlFor","size","components","Label"],"mappings":";;;;+BAcaA;;aAAAA;;;6DAdU;4BACM;4BACP;8BACS;gCACoD;AAU5E,MAAMA,qBAAqB,CAACC,OAAOC,MAAQ;IAChD,MAAM,EACJC,QAAO,EACPC,eAAc,EACdC,SAAQ,EACRC,eAAgB,QAAO,EACvBC,SAAQ,EACRC,SAAQ,EACT,GAAGP;IACJ,MAAMQ,cAAcC,IAAAA,yCAAyB,EAAC;QAC5CT;QACAU,oBAAoB;QACpBC,mBAAmB;YAAC;YAAW;YAAkB;SAAW;IAC9D;IACA,MAAMC,KAAKC,IAAAA,qBAAK,EAAC,WAAWL,YAAYM,OAAO,CAACF,EAAE;IAClD,MAAMG,OAAOC,IAAAA,gCAAgB,EAAChB,MAAMe,IAAI,EAAE;QACxCE,cAAc;YACZhB,KAAKiB,IAAAA,4BAAc;YACnB,GAAGV,YAAYO,IAAI;QACrB;QACAR,UAAU,IAAI;IAChB;IACA,MAAMY,YAAYH,IAAAA,gCAAgB,EAAChB,MAAMmB,SAAS,EAAE;QAClDF,cAAc;YACZ,eAAe,IAAI;YACnBG,UAAU,WAAW,GAAEC,OAAMC,aAAa,CAACC,wBAAY,EAAE,IAAI;QAC/D;QACAhB,UAAU,IAAI;IAChB;IACA,MAAMiB,QAAQR,IAAAA,gCAAgB,EAAChB,MAAMwB,KAAK,EAAE;QAC1CP,cAAc;YACZf;YACAC;YACAS;YACAX;YACAwB,MAAM;YACNC,MAAM;YACN,GAAGlB,YAAYM,OAAO;QACxB;QACAP,UAAU,IAAI;IAChB;IACAiB,MAAMlB,QAAQ,GAAGqB,IAAAA,8BAAc,EAACH,MAAMlB,QAAQ,EAAEsB,CAAAA,KAAMtB,WAAWsB,IAAI;YACnE1B,SAAS0B,GAAGC,aAAa,CAAC3B,OAAO;QACnC;IACA,MAAM4B,QAAQd,IAAAA,gCAAgB,EAAChB,MAAM8B,KAAK,EAAE;QAC1Cb,cAAc;YACZb;YACA2B,SAASnB;YACTL;YACAyB,MAAM;QACR;IACF;IACA,OAAO;QACL3B;QACA,kBAAkB;QAClB4B,YAAY;YACVlB,MAAM;YACNI,WAAW;YACXK,OAAO;YACPM,OAAOI,iBAAK;QACd;QACAnB;QACAI;QACAK;QACAM;IACF;AACF,GACA,qCAAqC"}