@hh.ru/magritte-ui-switch 1.4.4

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.
@@ -0,0 +1,12 @@
1
+ import './index.css';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { Skeleton } from '@hh.ru/magritte-ui-skeleton';
4
+
5
+ var styles = {"switch":"magritte-switch___0AZYC_1-4-4","slider":"magritte-slider___YN62u_1-4-4","checked":"magritte-checked___QEAn5_1-4-4","switch-skeleton":"magritte-switch-skeleton___g1MEY_1-4-4","switchSkeleton":"magritte-switch-skeleton___g1MEY_1-4-4"};
6
+
7
+ const SwitchSkeleton = ({ Component: Switch,
8
+ // skeleton props
9
+ width, height, borderRadius, inline, additionalClass, loading, ...switchProps }) => (jsx(Skeleton, { loading: loading, additionalClass: styles.switchSkeleton, inline: true, children: jsx(Switch, { ...switchProps }) }));
10
+
11
+ export { SwitchSkeleton as S, styles as s };
12
+ //# sourceMappingURL=Skeleton-a144d15a.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Skeleton-a144d15a.js","sources":["../src/Skeleton.tsx"],"sourcesContent":["import { IncompleteSkeletonComponent, Skeleton } from '@hh.ru/magritte-ui-skeleton';\nimport { SwitchProps } from '@hh.ru/magritte-ui-switch/types';\n\nimport styles from './switch.less';\n\nexport const SwitchSkeleton: IncompleteSkeletonComponent<SwitchProps> = ({\n Component: Switch,\n\n // skeleton props\n width,\n height,\n borderRadius,\n inline,\n additionalClass,\n loading,\n\n ...switchProps\n}) => (\n <Skeleton loading={loading} additionalClass={styles.switchSkeleton} inline>\n <Switch {...switchProps} />\n </Skeleton>\n);\n"],"names":["_jsx"],"mappings":";;;;;MAKa,cAAc,GAA6C,CAAC,EACrE,SAAS,EAAE,MAAM;AAEjB;AACA,KAAK,EACL,MAAM,EACN,YAAY,EACZ,MAAM,EACN,eAAe,EACf,OAAO,EAEP,GAAG,WAAW,EACjB,MACGA,GAAC,CAAA,QAAQ,EAAC,EAAA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,CAAC,cAAc,EAAE,MAAM,EAAA,IAAA,EAAA,QAAA,EACtEA,IAAC,MAAM,EAAA,EAAA,GAAK,WAAW,EAAI,CAAA,EAAA,CACpB;;;;"}
package/Skeleton.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { IncompleteSkeletonComponent } from '@hh.ru/magritte-ui-skeleton';
2
+ import { SwitchProps } from './types';
3
+ export declare const SwitchSkeleton: IncompleteSkeletonComponent<SwitchProps>;
package/Skeleton.js ADDED
@@ -0,0 +1,5 @@
1
+ import './index.css';
2
+ import 'react/jsx-runtime';
3
+ import '@hh.ru/magritte-ui-skeleton';
4
+ export { S as SwitchSkeleton } from './Skeleton-a144d15a.js';
5
+ //# sourceMappingURL=Skeleton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Skeleton.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
package/Switch.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { SwitchProps } from './types';
2
+ export declare const Switch: import("@hh.ru/magritte-ui-skeleton").ComponentWithSkeleton<SwitchProps>;
package/Switch.js ADDED
@@ -0,0 +1,19 @@
1
+ import './index.css';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import classnames from 'classnames';
4
+ import { useDisabled } from '@hh.ru/magritte-common-use-disabled';
5
+ import { LockClosedFilledSize16 } from '@hh.ru/magritte-ui-icon/icon';
6
+ import { enrichWithSkeleton } from '@hh.ru/magritte-ui-skeleton';
7
+ import { S as SwitchSkeleton, s as styles } from './Skeleton-a144d15a.js';
8
+
9
+ const SwitchComponent = ({ onClick, ariaLabel, disabled = false, checked = false, ...props }) => {
10
+ const forceDisabled = useDisabled();
11
+ const switchClasses = classnames(styles.switch, {
12
+ [styles.checked]: checked,
13
+ });
14
+ return (jsx("button", { ...props, type: "button", className: switchClasses, onClick: onClick, disabled: forceDisabled || disabled, "aria-checked": checked, "aria-label": ariaLabel, role: "switch", children: jsx("span", { className: styles.slider, children: (forceDisabled || disabled) && jsx(LockClosedFilledSize16, {}) }) }));
15
+ };
16
+ const Switch = enrichWithSkeleton(SwitchComponent, SwitchSkeleton);
17
+
18
+ export { Switch };
19
+ //# sourceMappingURL=Switch.js.map
package/Switch.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Switch.js","sources":["../src/Switch.tsx"],"sourcesContent":["import { FC } from 'react';\nimport classnames from 'classnames';\n\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport { LockClosedFilledSize16 } from '@hh.ru/magritte-ui-icon/icon';\nimport { enrichWithSkeleton } from '@hh.ru/magritte-ui-skeleton';\nimport { SwitchSkeleton } from '@hh.ru/magritte-ui-switch/Skeleton';\nimport { SwitchProps } from '@hh.ru/magritte-ui-switch/types';\n\nimport styles from './switch.less';\n\nconst SwitchComponent: FC<SwitchProps> = ({ onClick, ariaLabel, disabled = false, checked = false, ...props }) => {\n const forceDisabled = useDisabled();\n\n const switchClasses = classnames(styles.switch, {\n [styles.checked]: checked,\n });\n\n return (\n <button\n {...props}\n type=\"button\"\n className={switchClasses}\n onClick={onClick}\n disabled={forceDisabled || disabled}\n aria-checked={checked}\n aria-label={ariaLabel}\n role=\"switch\"\n >\n <span className={styles.slider}>{(forceDisabled || disabled) && <LockClosedFilledSize16 />}</span>\n </button>\n );\n};\n\nexport const Switch = enrichWithSkeleton(SwitchComponent, SwitchSkeleton);\n"],"names":["_jsx"],"mappings":";;;;;;;AAWA,MAAM,eAAe,GAAoB,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,GAAG,KAAK,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,KAAK,EAAE,KAAI;AAC7G,IAAA,MAAM,aAAa,GAAG,WAAW,EAAE,CAAC;AAEpC,IAAA,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE;AAC5C,QAAA,CAAC,MAAM,CAAC,OAAO,GAAG,OAAO;AAC5B,KAAA,CAAC,CAAC;IAEH,QACIA,mBACQ,KAAK,EACT,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,aAAa,EACxB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,aAAa,IAAI,QAAQ,EAAA,cAAA,EACrB,OAAO,EAAA,YAAA,EACT,SAAS,EACrB,IAAI,EAAC,QAAQ,EAAA,QAAA,EAEbA,cAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAA,QAAA,EAAG,CAAC,aAAa,IAAI,QAAQ,KAAKA,GAAA,CAAC,sBAAsB,EAAG,EAAA,CAAA,EAAA,CAAQ,EAC7F,CAAA,EACX;AACN,CAAC,CAAC;AAEW,MAAA,MAAM,GAAG,kBAAkB,CAAC,eAAe,EAAE,cAAc;;;;"}
package/index.css ADDED
@@ -0,0 +1,134 @@
1
+ :root{
2
+ --magritte-color-component-switch-stroke-state-focused-accessible-v18-1-1:#0070ff7a;
3
+ --magritte-color-component-switch-background-container-checked-v18-1-1:#0dc267;
4
+ --magritte-color-component-switch-background-container-unchecked-v18-1-1:#DCE3EB;
5
+ --magritte-color-component-switch-background-toggle-checked-v18-1-1:#ffffff;
6
+ --magritte-color-component-switch-background-toggle-unchecked-v18-1-1:#ffffff;
7
+ --magritte-color-component-switch-background-state-container-checked-hovered-v18-1-1:#5bcf83;
8
+ --magritte-color-component-switch-background-state-container-checked-pressed-v18-1-1:#5bcf83;
9
+ --magritte-color-component-switch-background-state-container-unchecked-hovered-v18-1-1:#CCD5DF;
10
+ --magritte-color-component-switch-background-state-container-unchecked-pressed-v18-1-1:#CCD5DF;
11
+ --magritte-color-component-switch-background-state-toggle-checked-pressed-v18-1-1:#ffffff;
12
+ --magritte-color-component-switch-background-state-toggle-unchecked-pressed-v18-1-1:#ffffff;
13
+ --magritte-color-component-switch-background-state-container-checked-disabled-v18-1-1:#0dc2677a;
14
+ --magritte-color-component-switch-background-state-container-unchecked-disabled-v18-1-1:#dce3eb7a;
15
+ --magritte-color-component-switch-icon-state-toggle-checked-disabled-v18-1-1:#0ea6587a;
16
+ --magritte-color-component-switch-icon-state-toggle-unchecked-disabled-v18-1-1:#7686947a;
17
+ --magritte-shadow-level-1-color-v18-1-1:#7090b029;
18
+ --magritte-shadow-level-1-x-v18-1-1:0px;
19
+ --magritte-shadow-level-1-y-v18-1-1:4px;
20
+ --magritte-shadow-level-1-blur-v18-1-1:12px;
21
+ --magritte-shadow-level-1-spread-v18-1-1:0px;
22
+ }
23
+ :root{
24
+ --magritte-semantic-animation-ease-in-out-leopard-300-timing-function-v18-1-1:cubic-bezier(0.35, 0.1, 0.1, 1);
25
+ --magritte-semantic-animation-ease-in-out-leopard-300-duration-v18-1-1:300ms;
26
+ }
27
+ .magritte-night-theme{
28
+ --magritte-color-component-switch-stroke-state-focused-accessible-v18-1-1:#0070ff7a;
29
+ --magritte-color-component-switch-background-container-checked-v18-1-1:#0dc267;
30
+ --magritte-color-component-switch-background-container-unchecked-v18-1-1:#303030;
31
+ --magritte-color-component-switch-background-toggle-checked-v18-1-1:#ffffff;
32
+ --magritte-color-component-switch-background-toggle-unchecked-v18-1-1:#ffffff;
33
+ --magritte-color-component-switch-background-state-container-checked-hovered-v18-1-1:#5bcf83;
34
+ --magritte-color-component-switch-background-state-container-checked-pressed-v18-1-1:#5bcf83;
35
+ --magritte-color-component-switch-background-state-container-unchecked-hovered-v18-1-1:#3B3B3B;
36
+ --magritte-color-component-switch-background-state-container-unchecked-pressed-v18-1-1:#3B3B3B;
37
+ --magritte-color-component-switch-background-state-toggle-checked-pressed-v18-1-1:#ffffff;
38
+ --magritte-color-component-switch-background-state-toggle-unchecked-pressed-v18-1-1:#ffffff;
39
+ --magritte-color-component-switch-background-state-container-checked-disabled-v18-1-1:#0dc2677a;
40
+ --magritte-color-component-switch-background-state-container-unchecked-disabled-v18-1-1:#3030307a;
41
+ --magritte-color-component-switch-icon-state-toggle-checked-disabled-v18-1-1:#0ea6587a;
42
+ --magritte-color-component-switch-icon-state-toggle-unchecked-disabled-v18-1-1:#7686947a;
43
+ --magritte-shadow-level-1-color-v18-1-1:#00000029;
44
+ --magritte-shadow-level-1-x-v18-1-1:0px;
45
+ --magritte-shadow-level-1-y-v18-1-1:4px;
46
+ --magritte-shadow-level-1-blur-v18-1-1:12px;
47
+ --magritte-shadow-level-1-spread-v18-1-1:0px;
48
+ }
49
+ .magritte-switch___0AZYC_1-4-4{
50
+ width:56px;
51
+ height:36px;
52
+ background-color:var(--magritte-color-component-switch-background-container-unchecked-v18-1-1);
53
+ border-radius:18px;
54
+ cursor:pointer;
55
+ position:relative;
56
+ }
57
+ .magritte-switch___0AZYC_1-4-4:active:not(:disabled){
58
+ background-color:var(--magritte-color-component-switch-background-state-container-unchecked-pressed-v18-1-1);
59
+ }
60
+ .magritte-switch___0AZYC_1-4-4:active:not(:disabled) .magritte-slider___YN62u_1-4-4{
61
+ border-radius:14px;
62
+ background-color:var(--magritte-color-component-switch-background-state-toggle-unchecked-pressed-v18-1-1);
63
+ width:36px;
64
+ }
65
+ .magritte-switch___0AZYC_1-4-4:disabled{
66
+ cursor:not-allowed;
67
+ background-color:var(--magritte-color-component-switch-background-state-container-unchecked-disabled-v18-1-1);
68
+ border-radius:20px;
69
+ }
70
+ .magritte-switch___0AZYC_1-4-4:disabled.magritte-checked___QEAn5_1-4-4{
71
+ background-color:var(--magritte-color-component-switch-background-state-container-checked-disabled-v18-1-1);
72
+ }
73
+ .magritte-switch___0AZYC_1-4-4:focus-visible{
74
+ outline:var(--magritte-color-component-switch-stroke-state-focused-accessible-v18-1-1) solid 4px;
75
+ }
76
+ @media (min-width: 1020px){
77
+ body.magritte-old-layout .magritte-switch___0AZYC_1-4-4:hover:not(:disabled):not(:active){
78
+ background-color:var(--magritte-color-component-switch-background-state-container-unchecked-hovered-v18-1-1);
79
+ }
80
+ }
81
+ @media (min-width: 1024px){
82
+ body:not(.magritte-old-layout) .magritte-switch___0AZYC_1-4-4:hover:not(:disabled):not(:active){
83
+ background-color:var(--magritte-color-component-switch-background-state-container-unchecked-hovered-v18-1-1);
84
+ }
85
+ }
86
+ .magritte-slider___YN62u_1-4-4{
87
+ width:28px;
88
+ height:28px;
89
+ background-color:var(--magritte-color-component-switch-background-toggle-unchecked-v18-1-1);
90
+ border-radius:50%;
91
+ position:absolute;
92
+ left:0;
93
+ right:auto;
94
+ top:0;
95
+ transition-duration:var(--magritte-semantic-animation-ease-in-out-leopard-300-duration-v18-1-1);
96
+ transition-timing-function:var(--magritte-semantic-animation-ease-in-out-leopard-300-timing-function-v18-1-1);
97
+ margin:4px;
98
+ display:flex;
99
+ justify-content:center;
100
+ align-items:center;
101
+ --magritte-ui-icon-color-override:var(--magritte-color-component-switch-icon-state-toggle-unchecked-disabled-v18-1-1);
102
+ box-shadow:var(--magritte-shadow-level-1-x-v18-1-1) var(--magritte-shadow-level-1-y-v18-1-1) var(--magritte-shadow-level-1-blur-v18-1-1) var(--magritte-shadow-level-1-spread-v18-1-1) var(--magritte-shadow-level-1-color-v18-1-1);
103
+ }
104
+ .magritte-checked___QEAn5_1-4-4{
105
+ background-color:var(--magritte-color-component-switch-background-container-checked-v18-1-1);
106
+ }
107
+ .magritte-checked___QEAn5_1-4-4 .magritte-slider___YN62u_1-4-4{
108
+ background-color:var(--magritte-color-component-switch-background-toggle-checked-v18-1-1);
109
+ left:calc(56px - (28px + 4px*2));
110
+ --magritte-ui-icon-color-override:var(--magritte-color-component-switch-icon-state-toggle-checked-disabled-v18-1-1);
111
+ }
112
+ .magritte-checked___QEAn5_1-4-4:active:not(:disabled){
113
+ background-color:var(--magritte-color-component-switch-background-state-container-checked-pressed-v18-1-1);
114
+ }
115
+ .magritte-checked___QEAn5_1-4-4:active:not(:disabled) .magritte-slider___YN62u_1-4-4{
116
+ background-color:var(--magritte-color-component-switch-background-state-toggle-checked-pressed-v18-1-1);
117
+ width:36px;
118
+ left:calc(56px - (36px + 4px*2));
119
+ }
120
+ @media (min-width: 1020px){
121
+ body.magritte-old-layout .magritte-checked___QEAn5_1-4-4:hover:not(:disabled):not(:active){
122
+ background-color:var(--magritte-color-component-switch-background-state-container-checked-hovered-v18-1-1);
123
+ }
124
+ }
125
+ @media (min-width: 1024px){
126
+ body:not(.magritte-old-layout) .magritte-checked___QEAn5_1-4-4:hover:not(:disabled):not(:active){
127
+ background-color:var(--magritte-color-component-switch-background-state-container-checked-hovered-v18-1-1);
128
+ }
129
+ }
130
+ .magritte-switch-skeleton___g1MEY_1-4-4{
131
+ width:56px;
132
+ height:36px;
133
+ border-radius:18px;
134
+ }
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './Switch';
2
+ export * from './types';
3
+ export * from '@hh.ru/magritte-ui-theme-provider';
package/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import './index.css';
2
+ export { Switch } from './Switch.js';
3
+ export * from '@hh.ru/magritte-ui-theme-provider';
4
+ import 'react/jsx-runtime';
5
+ import 'classnames';
6
+ import '@hh.ru/magritte-common-use-disabled';
7
+ import '@hh.ru/magritte-ui-icon/icon';
8
+ import '@hh.ru/magritte-ui-skeleton';
9
+ import './Skeleton-a144d15a.js';
10
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@hh.ru/magritte-ui-switch",
3
+ "version": "1.4.4",
4
+ "main": "index.js",
5
+ "types": "index.d.ts",
6
+ "sideEffects": [
7
+ "index.css"
8
+ ],
9
+ "scripts": {
10
+ "build": "yarn root:build $(pwd)",
11
+ "build-test-branch": "yarn root:build-test-branch $(pwd)",
12
+ "changelog": "yarn root:changelog $(pwd)",
13
+ "prepack": "yarn root:prepack $(pwd)",
14
+ "postpublish": "yarn root:postpublish $(pwd)",
15
+ "stylelint-test": "yarn root:stylelint-test $(pwd)",
16
+ "eslint-test": "yarn root:eslint-test $(pwd)",
17
+ "ts-config": "yarn root:ts-config $(pwd)",
18
+ "ts-check": "yarn root:ts-check $(pwd)",
19
+ "test": "yarn root:test $(pwd)"
20
+ },
21
+ "dependencies": {
22
+ "@hh.ru/magritte-common-use-disabled": "1.0.8",
23
+ "@hh.ru/magritte-design-tokens": "18.1.1",
24
+ "@hh.ru/magritte-ui-breakpoint": "4.0.1",
25
+ "@hh.ru/magritte-ui-icon": "7.1.3",
26
+ "@hh.ru/magritte-ui-skeleton": "2.1.2",
27
+ "@hh.ru/magritte-ui-theme-provider": "1.1.21"
28
+ },
29
+ "peerDependencies": {
30
+ "classnames": ">=2.3.2",
31
+ "react": ">=18.2.0"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "gitHead": "b660dd64fca3eaad5ec44ea9a73f92bb0d9694aa"
37
+ }
package/types.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ export interface SwitchProps {
2
+ /** флаг состояния по умолчанию - включен - true, выключен/отсутствует - false*/
3
+ checked?: boolean;
4
+ /** компонент отключен для взаимодействия */
5
+ disabled?: boolean;
6
+ /** функция действия на клик */
7
+ onClick?: () => void;
8
+ /** атрибут aria-label */
9
+ ariaLabel?: string;
10
+ }
package/types.js ADDED
@@ -0,0 +1,3 @@
1
+ import './index.css';
2
+
3
+ //# sourceMappingURL=types.js.map
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}