@synerise/ds-switch 1.2.18 → 1.2.20

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.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.2.20](https://github.com/synerise/synerise-design/compare/@synerise/ds-switch@1.2.19...@synerise/ds-switch@1.2.20) (2026-03-24)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-switch
9
+
10
+ ## [1.2.19](https://github.com/synerise/synerise-design/compare/@synerise/ds-switch@1.2.18...@synerise/ds-switch@1.2.19) (2026-03-20)
11
+
12
+ **Note:** Version bump only for package @synerise/ds-switch
13
+
6
14
  ## [1.2.18](https://github.com/synerise/synerise-design/compare/@synerise/ds-switch@1.2.17...@synerise/ds-switch@1.2.18) (2026-03-09)
7
15
 
8
16
  **Note:** Version bump only for package @synerise/ds-switch
package/README.md CHANGED
@@ -23,17 +23,18 @@ Based on [Ant Design Switch](https://ant.design/components/switch/)
23
23
  | className | additional class to Switch | string | - |
24
24
  | defaultChecked | to set the initial state | boolean | `false` |
25
25
  | disabled | Disable switch | boolean | `false` |
26
- | description | Switch description | string | - |
27
- | errorText | Error message, when provided changes switch style | string | - |
28
- | label | switch label | string | - |
29
- | tooltip | tooltip next to label | string | null | `null` |
26
+ | description | Switch description | React.ReactNode | - |
27
+ | errorText | Error message, when provided changes switch style | React.ReactNode | - |
28
+ | label | switch label (required) | React.ReactNode | - |
29
+ | tooltip | tooltip next to label | React.ReactNode | - |
30
30
  | tooltipIcon | icon for tooltip | React.ReactNode | - |
31
- | tooltipConfig | configuration of tooltip | React.ReactNode | - |
31
+ | tooltipConfig | configuration of tooltip | TooltipProps (`@synerise/ds-tooltip`) | - |
32
+ | withFormElementMargin | add 16px bottom margin (standard form field spacing) | boolean | `false` |
32
33
  | loading | loading state of switch | boolean | `false` |
33
34
  | onChange | trigger when the checked state is changing | (checked: boolean, event: Event) => void | - |
34
35
  | onClick | trigger when clicked | (checked: boolean, event: Event) => void | - |
35
36
  | unCheckedChildren | content to be shown when the state is unchecked | string / React.ReactNode | - |
36
- | size | the size of the Switch, | `small` | `default` | `default` |
37
+ | ~~size~~ | ~~the size of the Switch~~ — **not available**, always renders as `small` | — | — |
37
38
 
38
39
  ### Methods
39
40
 
package/dist/Switch.d.ts CHANGED
@@ -1,8 +1,6 @@
1
- import React from 'react';
2
- import '@synerise/ds-core/dist/js/style';
3
- import './style/index.less';
4
- export declare const RawSwitch: React.ForwardRefExoticComponent<import("antd/lib/switch").SwitchProps & React.RefAttributes<HTMLElement>>;
5
- export declare const Switch: React.ForwardRefExoticComponent<Omit<import("antd/lib/switch").SwitchProps, "size"> & {
1
+ import { default as React } from 'react';
2
+ export declare const RawSwitch: React.ForwardRefExoticComponent<import('antd/lib/switch').SwitchProps & React.RefAttributes<HTMLElement>>;
3
+ export declare const Switch: React.ForwardRefExoticComponent<Omit<import('antd/lib/switch').SwitchProps, "size"> & {
6
4
  errorText?: React.ReactNode;
7
5
  label: React.ReactNode;
8
6
  description?: React.ReactNode;
@@ -10,6 +8,6 @@ export declare const Switch: React.ForwardRefExoticComponent<Omit<import("antd/l
10
8
  } & {
11
9
  tooltipIcon?: React.ReactNode;
12
10
  tooltip?: React.ReactNode;
13
- tooltipConfig?: import("@synerise/ds-tooltip").TooltipProps;
11
+ tooltipConfig?: import('@synerise/ds-tooltip').TooltipProps;
14
12
  } & React.RefAttributes<HTMLDivElement>>;
15
13
  export default Switch;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,101 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import figma from "@figma/code-connect";
3
+ import { Switch, RawSwitch } from "./Switch.js";
4
+ const FIGMA_URL = "https://www.figma.com/design/fsSZONXpVvtrDsCgtu01Jb/Synerise-Design-System?node-id=249-3688&m=dev";
5
+ const labelProps = {
6
+ labelNested: figma.nestedProps("Label", {
7
+ text: figma.string("Text")
8
+ })
9
+ };
10
+ const descriptionProps = {
11
+ labelNested: figma.nestedProps("Label", {
12
+ text: figma.string("Text")
13
+ }),
14
+ descriptionNested: figma.nestedProps("Description", {
15
+ text: figma.string("Text")
16
+ })
17
+ };
18
+ figma.connect(Switch, FIGMA_URL, {
19
+ variant: {
20
+ State: "Default",
21
+ "Content Type": "Solo"
22
+ },
23
+ example: () => /* @__PURE__ */ jsx(RawSwitch, {})
24
+ });
25
+ figma.connect(Switch, FIGMA_URL, {
26
+ variant: {
27
+ State: "Default",
28
+ "Content Type": "Label"
29
+ },
30
+ props: labelProps,
31
+ example: ({
32
+ labelNested
33
+ }) => /* @__PURE__ */ jsx(Switch, { label: labelNested.text })
34
+ });
35
+ figma.connect(Switch, FIGMA_URL, {
36
+ variant: {
37
+ State: "Default",
38
+ "Content Type": "With Description"
39
+ },
40
+ props: descriptionProps,
41
+ example: ({
42
+ labelNested,
43
+ descriptionNested
44
+ }) => /* @__PURE__ */ jsx(Switch, { label: labelNested.text, description: descriptionNested.text })
45
+ });
46
+ figma.connect(Switch, FIGMA_URL, {
47
+ variant: {
48
+ State: "Selected",
49
+ "Content Type": "Solo"
50
+ },
51
+ example: () => /* @__PURE__ */ jsx(RawSwitch, { checked: true })
52
+ });
53
+ figma.connect(Switch, FIGMA_URL, {
54
+ variant: {
55
+ State: "Selected",
56
+ "Content Type": "Label"
57
+ },
58
+ props: labelProps,
59
+ example: ({
60
+ labelNested
61
+ }) => /* @__PURE__ */ jsx(Switch, { checked: true, label: labelNested.text })
62
+ });
63
+ figma.connect(Switch, FIGMA_URL, {
64
+ variant: {
65
+ State: "Selected",
66
+ "Content Type": "With Description"
67
+ },
68
+ props: descriptionProps,
69
+ example: ({
70
+ labelNested,
71
+ descriptionNested
72
+ }) => /* @__PURE__ */ jsx(Switch, { checked: true, label: labelNested.text, description: descriptionNested.text })
73
+ });
74
+ figma.connect(Switch, FIGMA_URL, {
75
+ variant: {
76
+ State: "Disabled",
77
+ "Content Type": "Solo"
78
+ },
79
+ example: () => /* @__PURE__ */ jsx(RawSwitch, { disabled: true })
80
+ });
81
+ figma.connect(Switch, FIGMA_URL, {
82
+ variant: {
83
+ State: "Disabled",
84
+ "Content Type": "Label"
85
+ },
86
+ props: labelProps,
87
+ example: ({
88
+ labelNested
89
+ }) => /* @__PURE__ */ jsx(Switch, { disabled: true, label: labelNested.text })
90
+ });
91
+ figma.connect(Switch, FIGMA_URL, {
92
+ variant: {
93
+ State: "Disabled",
94
+ "Content Type": "With Description"
95
+ },
96
+ props: descriptionProps,
97
+ example: ({
98
+ labelNested,
99
+ descriptionNested
100
+ }) => /* @__PURE__ */ jsx(Switch, { disabled: true, label: labelNested.text, description: descriptionNested.text })
101
+ });
package/dist/Switch.js CHANGED
@@ -1,57 +1,44 @@
1
- var _excluded = ["errorText", "label", "description", "onChange", "withFormElementMargin", "tooltipIcon", "tooltip", "className", "tooltipConfig"];
2
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
- import AntdSwitch from 'antd/lib/switch';
5
- import classnames from 'classnames';
6
- import React, { forwardRef, useId, useRef } from 'react';
7
- import '@synerise/ds-core/dist/js/style';
8
- import * as S from './Switch.styles';
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import AntdSwitch from "antd/lib/switch";
3
+ import classnames from "classnames";
4
+ import { forwardRef, useId, useRef } from "react";
5
+ import { SwitchWrapper, LabelSwitchWrapper, Texts, Label, DescriptionWrapper, BelowLabel, Error, Description } from "./Switch.styles.js";
9
6
  import "./style/index.css";
10
-
11
- // export RawSwitch from this file to have .less style side effects applied when only RawSwitch is used
12
- export var RawSwitch = AntdSwitch;
13
- export var Switch = /*#__PURE__*/forwardRef(function (_ref, ref) {
14
- var errorText = _ref.errorText,
15
- label = _ref.label,
16
- description = _ref.description,
17
- _onChange = _ref.onChange,
18
- withFormElementMargin = _ref.withFormElementMargin,
19
- tooltipIcon = _ref.tooltipIcon,
20
- tooltip = _ref.tooltip,
21
- className = _ref.className,
22
- tooltipConfig = _ref.tooltipConfig,
23
- antdSwitchProps = _objectWithoutPropertiesLoose(_ref, _excluded);
24
- var id = useId();
25
- var switchElement = useRef(null);
26
- return /*#__PURE__*/React.createElement(S.SwitchWrapper, {
27
- ref: ref,
28
- className: classnames(['ds-switch', className]),
29
- formElementMargin: Boolean(withFormElementMargin)
30
- }, /*#__PURE__*/React.createElement(S.LabelSwitchWrapper, null, /*#__PURE__*/React.createElement(RawSwitch, _extends({}, antdSwitchProps, {
31
- size: "small",
32
- className: errorText ? 'error' : '',
33
- id: id,
34
- ref: switchElement,
35
- onChange: function onChange(checked, event) {
36
- setTimeout(function () {
37
- if (switchElement !== null && switchElement.current !== null) {
38
- switchElement.current.blur();
39
- }
40
- }, 300);
41
- _onChange && _onChange(checked, event);
42
- }
43
- })), /*#__PURE__*/React.createElement(S.Texts, {
44
- className: "switch-texts"
45
- }, /*#__PURE__*/React.createElement(S.Label, {
46
- id: id,
47
- className: "switch-label",
48
- label: label,
49
- tooltip: tooltip,
50
- tooltipConfig: tooltipConfig
51
- }))), (errorText || description) && /*#__PURE__*/React.createElement(S.DescriptionWrapper, null, /*#__PURE__*/React.createElement(S.Texts, {
52
- className: "switch-texts"
53
- }, /*#__PURE__*/React.createElement(S.BelowLabel, null, errorText && /*#__PURE__*/React.createElement(S.Error, null, errorText), description && /*#__PURE__*/React.createElement(S.Description, {
54
- className: "switch-description"
55
- }, description)))));
7
+ const RawSwitch = AntdSwitch;
8
+ const Switch = forwardRef(({
9
+ errorText,
10
+ label,
11
+ description,
12
+ onChange,
13
+ withFormElementMargin,
14
+ tooltipIcon,
15
+ tooltip,
16
+ className,
17
+ tooltipConfig,
18
+ ...antdSwitchProps
19
+ }, ref) => {
20
+ const id = useId();
21
+ const switchElement = useRef(null);
22
+ return /* @__PURE__ */ jsxs(SwitchWrapper, { ref, className: classnames(["ds-switch", className]), formElementMargin: Boolean(withFormElementMargin), children: [
23
+ /* @__PURE__ */ jsxs(LabelSwitchWrapper, { children: [
24
+ /* @__PURE__ */ jsx(RawSwitch, { ...antdSwitchProps, size: "small", className: errorText ? "error" : "", id, ref: switchElement, onChange: (checked, event) => {
25
+ setTimeout(() => {
26
+ if (switchElement !== null && switchElement.current !== null) {
27
+ switchElement.current.blur();
28
+ }
29
+ }, 300);
30
+ onChange && onChange(checked, event);
31
+ } }),
32
+ /* @__PURE__ */ jsx(Texts, { className: "switch-texts", children: /* @__PURE__ */ jsx(Label, { id, className: "switch-label", label, tooltip, tooltipConfig }) })
33
+ ] }),
34
+ (errorText || description) && /* @__PURE__ */ jsx(DescriptionWrapper, { children: /* @__PURE__ */ jsx(Texts, { className: "switch-texts", children: /* @__PURE__ */ jsxs(BelowLabel, { children: [
35
+ errorText && /* @__PURE__ */ jsx(Error, { children: errorText }),
36
+ description && /* @__PURE__ */ jsx(Description, { className: "switch-description", children: description })
37
+ ] }) }) })
38
+ ] });
56
39
  });
57
- export default Switch;
40
+ export {
41
+ RawSwitch,
42
+ Switch,
43
+ Switch as default
44
+ };
@@ -1,10 +1,10 @@
1
- export declare const SwitchWrapper: import("styled-components").StyledComponent<"div", any, {
1
+ export declare const SwitchWrapper: import('styled-components').StyledComponent<"div", any, {
2
2
  formElementMargin: boolean;
3
3
  }, never>;
4
- export declare const Texts: import("styled-components").StyledComponent<"div", any, {}, never>;
5
- export declare const Label: import("styled-components").StyledComponent<({ id, label, tooltip, tooltipConfig, children, ...htmlAttributes }: import("@synerise/ds-form-field").FormFieldLabelProps) => React.JSX.Element, any, {}, never>;
6
- export declare const BelowLabel: import("styled-components").StyledComponent<"div", any, {}, never>;
7
- export declare const LabelSwitchWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
8
- export declare const Error: import("styled-components").StyledComponent<"div", any, {}, never>;
9
- export declare const Description: import("styled-components").StyledComponent<"div", any, {}, never>;
10
- export declare const DescriptionWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
4
+ export declare const Texts: import('styled-components').StyledComponent<"div", any, {}, never>;
5
+ export declare const Label: import('styled-components').StyledComponent<({ id, label, tooltip, tooltipConfig, children, ...htmlAttributes }: import('@synerise/ds-form-field').FormFieldLabelProps) => React.JSX.Element, any, {}, never>;
6
+ export declare const BelowLabel: import('styled-components').StyledComponent<"div", any, {}, never>;
7
+ export declare const LabelSwitchWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
8
+ export declare const Error: import('styled-components').StyledComponent<"div", any, {}, never>;
9
+ export declare const Description: import('styled-components').StyledComponent<"div", any, {}, never>;
10
+ export declare const DescriptionWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
@@ -1,41 +1,45 @@
1
- import styled from 'styled-components';
2
- import { FormFieldLabel } from '@synerise/ds-form-field';
3
- import { macro } from '@synerise/ds-typography';
4
- export var SwitchWrapper = styled.div.withConfig({
1
+ import styled from "styled-components";
2
+ import { FormFieldLabel } from "@synerise/ds-form-field";
3
+ import { macro } from "@synerise/ds-typography";
4
+ const SwitchWrapper = /* @__PURE__ */ styled.div.withConfig({
5
5
  displayName: "Switchstyles__SwitchWrapper",
6
6
  componentId: "sc-1gmh4sk-0"
7
- })(["display:flex;gap:3px 0;flex-direction:column;justify-content:space-between;", ";"], function (props) {
8
- return props.formElementMargin ? 'margin: 0 0 16px 0' : '';
9
- });
10
- export var Texts = styled.div.withConfig({
7
+ })(["display:flex;gap:3px 0;flex-direction:column;justify-content:space-between;", ";"], (props) => props.formElementMargin ? "margin: 0 0 16px 0" : "");
8
+ const Texts = /* @__PURE__ */ styled.div.withConfig({
11
9
  displayName: "Switchstyles__Texts",
12
10
  componentId: "sc-1gmh4sk-1"
13
11
  })(["margin-left:16px;display:flex;flex-direction:row;justify-content:space-between;"]);
14
- export var Label = styled(FormFieldLabel).withConfig({
12
+ const Label = /* @__PURE__ */ styled(FormFieldLabel).withConfig({
15
13
  displayName: "Switchstyles__Label",
16
14
  componentId: "sc-1gmh4sk-2"
17
15
  })(["", ";cursor:pointer;transition:0.3s ease;width:100%;display:flex;align-items:center;"], macro.heading);
18
- export var BelowLabel = styled.div.withConfig({
16
+ const BelowLabel = /* @__PURE__ */ styled.div.withConfig({
19
17
  displayName: "Switchstyles__BelowLabel",
20
18
  componentId: "sc-1gmh4sk-3"
21
19
  })([""]);
22
- export var LabelSwitchWrapper = styled.div.withConfig({
20
+ const LabelSwitchWrapper = /* @__PURE__ */ styled.div.withConfig({
23
21
  displayName: "Switchstyles__LabelSwitchWrapper",
24
22
  componentId: "sc-1gmh4sk-4"
25
23
  })(["display:flex;flex-direction:row;justify-content:flex-start;align-items:center;"]);
26
- export var Error = styled.div.withConfig({
24
+ const Error = /* @__PURE__ */ styled.div.withConfig({
27
25
  displayName: "Switchstyles__Error",
28
26
  componentId: "sc-1gmh4sk-5"
29
- })(["color:", ";margin-bottom:4px;"], function (props) {
30
- return props.theme.palette['red-600'];
31
- });
32
- export var Description = styled.div.withConfig({
27
+ })(["color:", ";margin-bottom:4px;"], (props) => props.theme.palette["red-600"]);
28
+ const Description = /* @__PURE__ */ styled.div.withConfig({
33
29
  displayName: "Switchstyles__Description",
34
30
  componentId: "sc-1gmh4sk-6"
35
- })(["color:", ";transition:0.3s ease;"], function (props) {
36
- return props.theme.palette['grey-600'];
37
- });
38
- export var DescriptionWrapper = styled.div.withConfig({
31
+ })(["color:", ";transition:0.3s ease;"], (props) => props.theme.palette["grey-600"]);
32
+ const DescriptionWrapper = /* @__PURE__ */ styled.div.withConfig({
39
33
  displayName: "Switchstyles__DescriptionWrapper",
40
34
  componentId: "sc-1gmh4sk-7"
41
- })(["justify-content:space-between;padding-left:28px;"]);
35
+ })(["justify-content:space-between;padding-left:28px;"]);
36
+ export {
37
+ BelowLabel,
38
+ Description,
39
+ DescriptionWrapper,
40
+ Error,
41
+ Label,
42
+ LabelSwitchWrapper,
43
+ SwitchWrapper,
44
+ Texts
45
+ };
@@ -1,6 +1,6 @@
1
- import { type SwitchProps as AntdSwitchProps } from 'antd/lib/switch';
2
- import { type ReactNode } from 'react';
3
- import { type TooltipProps as DsTooltipProps } from '@synerise/ds-tooltip';
1
+ import { SwitchProps as AntdSwitchProps } from 'antd/lib/switch';
2
+ import { ReactNode } from 'react';
3
+ import { TooltipProps as DsTooltipProps } from '@synerise/ds-tooltip';
4
4
  type TooltipProps = {
5
5
  tooltipIcon?: ReactNode;
6
6
  tooltip?: ReactNode;
@@ -1 +1 @@
1
- export {};
1
+
File without changes
package/dist/index.js CHANGED
@@ -1 +1,5 @@
1
- export { default, RawSwitch } from './Switch';
1
+ import { RawSwitch, Switch } from "./Switch.js";
2
+ export {
3
+ RawSwitch,
4
+ Switch as default
5
+ };
package/dist/modules.d.js CHANGED
@@ -1 +1 @@
1
- import '@testing-library/jest-dom';
1
+ import "@testing-library/jest-dom";
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-switch",
3
- "version": "1.2.18",
3
+ "version": "1.2.20",
4
4
  "description": "Switch UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "synerise/synerise-design",
@@ -16,10 +16,10 @@
16
16
  "access": "public"
17
17
  },
18
18
  "scripts": {
19
- "build": "pnpm run build:js && pnpm run build:css && pnpm run defs",
19
+ "build": "vite build",
20
20
  "build:css": "node ../../../scripts/style/less.js",
21
21
  "build:js": "babel --delete-dir-on-start --root-mode upward src --out-dir dist --extensions '.js,.ts,.tsx'",
22
- "build:watch": "pnpm run build:js -- --watch",
22
+ "build:watch": "vite build --watch",
23
23
  "defs": "tsc --declaration --outDir dist/ --emitDeclarationOnly",
24
24
  "pack:ci": "pnpm pack --pack-destination ../../storybook/storybook-static/static",
25
25
  "prepublish": "pnpm run build",
@@ -35,12 +35,12 @@
35
35
  ],
36
36
  "types": "dist/index.d.ts",
37
37
  "dependencies": {
38
- "@synerise/ds-form-field": "^1.3.8",
39
- "@synerise/ds-typography": "^1.1.11",
38
+ "@synerise/ds-form-field": "^1.3.10",
39
+ "@synerise/ds-typography": "^1.1.13",
40
40
  "classnames": "^2.5.1"
41
41
  },
42
42
  "devDependencies": {
43
- "@synerise/ds-tooltip": "^1.4.8"
43
+ "@synerise/ds-tooltip": "^1.4.10"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@synerise/ds-core": "*",
@@ -48,5 +48,5 @@
48
48
  "react": ">=16.9.0 <= 18.3.1",
49
49
  "styled-components": "^5.3.3"
50
50
  },
51
- "gitHead": "8dfafc5d7278f09d430f1e7499782d05c76b47c0"
51
+ "gitHead": "e4ecca8944fc9b41c1b9d59c8bcad5e5e2013225"
52
52
  }